本文整理汇总了Java中org.apache.commons.math3.linear.EigenDecomposition.getEigenvector方法的典型用法代码示例。如果您正苦于以下问题:Java EigenDecomposition.getEigenvector方法的具体用法?Java EigenDecomposition.getEigenvector怎么用?Java EigenDecomposition.getEigenvector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.linear.EigenDecomposition
的用法示例。
在下文中一共展示了EigenDecomposition.getEigenvector方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toOrientationMatrix
import org.apache.commons.math3.linear.EigenDecomposition; //导入方法依赖的package包/类
private Matrix3d toOrientationMatrix(final EigenDecomposition decomposition) {
final RealVector e1 = decomposition.getEigenvector(0);
final RealVector e2 = decomposition.getEigenvector(1);
final RealVector e3 = decomposition.getEigenvector(2);
final Vector3d x = new Vector3d(e1.getEntry(0), e1.getEntry(1), e1.getEntry(
2));
final Vector3d y = new Vector3d(e2.getEntry(0), e2.getEntry(1), e2.getEntry(
2));
final Vector3d z = new Vector3d(e3.getEntry(0), e3.getEntry(1), e3.getEntry(
2));
final Matrix3d orientation = new Matrix3d();
orientation.setColumn(0, x);
orientation.setColumn(1, y);
orientation.setColumn(2, z);
return orientation;
}
示例2: fitEllipsoid
import org.apache.commons.math3.linear.EigenDecomposition; //导入方法依赖的package包/类
/**
* Fit points to the polynomial expression Ax^2 + By^2 + Cz^2 + 2Dxy + 2Exz
* + 2Fyz + 2Gx + 2Hy + 2Iz = 1 and determine the center and radii of the
* fit ellipsoid.
*
* @param points
* the points to be fit to the ellipsoid.
*/
public void fitEllipsoid(ArrayList<ThreeSpacePoint> points)
{
// Fit the points to Ax^2 + By^2 + Cz^2 + 2Dxy + 2Exz
// + 2Fyz + 2Gx + 2Hy + 2Iz = 1 and solve the system.
// v = (( d' * d )^-1) * ( d' * ones.mapAddToSelf(1));
RealVector v = solveSystem(points);
// Form the algebraic form of the ellipsoid.
RealMatrix a = formAlgebraicMatrix(v);
// Find the center of the ellipsoid.
center = findCenter(a);
// Translate the algebraic form of the ellipsoid to the center.
RealMatrix r = translateToCenter(center, a);
// Generate a submatrix of r.
RealMatrix subr = r.getSubMatrix(0, 2, 0, 2);
// subr[i][j] = subr[i][j] / -r[3][3]).
double divr = -r.getEntry(3, 3);
for (int i = 0; i < subr.getRowDimension(); i++)
{
for (int j = 0; j < subr.getRowDimension(); j++)
{
subr.setEntry(i, j, subr.getEntry(i, j) / divr);
}
}
// Get the eigenvalues and eigenvectors.
EigenDecomposition ed = new EigenDecomposition(subr, 0);
evals = ed.getRealEigenvalues();
evecs = ed.getEigenvector(0);
evecs1 = ed.getEigenvector(1);
evecs2 = ed.getEigenvector(2);
// Find the radii of the ellipsoid.
radii = findRadii(evals);
}
示例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};
}
示例4: fitEllipsoid
import org.apache.commons.math3.linear.EigenDecomposition; //导入方法依赖的package包/类
/**
* Fit points to the polynomial expression Ax^2 + By^2 + Cz^2 + 2Dxy + 2Exz
* + 2Fyz + 2Gx + 2Hy + 2Iz = 1 and determine the center and radii of the
* fit ellipsoid.
*
* @param points the points to be fit to the ellipsoid.
*/
public boolean fitEllipsoid(List<? extends ThreeSpacePoint> points) {
// Fit the points to Ax^2 + By^2 + Cz^2 + 2Dxy + 2Exz
// + 2Fyz + 2Gx + 2Hy + 2Iz = 1 and solve the system.
// v = (( d' * d )^-1) * ( d' * ones.mapAddToSelf(1));
RealVector v = solveSystem(points);
if (v == null) {
return false;
}
// Form the algebraic form of the ellipsoid.
RealMatrix a = formAlgebraicMatrix(v);
// Find the center of the ellipsoid.
center = findCenter(a);
// Translate the algebraic form of the ellipsoid to the center.
RealMatrix r = translateToCenter(center, a);
// Generate a submatrix of r.
RealMatrix subr = r.getSubMatrix(0, 2, 0, 2);
// subr[i][j] = subr[i][j] / -r[3][3]).
double divr = -r.getEntry(3, 3);
for (int i = 0; i < subr.getRowDimension(); i++) {
for (int j = 0; j < subr.getRowDimension(); j++) {
subr.setEntry(i, j, subr.getEntry(i, j) / divr);
}
}
// Get the eigenvalues and eigenvectors.
EigenDecomposition ed = new EigenDecomposition(subr, 0);
evals = ed.getRealEigenvalues();
evecs = ed.getEigenvector(0);
evecs1 = ed.getEigenvector(1);
evecs2 = ed.getEigenvector(2);
// Find the radii of the ellipsoid.
radii = findRadii(evals);
return true;
}