Returns the new matrix <i>C</i> that is <i>C = A*B<sup>T</sup></i>
@param B the matrix to multiply by the transpose of
@param threadPool the source of threads to do computation in parallel
@return the result C
424762
public Matrix multiplyTranspose(final Matrix B, ExecutorService threadPool)
    {
        Matrix C = new DenseMatrix(this.rows(), B.rows());
        multiplyTranspose(B, C, threadPool);
        return C;
    }
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;
    }
1000194
public DenseDoubleMatrix multT(DoubleMatrix bMat, boolean transposeA, boolean transposeB) {
        int numRowsC = transposeA ? this.getNumColumns() : this.getNumRows();
        int numColsC = transposeB ? bMat.getNumRows() : bMat.getNumColumns();
        DenseDoubleMatrix cMat = new DenseDoubleMatrix(numRowsC, numColsC);
        this.multT(bMat, cMat, transposeA, transposeB);
        return cMat;
    }
199133
public Matrix add(Matrix m) throws MatrixException
    {
        // Validate m's size.
        if ((nRows != m.nRows) && (nCols != m.nCols)) {
            throw new MatrixException(
                                MatrixException.INVALID_DIMENSIONS);
        }

        double sv[][] = new double[nRows][nCols]; // sum values

        // Compute values of the sum.
        for (int r = 0; r < nRows; ++r) {
            for (int c = 0; c < nCols; ++c) {
                sv[r][c] = values[r][c] + m.values[r][c];
            }
        }

        return new Matrix(sv);
    }
225751
public static final DoubleMatrix2D add(DoubleMatrix2D A, DoubleMatrix2D B){
		if(A.rows()!=B.rows() || A.columns()!=B.columns()){
			throw new IllegalArgumentException("wrong matrices dimensions");
		}
		DoubleMatrix2D ret = DoubleFactory2D.dense.make(A.rows(), A.columns());
		for(int i=0; i<ret.rows(); i++){
			for(int j=0; j<ret.columns(); j++){
				ret.setQuick(i, j, A.getQuick(i, j) + B.getQuick(i, j));
			}
		}

		return ret;
	}
648075
public static double[][] transposeTimes(final double[][] m1, final double[][] m2) {
    final int rowdim1 = m1.length, coldim1 = getColumnDimensionality(m1);
    final int coldim2 = getColumnDimensionality(m2);
    assert m2.length == rowdim1 : ERR_MATRIX_INNERDIM;
    final double[][] re = new double[coldim1][coldim2];
    final double[] Bcolj = new double[rowdim1];
    for(int j = 0; j < coldim2; j++) {
      // Make a linear copy of column j from B
      for(int k = 0; k < rowdim1; k++) {
        Bcolj[k] = m2[k][j];
      }
      // multiply it with each row from A
      for(int i = 0; i < coldim1; i++) {
        double s = 0;
        for(int k = 0; k < rowdim1; k++) {
          s += m1[k][i] * Bcolj[k];
        }
        re[i][j] = s;
      }
    }
    return re;
  }
1149836
public static void mult(DMatrixSparseCSC A ,
                            double b[] , int offsetB ,
                            double c[] , int offsetC )
    {
        Arrays.fill(c,offsetC,offsetC+A.numRows,0);
        multAdd(A,b,offsetB,c,offsetC);
    }
35525
public IVector mul(double b) {
        IVector result = new IVector(size);
        mul(b, result);
        return result;
    }
1294034
public void mul(IMatrix b, IMatrix result) {
        if ((b == null) || (columns != b.rows)) return;

        if ((result.rows != rows) || (result.columns != b.columns)) result.reshape(rows, b.columns);
        int i, j, k;
        double realsum, imagsum;
        for (i = 0; i < rows; i++)
            for (k = 0; k < b.columns; k++) {
                realsum = 0;
                imagsum = 0;
                for (j = 0; j < columns; j++) {
                    realsum += realmatrix[i][j] * b.realmatrix[j][k] - imagmatrix[i][j] * b.imagmatrix[j][k];
                    imagsum += realmatrix[i][j] * b.imagmatrix[j][k] + imagmatrix[i][j] * b.realmatrix[j][k];
                }
                result.realmatrix[i][k] = realsum;
                result.imagmatrix[i][k] = imagsum;
            }
    }
1293528
public Matrix transposeMultiply(Matrix B)
    {
        Matrix C = new DenseMatrix(this.cols(), B.cols());
        transposeMultiply(B, C);
        return C;
    }
343008
public DoubleMatrix1D solve(DoubleMatrix1D b) {
		if (b.size() != dim) {
			log.error("wrong dimension of vector b: expected " + dim + ", actual "	+ b.size());
			throw new RuntimeException("wrong dimension of vector b: expected " + dim	+ ", actual " + b.size());
		}

		throw new RuntimeException("not yet implemented");
	}
117919
public Matrix transpose() {
        Matrix A = new Matrix(N, M);
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++) {
                A.data[j][i] = data[i][j];
            }
        }
        return A;
    }
1241069
public Matrix subtract(Matrix B, ExecutorService threadPool)
    {
        Matrix toReturn = getThisSideMatrix(B);
        toReturn.mutableSubtract(1.0, B, threadPool);
        return toReturn;
    }
1287983
public double[][] solve(double[][] B) {
        if (B.length != m) {
            throw new IllegalArgumentException("Matrix row dimensions must agree.");
        }
        if (!this.isNonsingular()) {
            throw new RuntimeException("Matrix is singular.");
        }

        // Copy right hand side with pivoting
        int nx = B[0].length;
        double[][] X = Matrix.Submatrix(B, piv, 0, nx - 1);

        // Solve L*Y = B(piv,:)
        for (int k = 0; k < n; k++) {
            for (int i = k + 1; i < n; i++) {
                for (int j = 0; j < nx; j++) {
                    X[i][j] -= X[k][j] * LU[i][k];
                }
            }
        }
        // Solve U*X = Y;
        for (int k = n - 1; k >= 0; k--) {
            for (int j = 0; j < nx; j++) {
                X[k][j] /= LU[k][k];
            }
            for (int i = 0; i < k; i++) {
                for (int j = 0; j < nx; j++) {
                    X[i][j] -= X[k][j] * LU[i][k];
                }
            }
        }
        return X;
    }
1146624
public IMatrix transpose() {
        IMatrix result = new IMatrix(rows, columns);
        transpose(result);
        return result;
    }
201353
public Matrix plus(final Matrix B)
    {
        final Matrix A = this;

        if ((B.m_rows != A.m_rows) || (B.m_columns != A.m_columns))
        {
            throw new GeometryException("Illegal matrix dimensions");
        }
        final Matrix C = new Matrix(m_rows, m_columns);

        for (int i = 0; i < m_rows; i++)
        {
            for (int j = 0; j < m_columns; j++)
            {
                C.m_data[i][j] = A.m_data[i][j] + B.m_data[i][j];
            }
        }
        return C;
    }
375804
public Matrix subtract(double c, ExecutorService threadPool)
    {
        Matrix toReturn = getThisSideMatrix(null);
        toReturn.mutableSubtract(c, threadPool);
        return toReturn;
    }