org.eclipse.january.dataset

## Class LinearAlgebra

- java.lang.Object
- - org.eclipse.january.dataset.LinearAlgebra

-     public class LinearAlgebra
      extends Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `LinearAlgebra.NormOrder` Order value for norm

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LinearAlgebra()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Dataset` | `calcCholeskyDecomposition(Dataset a)` Calculate Cholesky decomposition `A = L L^T`
    `static double` | `calcConditionNumber(Dataset a)` Calculate condition number of matrix by singular value decomposition method
    `static Dataset` | `calcConjugateGradient(Dataset a, Dataset v)` Calculation `A x = v` by conjugate gradient method with the stopping criterion being that the estimated residual `r = v - A x` satisfies `||r|| < ||v||` with maximum of 100 iterations
    `static Dataset` | `calcConjugateGradient(Dataset a, Dataset v, int maxIterations, double delta)` Calculation `A x = v` by conjugate gradient method with the stopping criterion being that the estimated residual `r = v - A x` satisfies `||r|| < delta ||v||`
    `static double` | `calcDeterminant(Dataset a)`
    `static Dataset[]` | `calcEigenDecomposition(Dataset a)` Calculate eigen-decomposition `A = V D V^T`
    `static Dataset` | `calcEigenvalues(Dataset a)`
    `static Dataset` | `calcInverse(Dataset a)` Calculate inverse of square dataset
    `static Dataset[]` | `calcLUDecomposition(Dataset a)` Calculate LU decomposition `A = P^-1 L U`
    `static int` | `calcMatrixRank(Dataset a)` Calculate matrix rank by singular value decomposition method
    `static Dataset` | `calcPseudoInverse(Dataset a)` Calculate (Moore-Penrose) pseudo-inverse
    `static Dataset[]` | `calcQRDecomposition(Dataset a)` Calculate QR decomposition `A = Q R`
    `static Dataset[]` | `calcSingularValueDecomposition(Dataset a)` Calculate singular value decomposition `A = U S V^T`
    `static double[]` | `calcSingularValues(Dataset a)`
    `static Dataset` | `crossProduct(Dataset a, Dataset b)` Calculate the cross product of two datasets.
    `static Dataset` | `crossProduct(Dataset a, Dataset b, int axisA, int axisB, int axisC)` Calculate the cross product of two datasets.
    `static Dataset` | `dotProduct(Dataset a, Dataset b)` Calculate the dot product of two datasets.
    `static Dataset` | `kroneckerProduct(Dataset a, Dataset b)` Create the Kronecker product as defined by `kron[k0,...,kN] = a[i0,...,iN] * b[j0,...,jN]` where `kn = sn * in + jn` for `n = 0...N` and `s` is shape of `b`
    `static double` | `norm(Dataset a)`
    `static double` | `norm(Dataset a, double p)`
    `static double` | `norm(Dataset a, LinearAlgebra.NormOrder order)`
    `static Dataset` | `outerProduct(Dataset a, Dataset b)` Calculate the outer product of two datasets
    `static Dataset` | `power(Dataset a, int n)` Raise dataset to given power by matrix multiplication
    `static Dataset` | `solve(Dataset a, Dataset v)` Solve linear matrix equation `A x = v`
    `static Dataset` | `solveSVD(Dataset a, Dataset v)` Solve least squares matrix equation `A x = v` by SVD
    `static Dataset` | `tensorDotProduct(Dataset a, Dataset b, int[] axisa, int[] axisb)` Calculate the tensor dot product over given axes.
    `static Dataset` | `tensorDotProduct(Dataset a, Dataset b, int axisa, int axisb)` Calculate the tensor dot product over given axes.
    `static Dataset` | `trace(Dataset a)` Calculate trace of dataset - sum of values over 1st axis and 2nd axis
    `static Dataset` | `trace(Dataset a, int offset, int axis1, int axis2)` Calculate trace of dataset - sum of values over axis1 and axis2 where axis2 is offset

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

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

- - ### Constructor Detail

    - #### LinearAlgebra

          public LinearAlgebra()

  - ### Method Detail

    - #### tensorDotProduct

          public static Dataset tensorDotProduct(Dataset a,
                                                 Dataset b,
                                                 int axisa,
                                                 int axisb)

      Calculate the tensor dot product over given axes. This is the sum of products of elements selected from the given axes in each dataset
      Parameters:
        `a` - first dataset
        `b` - second dataset
        `axisa` - axis dimension in a to sum over (can be -ve)
        `axisb` - axis dimension in b to sum over (can be -ve)
      Returns:
        tensor dot product

    - #### tensorDotProduct

          public static Dataset tensorDotProduct(Dataset a,
                                                 Dataset b,
                                                 int[] axisa,
                                                 int[] axisb)

      Calculate the tensor dot product over given axes. This is the sum of products of elements selected from the given axes in each dataset
      Parameters:
        `a` - first dataset
        `b` - second dataset
        `axisa` - axis dimensions in a to sum over (can be -ve)
        `axisb` - axis dimensions in b to sum over (can be -ve)
      Returns:
        tensor dot product

    - #### dotProduct

          public static Dataset dotProduct(Dataset a,
                                           Dataset b)

      Calculate the dot product of two datasets. When b is a 1D dataset, the sum product over the last axis of a and b is returned. Where a is also a 1D dataset, a zero-rank dataset is returned. If b is 2D or higher, its second-to-last axis is used
      Parameters:
        `a` - first dataset
        `b` - second dataset
      Returns:
        dot product

    - #### outerProduct

          public static Dataset outerProduct(Dataset a,
                                             Dataset b)

      Calculate the outer product of two datasets
      Parameters:
        `a` - first dataset
        `b` - second dataset
      Returns:
        outer product

    - #### crossProduct

          public static Dataset crossProduct(Dataset a,
                                             Dataset b)

      Calculate the cross product of two datasets. Datasets must be broadcastable and possess last dimensions of length 2 or 3
      Parameters:
        `a` - first dataset
        `b` - second dataset
      Returns:
        cross product

    - #### crossProduct

          public static Dataset crossProduct(Dataset a,
                                             Dataset b,
                                             int axisA,
                                             int axisB,
                                             int axisC)

      Calculate the cross product of two datasets. Datasets must be broadcastable and possess dimensions of length 2 or 3. The axis parameters can be negative to indicate dimensions from the end of their shapes
      Parameters:
        `a` - first dataset
        `b` - second dataset
        `axisA` - dimension to be used a vector (must have length of 2 or 3)
        `axisB` - dimension to be used a vector (must have length of 2 or 3)
        `axisC` - dimension to assign as cross-product
      Returns:
        cross product

    - #### power

          public static Dataset power(Dataset a,
                                      int n)

      Raise dataset to given power by matrix multiplication
      Parameters:
        `a` - dataset
        `n` - power
      Returns:
        `a ** n`

    - #### kroneckerProduct

          public static Dataset kroneckerProduct(Dataset a,
                                                 Dataset b)

      Create the Kronecker product as defined by `kron[k0,...,kN] = a[i0,...,iN] * b[j0,...,jN]` where `kn = sn * in + jn` for `n = 0...N` and `s` is shape of `b`
      Parameters:
        `a` - first dataset
        `b` - second dataset
      Returns:
        Kronecker product of a and b

    - #### trace

          public static Dataset trace(Dataset a)

      Calculate trace of dataset - sum of values over 1st axis and 2nd axis
      Parameters:
        `a` - dataset
      Returns:
        trace of dataset

    - #### trace

          public static Dataset trace(Dataset a,
                                      int offset,
                                      int axis1,
                                      int axis2)

      Calculate trace of dataset - sum of values over axis1 and axis2 where axis2 is offset
      Parameters:
        `a` - dataset
        `offset` - distance right of diagonal
        `axis1` - first axis
        `axis2` - second axis
      Returns:
        trace of dataset

    - #### norm

          public static double norm(Dataset a)

      Parameters:
        `a` - dataset
      Returns:
        norm of dataset

    - #### norm

          public static double norm(Dataset a,
                                    LinearAlgebra.NormOrder order)

      Parameters:
        `a` - dataset
        `order` - for norm
      Returns:
        norm of dataset

    - #### norm

          public static double norm(Dataset a,
                                    double p)

      Parameters:
        `a` - dataset
        `p` - norm value
      Returns:
        p-norm of dataset

    - #### calcSingularValues

          public static double[] calcSingularValues(Dataset a)

      Parameters:
        `a` - dataset
      Returns:
        array of singular values

    - #### calcSingularValueDecomposition

          public static Dataset[] calcSingularValueDecomposition(Dataset a)

      Calculate singular value decomposition `A = U S V^T`
      Parameters:
        `a` - dataset
      Returns:
        array of U - orthogonal matrix, s - singular values vector, V - orthogonal matrix

    - #### calcPseudoInverse

          public static Dataset calcPseudoInverse(Dataset a)

      Calculate (Moore-Penrose) pseudo-inverse
      Parameters:
        `a` - dataset
      Returns:
        pseudo-inverse

    - #### calcMatrixRank

          public static int calcMatrixRank(Dataset a)

      Calculate matrix rank by singular value decomposition method
      Parameters:
        `a` - dataset
      Returns:
        effective numerical rank of matrix

    - #### calcConditionNumber

          public static double calcConditionNumber(Dataset a)

      Calculate condition number of matrix by singular value decomposition method
      Parameters:
        `a` - dataset
      Returns:
        condition number

    - #### calcDeterminant

          public static double calcDeterminant(Dataset a)

      Parameters:
        `a` - dataset
      Returns:
        determinant of dataset

    - #### calcEigenvalues

          public static Dataset calcEigenvalues(Dataset a)

      Parameters:
        `a` - dataset
      Returns:
        dataset of eigenvalues (can be double or complex double)

    - #### calcEigenDecomposition

          public static Dataset[] calcEigenDecomposition(Dataset a)

      Calculate eigen-decomposition `A = V D V^T`
      Parameters:
        `a` - dataset
      Returns:
        array of D eigenvalues (can be double or complex double) and V eigenvectors

    - #### calcQRDecomposition

          public static Dataset[] calcQRDecomposition(Dataset a)

      Calculate QR decomposition `A = Q R`
      Parameters:
        `a` - dataset
      Returns:
        array of Q and R

    - #### calcLUDecomposition

          public static Dataset[] calcLUDecomposition(Dataset a)

      Calculate LU decomposition `A = P^-1 L U`
      Parameters:
        `a` - dataset
      Returns:
        array of L, U and P

    - #### calcInverse

          public static Dataset calcInverse(Dataset a)

      Calculate inverse of square dataset
      Parameters:
        `a` - dataset
      Returns:
        inverse

    - #### solve

          public static Dataset solve(Dataset a,
                                      Dataset v)

      Solve linear matrix equation `A x = v`
      Parameters:
        `a` - dataset
        `v` - vector
      Returns:
        x

    - #### solveSVD

          public static Dataset solveSVD(Dataset a,
                                         Dataset v)

      Solve least squares matrix equation `A x = v` by SVD
      Parameters:
        `a` - dataset
        `v` - vector
      Returns:
        x

    - #### calcCholeskyDecomposition

          public static Dataset calcCholeskyDecomposition(Dataset a)

      Calculate Cholesky decomposition `A = L L^T`
      Parameters:
        `a` - dataset
      Returns:
        L

    - #### calcConjugateGradient

          public static Dataset calcConjugateGradient(Dataset a,
                                                      Dataset v)

      Calculation `A x = v` by conjugate gradient method with the stopping criterion being that the estimated residual `r = v - A x` satisfies `||r|| < ||v||` with maximum of 100 iterations
      Parameters:
        `a` - dataset
        `v` - vector
      Returns:
        value of `A^-1 v` by conjugate gradient method

    - #### calcConjugateGradient

          public static Dataset calcConjugateGradient(Dataset a,
                                                      Dataset v,
                                                      int maxIterations,
                                                      double delta)

      Calculation `A x = v` by conjugate gradient method with the stopping criterion being that the estimated residual `r = v - A x` satisfies `||r|| < delta ||v||`
      Parameters:
        `a` - dataset
        `v` - vector
        `maxIterations` - maximum iterations
        `delta` - parameter used by stopping criterion
      Returns:
        value of `A^-1 v` by conjugate gradient method

Copyright © 2014–2022 Eclipse Foundation. All rights reserved.