本文整理匯總了Java中org.apache.commons.math3.linear.Array2DRowRealMatrix.multiply方法的典型用法代碼示例。如果您正苦於以下問題:Java Array2DRowRealMatrix.multiply方法的具體用法?Java Array2DRowRealMatrix.multiply怎麽用?Java Array2DRowRealMatrix.multiply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.math3.linear.Array2DRowRealMatrix
的用法示例。
在下文中一共展示了Array2DRowRealMatrix.multiply方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nextWishart
import org.apache.commons.math3.linear.Array2DRowRealMatrix; //導入方法依賴的package包/類
public RealMatrix nextWishart(double df, Cholesky invscale) {
int d = invscale.getL().getColumnDimension();
Array2DRowRealMatrix A = new Array2DRowRealMatrix(d,d);
ArrayRealVector v = new ArrayRealVector(d);
for (int i=0; i<d; i++) {
v.setEntry(i, sqrt(nextChiSquared(df-i)));
for (int j=0; j<i; j++) {
v.setEntry(j, 0.0);
}
for (int j=i+1; j<d; j++) {
v.setEntry(j, nextGaussian());
}
A.setColumnVector(i, invscale.solveLT(v));
}
return A.multiply(A.transpose());
}
示例2: DemoMihcComputation
import org.apache.commons.math3.linear.Array2DRowRealMatrix; //導入方法依賴的package包/類
public DemoMihcComputation() {
MihcConfigData conf = new MihcConfigData();
Array2DRowRealMatrix AsnInv = (Array2DRowRealMatrix) MatrixUtils.createRealMatrix(conf.inverse);
double[] gain = new double[]{1,1,1,1,1,1};
for (int i=0; i<gain.length; i++) gain[i] = 1d/gain[i];
RealMatrix GiiInv = MatrixUtils.createRealDiagonalMatrix(gain);
Array2DRowRealMatrix AsnInvNorm = (Array2DRowRealMatrix) AsnInv.multiply(GiiInv);
inverseMatrix = AsnInvNorm;
}
示例3: MultivariateNormalDistribution
import org.apache.commons.math3.linear.Array2DRowRealMatrix; //導入方法依賴的package包/類
/**
* Creates a multivariate normal distribution with the given mean vector and
* covariance matrix.
* <br/>
* The number of dimensions is equal to the length of the mean vector
* and to the number of rows and columns of the covariance matrix.
* It is frequently written as "p" in formulae.
*
* @param rng Random Number Generator.
* @param means Vector of means.
* @param covariances Covariance matrix.
* @throws DimensionMismatchException if the arrays length are
* inconsistent.
* @throws SingularMatrixException if the eigenvalue decomposition cannot
* be performed on the provided covariance matrix.
* @throws NonPositiveDefiniteMatrixException if any of the eigenvalues is
* negative.
*/
public MultivariateNormalDistribution(RandomGenerator rng,
final double[] means,
final double[][] covariances)
throws SingularMatrixException,
DimensionMismatchException,
NonPositiveDefiniteMatrixException {
super(rng, means.length);
final int dim = means.length;
if (covariances.length != dim) {
throw new DimensionMismatchException(covariances.length, dim);
}
for (int i = 0; i < dim; i++) {
if (dim != covariances[i].length) {
throw new DimensionMismatchException(covariances[i].length, dim);
}
}
this.means = MathArrays.copyOf(means);
covarianceMatrix = new Array2DRowRealMatrix(covariances);
// Covariance matrix eigen decomposition.
final EigenDecomposition covMatDec = new EigenDecomposition(covarianceMatrix);
// Compute and store the inverse.
covarianceMatrixInverse = covMatDec.getSolver().getInverse();
// Compute and store the determinant.
covarianceMatrixDeterminant = covMatDec.getDeterminant();
// Eigenvalues of the covariance matrix.
final double[] covMatEigenvalues = covMatDec.getRealEigenvalues();
for (int i = 0; i < covMatEigenvalues.length; i++) {
if (covMatEigenvalues[i] < 0) {
throw new NonPositiveDefiniteMatrixException(covMatEigenvalues[i], i, 0);
}
}
// Matrix where each column is an eigenvector of the covariance matrix.
final Array2DRowRealMatrix covMatEigenvectors = new Array2DRowRealMatrix(dim, dim);
for (int v = 0; v < dim; v++) {
final double[] evec = covMatDec.getEigenvector(v).toArray();
covMatEigenvectors.setColumn(v, evec);
}
final RealMatrix tmpMatrix = covMatEigenvectors.transpose();
// Scale each eigenvector by the square root of its eigenvalue.
for (int row = 0; row < dim; row++) {
final double factor = FastMath.sqrt(covMatEigenvalues[row]);
for (int col = 0; col < dim; col++) {
tmpMatrix.multiplyEntry(row, col, factor);
}
}
samplingMatrix = covMatEigenvectors.multiply(tmpMatrix);
}