Class Matrixn

  • All Implemented Interfaces:
    ConstantMatrix, Matrix, java.io.Serializable, java.lang.Cloneable

    public class Matrixn
    extends DenseMatrix
    implements java.lang.Cloneable
    Implementation of Matrix that allows arbitrary number of dimensions. This implementation simply uses a flat array. This also provides static utilities for doing arbitrary-dimensional array indexing (see singleIndex(int[]), singleToIndices(int, int[])). Created: Tue Sep 16 14:52:37 2003
    Version:
    $Id: Matrixn.java,v 1.1 2007/10/22 21:37:39 mccallum Exp $
    Author:
    Charles Sutton
    See Also:
    Serialized Form
    • Constructor Detail

      • Matrixn

        public Matrixn​(double[] vals)
        Create a 1-d matrix with the given values.
      • Matrixn

        public Matrixn​(int[] szs)
        Create a matrix with the given dimensions.
        Parameters:
        szs - An array containing the maximum for each dimension.
      • Matrixn

        public Matrixn​(int[] szs,
                       double[] vals)
        Create a matrix with the given dimensions and the given values.
        Parameters:
        szs - An array containing the maximum for each dimension.
        vals - A flat array of the entries of the matrix, in row-major order.
    • Method Detail

      • clone

        public java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object
      • singleIndex

        public static int singleIndex​(int[] szs,
                                      int[] indices)
      • singleToIndices

        public static void singleToIndices​(int single,
                                           int[] indices,
                                           int[] szs)
        Just a utility function for arbitrary-dimensional matrix dereferencing.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toArray

        public double[] toArray()
        Returns a one-dimensional array representation of the matrix. Caller must not modify the return value.
        Returns:
        An array of the values where index 0 is the major index, etc.
      • main

        public static void main​(java.lang.String[] args)