public DoubleMatrix1D apply(DoubleMatrix1D b, DoubleMatrix1D x) { if (x == null) { x = b.like(); } if (!(x instanceof DenseDoubleMatrix1D) || !(b instanceof DenseDoubleMatrix1D)) throw new IllegalArgumentException("a nad b must be dense vectors"); double[] xd = ((DenseDoubleMatrix1D) x).elements(); double[] bd = ((DenseDoubleMatrix1D) b).elements(); for (int i = 0; i < invdiag.length; ++i) xd[i] = bd[i] * invdiag[i]; return x; }
public DoubleMatrix1D apply(DoubleMatrix1D b, DoubleMatrix1D x) { if (x == null) { x = b.like(); } if (!(x instanceof DenseDoubleMatrix1D) || !(b instanceof DenseDoubleMatrix1D)) throw new IllegalArgumentException("a nad b must be dense vectors"); double[] xd = ((DenseDoubleMatrix1D) x).elements(); double[] bd = ((DenseDoubleMatrix1D) b).elements(); for (int i = 0; i < invdiag.length; ++i) xd[i] = bd[i] * invdiag[i]; return x; }
private DoubleMatrix1D unitLowerSolve(DoubleMatrix1D b, DoubleMatrix1D x) { double[] bd = ((DenseDoubleMatrix1D) b).elements(); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int rows = LU.rows(); for (int i = 0; i < rows; ++i) { // Get row i SparseDoubleMatrix1D row = LU.viewRow(i); // xi = bi - sum[j<i] Lij * xj double sum = 0; for (int j = 0; j < i; ++j) sum += row.getQuick(j) * xd[j]; xd[i] = bd[i] - sum; } return x; }
private DoubleMatrix1D unitLowerSolve(DoubleMatrix1D b, DoubleMatrix1D x) { double[] bd = ((DenseDoubleMatrix1D) b).elements(); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int rows = LU.rows(); for (int i = 0; i < rows; ++i) { // Get row i SparseDoubleMatrix1D row = LU.viewRow(i); // xi = bi - sum[j<i] Lij * xj double sum = 0; for (int j = 0; j < i; ++j) sum += row.getQuick(j) * xd[j]; xd[i] = bd[i] - sum; } return x; }
private DoubleMatrix1D upperSolve(DoubleMatrix1D b, DoubleMatrix1D x) { double[] bd = ((DenseDoubleMatrix1D) b).elements(); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int[] colind = LU.getColumnIndexes(); int[] rowptr = LU.getRowPointers(); double[] data = LU.getValues(); int rows = LU.rows(); for (int i = rows - 1; i >= 0; --i) { // xi = (bi - sum[j>i] Uij * xj) / Uii double sum = 0; for (int j = diagind[i] + 1; j < rowptr[i + 1]; ++j) sum += data[j] * xd[colind[j]]; xd[i] = (bd[i] - sum) / data[diagind[i]]; } return x; }
private DoubleMatrix1D upperSolve(DoubleMatrix1D b, DoubleMatrix1D x) { double[] bd = ((DenseDoubleMatrix1D) b).elements(); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int[] colind = R.getColumnIndexes(); int[] rowptr = R.getRowPointers(); double[] data = R.getValues(); int rows = R.rows(); for (int i = rows - 1; i >= 0; --i) { // xi = (bi - sum[j>i] Uij * xj) / Uii double sum = 0; for (int j = diagind[i] + 1; j < rowptr[i + 1]; ++j) sum += data[j] * xd[colind[j]]; xd[i] = (bd[i] - sum) / data[diagind[i]]; } return x; }
private DoubleMatrix1D upperSolve(DoubleMatrix1D b, DoubleMatrix1D x) { double[] bd = ((DenseDoubleMatrix1D) b).elements(); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int[] colind = R.getColumnIndexes(); int[] rowptr = R.getRowPointers(); double[] data = R.getValues(); int rows = R.rows(); for (int i = rows - 1; i >= 0; --i) { // xi = (bi - sum[j>i] Uij * xj) / Uii double sum = 0; for (int j = diagind[i] + 1; j < rowptr[i + 1]; ++j) sum += data[j] * xd[colind[j]]; xd[i] = (bd[i] - sum) / data[diagind[i]]; } return x; }
private DoubleMatrix1D lowerUnitSolve(DoubleMatrix1D b, DoubleMatrix1D x) { double[] bd = ((DenseDoubleMatrix1D) b).elements(); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int[] colind = LU.getColumnIndexes(); int[] rowptr = LU.getRowPointers(); double[] data = LU.getValues(); int rows = LU.rows(); for (int i = 0; i < rows; ++i) { // xi = bi - sum[j<i] Lij * xj double sum = 0; for (int j = rowptr[i]; j < diagind[i]; ++j) sum += data[j] * xd[colind[j]]; xd[i] = bd[i] - sum; } return x; }
private DoubleMatrix1D lowerUnitSolve(DoubleMatrix1D b, DoubleMatrix1D x) { double[] bd = ((DenseDoubleMatrix1D) b).elements(); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int[] colind = LU.getColumnIndexes(); int[] rowptr = LU.getRowPointers(); double[] data = LU.getValues(); int rows = LU.rows(); for (int i = 0; i < rows; ++i) { // xi = bi - sum[j<i] Lij * xj double sum = 0; for (int j = rowptr[i]; j < diagind[i]; ++j) sum += data[j] * xd[colind[j]]; xd[i] = bd[i] - sum; } return x; }
private DoubleMatrix1D upperSolve(DoubleMatrix1D b, DoubleMatrix1D x) { double[] bd = ((DenseDoubleMatrix1D) b).elements(); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int[] colind = LU.getColumnIndexes(); int[] rowptr = LU.getRowPointers(); double[] data = LU.getValues(); int rows = LU.rows(); for (int i = rows - 1; i >= 0; --i) { // xi = (bi - sum[j>i] Uij * xj) / Uii double sum = 0; for (int j = diagind[i] + 1; j < rowptr[i + 1]; ++j) sum += data[j] * xd[colind[j]]; xd[i] = (bd[i] - sum) / data[diagind[i]]; } return x; }
private DoubleMatrix1D upperSolve(DoubleMatrix1D b, DoubleMatrix1D x) { double[] bd = ((DenseDoubleMatrix1D) b).elements(); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int rows = LU.rows(); for (int i = rows - 1; i >= 0; --i) { // Get row i SparseDoubleMatrix1D row = LU.viewRow(i); int used = (int) row.size(); // xi = (bi - sum[j>i] Uij * xj) / Uii double sum = 0; for (int j = i + 1; j < used; ++j) sum += row.getQuick(j) * xd[j]; xd[i] = (bd[i] - sum) / row.getQuick(i); } return x; }
private DoubleMatrix1D upperSolve(DoubleMatrix1D b, DoubleMatrix1D x) { double[] bd = ((DenseDoubleMatrix1D) b).elements(); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int rows = LU.rows(); for (int i = rows - 1; i >= 0; --i) { // Get row i SparseDoubleMatrix1D row = LU.viewRow(i); int used = (int) row.size(); // xi = (bi - sum[j>i] Uij * xj) / Uii double sum = 0; for (int j = i + 1; j < used; ++j) sum += row.getQuick(j) * xd[j]; xd[i] = (bd[i] - sum) / row.getQuick(i); } return x; }
private DoubleMatrix1D unitLowerTransSolve(DoubleMatrix1D b, DoubleMatrix1D x) { x.assign(b); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int rows = LU.rows(); for (int i = rows - 1; i >= 0; --i) { // Get row i SparseDoubleMatrix1D row = LU.viewRow(i); // At this stage, x[i] is known, so move it over to the right // hand side for the remaining equations for (int j = 0; j < i; ++j) xd[j] -= row.getQuick(j) * xd[i]; } return x; }
private DoubleMatrix1D unitLowerTransSolve(DoubleMatrix1D b, DoubleMatrix1D x) { x.assign(b); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int rows = LU.rows(); for (int i = rows - 1; i >= 0; --i) { // Get row i SparseDoubleMatrix1D row = LU.viewRow(i); // At this stage, x[i] is known, so move it over to the right // hand side for the remaining equations for (int j = 0; j < i; ++j) xd[j] -= row.getQuick(j) * xd[i]; } return x; }
private DoubleMatrix1D loverUnitTransSolve(DoubleMatrix1D b, DoubleMatrix1D x) { x.assign(b); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int[] colind = LU.getColumnIndexes(); int[] rowptr = LU.getRowPointers(); double[] data = LU.getValues(); int rows = LU.rows(); for (int i = rows - 1; i >= 0; --i) // At this stage, x[i] is known, so move it over to the right hand // side for the remaining equations for (int j = rowptr[i]; j < diagind[i]; ++j) xd[colind[j]] -= data[j] * xd[i]; return x; }
private DoubleMatrix1D loverUnitTransSolve(DoubleMatrix1D b, DoubleMatrix1D x) { x.assign(b); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int[] colind = LU.getColumnIndexes(); int[] rowptr = LU.getRowPointers(); double[] data = LU.getValues(); int rows = LU.rows(); for (int i = rows - 1; i >= 0; --i) // At this stage, x[i] is known, so move it over to the right hand // side for the remaining equations for (int j = rowptr[i]; j < diagind[i]; ++j) xd[colind[j]] -= data[j] * xd[i]; return x; }
private DoubleMatrix1D upperTransSolve(DoubleMatrix1D b, DoubleMatrix1D x) { x.assign(b); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int[] colind = LU.getColumnIndexes(); int[] rowptr = LU.getRowPointers(); double[] data = LU.getValues(); int rows = LU.rows(); for (int i = 0; i < rows; ++i) { // Solve for the current entry xd[i] /= data[diagind[i]]; // Move this known solution over to the right hand side for the // remaining equations for (int j = diagind[i] + 1; j < rowptr[i + 1]; ++j) xd[colind[j]] -= data[j] * xd[i]; } return x; }
private DoubleMatrix1D upperTransSolve(DoubleMatrix1D b, DoubleMatrix1D x) { x.assign(b); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int[] colind = R.getColumnIndexes(); int[] rowptr = R.getRowPointers(); double[] data = R.getValues(); int rows = R.rows(); for (int i = 0; i < rows; ++i) { // Solve for the current entry xd[i] /= data[diagind[i]]; // Move this known solution over to the right hand side for the // remaining equations for (int j = diagind[i] + 1; j < rowptr[i + 1]; ++j) xd[colind[j]] -= data[j] * xd[i]; } return x; } }
private DoubleMatrix1D upperTransSolve(DoubleMatrix1D b, DoubleMatrix1D x) { x.assign(b); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int rows = LU.rows(); for (int i = 0; i < rows; ++i) { // Get row i SparseDoubleMatrix1D row = LU.viewRow(i); int used = (int) row.size(); // Solve for the current entry xd[i] /= row.getQuick(i); // Move this known solution over to the right hand side for the // remaining equations for (int j = i + 1; j < used; ++j) xd[j] -= row.getQuick(j) * xd[i]; } return x; }
private DoubleMatrix1D upperTransSolve(DoubleMatrix1D b, DoubleMatrix1D x) { x.assign(b); double[] xd = ((DenseDoubleMatrix1D) x).elements(); int rows = LU.rows(); for (int i = 0; i < rows; ++i) { // Get row i SparseDoubleMatrix1D row = LU.viewRow(i); int used = (int) row.size(); // Solve for the current entry xd[i] /= row.getQuick(i); // Move this known solution over to the right hand side for the // remaining equations for (int j = i + 1; j < used; ++j) xd[j] -= row.getQuick(j) * xd[i]; } return x; }