本文整理了Java中cern.colt.matrix.linalg.Algebra
类的一些代码示例,展示了Algebra
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Algebra
类的具体详情如下:
包路径:cern.colt.matrix.linalg.Algebra
类名称:Algebra
[英]Linear algebraic matrix operations operating on DoubleMatrix2D; concentrates most functionality of this package.
[中]双矩阵上的线性代数矩阵运算;集中此软件包的大部分功能。
代码示例来源:origin: cmu-phil/tetrad
private double lik(DoubleMatrix2D K, DoubleMatrix2D S, int n, int k) {
Algebra algebra = new Algebra();
DoubleMatrix2D SK = algebra.mult(S, K);
return (algebra.trace(SK) - Math.log(algebra.det(SK)) - k) * n;
}
代码示例来源:origin: com.blazegraph/colt
transposeMatrix = Algebra.DEFAULT.transpose (patternMatrix);
QMatrix = Algebra.DEFAULT.mult (transposeMatrix,patternMatrix);
inverseQMatrix = Algebra.DEFAULT.inverse (QMatrix);
pseudoInverseMatrix = Algebra.DEFAULT.mult (inverseQMatrix,transposeMatrix);
weightMatrix = Algebra.DEFAULT.mult (patternMatrix,pseudoInverseMatrix);
System.out.println("done.");
代码示例来源:origin: stackoverflow.com
Algebra algebra = new Algebra();
DoubleMatrix2D X = algebra.solve(matrix, D);
代码示例来源:origin: blazegraph/database
/**
* Solves X*A = B, which is also A'*X' = B'.
* @return X; a new independent matrix; solution if A is square, least squares solution otherwise.
*/
public DoubleMatrix2D solveTranspose(DoubleMatrix2D A, DoubleMatrix2D B) {
return solve(transpose(A), transpose(B));
}
/**
代码示例来源:origin: cmu-phil/tetrad
Algebra algebra = new Algebra();
DoubleMatrix2D K = algebra.inverse(factory.diagonal(factory.diagonal(S)));
int[] b = complement(all, a);
DoubleMatrix2D a1 = S.viewSelection(a, a);
DoubleMatrix2D a2 = algebra.inverse(a1);
DoubleMatrix2D a3 = K.viewSelection(a, b);
DoubleMatrix2D a4 = K.viewSelection(b, b);
DoubleMatrix2D a5 = algebra.inverse(a4);
DoubleMatrix2D a6 = K.viewSelection(b, a).copy();
DoubleMatrix2D a7 = algebra.mult(a3, a5);
DoubleMatrix2D a8 = algebra.mult(a7, a6);
a2.assign(a8, PlusMult.plusMult(1));
DoubleMatrix2D a9 = K.viewSelection(a, a);
double diff = algebra.norm1(a32);
DoubleMatrix2D V = algebra.inverse(K);
double dev = lik(algebra.inverse(V), S, n, k);
代码示例来源:origin: com.blazegraph/colt
/**
* Returns the two-norm (aka <i>euclidean norm</i>) of vector <tt>x</tt>; equivalent to <tt>mult(x,x)</tt>.
*/
public double norm2(DoubleMatrix1D x) {
return mult(x,x);
}
/**
代码示例来源:origin: blazegraph/database
try { values.add(String.valueOf(cond(matrix)));}
catch (IllegalArgumentException exc) { values.add(unknown+exc.getMessage()); }
try { values.add(String.valueOf(det(matrix)));}
catch (IllegalArgumentException exc) { values.add(unknown+exc.getMessage()); }
try { values.add(String.valueOf(norm1(matrix)));}
catch (IllegalArgumentException exc) { values.add(unknown+exc.getMessage()); }
try { values.add(String.valueOf(norm2(matrix)));}
catch (IllegalArgumentException exc) { values.add(unknown+exc.getMessage()); }
try { values.add(String.valueOf(normF(matrix)));}
catch (IllegalArgumentException exc) { values.add(unknown+exc.getMessage()); }
try { values.add(String.valueOf(normInfinity(matrix)));}
catch (IllegalArgumentException exc) { values.add(unknown+exc.getMessage()); }
try { values.add(String.valueOf(rank(matrix)));}
catch (IllegalArgumentException exc) { values.add(unknown+exc.getMessage()); }
try { values.add(String.valueOf(trace(matrix)));}
catch (IllegalArgumentException exc) { values.add(unknown+exc.getMessage()); }
代码示例来源:origin: org.ujmp/ujmp-colt
public Matrix inv() {
return new ColtDenseDoubleMatrix2D((DenseDoubleMatrix2D) new Algebra().inverse(matrix));
}
代码示例来源:origin: ca.umontreal.iro/ssj
Algebra alge = new Algebra();
final double mu = alge.trace(B) / n;
double x;
final double norm = alge.norm1(B) / THETA9;
int s;
if (norm > 1)
final DoubleMatrix2D B2 = alge.mult(B, B); // B^2
final DoubleMatrix2D B4 = alge.mult(B2, B2); // B^4
DoubleMatrix2D U = alge.mult(B4, W); // U <-- B4*W
W.assign (B0, F.plusMult(cPade[1])); // W <-- W + B0*cPade[1]
U = alge.mult(B, U); // U <-- B*U
W.assign (F.mult(cPade[8])); // W <-- W*cPade[8]
W.assign (T, F. plusMult(cPade[6])); // W <-- W + T*cPade[6]
DoubleMatrix2D V = alge.mult(B4, W); // V <-- B4*W
B.assign (F.mult(r));
for (int i = 0; i < s; i++)
B = alge.mult(B, B);
代码示例来源:origin: cmu-phil/tetrad
private static double norm2(DoubleMatrix2D mat){
//return Math.sqrt(mat.copy().assign(Functions.pow(2)).zSum());
Algebra al = new Algebra();
//norm found by svd so we need rows >= cols
if(mat.rows() < mat.columns()){
return al.norm2(al.transpose(mat));
}
return al.norm2(mat);
}
代码示例来源:origin: ca.umontreal.iro/ssj
DoubleMatrix2D coltN = Algebra.ZERO.subMatrix(DoubleFactory2D.dense.make(N), 1, x.length-1, 1, h-1).copy();
DoubleMatrix2D coltM = Algebra.ZERO.mult(Algebra.ZERO.transpose(coltN), coltN);
DoubleMatrix2D coltP;
coltP = Algebra.ZERO.solve(coltM, coltQ);
double[] pxTemp = coltP.viewColumn(0).toArray();
double[] pyTemp = coltP.viewColumn(1).toArray();
代码示例来源:origin: ujmp/universal-java-matrix-package
public Matrix inv() {
return new ColtDenseDoubleMatrix2D((DenseDoubleMatrix2D) Algebra.DEFAULT.inverse(matrix));
}
代码示例来源:origin: cmu-phil/tetrad
par.beta.assign(alg.transpose(par.beta), Functions.plus);
par.phi.assign(alg.transpose(par.phi), Functions.plus);
DoubleMatrix2D xBeta = alg.mult(xDat,alg.mult(par.beta, divBetaD));
DoubleMatrix2D dTheta = alg.mult(alg.mult(dDat, par.theta), divBetaD);
DoubleMatrix2D wxProd = alg.mult(xDat, alg.transpose(par.theta));
wxProd.assign(alg.mult(dDat, par.phi), Functions.plus);
for(int i = 0; i < n; i++){
if (Thread.currentThread().isInterrupted()) {
.5 * Math.pow(alg.normF(alg.mult(tempLoss, factory2D.diagonal(par.betad.copy().assign(Functions.sqrt)))), 2);
gradOut.beta = alg.mult(alg.transpose(xDat), tempLoss);
DoubleMatrix2D lowerBeta = alg.transpose(lowerTri(gradOut.beta.copy(), -1));
upperTri(gradOut.beta, 1).assign(lowerBeta, Functions.plus);
gradOut.alpha1 = alg.mult(factory2D.diagonal(par.betad),margSum(tempLoss, 1));
gradOut.theta = alg.mult(alg.transpose(dDat), tempLoss);
wxTemp.assign(alg.mult(factory2D.diagonal(invDenom), wxTemp));
for(int k = 0; k < n; k++){
if (Thread.currentThread().isInterrupted()) {
DoubleMatrix2D gradW = alg.mult(alg.transpose(xDat), wxProd);
代码示例来源:origin: lessthanoptimal/Java-Matrix-Benchmark
@Override
public long process(BenchmarkMatrix[] inputs, BenchmarkMatrix[] outputs, long numTrials) {
DenseDoubleMatrix2D matA = inputs[0].getOriginal();
DenseDoubleMatrix2D matB = inputs[1].getOriginal();
Algebra alg = new Algebra();
DoubleMatrix2D result = null;
long prev = System.nanoTime();
for( long i = 0; i < numTrials; i++ ) {
result = alg.mult(matA,matB);
}
long elapsed = System.nanoTime()-prev;
if( outputs != null ) {
outputs[0] = new ColtBenchmarkMatrix(result);
}
return elapsed;
}
}
代码示例来源:origin: com.github.vincentk/joptimizer
/**
* @TODO: check this!!!
* @see "http://mathworld.wolfram.com/PositiveDefiniteMatrix.html"
*/
public static DoubleMatrix2D randomValuesPositiveMatrix(int rows, int cols, double min, double max, Long seed) {
DoubleMatrix2D Q = Utils.randomValuesMatrix(rows, cols, min, max, seed);
DoubleMatrix2D P = Algebra.DEFAULT.mult(Q, Algebra.DEFAULT.transpose(Q.copy()));
return Algebra.DEFAULT.mult(P, P);
}
代码示例来源:origin: blazegraph/database
/**
Constructs and returns a new LU Decomposition object which uses the given tolerance for singularity detection;
*/
public LUDecompositionQuick(double tolerance) {
this.algebra = new Algebra(tolerance);
}
/**
代码示例来源:origin: cmu-phil/tetrad
par.beta.assign(alg.transpose(par.beta), Functions.plus);
par.phi.assign(alg.transpose(par.phi), Functions.plus);
DoubleMatrix2D xBeta = alg.mult(alg.mult(xDat, par.beta), divBetaD);
DoubleMatrix2D dTheta = alg.mult(alg.mult(dDat, par.theta), divBetaD);
DoubleMatrix2D wxProd = alg.mult(xDat, alg.transpose(par.theta));
wxProd.assign(alg.mult(dDat, par.phi), Functions.plus);
for(int i = 0; i < n; i++){
if (Thread.currentThread().isInterrupted()) {
grad.beta = alg.mult(alg.transpose(xDat), negLoss);
DoubleMatrix2D lowerBeta = alg.transpose(lowerTri(grad.beta.copy(), -1));
upperTri(grad.beta, 1).assign(lowerBeta, Functions.plus);
grad.alpha1 = alg.mult(factory2D.diagonal(par.betad),margSum(negLoss, 1));
grad.theta = alg.mult(alg.transpose(dDat), negLoss);
wxTemp.assign(alg.mult(factory2D.diagonal(invDenom), wxTemp));
for(int k = 0; k < n; k++){
DoubleMatrix1D curRow = wxTemp.viewRow(k);
DoubleMatrix2D gradW = alg.mult(alg.transpose(xDat), wxProd);
grad.theta.assign(alg.transpose(gradW), Functions.plus);
代码示例来源:origin: com.github.vincentk/joptimizer
public void setAMatrix(DoubleMatrix2D AMatrix) {
this.A = AMatrix;
this.AT = ALG.transpose(A);
}
代码示例来源:origin: cmu-phil/tetrad
public static double norm2(DoubleMatrix1D vec){
//return Math.sqrt(vec.copy().assign(Functions.pow(2)).zSum());
return Math.sqrt(new Algebra().norm2(vec));
}
}
代码示例来源:origin: lessthanoptimal/Java-Matrix-Benchmark
@Override
public long process(BenchmarkMatrix[] inputs, BenchmarkMatrix[] outputs, long numTrials) {
DenseDoubleMatrix2D matA = inputs[0].getOriginal();
Algebra alg = new Algebra();
long prev = System.nanoTime();
for( long i = 0; i < numTrials; i++ ) {
alg.det(matA);
}
return System.nanoTime()-prev;
}
}
内容来源于网络,如有侵权,请联系作者删除!