📄 matrix.java
字号:
* <code>B.numColumns() == C.numColumns()</code> * @param C * Matrix such that <code>C.numRows() == A.numColumns()</code> * and <code>B.numColumns() == C.numColumns()</code> * @return C */ Matrix transAmult(double alpha, Matrix B, Matrix C); /** * <code>C = A<sup>T</sup>*B + C</code> * * @param B * Matrix such that <code>B.numRows() == A.numRows()</code> and * <code>B.numColumns() == C.numColumns()</code> * @param C * Matrix such that <code>C.numRows() == A.numColumns()</code> * and <code>B.numColumns() == C.numColumns()</code> * @return C */ Matrix transAmultAdd(Matrix B, Matrix C); /** * <code>C = alpha*A<sup>T</sup>*B + C</code> * * @param B * Matrix such that <code>B.numRows() == A.numRows()</code> and * <code>B.numColumns() == C.numColumns()</code> * @param C * Matrix such that <code>C.numRows() == A.numColumns()</code> * and <code>B.numColumns() == C.numColumns()</code> * @return C */ Matrix transAmultAdd(double alpha, Matrix B, Matrix C); /** * <code>C = A*B<sup>T</sup></code> * * @param B * Matrix such that <code>B.numRows() == A.numRows()</code> and * <code>B.numColumns() == C.numColumns()</code> * @param C * Matrix such that <code>C.numRows() == A.numColumns()</code> * and <code>B.numColumns() == C.numColumns()</code> * @return C */ Matrix transBmult(Matrix B, Matrix C); /** * <code>C = alpha*A*B<sup>T</sup></code> * * @param B * Matrix such that <code>B.numRows() == A.numRows()</code> and * <code>B.numColumns() == C.numColumns()</code> * @param C * Matrix such that <code>C.numRows() == A.numColumns()</code> * and <code>B.numColumns() == C.numColumns()</code> * @return C */ Matrix transBmult(double alpha, Matrix B, Matrix C); /** * <code>C = A*B<sup>T</sup> + C</code> * * @param B * Matrix such that <code>B.numRows() == A.numRows()</code> and * <code>B.numColumns() == C.numColumns()</code> * @param C * Matrix such that <code>C.numRows() == A.numColumns()</code> * and <code>B.numColumns() == C.numColumns()</code> * @return C */ Matrix transBmultAdd(Matrix B, Matrix C); /** * <code>C = alpha*A*B<sup>T</sup> + C</code> * * @param B * Matrix such that <code>B.numRows() == A.numRows()</code> and * <code>B.numColumns() == C.numColumns()</code> * @param C * Matrix such that <code>C.numRows() == A.numColumns()</code> * and <code>B.numColumns() == C.numColumns()</code> * @return C */ Matrix transBmultAdd(double alpha, Matrix B, Matrix C); /** * <code>C = A<sup>T</sup>*B<sup>T</sup></code> * * @param B * Matrix such that <code>B.numColumns() == A.numRows()</code> * and <code>B.numRows() == C.numColumns()</code> * @param C * Matrix such that <code>C.numRows() == A.numColumns()</code> * and <code>B.numRows() == C.numColumns()</code> * @return C */ Matrix transABmult(Matrix B, Matrix C); /** * <code>C = alpha*A<sup>T</sup>*B<sup>T</sup></code> * * @param B * Matrix such that <code>B.numColumns() == A.numRows()</code> * and <code>B.numRows() == C.numColumns()</code> * @param C * Matrix such that <code>C.numRows() == A.numColumns()</code> * and <code>B.numRows() == C.numColumns()</code> * @return C */ Matrix transABmult(double alpha, Matrix B, Matrix C); /** * <code>C = A<sup>T</sup>*B<sup>T</sup> + C</code> * * @param B * Matrix such that <code>B.numColumns() == A.numRows()</code> * and <code>B.numRows() == C.numColumns()</code> * @param C * Matrix such that <code>C.numRows() == A.numColumns()</code> * and <code>B.numRows() == C.numColumns()</code> * @return C */ Matrix transABmultAdd(Matrix B, Matrix C); /** * <code>C = alpha*A<sup>T</sup>*B<sup>T</sup> + C</code> * * @param B * Matrix such that <code>B.numColumns() == A.numRows()</code> * and <code>B.numRows() == C.numColumns()</code> * @param C * Matrix such that <code>C.numRows() == A.numColumns()</code> * and <code>B.numRows() == C.numColumns()</code> * @return C */ Matrix transABmultAdd(double alpha, Matrix B, Matrix C); /** * <code>X = A\B</code>. Not all matrices support this operation, those * that do not throw <code>UnsupportedOperationException</code>. Note * that it is often more efficient to use a matrix decomposition and its * associated solver * * @param B * Matrix with the same number of rows as <code>A</code>, and * the same number of columns as <code>X</code> * @param X * Matrix with a number of rows equal <code>A.numColumns()</code>, * and the same number of columns as <code>B</code> * @return X * @throws MatrixSingularException * If the matrix is singular * @throws MatrixNotSPDException * If the solver assumes that the matrix is symmetrical, * positive definite, but that that property does not hold */ Matrix solve(Matrix B, Matrix X) throws MatrixSingularException, MatrixNotSPDException; /** * <code>X = A<sup>T</sup>\B</code>. Not all matrices support this * operation, those that do not throw * <code>UnsupportedOperationException</code>. Note that it is often more * efficient to use a matrix decomposition and its associated transpose * solver * * @param B * Matrix with a number of rows equal <code>A.numColumns()</code>, * and the same number of columns as <code>X</code> * @param X * Matrix with the same number of rows as <code>A</code>, and * the same number of columns as <code>B</code> * @return X * @throws MatrixSingularException * If the matrix is singular * @throws MatrixNotSPDException * If the solver assumes that the matrix is symmetrical, * positive definite, but that that property does not hold */ Matrix transSolve(Matrix B, Matrix X) throws MatrixSingularException, MatrixNotSPDException; /** * <code>A = C*C<sup>T</sup> + A</code>. The matrices must be square * and of the same size * * @return A */ Matrix rank1(Matrix C); /** * <code>A = alpha*C*C<sup>T</sup> + A</code>. The matrices must be * square and of the same size * * @return A */ Matrix rank1(double alpha, Matrix C); /** * <code>A = C<sup>T</sup>*C + A</code> The matrices must be square and * of the same size * * @return A */ Matrix transRank1(Matrix C); /** * <code>A = alpha*C<sup>T</sup>*C + A</code> The matrices must be * square and of the same size * * @return A */ Matrix transRank1(double alpha, Matrix C); /** * <code>A = B*C<sup>T</sup> + C*B<sup>T</sup> + A</code>. This * matrix must be square * * @param B * Matrix with the same number of rows as <code>A</code> and * the same number of columns as <code>C</code> * @param C * Matrix with the same number of rows as <code>A</code> and * the same number of columns as <code>B</code> * @return A */ Matrix rank2(Matrix B, Matrix C); /** * <code>A = alpha*B*C<sup>T</sup> + alpha*C*B<sup>T</sup> + A</code>. * This matrix must be square * * @param B * Matrix with the same number of rows as <code>A</code> and * the same number of columns as <code>C</code> * @param C * Matrix with the same number of rows as <code>A</code> and * the same number of columns as <code>B</code> * @return A */ Matrix rank2(double alpha, Matrix B, Matrix C); /** * <code>A = B<sup>T</sup>*C + C<sup>T</sup>*B + A</code>. This * matrix must be square * * @param B * Matrix with the same number of rows as <code>C</code> and * the same number of columns as <code>A</code> * @param C * Matrix with the same number of rows as <code>B</code> and * the same number of columns as <code>A</code> * @return A */ Matrix transRank2(Matrix B, Matrix C); /** * <code>A = alpha*B<sup>T</sup>*C + alpha*C<sup>T</sup>*B + A</code>. * This matrix must be square * * @param B * Matrix with the same number of rows as <code>C</code> and * the same number of columns as <code>A</code> * @param C * Matrix with the same number of rows as <code>B</code> and * the same number of columns as <code>A</code> * @return A */ Matrix transRank2(double alpha, Matrix B, Matrix C); /** * <code>A = alpha*A</code> * * @return A */ Matrix scale(double alpha); /** * <code>A=B</code>. The matrices must be of the same size * * @return A */ Matrix set(Matrix B); /** * <code>A=alpha*B</code>. The matrices must be of the same size * * @return A */ Matrix set(double alpha, Matrix B); /** * <code>A = B + A</code>. The matrices must be of the same size * * @return A */ Matrix add(Matrix B); /** * <code>A = alpha*B + A</code>. The matrices must be of the same size * * @return A */ Matrix add(double alpha, Matrix B); /** * Transposes the matrix in-place. In most cases, the matrix must be square * for this to work. * * @return This matrix */ Matrix transpose(); /** * Sets the tranpose of this matrix into <code>B</code>. Matrix * dimensions must be compatible * * @param B * Matrix with as many rows as this matrix has columns, and as * many columns as this matrix has rows * @return The matrix <code>B=A<sup>T</sup></code> */ Matrix transpose(Matrix B); /** * Computes the given norm of the matrix * * @param type * The type of norm to compute */ double norm(Norm type); /** * Supported matrix-norms. Note that <code>Maxvalue</code> is not a proper * matrix norm */ enum Norm { /** * Maximum absolute row sum */ One, /** * The root of sum of the sum of squares */ Frobenius, /** * Maximum column sum */ Infinity, /** * Largest entry in absolute value. Not a proper matrix norm */ Maxvalue; /** * @return the String as required by the netlib libraries to represent this norm. */ public String netlib() { // TODO: this is a bit of a hack // shouldn't need to know about the internals of netlib if (this == One) return "1"; else if (this == Infinity) return "I"; else throw new IllegalArgumentException( "Norm must be the 1 or the Infinity norm"); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -