Class AbstractGenericMatrix<D,​L extends List<?>>

    • Field Detail

      • size

        protected final int[] size
        The dimensions, rows x columns x depth x ....
      • dataL

        protected L extends List<?> dataL
        The data, vectorized.
    • Constructor Detail

      • AbstractGenericMatrix

        protected AbstractGenericMatrix​(int... size)
        Constructor that creates new blank matrix.
        Parameters:
        size -
      • AbstractGenericMatrix

        protected AbstractGenericMatrix​(D dataA,
                                        int... size)
        Constructor that reuses data in the new object.
        Parameters:
        dataA - data as an array
        size - must have at least two dimensions
      • AbstractGenericMatrix

        protected AbstractGenericMatrix​(AbstractGenericMatrix<D,​L> o)
        Copy constructor.
        Parameters:
        o -
    • Method Detail

      • checkDataSize

        private void checkDataSize​(int dataLength)
        Check that the overall size given by the product of size does not exceed the length of the backed array.
      • newL

        protected abstract L newL​(int size)
        Returns a new data store with given size and entries carrying the default value. The latter depends on the types: false for boolean, 0 for int, 0.0 for double and null for GenericMatrix's.
        Parameters:
        size -
        Returns:
        new D[size]
      • initL

        protected abstract int initL​(D data,
                                     int size)
      • dataSize

        public final int dataSize()
        The number of data entries. Note that it is heavy load to compute this at the moment.
      • getDataA

        protected abstract D getDataA()
        Returns the data store as an array. There are subclasses with array of primitive types.
      • product

        private static int product​(int... ns)
        Parameters:
        ns -
        Returns:
        product of ns
      • resizeUp

        public final void resizeUp​(int... pos)
        Resize matrix up to include pos if necessary, i.e. if an entry of pos is greater than the according entry in size.
        Parameters:
        pos - an index vector with same dimension as size
        Throws:
        UnsupportedOperationException - if pos has dimension other than that of size.
      • pos2ind

        public final int pos2ind​(int... pos)
        Parameters:
        pos -
        Returns:
        the index into data() for the position
      • getPlainString

        public abstract String getPlainString​(int pos)
        Returns the string representation of the given plain position.
      • getSizeLength

        public final int getSizeLength()
      • getSize

        public final int getSize​(int i)
        Parameters:
        i - dimension number in 1 based numbering, 1=row, 2=column
        Returns:
        the size in dimension i
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        public final boolean equals​(Object obj)
        Overrides:
        equals in class Object
      • shallowCopy

        public abstract OctaveObject shallowCopy()
        Description copied from interface: OctaveObject
        Make a shallow copy of this object. In general when an OctaveObject is returned from a getter, e.g. on OctaveStruct or OctaveStruct, a shallow copy is returned in order to follow the way octave behaves. This method is used to make that copy.
        Specified by:
        shallowCopy in interface OctaveObject
        Returns:
        a shallow copy of this
      • main

        public static void main​(String[] args)