/** * Gets the eigenvector u for the tensor with specified indices. * @param i1 index for 1st dimension. * @param i2 index for 2nd dimension. * @param i3 index for 3rd dimension. * @return array {u1,u2,u3} of eigenvector components. */ public float[] getEigenvectorU(int i1, int i2, int i3) { float[] u = new float[3]; getEigenvectorU(i1,i2,i3,u); return u; }
/** * Gets the eigenvector v for the tensor with specified indices. * @param i1 index for 1st dimension. * @param i2 index for 2nd dimension. * @param i3 index for 3rd dimension. * @param v array {v1,v2,v3} of eigenvector components. */ public void getEigenvectorV(int i1, int i2, int i3, float[] v) { float[] u = getEigenvectorU(i1,i2,i3); float[] w = getEigenvectorW(i1,i2,i3); v[0] = w[1]*u[2]-w[2]*u[1]; // v = w cross u v[1] = w[2]*u[0]-w[0]*u[2]; v[2] = w[0]*u[1]-w[1]*u[0]; }
/** * Constructs tensors from the specified tensors. * @param t the tensors from which to copy eigenvectors and eigenvalues. */ public EigenTensors3(EigenTensors3 t) { this(t._n1,t._n2,t._n3,t._compressed); float[] a = new float[3]; float[] u = new float[3]; float[] w = new float[3]; for (int i3=0; i3<_n3; ++i3) { for (int i2=0; i2<_n2; ++i2) { for (int i1=0; i1<_n1; ++i1) { t.getEigenvalues(i1,i2,i3,a); t.getEigenvectorU(i1,i2,i3,u); t.getEigenvectorW(i1,i2,i3,w); setEigenvalues(i1,i2,i3,a); setEigenvectorU(i1,i2,i3,u); setEigenvectorW(i1,i2,i3,w); } } } }
for (int i1=0; i1<n1; ++i1) { et1.getEigenvalues(i1,i2,i3,a1); et1.getEigenvectorU(i1,i2,i3,u1); et1.getEigenvectorW(i1,i2,i3,w1); et2.getEigenvalues(i1,i2,i3,a2); et2.getEigenvectorU(i1,i2,i3,u2); et2.getEigenvectorW(i1,i2,i3,w2); assertEqual(a1,a2);
if (zmin<zc-dzmax && zc+dzmax<zmax) { float[] e = _et.getEigenvalues(iz,iy,ix); float[] u = _et.getEigenvectorU(iz,iy,ix); float[] v = _et.getEigenvectorV(iz,iy,ix); float[] w = _et.getEigenvectorW(iz,iy,ix); if (zmin<zc-dzmax && zc+dzmax<zmax) { float[] e = _et.getEigenvalues(iz,iy,ix); float[] u = _et.getEigenvectorU(iz,iy,ix); float[] v = _et.getEigenvectorV(iz,iy,ix); float[] w = _et.getEigenvectorW(iz,iy,ix); if (ymin<yc-dymax && yc+dymax<ymax) { float[] e = _et.getEigenvalues(iz,iy,ix); float[] u = _et.getEigenvectorU(iz,iy,ix); float[] v = _et.getEigenvectorV(iz,iy,ix); float[] w = _et.getEigenvectorW(iz,iy,ix);
private static void testRandom( boolean compressed, double errorAngle, double errorValue, double errorTensor) { int n1 = 19, n2 = 20, n3 = 21; EigenTensors3 et = new EigenTensors3(n1,n2,n3,compressed); for (int i3=0; i3<n3; ++i3) { for (int i2=0; i2<n2; ++i2) { for (int i1=0; i1<n1; ++i1) { float[] a = makeRandomEigenvalues(); float[] u = makeRandomEigenvector(); float[] w = makeOrthogonalVector(u); et.setEigenvalues(i1,i2,i3,a); et.setEigenvectorU(i1,i2,i3,u); et.setEigenvectorW(i1,i2,i3,w); float[] c; c = et.getEigenvectorU(i1,i2,i3); checkEigenvectors(u,c,errorAngle); c = et.getEigenvectorW(i1,i2,i3); checkEigenvectors(w,c,errorAngle); c = et.getEigenvalues(i1,i2,i3); checkEigenvalues(a,c,errorValue); float[] t1 = et.getTensor(i1,i2,i3); et.setTensor(i1,i2,i3,t1); float[] t2 = et.getTensor(i1,i2,i3); checkTensors(t1,t2,errorTensor); } } } }