<p>Performs the following operation:<br>
<br>
a = a + b <br>
a<sub>ij</sub> = a<sub>ij</sub> + b<sub>ij</sub> <br>
</p>

@param a A Matrix. Modified.
@param b A Matrix. Not modified.
184818
public static void addEquals( DMatrix2x2 a , DMatrix2x2 b ) {
        a.a11 += b.a11;
        a.a12 += b.a12;
        a.a21 += b.a21;
        a.a22 += b.a22;
    }
1227463
public static long addExact(long a, long b) {
        long result = a + b;
        checkNoOverflow((a ^ b) < 0 | (a ^ result) >= 0);
        return result;
    }
670946
public SparseSquareMatrix plus(SparseSquareMatrix B) {

		SparseSquareMatrix A = this;

		if (A.N != B.N) throw new IllegalArgumentException("Dimensions disagree. " + A.N + " != " + B.N);

		SparseSquareMatrix C = new SparseSquareMatrix(N);

		for (int i = 0; i < N; i++)
			C.rows[i] = A.rows[i].plus(B.rows[i]);

		return C;
	}
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);
    }
1253729
public boolean eq(Matrix B) {
        Matrix A = this;
        if (B.M != A.M || B.N != A.N) {
            throw new RuntimeException("Illegal matrix dimensions.");
        }
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++) {
                if (A.data[i][j] != B.data[i][j]) {
                    return false;
                }
            }
        }
        return true;
    }
374400
public static void multTranA( DMatrixRMaj A , DMatrixRMaj B , DMatrixRMaj C , DMatrixRMaj output )
	{
		double t11 = A.data[0]*B.data[0] + A.data[3]*B.data[3] + A.data[6]*B.data[6];
		double t12 = A.data[0]*B.data[1] + A.data[3]*B.data[4] + A.data[6]*B.data[7];
		double t13 = A.data[0]*B.data[2] + A.data[3]*B.data[5] + A.data[6]*B.data[8];

		double t21 = A.data[1]*B.data[0] + A.data[4]*B.data[3] + A.data[7]*B.data[6];
		double t22 = A.data[1]*B.data[1] + A.data[4]*B.data[4] + A.data[7]*B.data[7];
		double t23 = A.data[1]*B.data[2] + A.data[4]*B.data[5] + A.data[7]*B.data[8];

		double t31 = A.data[2]*B.data[0] + A.data[5]*B.data[3] + A.data[8]*B.data[6];
		double t32 = A.data[2]*B.data[1] + A.data[5]*B.data[4] + A.data[8]*B.data[7];
		double t33 = A.data[2]*B.data[2] + A.data[5]*B.data[5] + A.data[8]*B.data[8];

		output.data[0] = t11*C.data[0] + t12*C.data[3] + t13*C.data[6];
		output.data[1] = t11*C.data[1] + t12*C.data[4] + t13*C.data[7];
		output.data[2] = t11*C.data[2] + t12*C.data[5] + t13*C.data[8];

		output.data[3] = t21*C.data[0] + t22*C.data[3] + t23*C.data[6];
		output.data[4] = t21*C.data[1] + t22*C.data[4] + t23*C.data[7];
		output.data[5] = t21*C.data[2] + t22*C.data[5] + t23*C.data[8];

		output.data[6] = t31*C.data[0] + t32*C.data[3] + t33*C.data[6];
		output.data[7] = t31*C.data[1] + t32*C.data[4] + t33*C.data[7];
		output.data[8] = t31*C.data[2] + t32*C.data[5] + t33*C.data[8];
	}
939018
public static void subtractEquals(DMatrixD1 a, DMatrixD1 b)
    {
        if( a.numCols != b.numCols || a.numRows != b.numRows ) {
            throw new MatrixDimensionException("The 'a' and 'b' matrices do not have compatible dimensions");
        }

        final int length = a.getNumElements();

        for( int i = 0; i < length; i++ ) {
            a.data[i] -= b.data[i];
        }
    }
92052
public void addEdge(N a, N b)
    {
        if( !containsBoth(a, b) )
            return;//Cant add nodes to things that doing exist
        nodes.get(a).getOutgoing().add(b);
        nodes.get(b).getIncoming().add(a);
    }
1367612
public static void multAddTransAB(DMatrixSparseCSC A , DMatrixRMaj B , DMatrixRMaj C )
    {
        if( A.numCols != C.numRows || B.numRows != C.numCols )
            throw new IllegalArgumentException("Inconsistent matrix shapes. "+stringShapes(A,B,C));

        ImplSparseSparseMult_DSCC.multAddTransAB(A,B,C);
    }
1248419
public Matrix plus(Matrix B) {
        Matrix A = this;
        if (B.M != A.M || B.N != A.N) {
            throw new RuntimeException("Illegal matrix dimensions.");
        }
        Matrix C = new Matrix(M, N);
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++) {
                C.data[i][j] = A.data[i][j] + B.data[i][j];
            }
        }
        return C;
    }
439845
public static SimpleMatrix convertSimple( DMatrixRBlock A ) {
        DMatrixRMaj B = ConvertDMatrixStruct.convert(A, null);

        return SimpleMatrix.wrap(B);
    }
451433
public static void subtractEquals( DMatrix2 a , DMatrix2 b ) {
        a.a1 -= b.a1;
        a.a2 -= b.a2;
    }
887365
public void set(int i, int j, Matrix<T> B)
    {
        int m = B.rows();
        int n = B.columns();
        for (int ii = 0; ii < m; ii++)
        {
            for (int jj = 0; jj < n; jj++)
            {
                set(i+ii, j+jj, B.get(ii, jj));
            }
        }
    }
596434
@Override
    public double compute(double a, double b) {
        if (Op.isEq(a + b, 0.0)) return 0.0;
        return (a * b) / (a + b - a * b);
    }
288004
public static final DoubleMatrix1D zMult(final DoubleMatrix2D A, final DoubleMatrix1D a, final DoubleMatrix1D b, final double beta){

		if(A.columns()!=a.size()){
			throw new IllegalArgumentException("Wrong matrix dimensions. Number of columns must be " + a.size() + ", found: " + A.columns());
		}

		if(A.rows()!=b.size()){
			throw new IllegalArgumentException("Wrong matrix dimensions. Number of rows must be " + b.size() + ", found: " + A.rows());
		}

		final DoubleMatrix1D ret = DoubleFactory1D.dense.make(A.rows());

		if(A instanceof SparseDoubleMatrix2D){
			//sparse matrix
			A.forEachNonZero(new IntIntDoubleFunction() {
				@Override
				public double apply(int i, int j, double Aij) {
					ret.setQuick(i, ret.getQuick(i) + Aij * a.getQuick(j));
					return Aij;
				}
			});
			for(int i=0; i<ret.size(); i++){
				ret.setQuick(i, ret.getQuick(i) + beta * b.getQuick(i));
			}
		}else{
			//dense matrix
			for(int i=0; i<A.rows(); i++){
				double vi = beta * b.getQuick(i);
				for(int j=0; j<A.columns(); j++){
					vi += A.getQuick(i, j) * a.getQuick(j);
				}
				ret.setQuick(i, vi);
			}
		}

		return ret;
	}
857270
public static DoubleMatrix solve(DoubleMatrix A, DoubleMatrix B) {
		A.assertSquare();
		DoubleMatrix X = B.dup();
		int[] ipiv = new int[B.rows];
		SimpleBlas.gesv(A.dup(), ipiv, X);
		return X;
	}
998589
public static void subtractEquals( DMatrix2x2 a , DMatrix2x2 b ) {
        a.a11 -= b.a11;
        a.a12 -= b.a12;
        a.a21 -= b.a21;
        a.a22 -= b.a22;
    }