Computes the inverse permutation vector

@param original Original permutation vector
@param inverse It's inverse
517042
public static void permutationInverse( int []original , int []inverse , int length ) {
        for (int i = 0; i < length; i++) {
            inverse[original[i]] = i;
        }
    }
733624
def inverse(self):
        
        result = G1Element()
        librelic.g1_neg_abi(byref(result), byref(self))
        return result
412109
private static char[] copyOf(char[] original, int length) {
    char[] copy = new char[length];
    System.arraycopy(original, 0, copy, 0, Math.min(original.length, length));
    return copy;
  }
1331765
public void inverse(float data[], int rowspan) {
    backtransform(data, rowspan); 
    float norm = normalization();
    for(int i=0; i<nrows; i++){
      for(int j=0; j<ncols; j++){
	data[i*rowspan + 2*j]   *= norm; 
	data[i*rowspan + 2*j+1] *= norm; }}}
972266
@Override
    public DenseMatrix inverse() {
        int m = lu.nrows();
        int n = lu.ncols();

        if (m != n) {
            throw new IllegalArgumentException(String.format("Matrix is not square: %d x %d", m, n));
        }

        int nb = LAPACK.getInstance().ilaenv(1, "DGETRI", "", n, -1, -1, -1);
        if (nb < 0) {
            logger.warn("LAPACK ILAENV error code: {}", nb);
        }

        if (nb < 1) nb = 1;

        int lwork = lu.ncols() * nb;
        double[] work = new double[lwork];
        intW info = new intW(0);
        LAPACK.getInstance().dgetri(lu.ncols(), lu.data(), lu.ld(), piv, work, lwork, info);

        if (info.val != 0) {
            logger.error("LAPACK DGETRI error code: {}", info.val);
            throw new IllegalArgumentException("LAPACK DGETRI error code: " + info.val);
        }

        return lu;
    }
166792
def inverse(self):
        """"""
        result = self.__class__()
        result.forward = copy.copy(self.reverse)
        result.reverse = copy.copy(self.forward)
        return result
712505
@Override
    public boolean invert() {
        double determinant = determinant();
        if (determinant == 0) {
            return false;
        }

        // first row
        double t00 =  determinant3x3(m11, m12, m13, m21, m22, m23, m31, m32, m33);
        double t01 = -determinant3x3(m10, m12, m13, m20, m22, m23, m30, m32, m33);
        double t02 =  determinant3x3(m10, m11, m13, m20, m21, m23, m30, m31, m33);
        double t03 = -determinant3x3(m10, m11, m12, m20, m21, m22, m30, m31, m32);

        // second row
        double t10 = -determinant3x3(m01, m02, m03, m21, m22, m23, m31, m32, m33);
        double t11 =  determinant3x3(m00, m02, m03, m20, m22, m23, m30, m32, m33);
        double t12 = -determinant3x3(m00, m01, m03, m20, m21, m23, m30, m31, m33);
        double t13 =  determinant3x3(m00, m01, m02, m20, m21, m22, m30, m31, m32);

        // third row
        double t20 =  determinant3x3(m01, m02, m03, m11, m12, m13, m31, m32, m33);
        double t21 = -determinant3x3(m00, m02, m03, m10, m12, m13, m30, m32, m33);
        double t22 =  determinant3x3(m00, m01, m03, m10, m11, m13, m30, m31, m33);
        double t23 = -determinant3x3(m00, m01, m02, m10, m11, m12, m30, m31, m32);

        // fourth row
        double t30 = -determinant3x3(m01, m02, m03, m11, m12, m13, m21, m22, m23);
        double t31 =  determinant3x3(m00, m02, m03, m10, m12, m13, m20, m22, m23);
        double t32 = -determinant3x3(m00, m01, m03, m10, m11, m13, m20, m21, m23);
        double t33 =  determinant3x3(m00, m01, m02, m10, m11, m12, m20, m21, m22);

        // transpose and divide by the determinant
        m00 = t00 / determinant;
        m01 = t10 / determinant;
        m02 = t20 / determinant;
        m03 = t30 / determinant;

        m10 = t01 / determinant;
        m11 = t11 / determinant;
        m12 = t21 / determinant;
        m13 = t31 / determinant;

        m20 = t02 / determinant;
        m21 = t12 / determinant;
        m22 = t22 / determinant;
        m23 = t32 / determinant;

        m30 = t03 / determinant;
        m31 = t13 / determinant;
        m32 = t23 / determinant;
        m33 = t33 / determinant;

        return true;
    }
655038
public static <T> T[] copyOf(final T[] original, final int newLength) {
        if (newLength == original.length) {
            return original.clone();
        }

        return (T[]) copyOf(original, newLength, original.getClass());
    }
420946
function(originalArray) {
            var cleanArray = [],
                i = -1;

            for (i = 0; i < originalArray.length; i++) {
                if (originalArray[i] !== '') {
                    cleanArray.push(originalArray[i]);
                }
            }

            return cleanArray;
        }
825080
public static boolean isInverse(DMatrixRMaj a , DMatrixRMaj b , double tol ) {
        if( a.numRows != b.numRows || a.numCols != b.numCols ) {
            return false;
        }

        int numRows = a.numRows;
        int numCols = a.numCols;

        for( int i = 0; i < numRows; i++ ) {
            for( int j = 0; j < numCols; j++ ) {
                double total = 0;
                for( int k = 0; k < numCols; k++ ) {
                    total += a.get(i,k)*b.get(k,j);
                }

                if( i == j ) {
                    if( !(Math.abs(total-1) <= tol) )
                        return false;
                } else if( !(Math.abs(total) <= tol) )
                    return false;
            }
        }

        return true;
    }
1260961
def inverse(self):
        
        new = self.conjugate()
        tmp = self.norm()**2
        new.w /= tmp
        new.x /= tmp
        new.y /= tmp
        new.z /= tmp
        return new
225817
@Override
    public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
        /*
         * IMPLEMENTATION NOTES
         * --------------------
         * Where applicable, use is made of the one-sided Chebyshev inequality
         * to bracket the root. This inequality states that
         * P(X - mu >= k * sig) <= 1 / (1 + k^2),
         * mu: mean, sig: standard deviation. Equivalently
         * 1 - P(X < mu + k * sig) <= 1 / (1 + k^2),
         * F(mu + k * sig) >= k^2 / (1 + k^2).
         *
         * For k = sqrt(p / (1 - p)), we find
         * F(mu + k * sig) >= p,
         * and (mu + k * sig) is an upper-bound for the root.
         *
         * Then, introducing Y = -X, mean(Y) = -mu, sd(Y) = sig, and
         * P(Y >= -mu + k * sig) <= 1 / (1 + k^2),
         * P(-X >= -mu + k * sig) <= 1 / (1 + k^2),
         * P(X <= mu - k * sig) <= 1 / (1 + k^2),
         * F(mu - k * sig) <= 1 / (1 + k^2).
         *
         * For k = sqrt((1 - p) / p), we find
         * F(mu - k * sig) <= p,
         * and (mu - k * sig) is a lower-bound for the root.
         *
         * In cases where the Chebyshev inequality does not apply, geometric
         * progressions 1, 2, 4, ... and -1, -2, -4, ... are used to bracket
         * the root.
         */
        if (p < 0.0 || p > 1.0) {
            throw new OutOfRangeException(p, 0, 1);
        }

        double lowerBound = getSupportLowerBound();
        if (p == 0.0) {
            return lowerBound;
        }

        double upperBound = getSupportUpperBound();
        if (p == 1.0) {
            return upperBound;
        }

        final double mu = getNumericalMean();
        final double sig = FastMath.sqrt(getNumericalVariance());
        final boolean chebyshevApplies;
        chebyshevApplies = !(Double.isInfinite(mu) || Double.isNaN(mu) || Double.isInfinite(sig) || Double.isNaN(sig));

        if (lowerBound == Double.NEGATIVE_INFINITY) {
            if (chebyshevApplies) {
                lowerBound = mu - sig * FastMath.sqrt((1. - p) / p);
            } else {
                lowerBound = -1.0;
                while (cumulativeProbability(lowerBound) >= p) {
                    lowerBound *= 2.0;
                }
            }
        }

        if (upperBound == Double.POSITIVE_INFINITY) {
            if (chebyshevApplies) {
                upperBound = mu + sig * FastMath.sqrt(p / (1. - p));
            } else {
                upperBound = 1.0;
                while (cumulativeProbability(upperBound) < p) {
                    upperBound *= 2.0;
                }
            }
        }

        final UnivariateFunction toSolve = new UnivariateFunction() {

            public double value(final double x) {
                return cumulativeProbability(x) - p;
            }
        };

        double x = UnivariateSolverUtils.solve(toSolve, lowerBound, upperBound, getSolverAbsoluteAccuracy());

        if (!isSupportConnected()) {
            /* Test for plateau. */
            final double dx = getSolverAbsoluteAccuracy();
            if (x - dx >= getSupportLowerBound()) {
                double px = cumulativeProbability(x);
                if (cumulativeProbability(x - dx) == px) {
                    upperBound = x;
                    while (upperBound - lowerBound > dx) {
                        final double midPoint = 0.5 * (lowerBound + upperBound);
                        if (cumulativeProbability(midPoint) < px) {
                            lowerBound = midPoint;
                        } else {
                            upperBound = midPoint;
                        }
                    }
                    return upperBound;
                }
            }
        }
        return x;
    }
50408
public void reverse(int start) {
    int end = size - 1;
    int num = end - start >> 1;
    for (int i = 0; i <= num; i++) {
      int j = start + i;
      int k = end - i;
      char c = buf[k];
      buf[k] = buf[j];
      buf[j] = c;
    }
  }
336397
function getInversionOf(comparator) {
    function inversion(a, b) {
        return -comparator(a, b);
    }

    inversion.original = comparator;

    return inversion;
}
1016787
private List<List<Double>> deepCopy(final List<List<Double>> original) {
    final List<List<Double>> result = new ArrayList<>(original.size());
    for (final List<Double> originalRow : original) {
      final List<Double> row = new ArrayList<>(originalRow.size());
      for (final double element : originalRow) {
        row.add(element);
      }
      result.add(row);
    }
    return result;
  }
748032
@Deprecated
  public static void permute(final int[] arr, final int[] permutation) {
    checkArgument(arr.length == permutation.length);
    final int[] tmp = new int[arr.length];
    for (int i = 0; i < tmp.length; ++i) {
      tmp[i] = arr[permutation[i]];
    }
    System.arraycopy(tmp, 0, arr, 0, arr.length);
  }
1372397
@Override
    public void apply(PermutationSolution solution) {
        int start = from;
        int stop = to;
        int n = solution.size();
        // reverse subsequence by performing a series of swaps
        // (works cyclically when start > stop)
        int reversedLength;
        if(start < stop){
            reversedLength = stop-start+1;
        } else {
            reversedLength = n - (start-stop-1);
        }
        int numSwaps = reversedLength/2;
        for(int k=0; k<numSwaps; k++){
            solution.swap(start, stop);
            start = (start+1) % n;
            stop = (stop-1+n) % n;
        }
    }