本文整理汇总了Java中no.uib.cipr.matrix.DenseMatrix.getData方法的典型用法代码示例。如果您正苦于以下问题:Java DenseMatrix.getData方法的具体用法?Java DenseMatrix.getData怎么用?Java DenseMatrix.getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类no.uib.cipr.matrix.DenseMatrix
的用法示例。
在下文中一共展示了DenseMatrix.getData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: sumLogFactorial
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
private double sumLogFactorial(DenseMatrix fv) {
double sum = 0;
final double[] data = fv.getData();
for (int i = 0; i < fv.numColumns(); i++) {
final int fvi = (int) data[i];
if (logFacCache.contains(fvi))
{
sum += logFacCache.get(fvi);
}
else {
for (int j = 1; j < fvi + 1; j++) {
sum += Math.log(j);
}
}
}
return sum;
}
示例3: 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<Matrix, double[]> symmetricGeneralisedEigenvectors(Matrix A, Matrix B) {
if ((A.getRowDimension() != A.getColumnDimension()) || (B.getRowDimension() != B.getColumnDimension()))
throw new IllegalArgumentException("Input matrices must be square");
int dim = A.getRowDimension();
DenseMatrix vecs = new DenseMatrix(A.getArray());
DenseVector W = new DenseVector(dim);
sygvd(1, "V", "U", vecs, new DenseMatrix(B.getArray()), W);
Matrix evecs = new Matrix(dim, dim);
final double[][] evecsData = evecs.getArray();
final double[] vecsData = vecs.getData();
for (int r=0; r<dim; r++)
for (int c=0; c<dim; c++)
evecsData[r][c] = vecsData[r + c * dim];
return new IndependentPair<Matrix, double[]>(evecs, W.getData());
}
示例4: symmetricGeneralisedEigenvectorsSorted
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
/**
* Solve the general problem A x = L B x.
* The returned eigenvalues ordered in a decreasing manner.
*
* @param A symmetric matrix A
* @param B symmetric matrix B
* @return The eigenvectors x and eigenvalues L.
*/
public static IndependentPair<Matrix, double[]> symmetricGeneralisedEigenvectorsSorted(Matrix A, Matrix B) {
if ((A.getRowDimension() != A.getColumnDimension()) || (B.getRowDimension() != B.getColumnDimension()))
throw new IllegalArgumentException("Input matrices must be square");
int dim = A.getRowDimension();
DenseMatrix vecs = new DenseMatrix(A.getArray());
DenseVector W = new DenseVector(dim);
sygvd(1, "V", "U", vecs, new DenseMatrix(B.getArray()), W);
Matrix evecs = new Matrix(dim, dim);
final double[][] evecsData = evecs.getArray();
final double[] vecsData = vecs.getData();
final double[] valsData = W.getData();
int [] indices = ArrayUtils.range(0, valsData.length-1);
ArrayUtils.parallelQuicksortDescending(valsData, indices);
for (int r=0; r<dim; r++)
for (int c=0; c<dim; c++)
evecsData[r][c] = vecsData[r + indices[c] * dim];
return new IndependentPair<Matrix, double[]>(evecs, valsData);
}
示例5: getTensor
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
public static <
V extends Vertex<V, E, F>,
E extends Edge<V, E, F>,
F extends Face<V, E, F>
> double[][] getTensor(
double[] p,
double scale,
KdTree<V, E, F> kd,
AdapterSet a
){
Collection<F> faces = KdUtility.collectFacesInRadius(kd, p, scale);
Collection<E> edges = KdUtility.collectEdgesInRadius(kd, p, scale);
double area=0;
for(F f :faces){
area += area(f, a);
}
DenseMatrix matrix = new DenseMatrix(3,3);
double beta = 0;
double edgeLength = 0;
for(E e :edges){
beta = getAngle(e, a);
edgeLength = getLength(e, a);
double[][] T = getEdgeCurvatureTensor(e, a);
DenseMatrix tmp = new DenseMatrix(T);
matrix.add(beta * edgeLength, tmp);
}
matrix.scale(1/area);
double[][] result = {
{matrix.getData()[0], matrix.getData()[3], matrix.getData()[6]},
{matrix.getData()[1], matrix.getData()[4], matrix.getData()[7]},
{matrix.getData()[2], matrix.getData()[5], matrix.getData()[8]}
};
return result;
}
示例6: convert
import no.uib.cipr.matrix.DenseMatrix; //导入方法依赖的package包/类
/**
* Convert a {@link DenseMatrix} to a {@link Matrix}.
*
* @param mjt
* {@link DenseMatrix} to convert
* @param nrows
* number of rows to copy
* @param ncols
* number of columns to copy
* @return converted matrix.
*/
public static Matrix convert(DenseMatrix mjt, int nrows, int ncols) {
final double[][] d = new double[nrows][ncols];
final double[] mjtd = mjt.getData();
for (int r = 0; r < nrows; r++) {
for (int c = 0; c < ncols; c++) {
d[r][c] = mjtd[r + c * d.length];
}
}
return new Matrix(d);
}