/** * Computes eigenvalues and eigenvectors for a symmetric 3x3 matrix A. * If the eigenvectors are placed in columns in a matrix V, and the * eigenvalues are placed in corresponding columns of a diagonal * matrix D, then AV = VD. * <p> * This method is typically faster but not as accurate when eigenvalues * differ by more than a few orders of magnitude. * @param a the symmetric matrix A. * @param v the array of eigenvectors v[0], v[1], and v[2]. * @param d the array of eigenvalues d[0], d[1], and d[2]. */ public static void solveSymmetric33Fast( double[][] a, double[][] v, double[] d) { solveSymmetric33Hybrid(a,v,d); }
/** * Computes eigenvalues and eigenvectors for a symmetric 3x3 matrix A. * If the eigenvectors are placed in columns in a matrix V, and the * eigenvalues are placed in corresponding columns of a diagonal * matrix D, then AV = VD. * @param a the symmetric matrix A. * @param v the array of eigenvectors v[0], v[1], and v[2]. * @param d the array of eigenvalues d[0], d[1], and d[2]. */ public static void solveSymmetric33(double[][] a, double[][] v, double[] d) { solveSymmetric33Jacobi(a,v,d); // slow but more accurate }
public void testSymmetric33Special() { double[][] v = new double[3][3]; double[] d = new double[3]; double[][][] as = {ASMALL,A100,A110,A111,ATEST1}; for (double[][] a:as) { Eigen.solveSymmetric33(a,v,d); check(a,v,d); } }
/** * Sets tensor elements for specified indices. * This method first computes an eigen-decomposition of the specified * tensor, and then stores the computed eigenvectors and eigenvalues. * The eigenvalues are ordered such that au >= av >= 0. * @param i1 index for 1st dimension. * @param i2 index for 2nd dimension. * @param a11 tensor element a11. * @param a12 tensor element a12. * @param a22 tensor element a22. */ public void setTensor(int i1, int i2, float a11, float a12, float a22) { float[][] aa = { {a11,a12}, {a12,a22} }; float[][] vv = new float[2][2]; float[] ev = new float[2]; Eigen.solveSymmetric22(aa,vv,ev); float[] u = vv[0]; float au = ev[0]; if (au<0.0f) au = 0.0f; float av = ev[1]; if (av<0.0f) av = 0.0f; setEigenvectorU(i1,i2,u); setEigenvalues(i1,i2,au,av); }
for (nloop=0; s.time()<maxtime; ++nloop) { for (int irand=0; irand<nrand; ++irand) { Eigen.solveSymmetric33(a[irand],v,d); for (nloop=0; s.time()<maxtime; ++nloop) { for (int irand=0; irand<nrand; ++irand) { Eigen.solveSymmetric33Fast(a[irand],v,d);
double[][] a, double[][] v, double[] d) getEigenvaluesSymmetric33(a,d); double a00 = a[0][0], a01 = a[0][1], a11 = a[1][1], solveSymmetric33Ql(a,v,d); return; } else { solveSymmetric33Ql(a,v,d); return; } else {
reduceSymmetric33(a,v,d,e); sortDescending33(v,d);
a[2][1] = g23[i3][i2][i1]; a[2][2] = g33[i3][i2][i1]; Eigen.solveSymmetric33(a,z,e); float u1i = (float)z[0][0]; float u2i = (float)z[0][1];
public void testSymmetric22() { int nrand = 10000; double[][] v = new double[2][2]; double[] d = new double[2]; for (int irand=0; irand<nrand; ++irand) { double[][] a = randdouble(2,2); a = add(a, transpose(a)); Eigen.solveSymmetric22(a,v,d); check(a,v,d); } }
public void testSymmetric33() { double[][] v = new double[3][3]; double[] d = new double[3]; int nrand = 10000; for (int irand=0; irand<nrand; ++irand) { //double[][] a = randdouble(3,3); //a = add(a,transpose(a)); double[][] a = makeRandomSymmetric33(); Eigen.solveSymmetric33(a,v,d); check(a,v,d); } }
a[1][0] = g12[i2][i1]; a[1][1] = g22[i2][i1]; Eigen.solveSymmetric22(a,z,e); float u1i = z[0][0]; float u2i = z[0][1];
double[] ev = new double[3]; Eigen.solveSymmetric33(aa,vv,ev); // slow but accurate! double[] u = vv[0]; double[] w = vv[2];