/** {@inheritDoc} */ @Override public void visit(final int row, final int column, final T value) { out.setEntry(column, row, value); }
/** {@inheritDoc} */ @Override public void visit(final int row, final int column, final T value) { out.setEntry(column, row, value); }
/** {@inheritDoc} */ public FieldMatrix<T> getU() { if ((cachedU == null) && !singular) { final int m = pivot.length; cachedU = new Array2DRowFieldMatrix<T>(field, m, m); for (int i = 0; i < m; ++i) { final T[] luI = lu[i]; for (int j = i; j < m; ++j) { cachedU.setEntry(i, j, luI[j]); } } } return cachedU; }
/** {@inheritDoc} */ public FieldMatrix<T> getL() { if ((cachedL == null) && !singular) { final int m = pivot.length; cachedL = new Array2DRowFieldMatrix<T>(field, m, m); for (int i = 0; i < m; ++i) { final T[] luI = lu[i]; for (int j = 0; j < i; ++j) { cachedL.setEntry(i, j, luI[j]); } cachedL.setEntry(i, i, field.getOne()); } } return cachedL; }
/** {@inheritDoc} */ public FieldMatrix<T> getU() { if ((cachedU == null) && !singular) { final int m = pivot.length; cachedU = new Array2DRowFieldMatrix<T>(field, m, m); for (int i = 0; i < m; ++i) { final T[] luI = lu[i]; for (int j = i; j < m; ++j) { cachedU.setEntry(i, j, luI[j]); } } } return cachedU; }
/** {@inheritDoc} */ public FieldMatrix<T> getP() { if ((cachedP == null) && !singular) { final int m = pivot.length; cachedP = new Array2DRowFieldMatrix<T>(field, m, m); for (int i = 0; i < m; ++i) { cachedP.setEntry(i, pivot[i], field.getOne()); } } return cachedP; }
/** {@inheritDoc} */ public FieldMatrix<T> getP() { if ((cachedP == null) && !singular) { final int m = pivot.length; cachedP = new Array2DRowFieldMatrix<T>(field, m, m); for (int i = 0; i < m; ++i) { cachedP.setEntry(i, pivot[i], field.getOne()); } } return cachedP; }
/** {@inheritDoc} */ public FieldMatrix<T> getInverse() throws InvalidMatrixException { final int m = pivot.length; final T one = field.getOne(); FieldMatrix<T> identity = new Array2DRowFieldMatrix<T>(field, m, m); for (int i = 0; i < m; ++i) { identity.setEntry(i, i, one); } return solve(identity); }
/** {@inheritDoc} */ public FieldMatrix<T> getInverse() throws InvalidMatrixException { final int m = pivot.length; final T one = field.getOne(); FieldMatrix<T> identity = new Array2DRowFieldMatrix<T>(field, m, m); for (int i = 0; i < m; ++i) { identity.setEntry(i, i, one); } return solve(identity); }
/** {@inheritDoc} */ public FieldMatrix<T> outerProduct(T[] v) throws IllegalArgumentException { checkVectorDimensions(v.length); final int m = data.length; final FieldMatrix<T> out = new Array2DRowFieldMatrix<T>(field, m, m); for (int i = 0; i < data.length; i++) { for (int j = 0; j < data.length; j++) { out.setEntry(i, j, data[i].multiply(v[j])); } } return out; }
/** {@inheritDoc} */ public FieldMatrix<T> getRowMatrix(final int row) throws MatrixIndexException { checkRowIndex(row); final int nCols = getColumnDimension(); final FieldMatrix<T> out = createMatrix(1, nCols); for (int i = 0; i < nCols; ++i) { out.setEntry(0, i, getEntry(row, i)); } return out; }
/** {@inheritDoc} */ public FieldMatrix<T> getColumnMatrix(final int column) throws MatrixIndexException { checkColumnIndex(column); final int nRows = getRowDimension(); final FieldMatrix<T> out = createMatrix(nRows, 1); for (int i = 0; i < nRows; ++i) { out.setEntry(i, 0, getEntry(i, column)); } return out; }
/** {@inheritDoc} */ public FieldMatrix<T> getRowMatrix(final int row) throws MatrixIndexException { checkRowIndex(row); final int nCols = getColumnDimension(); final FieldMatrix<T> out = createMatrix(1, nCols); for (int i = 0; i < nCols; ++i) { out.setEntry(0, i, getEntry(row, i)); } return out; }
/** {@inheritDoc} */ public FieldMatrix<T> getColumnMatrix(final int column) throws MatrixIndexException { checkColumnIndex(column); final int nRows = getRowDimension(); final FieldMatrix<T> out = createMatrix(nRows, 1); for (int i = 0; i < nRows; ++i) { out.setEntry(i, 0, getEntry(i, column)); } return out; }
/** {@inheritDoc} */ public FieldMatrix<T> scalarMultiply(final T d) { final int rowCount = getRowDimension(); final int columnCount = getColumnDimension(); final FieldMatrix<T> out = createMatrix(rowCount, columnCount); for (int row = 0; row < rowCount; ++row) { for (int col = 0; col < columnCount; ++col) { out.setEntry(row, col, getEntry(row, col).multiply(d)); } } return out; }
/** {@inheritDoc} */ public FieldMatrix<T> scalarMultiply(final T d) { final int rowCount = getRowDimension(); final int columnCount = getColumnDimension(); final FieldMatrix<T> out = createMatrix(rowCount, columnCount); for (int row = 0; row < rowCount; ++row) { for (int col = 0; col < columnCount; ++col) { out.setEntry(row, col, getEntry(row, col).multiply(d)); } } return out; }
/** {@inheritDoc} */ public FieldMatrix<T> scalarAdd(final T d) { final int rowCount = getRowDimension(); final int columnCount = getColumnDimension(); final FieldMatrix<T> out = createMatrix(rowCount, columnCount); for (int row = 0; row < rowCount; ++row) { for (int col = 0; col < columnCount; ++col) { out.setEntry(row, col, getEntry(row, col).add(d)); } } return out; }
/** {@inheritDoc} */ public FieldMatrix<T> scalarAdd(final T d) { final int rowCount = getRowDimension(); final int columnCount = getColumnDimension(); final FieldMatrix<T> out = createMatrix(rowCount, columnCount); for (int row = 0; row < rowCount; ++row) { for (int col = 0; col < columnCount; ++col) { out.setEntry(row, col, getEntry(row, col).add(d)); } } return out; }
/** {@inheritDoc} */ public FieldMatrix<T> subtract(final FieldMatrix<T> m) throws IllegalArgumentException { // safety check checkSubtractionCompatible(m); final int rowCount = getRowDimension(); final int columnCount = getColumnDimension(); final FieldMatrix<T> out = createMatrix(rowCount, columnCount); for (int row = 0; row < rowCount; ++row) { for (int col = 0; col < columnCount; ++col) { out.setEntry(row, col, getEntry(row, col).subtract(m.getEntry(row, col))); } } return out; }
/** {@inheritDoc} */ public FieldMatrix<T> outerProduct(T[] v) throws IllegalArgumentException { checkVectorDimensions(v.length); FieldMatrix<T> res = new SparseFieldMatrix<T>(field, virtualSize, virtualSize); OpenIntToFieldHashMap<T>.Iterator iter = entries.iterator(); while (iter.hasNext()) { iter.advance(); int row = iter.key(); FieldElement<T>value = iter.value(); for (int col = 0; col < virtualSize; col++) { res.setEntry(row, col, value.multiply(v[col])); } } return res; }