jm.music.tools
Class AdaptiveMatrix

java.lang.Object
  extended byjm.music.tools.AdaptiveMatrix

public final class AdaptiveMatrix
extends java.lang.Object

AdaptiveMatrix is responsible for hold Markov information in an internal matrix which may be written to disk as a serialized java object The matrix itself will contain two arrays. The first array will contain historic information. The second array will contain weightings. These arrays will both allow for n level markov Matrix's.

Author:
Andrew Sorensen

Constructor Summary
AdaptiveMatrix(int[] numArray, int depth, int indexRange)
          This constructor is used when the Matrix is being created for the first time.
AdaptiveMatrix(java.lang.String fileName)
          This constructor is used when the matrix is being read from an existing file.
 
Method Summary
 int[] generate(int length, int[] seed)
          Generate returns an array of generated index values
 java.util.Hashtable getCountMatrix()
          retrieve the count matrix
 int getDepth()
          get matrix's depth
 int getIndexRange()
          retrieve the index range
 java.util.Hashtable getWeightMatrix()
          retrieve the matrix
 void print()
          A simple print method for displaying the contents of a matrix.
 void read(java.lang.String fileName)
          Read the matrix to file
 void update(int[] numArray)
          update an existing AdaptiveMatrix with new data
 void write(java.lang.String fileName)
          Saves the matrix to file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdaptiveMatrix

public AdaptiveMatrix(int[] numArray,
                      int depth,
                      int indexRange)
This constructor is used when the Matrix is being created for the first time. The score parameter is the jMusic score to used in building the matrix. The depth attribute is the number of prior states to use in creating the Matrix. The fileName is a string containing the name of the file to use for storing a copy of this matrix. This contructor should be used when a Matrix is being created for the first time. For matrix's that have already been written to disk the AdaptiveMatrix(fileName) constructor should be used.

Parameters:
numArray - are the values to use in the matriX
depth - the number of prior states.
indexRange - the range of numbers to use for indexing

AdaptiveMatrix

public AdaptiveMatrix(java.lang.String fileName)
This constructor is used when the matrix is being read from an existing file. The file is read by default upon calling this constructor which then assigns all instance variables to those of the AdaptiveMatrix being read back from disk.

Parameters:
fileName - the fileName to read an existing Matrix from
Method Detail

update

public void update(int[] numArray)
update an existing AdaptiveMatrix with new data

Parameters:
numArray - are the valuew to use in the matrix

generate

public int[] generate(int length,
                      int[] seed)
Generate returns an array of generated index values

Parameters:
length - the number of indexes to return. The seed data is included in the length value.
seed - the data to use as a starting point
Returns:
an array of indexes equal to the length required.

read

public void read(java.lang.String fileName)
Read the matrix to file


write

public void write(java.lang.String fileName)
Saves the matrix to file


print

public void print()
A simple print method for displaying the contents of a matrix.


getDepth

public int getDepth()
get matrix's depth

Returns:
depth the number prior states

getWeightMatrix

public java.util.Hashtable getWeightMatrix()
retrieve the matrix

Returns:
Hashtable

getCountMatrix

public java.util.Hashtable getCountMatrix()
retrieve the count matrix

Returns:
Hashtable

getIndexRange

public int getIndexRange()
retrieve the index range

Returns:
indexRange