Add a factor times one row to another row

@param matrix
the matrix to modify
@param diag
coordinate on the diagonal
@param fromCol
first column to process
@param row
row to process
@param factor
factor to multiply
977053
public static void addRowTimes(Matrix matrix, long diag, long fromCol, long row, double factor) {
		long cols = matrix.getColumnCount();
		for (long col = fromCol; col < cols; col++) {
			matrix.setAsDouble(
					matrix.getAsDouble(row, col) - factor * matrix.getAsDouble(diag, col), row, col);
		}
	}
273375
public static void setCol(final double[][] m1, final int c, final double[] column) {
    assert column.length == m1.length : ERR_DIMENSIONS;
    for(int i = 0; i < m1.length; i++) {
      m1[i][c] = column[i];
    }
  }
126725
public static void addRowTimes(double[][] matrix, int diag, int fromCol, int row, double factor) {
		int cols = matrix[0].length;
		double[] d = matrix[diag];
		double[] r = matrix[row];
		for (int col = fromCol; col < cols; col++) {
			r[col] -= factor * d[col];
		}
	}
1335331
public void insertIntoThis(int insertRow, int insertCol, T B) {
        convertType.specify(this,B);
        B = convertType.convert(B);

        // See if this type's need to be changed or not
        if( convertType.commonType == getType() ) {
            insert(B.mat,mat,insertRow,insertCol);
        } else {
            T A = convertType.convert(this);
            A.insert(B.mat,A.mat,insertRow,insertCol);
            setMatrix(A.mat);
        }
    }
912904
public static void multRow(Matrix A, int i, double[] c)
    {
        if(A.cols() != c.length)
            throw new ArithmeticException("Can not perform row update, length miss match " + A.cols() + " and " + c.length);
        multRow(A, i, 0, c.length, c);
    }
107289
public static double[][] diag(double[] vector){

		// Note: According to the Java Language spec, an array is initialized with the default value, here 0.
		double[][] diagonalMatrix = new double[vector.length][vector.length];

		for(int index = 0; index < vector.length; index++) {
			diagonalMatrix[index][index] = vector[index];
		}

		return diagonalMatrix;
	}
193028
public static void diag( DMatrix4x4 input , DMatrix4 out ) {
        out.a1 = input.a11;
        out.a2 = input.a22;
        out.a3 = input.a33;
        out.a4 = input.a44;
    }
927898
private void pivotOperation(int k) {
    double pivot = coeff[row[k]][col[k]];

    // pivot row: set pivot to 1
    coeff[row[k]][col[k]] = 1;
    for(int i = k + 1; i < coeff[k].length; i++) {
      coeff[row[k]][col[i]] /= pivot;
    }
    rhs[row[k]] /= pivot;

    if(LOG.isDebugging()) {
      StringBuilder msg = new StringBuilder();
      msg.append("set pivot element to 1 ").append(equationsToString(4));
      LOG.debugFine(msg.toString());
    }

    // for (int i = k + 1; i < coeff.length; i++) {
    for(int i = 0; i < coeff.length; i++) {
      if(i == k) {
        continue;
      }

      // compute factor
      double q = coeff[row[i]][col[k]];

      // modify entry a[i,k], i <> k
      coeff[row[i]][col[k]] = 0;

      // modify entries a[i,j], i > k fixed, j = k+1...n-1
      for(int j = k + 1; j < coeff[0].length; j++) {
        coeff[row[i]][col[j]] = coeff[row[i]][col[j]] - coeff[row[k]][col[j]] * q;
      } // end for j

      // modify right-hand-side
      rhs[row[i]] = rhs[row[i]] - rhs[row[k]] * q;
    } // end for k

    if(LOG.isDebugging()) {
      StringBuilder msg = new StringBuilder();
      msg.append("after pivot operation ").append(equationsToString(4));
      LOG.debugFine(msg.toString());
    }
  }
1305358
public static SVD factorize(Matrix A) throws NotConvergedException {
        return new SVD(A.numRows(), A.numColumns()).factor(new DenseMatrix(A));
    }
307811
public static void swapCols(Matrix matrix, long col1, long col2) {
		double temp = 0;
		long rows = matrix.getRowCount();
		for (long row = 0; row < rows; row++) {
			temp = matrix.getAsDouble(row, col1);
			matrix.setAsDouble(matrix.getAsDouble(row, col2), row, col1);
			matrix.setAsDouble(temp, row, col2);
		}
	}
80771
public void addFactor(Factor factor) {
        int id = factor.getId();
        boolean alreadyAdded = (0 <= id && id < factors.size());
        if (alreadyAdded) {
            if (factors.get(id) != factor) {
                throw new IllegalStateException("Factor id already set, but factor not yet added.");
            }
        } else {            
            // Factor was not yet in the factor graph.
            //
            // Check and set the id.
            if (id != -1 && id != factors.size()) {
                throw new IllegalStateException("Factor id already set, but incorrect: " + id);
            }
            factor.setId(factors.size());
            // Add the factor.
            factors.add(factor);
            
            // Add each variable...
            for (Var var : factor.getVars()) {
                // Add the variable.
                addVar(var);
                numUndirEdges++;
            }

            if (bg != null) { log.warn("Discarding BipartiteGraph. This may indicate inefficiency."); }
            bg = null;
        }
    }
533367
public static void mult( double a[] , int offsetA ,
                             DMatrixSparseCSC B ,
                             double c[] , int offsetC )
    {
        if( a.length-offsetA < B.numRows)
            throw new IllegalArgumentException("Length of 'a' isn't long enough");
        if( c.length-offsetC < B.numCols)
            throw new IllegalArgumentException("Length of 'c' isn't long enough");

        for (int k = 0; k < B.numCols; k++) {
            int idx0 = B.col_idx[k  ];
            int idx1 = B.col_idx[k+1];

            double sum = 0;
            for (int indexB = idx0; indexB < idx1; indexB++) {
                sum += a[offsetA+B.nz_rows[indexB]]*B.nz_values[indexB];
            }
            c[offsetC+k] = sum;
        }
    }
129831
public EVD factor(DenseMatrix A) throws NotConvergedException {
        if (!A.isSquare())
            throw new IllegalArgumentException("!A.isSquare()");
        else if (A.numRows() != n)
            throw new IllegalArgumentException("A.numRows() != n");

        intW info = new intW(0);
        LAPACK.getInstance().dgeev(jobLeft.netlib(), jobRight.netlib(), n,
                A.getData(), Matrices.ld(n), Wr, Wi,
                jobLeft == JobEig.All ? Vl.getData() : new double[0],
                Matrices.ld(n),
                jobRight == JobEig.All ? Vr.getData() : new double[0],
                Matrices.ld(n), work, work.length, info);

        if (info.val > 0)
            throw new NotConvergedException(
                    NotConvergedException.Reason.Iterations);
        else if (info.val < 0)
            throw new IllegalArgumentException();

        return this;
    }
1089916
public static void setMatrix(final double[][] m1, final int[] r, final int[] c, final double[][] m2) {
    for(int i = 0; i < r.length; i++) {
      final double[] row1 = m1[r[i]], row2 = m2[i];
      for(int j = 0; j < c.length; j++) {
        row1[c[j]] = row2[j];
      }
    }
  }
1045323
public static void divideRowBy(DenseDoubleMatrix2D matrix, long aRow, long fromCol, double value) {
		long cols = matrix.getColumnCount();
		for (long col = fromCol; col < cols; col++) {
			matrix.setDouble(matrix.getDouble(aRow, col) / value, aRow, col);
		}
	}
1162864
private void addColumnsToCF(List<?> row, ColumnFamily cfamily)
    {
        CFMetaData cfm = cfamily.metadata();
        assert cfm != null;

        for (Object c : row)
        {
            JsonColumn col = new JsonColumn<List>((List) c, cfm);
            if (col.isRangeTombstone())
            {
                Composite start = cfm.comparator.fromByteBuffer(col.getName());
                Composite end = cfm.comparator.fromByteBuffer(col.getValue());
                cfamily.addAtom(new RangeTombstone(start, end, col.timestamp, col.localExpirationTime));
                continue;
            }
            
            assert cfm.isCQL3Table() || col.getName().hasRemaining() : "Cell name should not be empty";
            CellName cname = col.getName().hasRemaining() ? cfm.comparator.cellFromByteBuffer(col.getName()) 
                    : cfm.comparator.rowMarker(Composites.EMPTY);

            if (col.isExpiring())
            {
                cfamily.addColumn(new BufferExpiringCell(cname, col.getValue(), col.timestamp, col.ttl, col.localExpirationTime));
            }
            else if (col.isCounter())
            {
                cfamily.addColumn(new BufferCounterCell(cname, col.getValue(), col.timestamp, col.timestampOfLastDelete));
            }
            else if (col.isDeleted())
            {
                cfamily.addTombstone(cname, col.getValue(), col.timestamp);
            }
            else if (col.isRangeTombstone())
            {
                CellName end = cfm.comparator.cellFromByteBuffer(col.getValue());
                cfamily.addAtom(new RangeTombstone(cname, end, col.timestamp, col.localExpirationTime));
            }
            // cql3 row marker, see CASSANDRA-5852
            else if (cname.isEmpty())
            {
                cfamily.addColumn(cfm.comparator.rowMarker(Composites.EMPTY), col.getValue(), col.timestamp);
            }
            else
            {
                cfamily.addColumn(cname, col.getValue(), col.timestamp);
            }
        }
    }
888326
public static RQ factorize(Matrix A) {
        return new RQ(A.numRows(), A.numColumns()).factor(new DenseMatrix(A));
    }