<p>Converts the block matrix into a SimpleMatrix.</p>

@param A Block matrix that is being converted.  Not modified.
@return Equivalent SimpleMatrix.
439845
public static SimpleMatrix convertSimple( DMatrixRBlock A ) {
        DMatrixRMaj B = ConvertDMatrixStruct.convert(A, null);

        return SimpleMatrix.wrap(B);
    }
623048
public Matrix mtimes(Matrix m2) {
		if (m2 instanceof DenseDoubleMatrix2D) {
			final DenseDoubleMatrix2D result = new BlockDenseDoubleMatrix2D((int) getRowCount(),
					(int) m2.getColumnCount(), layout.blockStripe, BlockOrder.ROWMAJOR);
			Mtimes.DENSEDOUBLEMATRIX2D.calc(this, (DenseDoubleMatrix2D) m2, result);
			return result;
		} else {
			return super.mtimes(m2);
		}
	}
373605
public IMatrix sub(IMatrix b) {
        IMatrix result = new IMatrix(rows, columns);
        sub(b, result);
        return result;
    }
808943
public static final DoubleMatrix2D invert2x2Matrix(DoubleMatrix2D A) throws Exception{
		if(2!=A.rows() || A.rows() != A.columns()){
			throw new IllegalArgumentException("matrix is not 2x2");
		}
		//ad - bc
		double s = A.getQuick(0, 0)*A.getQuick(1, 1)-A.getQuick(0, 1)*A.getQuick(1, 0);
		if(Math.abs(s) < 1.e-16){
			throw new Exception("Matrix is singular");
		}
		DoubleMatrix2D ret = new DenseDoubleMatrix2D(2, 2);
		ret.setQuick(0, 0, A.getQuick(1, 1) / s);
		ret.setQuick(1, 1, A.getQuick(0, 0) / s);
		ret.setQuick(0, 1, -A.getQuick(1, 0) / s);
		ret.setQuick(1, 0, A.getQuick(0, 1) / s);
		return ret;
	}
1164752
public static SparseMatrix block(Matrix a, Matrix b, Matrix c, Matrix d) {
        return CRSMatrix.block(a, b, c, d);
    }
583711
public static QRP factorize(Matrix A) {
        return new QRP(A.numRows(), A.numColumns()).factor(A);
    }
1176828
public static void setMatrix(final double[][] m1, final int r0, final int r1, final int[] c, final double[][] m2) {
    assert r0 <= r1 : ERR_INVALID_RANGE;
    assert r1 <= m1.length : ERR_MATRIX_DIMENSIONS;
    for(int i = r0; i < r1; i++) {
      final double[] row1 = m1[i], row2 = m2[i - r0];
      for(int j = 0; j < c.length; j++) {
        row1[c[j]] = row2[j];
      }
    }
  }
992882
public static void multPlusTransA(int blockLength ,
                                      DSubmatrixD1 A , DSubmatrixD1 B ,
                                      DSubmatrixD1 C )
    {
        int heightA = Math.min( blockLength , A.row1 - A.row0 );

        for( int i = C.row0+blockLength; i < C.row1; i += blockLength ) {
            int heightC = Math.min( blockLength , C.row1 - i );

            int indexA = A.row0*A.original.numCols + (i-C.row0+A.col0)*heightA;

            for( int j = i; j < C.col1; j += blockLength ) {
                int widthC = Math.min( blockLength , C.col1 - j );

                int indexC = i*C.original.numCols + j*heightC;
                int indexB = B.row0*B.original.numCols + (j-C.col0+B.col0)*heightA;

                blockMultPlusTransA(A.original.data,B.original.data,C.original.data,
                            indexA,indexB,indexC,heightA,heightC,widthC);
            }
        }
    }
444566
public T concatColumns( SimpleBase ...matrices ) {
        convertType.specify0(this,matrices);
        T A = convertType.convert(this);

        int numCols = A.numCols();
        int numRows = A.numRows();
        for (int i = 0; i < matrices.length; i++) {
            numRows = Math.max(numRows,matrices[i].numRows());
            numCols += matrices[i].numCols();
        }

        SimpleMatrix combined = SimpleMatrix.wrap(convertType.commonType.create(numRows,numCols));

        A.ops.extract(A.mat,0,A.numRows(),0,A.numCols(),combined.mat,0,0);
        int col = A.numCols();
        for (int i = 0; i < matrices.length; i++) {
            Matrix m = convertType.convert(matrices[i]).mat;
            int cols = m.getNumCols();
            int rows = m.getNumRows();;
            A.ops.extract(m,0,rows,0,cols,combined.mat,0,col);
            col += cols;
        }

        return (T)combined;
    }
747566
public Matrix add(Matrix B)
    {
        Matrix toReturn = getThisSideMatrix(B);
        toReturn.mutableAdd(1.0, B);
        return toReturn;
    }
239828
@Override
    protected StatisticsMatrix createMatrix(int numRows, int numCols, MatrixType type) {
        return new StatisticsMatrix(numRows,numCols);
    }
599517
public AbstractMatrix transpose()
    {
        int m = rows();
        int n = columns();
        AbstractMatrix tr = getInstance(n, m, cls);
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < n; j++)
            {
                Array.set(tr.array, M.at(j, i), Array.get(array, M.at(i, j)));
            }
        }
        return tr;
    }
494292
public static Basic1DMatrix diagonal(int size, double diagonal) {
        double[] array = new double[size * size];

        for (int i = 0; i < size; i++) {
            array[i * size + i] = diagonal;
        }

        return new Basic1DMatrix(size, size, array);
    }
1305358
public static SVD factorize(Matrix A) throws NotConvergedException {
        return new SVD(A.numRows(), A.numColumns()).factor(new DenseMatrix(A));
    }
968556
public static StatisticsMatrix wrap( DMatrixRMaj m ) {
        StatisticsMatrix ret = new StatisticsMatrix();
        ret.setMatrix( m );

        return ret;
    }
319942
public IMatrix mul(IMatrix b) {
        IMatrix result = new IMatrix(rows, columns);
        mul(b, result);
        return result;
    }
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;
    }