Class Matrixn

  • All Implemented Interfaces:
    ConstantMatrix, Matrix,, 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
    $Id:,v 1.1 2007/10/22 21:37:39 mccallum Exp $
    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.
        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.
        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()
        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)
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        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.
        An array of the values where index 0 is the major index, etc.
      • main

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