public SynchronizedColumnMatrix(Matrix A) { super(A); this.A = A; lock = new Object[A.numColumns()]; for (int i = 0; i < lock.length; ++i) lock[i] = new Object(); }
/** * Checks that a transposed rank1 update is leagal with the given argument */ protected void checkTransRank1(Matrix C) { if (!isSquare()) throw new IndexOutOfBoundsException("!A.isSquare"); if (numRows != C.numColumns()) throw new IndexOutOfBoundsException("A.numRows != C.numColumns (" + numRows + " != " + C.numColumns() + ")"); }
/** * Checks that a transposed rank1 update is leagal with the given argument */ protected void checkTransRank1(Matrix C) { if (!isSquare()) throw new IndexOutOfBoundsException("!A.isSquare"); if (numRows != C.numColumns()) throw new IndexOutOfBoundsException("A.numRows != C.numColumns (" + numRows + " != " + C.numColumns() + ")"); }
/** * Constructor for UpperTriangDenseMatrix * * @param A * Matrix to copy from. Only the upper triangular part is copied * @param deep * True for deep copy, false for reference (in which case * <code>A</code> must be a dense matrix) */ public UpperTriangDenseMatrix(Matrix A, boolean deep) { this(A, Math.min(A.numRows(), A.numColumns()), deep); }
/** * Constructor for AbstractMatrix, same size as A. The invoking constructor * should set this matrix equal the argument matrix */ protected AbstractMatrix(Matrix A) { this(A.numRows(), A.numColumns()); }
/** * Constructor for AbstractMatrix, same size as A. The invoking constructor * should set this matrix equal the argument matrix */ protected AbstractMatrix(Matrix A) { this(A.numRows(), A.numColumns()); }
/** * Checks that the sizes of this matrix and the given conform */ protected void checkSize(Matrix B) { if (numRows != B.numRows()) throw new IndexOutOfBoundsException("A.numRows != B.numRows (" + numRows + " != " + B.numRows() + ")"); if (numColumns != B.numColumns()) throw new IndexOutOfBoundsException( "A.numColumns != B.numColumns (" + numColumns + " != " + B.numColumns() + ")"); }
/** * Constructor for AbstractTriangDenseMatrix * * @param A * Matrix to copy from */ AbstractTriangDenseMatrix(Matrix A, UpLo uplo, Diag diag) { this(A, Math.min(A.numRows(), A.numColumns()), uplo, diag); }
/** * Constructor for UpperTriangDenseMatrix * * @param A * Matrix to copy from. Only the upper triangular part is copied * @param deep * True for deep copy, false for reference (in which case * <code>A</code> must be a dense matrix) */ UpperTriangDenseMatrix(Matrix A, boolean deep, Diag diag) { this(A, Math.min(A.numRows(), A.numColumns()), deep, diag); }
/** * Convenience method to compute a QR decomposition * * @param A * the matrix to decompose (not modified) * @return Newly allocated decomposition */ public static QRP factorize(Matrix A) { return new QRP(A.numRows(), A.numColumns()).factor(A); }
/** * Convenience method to compute a LQ decomposition * * @param A * Matrix to decompose. Not modified * @return Newly allocated decomposition */ public static LQ factorize(Matrix A) { return new LQ(A.numRows(), A.numColumns()).factor(new DenseMatrix(A)); }
public Matrix transBmultAdd(double alpha, Matrix B, Matrix C) { checkTransBmultAdd(B, C); if (alpha != 0) for (int i = 0; i < numRows; ++i) for (int j = 0; j < C.numColumns(); ++j) { double dot = 0; for (int k = 0; k < numColumns; ++k) dot += get(i, k) * B.get(j, k); C.add(i, j, alpha * dot); } return C; }
@Override public Matrix rank1(double alpha, Matrix C) { if (!(C instanceof DenseMatrix)) return super.rank1(alpha, C); checkRank1(C); double[] Cd = ((DenseMatrix) C).getData(); BLAS.getInstance().dsyrk(uplo.netlib(), Transpose.NoTranspose.netlib(), numRows, C.numColumns(), alpha, Cd, Math.max(1, numRows), 1, data, Math.max(1, numRows)); return this; }
/** * Convenience method for computing a full SVD * * @param A * Matrix to decompose, not modified * @return Newly allocated factorization * @throws NotConvergedException */ public static SVD factorize(Matrix A) throws NotConvergedException { return new SVD(A.numRows(), A.numColumns()).factor(new DenseMatrix(A)); }
/** * Creates an LU decomposition of the given matrix * * @param A * Matrix to decompose. Not modified * @return The current decomposition */ public static DenseLU factorize(Matrix A) { return new DenseLU(A.numRows(), A.numColumns()).factor(new DenseMatrix( A)); }
public Matrix transAmultAdd(double alpha, Matrix B, Matrix C) { checkTransAmultAdd(B, C); if (alpha != 0) for (int i = 0; i < numColumns; ++i) for (int j = 0; j < C.numColumns(); ++j) { double dot = 0; for (int k = 0; k < numRows; ++k) dot += get(k, i) * B.get(k, j); C.add(i, j, alpha * dot); } return C; }
public Matrix transBmultAdd(double alpha, Matrix B, Matrix C) { checkTransBmultAdd(B, C); if (alpha != 0) for (int i = 0; i < numRows; ++i) for (int j = 0; j < C.numColumns(); ++j) { double dot = 0; for (int k = 0; k < numColumns; ++k) dot += get(i, k) * B.get(j, k); C.add(i, j, alpha * dot); } return C; }
/** * Convenience method for computing a full SVD * * @param A * Matrix to decompose, not modified * @return Newly allocated factorization * @throws NotConvergedException */ public static SVD factorize(Matrix A) throws NotConvergedException { return new SVD(A.numRows(), A.numColumns()).factor(new DenseMatrix(A)); }
/** * Returns an array of arrays containing a copy of the given matrix. Each * array contains one row. */ public static double[][] getArray(Matrix A) { double[][] Ad = new double[A.numRows()][A.numColumns()]; for (MatrixEntry e : A) Ad[e.row()][e.column()] = e.get(); return Ad; }
/** * Creates an LU decomposition of the given matrix * * @param A * Matrix to decompose. Not modified * @return The current decomposition */ public static DenseLU factorize(Matrix A) { return new DenseLU(A.numRows(), A.numColumns()).factor(new DenseMatrix( A)); }