Returns immutable PermutationMatrix possibly from cache.
@param n
@return
494122
public static PermutationMatrix getInstance(int n)
    {
        PermutationMatrix pm = map.get(n);
        if (pm == null)
        {
            pm = new PermutationMatrix(n);
            map.put(n, pm);
        }
        return pm;
    }
862231
private List<Integer> getPermutation() {
		List<Integer> permutation = new ArrayList<Integer>(transformedCoords.length);
		double sum = 0.0f;

		for (Point3d t: transformedCoords) {
			List<Integer> neighbors = box.getNeighborsWithCache(t);
			int closest = -1;
			double minDist = Double.MAX_VALUE;

			 for (int j : neighbors) {
				double dist = t.distanceSquared(originalCoords[j]);
				if (dist < minDist) {
					closest = j;
					minDist = dist;
				}
			}

			sum += minDist;
			if (closest == -1) {
				 break;
			}
			permutation.add(closest);
		}
		double rmsd = Math.sqrt(sum / transformedCoords.length);

		if (rmsd > distanceThreshold || permutation.size() != transformedCoords.length) {
			permutation.clear();
			return permutation;
		}

		// check uniqueness of indices
		Set<Integer> set = new HashSet<Integer>(permutation);

		// if size mismatch, clear permutation (its invalid)
		if (set.size() != originalCoords.length) {
			permutation.clear();
		}

		return permutation;
	}
93072
private boolean hasCandidate(int n) {
        for (int j = (n * matrix.mCols), end = (j + matrix.mCols); j < end; j++)
            if (matrix.get(j)) return true;
        return false;
    }
1092641
public DMatrixRMaj getH(DMatrixRMaj H ) {
        H = UtilDecompositons_DDRM.checkZeros(H,N,N);

        // copy the first row
        System.arraycopy(QH.data, 0, H.data, 0, N);

        for( int i = 1; i < N; i++ ) {
            for( int j = i-1; j < N; j++ ) {
                H.set(i,j, QH.get(i,j));
            }
        }

        return H;
    }
925695
public static ImmutableMatrix identity(final int size) {
		if (size <= 0) throw new IllegalArgumentException("Invalid size");
		return create(new ImmutableData(size, size) {
			@Override
			public double getQuick(int row, int col) {
				return row == col ? 1 : 0;
			}
		});
	}
495810
public Matrix getMatrix(int[] r, int[] c)
    {
        Matrix X = new Matrix(r.length, c.length);
        double[][] B = X.getArray();
        try
        {
            for (int i = 0; i < r.length; i++)
            {
                for (int j = 0; j < c.length; j++)
                {
                    B[i][j] = A[r[i]][c[j]];
                }
            }
        }
        catch (ArrayIndexOutOfBoundsException e)
        {
            throw new ArrayIndexOutOfBoundsException("Submatrix indices");
        }
        return X;
    }
87499
public static DoubleMatrix identity(int n)
    {
        return getInstance(n ,n, (i, j) -> i == j ? 1 : 0);
    }
496746
private Matrix<Double> generateRandomMatrix(final int nRows, final int nColumns) {
    final List<List<Double>> rows = new ArrayList<>(nRows);
    final Random random = new Random();
    for (int i = 0; i < nRows; i++) {
      final List<Double> row = new ArrayList<>(nColumns);
      for (int j = 0; j < nColumns; j++) {
        row.add(random.nextDouble());
      }
      rows.add(row);
    }
    return new RowMatrix(rows);
  }
23753
public static DMatrixRMaj identity(int numRows , int numCols )
    {
        DMatrixRMaj ret = new DMatrixRMaj(numRows,numCols);

        int small = numRows < numCols ? numRows : numCols;

        for( int i = 0; i < small; i++ ) {
            ret.set(i,i,1.0);
        }

        return ret;
    }
164831
public BigInteger[][] getMatrix()
    {
        BigInteger[][] ret = new BigInteger[rows.size()][rows.get(0).size()];

        final int height = ret.length;
        final int width = ret[0].length;
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                ret[i][j] = rows.get(i).getColumn(j);
            }
        }

        return ret;
    }
98987
public ZMatrixRMaj getH(ZMatrixRMaj H ) {
        H = UtilDecompositons_ZDRM.checkZeros(H,N,N);

        // copy the first row
        System.arraycopy(QH.data, 0, H.data, 0, N*2);

        for( int i = 1; i < N; i++ ) {
            System.arraycopy(QH.data, (i*N+i-1)*2, H.data, (i*N+i-1)*2, (N-i+1)*2);
        }

        return H;
    }
1107683
private String getHalfMatrixString(Permutation permutation) {
        StringBuilder builder = new StringBuilder(permutation.size());
        int size = permutation.size();
        for (int indexI = 0; indexI < size - 1; indexI++) {
            for (int indexJ = indexI + 1; indexJ < size; indexJ++) {
                builder.append(getConnectivity(permutation.get(indexI), permutation.get(indexJ)));
            }
        }
        return builder.toString();
    }
732793
public Matrix getU () {
      Matrix X = MatrixFactory.createMatrix(n,n);
      for (int i = 0; i < n; i++) {
         for (int j = 0; j < n; j++) {
            if (i <= j) {
					X.set(i, j, LU[i][j]);
            }
         }
      }
      return X;
   }
337563
public static int[][] getMatrix(IAtomContainer container) {
        int[][] conMat = AdjacencyMatrix.getMatrix(container);
        int[][] topolDistance = PathTools.computeFloydAPSP(conMat);

        return topolDistance;
    }
45219
public static double[][] getMatrix(final double[][] m1, final int r0, final int r1, final int[] c) {
    assert r0 <= r1 : ERR_INVALID_RANGE;
    assert r1 <= m1.length : ERR_MATRIX_DIMENSIONS;
    final int rowdim = r1 - r0, coldim = c.length;
    final double[][] X = new double[rowdim][coldim];
    for(int i = r0; i < r1; i++) {
      final double[] row = m1[i];
      final double[] Xi = X[i - r0];
      for(int j = 0; j < coldim; j++) {
        Xi[j] = row[c[j]];
      }
    }
    return X;
  }
937483
private Matrix getThisSideMatrix(Matrix B)
    {
        if(this.canBeMutated())
            return this.clone();
        else//so far, only other option in JSAT is a dense matrix
        {
            DenseMatrix dm = new DenseMatrix(rows(), cols());
            dm.mutableAdd(this);
            return dm;
        }
    }
766364
public Set<N> getChildren(N n)
    {
        Pair<HashSet<N>, HashSet<N>> p = nodes.get(n);
        
        if(p == null)
            return null;
        
        return p.getOutgoing();
    }