本文整理汇总了Java中no.uib.cipr.matrix.DenseMatrix.numRows方法的典型用法代码示例。如果您正苦于以下问题:Java DenseMatrix.numRows方法的具体用法?Java DenseMatrix.numRows怎么用?Java DenseMatrix.numRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类no.uib.cipr.matrix.DenseMatrix
的用法示例。
在下文中一共展示了DenseMatrix.numRows方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ignoredTimedTransMult
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
public void ignoredTimedTransMult() {
Stopwatch watch = Stopwatch.createUnstarted();
DenseMatrix dense = new DenseMatrix(1000, 1000);
int[][] nz = Utilities.getRowPattern(dense.numRows(),
dense.numColumns(), 100);
Utilities.rowPopulate(dense, nz);
log.info("created matrices");
Matrix sparse = new LinkedSparseMatrix(dense.numRows(),
dense.numColumns());
sparse.set(dense);
for (Matrix m : Lists.newArrayList(dense, sparse)) {
log.info("starting " + m.getClass());
Matrix t = new DenseMatrix(m);
Matrix o = new DenseMatrix(dense.numRows(), dense.numColumns());
log.info("warming up " + m.getClass() + " " + o.getClass());
for (int i = 0; i < 10; i++)
m.transAmult(t, o);
log.info("starting " + m.getClass() + " " + o.getClass());
watch.start();
for (int i = 0; i < 100; i++)
m.transAmult(t, o);
watch.stop();
log.info(m.getClass() + " " + o.getClass() + " " + watch);
}
}
示例2: mtimes
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
public Matrix mtimes(Matrix m2) {
if (m2 instanceof MTJDenseDoubleMatrix2D) {
DenseMatrix a = matrix;
DenseMatrix b = ((MTJDenseDoubleMatrix2D) m2).getWrappedObject();
DenseMatrix c = new DenseMatrix(a.numRows(), b.numColumns());
// try {
a.mult(b, c);
return new MTJDenseDoubleMatrix2D(c);
// } catch (Exception e) {
// // sometimes BLAS cannot be found. Don't know why. Use direct
// // method instead.
// double[] Bd = ((DenseMatrix) b).getData(), Cd = ((DenseMatrix)
// c).getData();
// org.netlib.blas.Dgemm.dgemm("N", "N", c.numRows(),
// c.numColumns(), a.numColumns(), 1, a.getData(), 0,
// Math.max(1, a.numRows()), Bd, 0, Math.max(1, b.numRows()), 1, Cd,
// 0, Math.max(1, c.numRows()));
// return new MTJDenseDoubleMatrix2D(c);
// }
}
return super.mtimes(m2);
}
示例3: multBLASAdd
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
public static DenseMatrix multBLASAdd(double alpha, DenseMatrix B, DenseMatrix C) {
double[] Bd = B.getData(), Cd = C.getData();
int CRows = C.numRows();
int cCols = C.numColumns();
int BRows = B.numRows();
int bCols = B.numColumns();
BLAS.getInstance().dgemm("N", "N",
C.numRows(), C.numColumns(),
B.numColumns(), alpha,
Bd,
Math.max(1, B.numRows()), Bd, Math.max(1, B.numRows()), 0.0, Cd,
Math.max(1, C.numRows()));
return C;
}
示例4: factor
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
/**
* Computes the eigenvalue decomposition of the given matrix
*
* @param A Matrix to factorize. Overwritten on return
* @return The current decomposition
* @throws NotConvergedException
*/
public NativeEVD factor(DenseMatrix A) throws NotConvergedException {
if (!A.isSquare())
throw new IllegalArgumentException("!A.isSquare()");
else if (A.numRows() != n)
throw new IllegalArgumentException("A.numRows() != n");
intW info = new intW(0);
//NativeBlas.dgeev(jobLeft.netlib(), jobRight.netlib(), n, A.getData(),
// LAPACKUtils.ld(n), Wr, Wi, jobLeft == JobEigEnum.All ? Vl.getData() : new double[0],
// LAPACKUtils.ld(n), jobRight == JobEigEnum.All ? Vr.getData() : new double[0], LAPACKUtils.ld(n),
// work, work.length, info);
if (info.val > 0)
throw new NotConvergedException(
NotConvergedException.Reason.Iterations);
else if (info.val < 0)
throw new IllegalArgumentException();
return this;
}
示例5: ignoredTimedMult
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
public void ignoredTimedMult() {
Stopwatch watch = Stopwatch.createUnstarted();
DenseMatrix dense = new DenseMatrix(1000, 1000);
int[][] nz = Utilities.getRowPattern(dense.numRows(),
dense.numColumns(), 100);
Utilities.rowPopulate(dense, nz);
log.info("created matrices");
Matrix sparse = new LinkedSparseMatrix(dense.numRows(),
dense.numColumns());
sparse.set(dense);
for (Matrix m : Lists.newArrayList(dense, sparse)) {
log.info("starting " + m.getClass());
Matrix t = new DenseMatrix(m);
t.transpose();
Matrix o = new DenseMatrix(dense.numRows(), dense.numColumns());
log.info("warming up " + m.getClass() + " " + o.getClass());
for (int i = 0; i < 10; i++)
m.mult(t, o);
log.info("starting " + m.getClass() + " " + o.getClass());
watch.start();
for (int i = 0; i < 100; i++)
m.mult(t, o);
watch.stop();
log.info(m.getClass() + " " + o.getClass() + " " + watch);
}
}
示例6: symmetricGeneralisedEigenvalues
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
/**
* Compute the generalised eigenvalues, L, of the problem A x = L B x.
* The returned eigenvalues are not ordered.
*
* @param A symmetric Matrix A; only the upper triangle is used.
* @param B symmetric Matrix B; only the upper triangle is used.
* @return the eigenvalues L.
*/
public static DenseVector symmetricGeneralisedEigenvalues(DenseMatrix A, DenseMatrix B) {
if (!A.isSquare() || !B.isSquare())
throw new IllegalArgumentException("Input matrices must be square");
DenseVector W = new DenseVector(A.numRows());
sygvd(1, "N", "U", A.copy(), B.copy(), W);
return W;
}
示例7: symmetricGeneralisedEigenvectors
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
/**
* Solve the general problem A x = L B x.
* The returned eigenvalues are not ordered.
*
* @param A symmetric matrix A
* @param B symmetric matrix B
* @return The eigenvectors x and eigenvalues L.
*/
public static IndependentPair<DenseMatrix, DenseVector> symmetricGeneralisedEigenvectors(DenseMatrix A, DenseMatrix B) {
if (!A.isSquare() || !B.isSquare())
throw new IllegalArgumentException("Input matrices must be square");
DenseMatrix vecs = A.copy();
DenseVector W = new DenseVector(A.numRows());
sygvd(1, "V", "U", vecs, B.copy(), W);
return new IndependentPair<DenseMatrix, DenseVector>(vecs, W);
}
示例8: reduceRank
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
/**
* Reduce the rank a matrix by estimating a the best (in a least-squares
* sense) approximation using the thin SVD.
*
* @param m
* the matrix to reduce.
* @param rank
* the desired rank.
* @return the rank-reduced matrix.
*/
public static Matrix reduceRank(Matrix m, int rank) {
if (rank > Math.min(m.getColumnDimension(), m.getRowDimension())) {
return m;
}
final no.uib.cipr.matrix.DenseMatrix mjtA = new no.uib.cipr.matrix.DenseMatrix(
m.getArray());
no.uib.cipr.matrix.SVD svd;
try {
svd = no.uib.cipr.matrix.SVD.factorize(mjtA);
} catch (final NotConvergedException e) {
throw new RuntimeException(e);
}
final DenseMatrix U = svd.getU();
final DenseMatrix Vt = svd.getVt();
final double[] svector = svd.getS();
final DenseMatrix S = new DenseMatrix(U.numColumns(), Vt.numRows());
for (int i = 0; i < rank; i++)
S.set(i, i, svector[i]);
final DenseMatrix C = new DenseMatrix(U.numRows(), S.numColumns());
final DenseMatrix out = new DenseMatrix(C.numRows(), Vt.numColumns());
U.mult(S, C);
C.mult(Vt, out);
final Matrix outFinal = convert(out);
return outFinal;
}
示例9: setMatrix
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
public void setMatrix(Matrix A) {
List<CompRowMatrix> Al = new LinkedList<CompRowMatrix>();
List<CompColMatrix> Il = new LinkedList<CompColMatrix>();
Al.add(new CompRowMatrix(A));
for (int k = 0; Al.get(k).numRows() > min; ++k) {
CompRowMatrix Af = Al.get(k);
double eps = 0.08 * Math.pow(0.5, k);
// Create the aggregates
Aggregator aggregator = new Aggregator(Af, eps);
// If no aggregates were created, no interpolation operator will be
// created, and the setup phase stops
if (aggregator.getAggregates().isEmpty())
break;
// Create an interpolation operator using smoothing. This also
// creates the Galerkin operator
Interpolator sa = new Interpolator(aggregator, Af, omega);
Al.add(sa.getGalerkinOperator());
Il.add(sa.getInterpolationOperator());
}
// Copy to array storage
m = Al.size();
if (m == 0)
throw new RuntimeException("Matrix too small for AMG");
I = new CompColMatrix[m - 1];
this.A = new CompRowMatrix[m - 1];
Il.toArray(I);
for (int i = 0; i < Al.size() - 1; ++i)
this.A[i] = Al.get(i);
// Create a LU decomposition of the smallest Galerkin matrix
DenseMatrix Ac = new DenseMatrix(Al.get(Al.size() - 1));
lu = new DenseLU(Ac.numRows(), Ac.numColumns());
lu.factor(Ac);
// Allocate vectors at each level
u = new DenseVector[m];
f = new DenseVector[m];
r = new DenseVector[m];
for (int k = 0; k < m; ++k) {
int n = Al.get(k).numRows();
u[k] = new DenseVector(n);
f[k] = new DenseVector(n);
r[k] = new DenseVector(n);
}
// Set up the SSOR relaxation schemes
preM = new SSOR[m - 1];
postM = new SSOR[m - 1];
for (int k = 0; k < m - 1; ++k) {
CompRowMatrix Ak = this.A[k];
preM[k] = new SSOR(Ak, reverse, omegaPreF, omegaPreR);
postM[k] = new SSOR(Ak, reverse, omegaPostF, omegaPostR);
preM[k].setMatrix(Ak);
postM[k].setMatrix(Ak);
}
}
示例10: MTJDenseDoubleMatrix2D
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
public MTJDenseDoubleMatrix2D(DenseMatrix m) {
super(m.numRows(), m.numColumns());
this.matrix = m;
}