本文整理汇总了Java中org.apache.commons.math3.linear.EigenDecomposition.hasComplexEigenvalues方法的典型用法代码示例。如果您正苦于以下问题:Java EigenDecomposition.hasComplexEigenvalues方法的具体用法?Java EigenDecomposition.hasComplexEigenvalues怎么用?Java EigenDecomposition.hasComplexEigenvalues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.linear.EigenDecomposition
的用法示例。
在下文中一共展示了EigenDecomposition.hasComplexEigenvalues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calcEigenvalues
import org.apache.commons.math3.linear.EigenDecomposition; //导入方法依赖的package包/类
/**
* @param a
* @return dataset of eigenvalues (can be double or complex double)
*/
public static Dataset calcEigenvalues(Dataset a) {
EigenDecomposition evd = new EigenDecomposition(createRealMatrix(a));
double[] rev = evd.getRealEigenvalues();
if (evd.hasComplexEigenvalues()) {
double[] iev = evd.getImagEigenvalues();
return DatasetFactory.createComplexDataset(ComplexDoubleDataset.class, rev, iev);
}
return DatasetFactory.createFromObject(rev);
}
示例2: calcEigenDecomposition
import org.apache.commons.math3.linear.EigenDecomposition; //导入方法依赖的package包/类
/**
* Calculate eigen-decomposition A = V D V^T
* @param a
* @return array of D eigenvalues (can be double or complex double) and V eigenvectors
*/
public static Dataset[] calcEigenDecomposition(Dataset a) {
EigenDecomposition evd = new EigenDecomposition(createRealMatrix(a));
Dataset[] results = new Dataset[2];
double[] rev = evd.getRealEigenvalues();
if (evd.hasComplexEigenvalues()) {
double[] iev = evd.getImagEigenvalues();
results[0] = DatasetFactory.createComplexDataset(ComplexDoubleDataset.class, rev, iev);
} else {
results[0] = DatasetFactory.createFromObject(rev);
}
results[1] = createDataset(evd.getV());
return results;
}
示例3: eigen_bak
import org.apache.commons.math3.linear.EigenDecomposition; //导入方法依赖的package包/类
/**
* Calculates the eigen decomposition of a real matrix. The eigen
* decomposition of matrix A is a set of two matrices: V and D such that A =
* V × D × VT. A, V and D are all m × m matrices.
*
* @param a Given matrix.
* @return Result W/V arrays.
*/
public static Array[] eigen_bak(Array a) {
int m = a.getShape()[0];
Array Wa;
Array Va = Array.factory(DataType.DOUBLE, new int[]{m, m});
double[][] aa = (double[][]) ArrayUtil.copyToNDJavaArray(a);
RealMatrix matrix = new Array2DRowRealMatrix(aa, false);
EigenDecomposition decomposition = new EigenDecomposition(matrix);
if (decomposition.hasComplexEigenvalues()) {
Wa = Array.factory(DataType.OBJECT, new int[]{m});
double[] rev = decomposition.getRealEigenvalues();
double[] iev = decomposition.getImagEigenvalues();
for (int i = 0; i < m; i++) {
Wa.setObject(i, new Complex(rev[i], iev[i]));
RealVector v = decomposition.getEigenvector(i);
for (int j = 0; j < v.getDimension(); j++) {
Va.setDouble(j * m + i, v.getEntry(j));
}
}
} else {
RealMatrix V = decomposition.getV();
RealMatrix D = decomposition.getD();
Wa = Array.factory(DataType.DOUBLE, new int[]{m});
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
Va.setDouble(i * m + (m - j - 1), V.getEntry(i, j));
if (i == j) {
Wa.setDouble(m - i - 1, D.getEntry(i, j));
}
}
}
}
return new Array[]{Wa, Va};
}