Package cc.mallet.types
Class Matrixn
- java.lang.Object
-
- cc.mallet.types.DenseMatrix
-
- cc.mallet.types.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 (seesingleIndex(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
-
-
Field Summary
-
Fields inherited from class cc.mallet.types.DenseMatrix
hasInfinite
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
ConstantMatrix
cloneMatrix()
boolean
equals(java.lang.Object o)
int
getDimensions(int[] szs)
int
getNumDimensions()
int
hashCode()
static void
main(java.lang.String[] args)
void
setValue(int[] indices, double value)
int
singleIndex(int[] indices)
static int
singleIndex(int[] szs, int[] indices)
void
singleToIndices(int single, int[] indices)
static void
singleToIndices(int single, int[] indices, int[] szs)
Just a utility function for arbitrary-dimensional matrix dereferencing.double[]
toArray()
Returns a one-dimensional array representation of the matrix.double
value(int[] indices)
-
Methods inherited from class cc.mallet.types.DenseMatrix
absNorm, absNormalize, almostEquals, divideEquals, dotProduct, elementwiseDivideEquals, elementwiseDivideEquals, elementwiseTimesEquals, elementwiseTimesEquals, equalsPlus, incrementSingleValue, indexAtLocation, infinityNorm, infinityNorm, infinityNormalize, isNaN, location, numLocations, oneNorm, oneNormalize, plusEquals, plusEquals, plusEquals, plusEquals, plusEquals, print, set, setAll, setSingleValue, setValueAtLocation, setWithAddend, setWithFactor, singleSize, singleValue, substitute, timesEquals, timesEquals, twoNorm, twoNormalize, valueAtLocation
-
-
-
-
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
-
getNumDimensions
public int getNumDimensions()
- Specified by:
getNumDimensions
in interfaceConstantMatrix
- Specified by:
getNumDimensions
in classDenseMatrix
-
getDimensions
public int getDimensions(int[] szs)
- Specified by:
getDimensions
in interfaceConstantMatrix
- Specified by:
getDimensions
in classDenseMatrix
-
value
public double value(int[] indices)
- Specified by:
value
in interfaceConstantMatrix
- Specified by:
value
in classDenseMatrix
-
setValue
public void setValue(int[] indices, double value)
- Specified by:
setValue
in interfaceMatrix
- Specified by:
setValue
in classDenseMatrix
-
cloneMatrix
public ConstantMatrix cloneMatrix()
- Specified by:
cloneMatrix
in interfaceConstantMatrix
- Specified by:
cloneMatrix
in classDenseMatrix
-
clone
public java.lang.Object clone()
- Overrides:
clone
in classjava.lang.Object
-
singleIndex
public int singleIndex(int[] indices)
- Specified by:
singleIndex
in interfaceConstantMatrix
- Specified by:
singleIndex
in classDenseMatrix
-
singleIndex
public static int singleIndex(int[] szs, int[] indices)
-
singleToIndices
public void singleToIndices(int single, int[] indices)
- Specified by:
singleToIndices
in interfaceConstantMatrix
- Specified by:
singleToIndices
in classDenseMatrix
-
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 classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.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)
-
-