Documentation of 'mikera.matrixx.Matrixx' Java class
Matrixx
mikera.matrixx

Class Matrixx



  • public class Matrixx
    extends java.lang.Object
    Static method class for matrices
    • Constructor Detail

      • Matrixx

        public Matrixx()
    • Method Detail

      • createIdentityMatrix

        public static AMatrix createIdentityMatrix(int dimensions)
        Creates an identity matrix
      • createImmutableIdentityMatrix

        public static IdentityMatrix createImmutableIdentityMatrix(int dimensions)
        Creates a sparse, immutable identity matrix. This is the most efficient format for identity matrices
      • createMutableIdentityMatrix

        public static AMatrix createMutableIdentityMatrix(int dimensions)
        Creates a fully mutable identity matrix
      • toMatrix

        public static AMatrix toMatrix(INDArray a)
        Coerce an object to a matrix format, on a best effort basis. Can handle: - Existing matrices - Vectors (will be broadcast to a n x 1 column matrix) - Scalars (will be broadcast to a 1 x 1 matrix)
      • toMatrix

        public static AMatrix toMatrix(java.lang.Object o)
        Coerce an object to a matrix format, on a best effort basis. Can handle: - INDArray instances of suitable shape (will be broadcast to a matrix if needed) - Iterable objects representing a list of rows
      • createSparse

        public static AMatrix createSparse(AMatrix m)
        Creates a sparse matrix from the given matrix, ignoring zeros
      • createSparse

        public static SparseRowMatrix createSparse(int rowCount,
                                                   int columnCount)
        Creates a sparse matrix of the given size, initially zero-filled. Uses row-based storage by default
      • createSparseRows

        public static SparseRowMatrix createSparseRows(java.lang.Iterable<AVector> rows)
        Creates a sparse matrix from the given matrix, ignoring zeros. Uses row-based storage by default
      • createSparseArray

        public static java.util.ArrayList<AVector> createSparseArray(java.util.Iterator<AVector> vecIterator)
        Creates a sparse matrix from the given iterator. Each vector in the iterator will be copied to a row in the new sparse matrix
      • createSparse

        public static AMatrix createSparse(int columnCount,
                                           Index[] indexes,
                                           AVector[] weights)
        Create a sparse array, given an Index of column positions and AVector of corresponding values for each row in the sparse array Performs a defensive copy of underlying data.
      • createSparseColumns

        public static SparseColumnMatrix createSparseColumns(AMatrix m)
        Creates a SparseColumnMatrix from the given matrix, ignoring zeros
      • createSparseRows

        public static AMatrix createSparseRows(AMatrix m)
        Creates a SparseRowMatrix matrix from the given matrix, ignoring zeros
      • createSparseRows

        public static SparseRowMatrix createSparseRows(INDArray a)
        Creates a SparseRowMatrix matrix from the given INDArray, ignoring zeros
      • createImmutableZeroMatrix

        public static ZeroMatrix createImmutableZeroMatrix(int rows,
                                                           int columns)
        Creates an immutable zero-filled matrix
      • createScaleMatrix

        public static ADiagonalMatrix createScaleMatrix(int dimensions,
                                                        double factor)
        Creates a diagonal scaling matrix (same factor on every element of main diagonal, 0.0 elsewhere) Mutable only on main diagonal.
        Parameters:
        dimensions -
        factor -
        Returns:
      • createScalarMatrix

        public static ADiagonalMatrix createScalarMatrix(int dimensions,
                                                         double factor)
        Creates a scalar matrix with the given scale factor. Scalar matrices are efficient, lightweight and immutable.
      • createScaleMatrix

        public static DiagonalMatrix createScaleMatrix(double... scalingFactors)
        Creates a diagonal scaling matrix with the given scale factors for each dimension
      • createDiagonalMatrix

        public static DiagonalMatrix createDiagonalMatrix(double... diagonalValues)
        Creates a diagonal matrix, using the given diagonal values. Performs a defensive copy of the data.
      • createDiagonalMatrix

        public static DiagonalMatrix createDiagonalMatrix(AVector diagonalValues)
        Creates a diagonal matrix using the given vector of values on the main diagonal.
      • createRotationMatrix

        public static Matrix33 createRotationMatrix(Vector3 axis,
                                                    double angle)
        Creates a 3D rotation matrix for a given angle or rotation in radians around an axis vector. The axis vector need not be normalised.
      • createRotationMatrix

        public static Matrix33 createRotationMatrix(double x,
                                                    double y,
                                                    double z,
                                                    double angle)
        Create a 3x3 rotation matrix using the given rotation axis and angle in radians
        Parameters:
        angle - Rotation angle in radians
        x - x-element of rotation vector
        y - y-element of rotation vector
        z - z-element of rotation vector
      • createRotationMatrix

        public static Matrix33 createRotationMatrix(AVector v,
                                                    double angle)
        Create a 3x3 rotation matrix using the given rotation axis and angle in radians
        Parameters:
        angle - Rotation angle in radians
        v - Rotation axis vector
      • createXAxisRotationMatrix

        public static Matrix33 createXAxisRotationMatrix(double angle)
        Create a 3x3 rotation matrix using the given rotation angle in radians around the x-axis
        Parameters:
        angle - Rotation angle in radians
      • createYAxisRotationMatrix

        public static Matrix33 createYAxisRotationMatrix(double angle)
        Create a 3x3 rotation matrix using the given rotation angle in radians around the y-axis
        Parameters:
        angle - Rotation angle in radians
      • createZAxisRotationMatrix

        public static Matrix33 createZAxisRotationMatrix(double angle)
        Create a 3x3 rotation matrix using the given rotation angle in radians around the z-axis
        Parameters:
        angle - Rotation angle in radians
      • create2DRotationMatrix

        public static Matrix22 create2DRotationMatrix(double angle)
      • createRandomSquareMatrix

        public static Matrix createRandomSquareMatrix(int dimensions)
      • createRandomSquareMatrix

        public static Matrix createRandomSquareMatrix(int dimensions,
                                                      java.util.Random rand)
      • createRandomMatrix

        public static AMatrix createRandomMatrix(int rows,
                                                 int columns)
        Creates a mutable matrix containing random double values in the range [0.0 , 1.0)
        Parameters:
        rows -
        columns -
        Returns:
      • createRandomMatrix

        public static AMatrix createRandomMatrix(int rows,
                                                 int columns,
                                                 java.util.Random rand)
        Creates a mutable matrix containing random double values in the range [0.0 , 1.0)
        Parameters:
        rows -
        columns -
        rand - A random number generator to use as the seed
        Returns:
      • newMatrix

        public static AMatrix newMatrix(int rows,
                                        int columns)
        Creates an empty (zero-filled) mutable matrix of the specified size. Uses mutable primitive matrices for small sizes (1x1, 2x2, 3x3)
        Parameters:
        rows -
        columns -
        Returns:
      • createFromVector

        public static Matrix createFromVector(AVector source,
                                              int rows,
                                              int columns)
        Creates a new matrix using the elements in the specified vector. Truncates or zero-pads the data as required to fill the new matrix
        Parameters:
        data -
        rows -
        columns -
        Returns:
      • createInverse

        public AMatrix createInverse(AMatrix m)
        Computes the inverse of a matrix. Returns null if the matrix is singular. Throws an Exception is the matrix is not square
        Parameters:
        m -
        Returns:
      • extractLowerTriangular

        public static AMatrix extractLowerTriangular(AMatrix a)
        Extracts a lower triangular matrix from a matrix
      • extractUpperTriangular

        public static AMatrix extractUpperTriangular(AMatrix a)
        Extracts an upper triangular matrix from a matrix
      • create

        public static Matrix create(AMatrix m)
        Creates a mutable deep copy of a matrix
      • create

        public static Matrix create(java.util.List<java.lang.Object> rows)
        Create a matrix from a list of rows
        Parameters:
        rows -
        Returns:
      • create

        public static AMatrix create(IMatrix m)
        Creates a mutable copy of a matrix
      • fillRandomValues

        public static void fillRandomValues(AMatrix m)
        Fills a matrix with uniform random numbers
        Parameters:
        m -
      • fillRandomValues

        public static void fillRandomValues(AMatrix m,
                                            java.util.Random rand)
        Fills a matrix with uniform random numbers, using the specified Random instance
        Parameters:
        m -
      • createFromVectors

        public static AMatrix createFromVectors(INDArray... data)
        Create a matrix using as array of vectors which represent the data for each row
        Parameters:
        data -
        Returns:
      • createFromVectors

        public static AMatrix createFromVectors(java.util.List<INDArray> data)
        Create a matrix using a list of vectors as the data for each row
        Parameters:
        data -
        Returns:
      • parse

        public static AMatrix parse(java.lang.String ednString)
        Parse a matrix in edn format
        Parameters:
        ednString -
        Returns:
      • create

        public static AMatrix create(java.lang.Object... vs)
        Creates a matrix using the given objects to generate individual rows
        Parameters:
        vs -
        Returns:
      • create

        public static Matrix create(double[][] data)
        Creates a matrix using the given double[][] data
        Parameters:
        data -
        Returns:
      • wrapStrided

        public static AStridedMatrix wrapStrided(double[] data,
                                                 int rows,
                                                 int cols,
                                                 int offset,
                                                 int rowStride,
                                                 int colStride)
        Wraps double[] data in a strided matrix of the most efficient available type.
        Parameters:
        array -
        arrayOffset -
        reverse -
        reverse2 -
        Returns:
      • createSparse

        public static AMatrix createSparse(java.lang.Iterable<INDArray> slices)
        Creates a sparse matrix using the given arrays as slices
        Parameters:
        slices - An iterable object containing n length m vectors to use as matrix rows
        Returns:
      • createSparse

        public static AMatrix createSparse(java.lang.Object... slices)
        Creates a sparse matrix using the given objects as slices
        Parameters:
        slices -
        Returns:

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.