Get a submatrix.

@param r Array of row indices.
@param c Array of column indices.
@return A(r(:), c(:))
@throws ArrayIndexOutOfBoundsException Submatrix indices
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;
    }
770261
public static void setMatrix(final double[][] m1, final int r0, final int r1, final int c0, final int c1, final double[][] m2) {
    assert r0 <= r1 && c0 <= c1 : ERR_INVALID_RANGE;
    assert r1 <= m1.length && c1 <= m1[0].length : ERR_MATRIX_DIMENSIONS;
    final int coldim = c1 - c0;
    for(int i = r0; i < r1; i++) {
      System.arraycopy(m2[i - r0], 0, m1[i], c0, coldim);
    }
  }
1212149
public static AbstractMatrix getInstance(int rows, Object values, Class<?> cls)
    {
        int length = Array.getLength(values);
        if (length % rows != 0)
        {
            throw new IllegalArgumentException("not full rows");
        }
        return new AbstractMatrix(rows, copyOf(values, cls));
    }
989915
public static void setMatrix(final double[][] m1, final int[] r, final int c0, final int c1, final double[][] m2) {
    assert c0 <= c1 : ERR_INVALID_RANGE;
    assert c1 <= m1[0].length : ERR_MATRIX_DIMENSIONS;
    for(int i = 0; i < r.length; i++) {
      System.arraycopy(m2[i], 0, m1[r[i]], c0, c1 - c0);
    }
  }
127831
public static void subtract(double val , DMatrixD1 a , DMatrixD1 c ) {
        c.reshape(a.numRows,a.numCols);

        final int length = a.getNumElements();

        for( int i = 0; i < length; i++ ) {
            c.data[i] = val - a.data[i];
        }
    }
896885
public Matrix getMatrix(int i0, int i1, int[] c)
    {
        Matrix X = new Matrix(i1 - i0 + 1, c.length);
        double[][] B = X.getArray();
        try
        {
            for (int i = i0; i <= i1; i++)
            {
                for (int j = 0; j < c.length; j++)
                {
                    B[i - i0][j] = A[i][c[j]];
                }
            }
        }
        catch (ArrayIndexOutOfBoundsException e)
        {
            throw new ArrayIndexOutOfBoundsException("Submatrix indices");
        }
        return X;
    }
109927
public static void multCol(Matrix A, int j, double c)
    {
        multCol(A, j, 0, A.rows(), c);
    }
373605
public IMatrix sub(IMatrix b) {
        IMatrix result = new IMatrix(rows, columns);
        sub(b, result);
        return result;
    }
116888
public static void symmRankTranA_sub(DMatrixRMaj a , DMatrixRMaj c ,
                                         int startIndexC )
    {
        // TODO update so that it doesn't modify/read parts that it shouldn't
        final double dataA[] = a.data;
        final double dataC[] = c.data;

//        for( int i = 0; i < a.numCols; i++ ) {
//            for( int k = 0; k < a.numRows; k++ ) {
//                double valA = dataA[k*a.numCols+i];
//
//                for( int j = i; j < a.numCols; j++ ) {
//                    dataC[startIndexC+i*c.numCols+j] -= valA * dataA[k*a.numCols+j];
//                }
//            }
//        }

        final int strideC = c.numCols + 1;
        for( int i = 0; i < a.numCols; i++ ) {
            int indexA = i;
            int endR = a.numCols;

            for( int k = 0; k < a.numRows; k++ , indexA += a.numCols , endR += a.numCols) {
                int indexC = startIndexC;
                final double valA = dataA[indexA];
                int indexR = indexA;

                while( indexR < endR ) {
                    dataC[indexC++] -= valA * dataA[indexR++];
                }
            }
            startIndexC += strideC;
        }

    }
219890
public IVector getVectorFromColumn(int index) {
        IVector result = new IVector(rows);
        for (int i = 0; i < rows; i++) {
            result.realvector[i] = realmatrix[i][index];
            result.imagvector[i] = imagmatrix[i][index];
        }
        return result;
    }
401939
public static DMatrixRMaj concatRowsMulti(DMatrixRMaj ...m ) {
        int rows = 0;
        int cols = 0;

        for (int i = 0; i < m.length; i++) {
            rows += m[i].numRows;
            cols = Math.max(cols,m[i].numCols);
        }
        DMatrixRMaj R = new DMatrixRMaj(rows,cols);

        int row = 0;
        for (int i = 0; i < m.length; i++) {
            insert(m[i],R,row,0);
            row += m[i].numRows;
        }

        return R;
    }
1234461
@Override
    public Matrix<T> repmat(final int rowRepeats, final int colRepeats) {
        N.checkArgument(rowRepeats > 0 && colRepeats > 0, "rowRepeats=%s and colRepeats=%s must be bigger than 0", rowRepeats, colRepeats);

        final T[][] c = N.newArray(arrayType, rows * rowRepeats);

        for (int i = 0, len = c.length; i < len; i++) {
            c[i] = N.newArray(componentType, cols * colRepeats);
        }

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < colRepeats; j++) {
                N.copy(a[i], 0, c[i], j * cols, cols);
            }
        }

        for (int i = 1; i < rowRepeats; i++) {
            for (int j = 0; j < rows; j++) {
                N.copy(c[j], 0, c[i * rows + j], 0, c[j].length);
            }
        }

        return new Matrix<T>(c);
    }
1205851
@Override
	protected DoubleMatrix1D getFi(DoubleMatrix1D X){
		double[] ret = new double[getMieq()];
		for(int i=0; i<getDim(); i++){
			ret[i] = -X.getQuick(i) + getLb().getQuick(i);
			ret[getDim() + i] = X.getQuick(i) - getUb().getQuick(i) ;
		}
		return F1.make(ret);
	}
179082
public static DMatrix2 extractRow( DMatrix2x2 a , int row , DMatrix2 out ) {
        if( out == null) out = new DMatrix2();
        switch( row ) {
            case 0:
                out.a1 = a.a11;
                out.a2 = a.a12;
            break;
            case 1:
                out.a1 = a.a21;
                out.a2 = a.a22;
            break;
            default:
                throw new IllegalArgumentException("Out of bounds row.  row = "+row);
        }
        return out;
    }
1144392
@Override
    public DMatrixRMaj getA() {
        if( A.data.length < numRows*numCols ) {
            A = new DMatrixRMaj(numRows,numCols);
        }
        A.reshape(numRows,numCols, false);
        CommonOps_DDRM.mult(Q,R,A);

        return A;
    }
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;
    }
699030
public static ColumnMajorSparseMatrix block(Matrix a, Matrix b, Matrix c, Matrix d) {
        return CCSMatrix.block(a, b, c, d);
    }