/** * 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 a array {a11,a12,a22} of tensor elements. */ public void setTensor(int i1, int i2, float[] a) { setTensor(i1,i2,a[0],a[1],a[2]); }
/** * Applies this mask to a specified eigentensor field. * @param efalse eigentensor {e11,e12,e22} to use for samples * where the mask is false. * @param e eigentensors to be masked. */ public void apply(float[] efalse, EigenTensors2 e) { Check.state(_mask2!=null,"mask constructed for a 2D image"); for (int i2=0; i2<_n2; ++i2) { for (int i1=0; i1<_n1; ++i1) { if (!_mask2[i2][i1]) e.setTensor(i1,i2,efalse); } } }
private static void testRandom(double errorAngle, double errorCoeff) { int n1 = 13, n2 = 14; EigenTensors2 et = new EigenTensors2(n1,n2); for (int i2=0; i2<n2; ++i2) { for (int i1=0; i1<n1; ++i1) { float[] a = makeRandomEigenvalues(); float[] u = makeRandomEigenvector(); et.setEigenvalues(i1,i2,a); et.setEigenvectorU(i1,i2,u); float[] c; c = et.getEigenvectorU(i1,i2); checkEigenvectors(u,c,errorAngle); c = et.getEigenvalues(i1,i2); checkEigenvalues(c,a,errorCoeff); et.setTensor(i1,i2,et.getTensor(i1,i2)); c = et.getEigenvectorU(i1,i2); checkEigenvectors(u,c,errorAngle); c = et.getEigenvalues(i1,i2); checkEigenvalues(c,a,errorCoeff); } } }