Tensor
Date: 2019-10-22

org.jmol.util

## Class Tensor

- java.lang.Object
- - org.jmol.util.Tensor

-     public class Tensor
      extends java.lang.Object

  Author:
    Bob Hanson hansonr@stolaf.edu 6/30/2013, Simone Sturniolo

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private static float` | `ADP_FACTOR`
    `java.lang.String` | `altType`
    `double[][]` | `asymMatrix`
    `int` | `atomIndex1`
    `int` | `atomIndex2`
    `int` | `eigenSignMask`
    `float[]` | `eigenValues`
    `javajs.util.V3[]` | `eigenVectors`
    `boolean` | `forThermalEllipsoid`
    `java.lang.String` | `id`
    `private static java.lang.String` | `infoList`
    `private static float` | `INTERACTION_FACTOR`
    `boolean` | `isIsotropic`
    `boolean` | `isModulated`
    `boolean` | `isUnmodulated`
    `int` | `iType`
    `private static java.lang.String` | `KNOWN_TYPES`
    `private static float` | `MAGNETIC_SUSCEPTIBILITY_FACTOR`
    `int` | `modelIndex`
    `float[]` | `parBorU`
    `private boolean` | `sortIso`
    `double[][]` | `symMatrix`
    `private static EigenSort` | `tSort`
    `java.lang.String` | `type`
    `static int` | `TYPE_ADP`
    `static int` | `TYPE_CHARGE`
    `static int` | `TYPE_EFG`
    `static int` | `TYPE_ISC`
    `static int` | `TYPE_ISO`
    `static int` | `TYPE_MS`
    `static int` | `TYPE_OTHER`
    `static int` | `TYPE_QUADRUPOLE`
    `static int` | `TYPE_RAMAN`
    `static int` | `TYPE_TLS_R`
    `static int` | `TYPE_TLS_U`
    `private float` | `typeFactor`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Tensor()` Although this constructor is public, to be a valid tensor, one must invoke one of the "setFrom" methods.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `float` | `anisotropy()` anisotropy = directed distance from (center of two closest) to (the furthest)
    `float` | `asymmetry()` asymmetry = deviation from a symmetric tensor
    `Tensor` | `copyTensor()`
    `private static java.util.Comparator<? super java.lang.Object>` | `getEigenSort()`
    `float` | `getFactoredValue(int i)` Returns a factored eigenvalue; thermal ellipsoids use sqrt(abs(eigenvalue)) for ellipsoid axes; others use just use abs(eigenvalue); all cases get factored by typeFactor
    `java.lang.Object` | `getInfo(java.lang.String infoType)` returns an object of the specified type, including "eigenvalues", "eigenvectors", "asymmetric", "symmetric", "trace", "indices", and "type"
    `private static int` | `getInfoIndex(java.lang.String infoType)`
    `private static int` | `getType(java.lang.String type)`
    `boolean` | `isEquiv(Tensor t)`
    `static boolean` | `isFloatInfo(java.lang.String infoType)`
    `float` | `isotropy()` isotropy = average of eigenvalues
    `boolean` | `isSelected(javajs.util.BS bsSelected, int iAtom)`
    `private void` | `newTensorType(javajs.util.V3[] vectors, float[] values, java.lang.String type, java.lang.String id)` common processing of eigenvectors.
    `private void` | `processType()` Sets typeFactor, altType, isIsotropic, forThermalEllipsoid; type "iso" changed to "" here.
    `float` | `reducedAnisotropy()` reduced anisotropy = largest difference from isotropy (may be negative)
    `void` | `setAtomIndexes(int index1, int index2)`
    `Tensor` | `setFromAsymmetricTensor(double[][] asymmetricTensor, java.lang.String type, java.lang.String id)` Standard constructor for QM tensors
    `Tensor` | `setFromAxes(javajs.util.V3[] axes)` Standard constructor for ellipsoids based on axes
    `Tensor` | `setFromEigenVectors(javajs.util.T3[] eigenVectors, float[] eigenValues, java.lang.String type, java.lang.String id, Tensor t)` Standard constructor for charge and iso.
    `Tensor` | `setFromThermalEquation(double[] coefs, java.lang.String id)` standard constructor for thermal ellipsoids convention beta (see http://www.iucr.org/iucr-top/comm/cnom/adp/finrepone/finrepone.html)
    `Tensor` | `setType(java.lang.String type)` Note that type may be null here to skip type initialization and allow later setting of type; this should be used with care.
    `float` | `skew()` a measure of asymmetry.
    `private void` | `sortAndNormalize()` The expression: |sigma_3 - sigma_iso| >= |sigma_1 - sigma_iso| >= |sigma_2 - sigma_iso| simply sorts the values from largest to smallest or smallest to largest, depending upon the direction of the asymmetry, always setting the last value to be the farthest from the mean.
    `float` | `span()` width of the signal; |e2 - e0|
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ADP_FACTOR

          private static final float ADP_FACTOR

    - #### MAGNETIC_SUSCEPTIBILITY_FACTOR

          private static final float MAGNETIC_SUSCEPTIBILITY_FACTOR

      See Also:
        Constant Field Values

    - #### INTERACTION_FACTOR

          private static final float INTERACTION_FACTOR

      See Also:
        Constant Field Values

    - #### tSort

          private static EigenSort tSort

    - #### id

          public java.lang.String id

    - #### type

          public java.lang.String type

    - #### iType

          public int iType

    - #### KNOWN_TYPES

          private static final java.lang.String KNOWN_TYPES

      See Also:
        Constant Field Values

    - #### TYPE_OTHER

          public static final int TYPE_OTHER

      See Also:
        Constant Field Values

    - #### TYPE_ISO

          public static final int TYPE_ISO

      See Also:
        Constant Field Values

    - #### TYPE_ADP

          public static final int TYPE_ADP

      See Also:
        Constant Field Values

    - #### TYPE_TLS_U

          public static final int TYPE_TLS_U

      See Also:
        Constant Field Values

    - #### TYPE_TLS_R

          public static final int TYPE_TLS_R

      See Also:
        Constant Field Values

    - #### TYPE_MS

          public static final int TYPE_MS

      See Also:
        Constant Field Values

    - #### TYPE_EFG

          public static final int TYPE_EFG

      See Also:
        Constant Field Values

    - #### TYPE_ISC

          public static final int TYPE_ISC

      See Also:
        Constant Field Values

    - #### TYPE_CHARGE

          public static final int TYPE_CHARGE

      See Also:
        Constant Field Values

    - #### TYPE_QUADRUPOLE

          public static final int TYPE_QUADRUPOLE

      See Also:
        Constant Field Values

    - #### TYPE_RAMAN

          public static final int TYPE_RAMAN

      See Also:
        Constant Field Values

    - #### asymMatrix

          public double[][] asymMatrix

    - #### symMatrix

          public double[][] symMatrix

    - #### eigenVectors

          public javajs.util.V3[] eigenVectors

    - #### eigenValues

          public float[] eigenValues

    - #### parBorU

          public float[] parBorU

    - #### altType

          public java.lang.String altType

    - #### isIsotropic

          public boolean isIsotropic

    - #### forThermalEllipsoid

          public boolean forThermalEllipsoid

    - #### eigenSignMask

          public int eigenSignMask

    - #### typeFactor

          private float typeFactor

    - #### sortIso

          private boolean sortIso

    - #### modelIndex

          public int modelIndex

    - #### atomIndex1

          public int atomIndex1

    - #### atomIndex2

          public int atomIndex2

    - #### isModulated

          public boolean isModulated

    - #### isUnmodulated

          public boolean isUnmodulated

    - #### infoList

          private static final java.lang.String infoList

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Tensor

          public Tensor()

      Although this constructor is public, to be a valid tensor, one must invoke one of the "setFrom" methods. These had been static, but it turns out when that is the case, then JavaScript versions cannot be modularized to omit this class along with Eigen. So the general full constructor would look something like: new Tensor().setFrom...(....)

  - ### Method Detail

    - #### getType

          private static int getType(java.lang.String type)

    - #### getInfoIndex

          private static int getInfoIndex(java.lang.String infoType)

    - #### isFloatInfo

          public static boolean isFloatInfo(java.lang.String infoType)

    - #### getInfo

          public java.lang.Object getInfo(java.lang.String infoType)

      returns an object of the specified type, including "eigenvalues", "eigenvectors", "asymmetric", "symmetric", "trace", "indices", and "type"
      Parameters:
        `infoType` -
      Returns:
        Object or null

    - #### isotropy

          public float isotropy()

      isotropy = average of eigenvalues
      Returns:
        isotropy

    - #### span

          public float span()

      width of the signal; |e2 - e0|
      Returns:
        unitless; >= 0

    - #### skew

          public float skew()

      a measure of asymmetry.
      Returns:
        range [-1, 1]

    - #### anisotropy

          public float anisotropy()

      anisotropy = directed distance from (center of two closest) to (the furthest)
      Returns:
        unitless number

    - #### reducedAnisotropy

          public float reducedAnisotropy()

      reduced anisotropy = largest difference from isotropy (may be negative)
      Returns:
        unitless number

    - #### asymmetry

          public float asymmetry()

      asymmetry = deviation from a symmetric tensor
      Returns:
        range [0,1]

    - #### copyTensor

          public Tensor copyTensor()

    - #### setFromAsymmetricTensor

          public Tensor setFromAsymmetricTensor(double[][] asymmetricTensor,
                                                java.lang.String type,
                                                java.lang.String id)

      Standard constructor for QM tensors
      Parameters:
        `asymmetricTensor` -
        `type` -
        `id` -
      Returns:
        this

    - #### setFromEigenVectors

          public Tensor setFromEigenVectors(javajs.util.T3[] eigenVectors,
                                            float[] eigenValues,
                                            java.lang.String type,
                                            java.lang.String id,
                                            Tensor t)

      Standard constructor for charge and iso.
      Parameters:
        `eigenVectors` -
        `eigenValues` -
        `type` -
        `id` -
        `t` -
      Returns:
        this

    - #### setFromAxes

          public Tensor setFromAxes(javajs.util.V3[] axes)

      Standard constructor for ellipsoids based on axes
      Parameters:
        `axes` -
      Returns:
        Tensor

    - #### setFromThermalEquation

          public Tensor setFromThermalEquation(double[] coefs,
                                               java.lang.String id)

      standard constructor for thermal ellipsoids convention beta (see http://www.iucr.org/iucr-top/comm/cnom/adp/finrepone/finrepone.html)
      Parameters:
        `coefs` -
        `id` -
      Returns:
        this

    - #### setType

          public Tensor setType(java.lang.String type)

      Note that type may be null here to skip type initialization and allow later setting of type; this should be used with care.
      Parameters:
        `type` -
      Returns:
        "this" for convenience only

    - #### getFactoredValue

          public float getFactoredValue(int i)

      Returns a factored eigenvalue; thermal ellipsoids use sqrt(abs(eigenvalue)) for ellipsoid axes; others use just use abs(eigenvalue); all cases get factored by typeFactor
      Parameters:
        `i` -
      Returns:
        factored eigenvalue

    - #### setAtomIndexes

          public void setAtomIndexes(int index1,
                                     int index2)

    - #### isSelected

          public boolean isSelected(javajs.util.BS bsSelected,
                                    int iAtom)

    - #### newTensorType

          private void newTensorType(javajs.util.V3[] vectors,
                                     float[] values,
                                     java.lang.String type,
                                     java.lang.String id)

      common processing of eigenvectors.
      Parameters:
        `vectors` -
        `values` -
        `type` -
        `id` -

    - #### processType

          private void processType()

      Sets typeFactor, altType, isIsotropic, forThermalEllipsoid; type "iso" changed to "" here.

    - #### sortAndNormalize

          private void sortAndNormalize()

      The expression: |sigma_3 - sigma_iso| >= |sigma_1 - sigma_iso| >= |sigma_2 - sigma_iso| simply sorts the values from largest to smallest or smallest to largest, depending upon the direction of the asymmetry, always setting the last value to be the farthest from the mean. We use a simpler form here: |sigma_3 - sigma_1| >= |sigma_3 - sigma_2| >= |sigma_2 - sigma_1| which amounts to the same thing and is prettier. (Think about it!)

    - #### isEquiv

          public boolean isEquiv(Tensor t)

    - #### getEigenSort

          private static java.util.Comparator<? super java.lang.Object> getEigenSort()

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`