/** * Return the column at the given index * * @param column an int column index * @return a Vector at the index * @throws org.apache.mahout.math.IndexException * if the index is out of bounds */ @Override public Vector viewColumn(int column) { if (column < 0 || column >= columnSize()) { throw new IndexException(column, columnSize()); } return new PermutedVectorView(base.viewColumn(columnPivot[column]), rowPivot, rowUnpivot); }
/** * Compute inv(L) * z efficiently. * * @param z */ public Matrix solveLeft(Matrix z) { int n = L.columnSize(); int nx = z.columnSize(); Matrix X = new DenseMatrix(n, z.columnSize()); X.assign(z); // Solve L*Y = Z using back-substitution // note that k and i have to go in a funny order because L is pivoted for (int internalK = 0; internalK < n; internalK++) { int k = L.rowUnpivot(internalK); for (int j = 0; j < nx; j++) { for (int internalI = 0; internalI < internalK; internalI++) { int i = L.rowUnpivot(internalI); X.set(k, j, X.get(k, j) - X.get(i, j) * L.get(k, i)); } if (L.get(k, k) != 0) { X.set(k, j, X.get(k, j) / L.get(k, k)); } else { X.set(k, j, 0); } } } return X; }
/** * Return the column at the given index * * @param column an int column index * @return a Vector at the index * @throws org.apache.mahout.math.IndexException * if the index is out of bounds */ @Override public Vector viewColumn(int column) { if (column < 0 || column >= columnSize()) { throw new IndexException(column, columnSize()); } return new PermutedVectorView(base.viewColumn(columnPivot[column]), rowPivot, rowUnpivot); }
/** * Return the column at the given index * * @param column an int column index * @return a Vector at the index * @throws org.apache.mahout.math.IndexException * if the index is out of bounds */ @Override public Vector viewColumn(int column) { if (column < 0 || column >= columnSize()) { throw new IndexException(column, columnSize()); } return new PermutedVectorView(base.viewColumn(columnPivot[column]), rowPivot, rowUnpivot); }
/** * Compute inv(L) * z efficiently. * * @param z */ public Matrix solveLeft(Matrix z) { int n = L.columnSize(); int nx = z.columnSize(); Matrix X = new DenseMatrix(n, z.columnSize()); X.assign(z); // Solve L*Y = Z using back-substitution // note that k and i have to go in a funny order because L is pivoted for (int internalK = 0; internalK < n; internalK++) { int k = L.rowUnpivot(internalK); for (int j = 0; j < nx; j++) { for (int internalI = 0; internalI < internalK; internalI++) { int i = L.rowUnpivot(internalI); X.set(k, j, X.get(k, j) - X.get(i, j) * L.get(k, i)); } if (L.get(k, k) != 0) { X.set(k, j, X.get(k, j) / L.get(k, k)); } else { X.set(k, j, 0); } } } return X; }
/** * Compute inv(L) * z efficiently. * * @param z */ public Matrix solveLeft(Matrix z) { int n = L.columnSize(); int nx = z.columnSize(); Matrix X = new DenseMatrix(n, z.columnSize()); X.assign(z); // Solve L*Y = Z using back-substitution // note that k and i have to go in a funny order because L is pivoted for (int internalK = 0; internalK < n; internalK++) { int k = L.rowUnpivot(internalK); for (int j = 0; j < nx; j++) { for (int internalI = 0; internalI < internalK; internalI++) { int i = L.rowUnpivot(internalI); X.set(k, j, X.get(k, j) - X.get(i, j) * L.get(k, i)); } if (L.get(k, k) != 0) { X.set(k, j, X.get(k, j) / L.get(k, k)); } else { X.set(k, j, 0); } } } return X; }