public class SimilarityMatrix
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
SimilarityMatrix(int rows,
int cols)
Creates a matrix filled with zeros with the size given by the parameters.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int row,
int col,
double value)
Adds the
value to the current value of the position given by
row and col |
void |
div(int row,
int col,
double value)
Divides the current value of the position given by
row and
col by the indicated value |
static SimilarityMatrix |
getFromFile(java.io.File file,
boolean binary)
Loads a similarity matrix froma binary a file.
|
double[][] |
getMatrix() |
int |
getNCols() |
int |
getNRows() |
double |
getSimilarity(int row,
int col) |
int |
getSize() |
SimilarityMatrixIterator |
iterator() |
void |
serialize(java.io.File output)
Saves this object in a file as binary raw data.
|
void |
setMatrix(double[][] matrix) |
void |
setSimilarity(int row,
int col,
float value)
Changes the value of the position of the matrix given by
row and
col . |
void |
toFile(java.io.File output)
Writes the matrix as text in a given file
|
java.lang.String |
toString() |
public SimilarityMatrix(int rows, int cols)
rows
- Number of rows of the matrix. (Number of source fragments)cols
- Number of columns of the matrix. (Number of target fragments)public java.lang.String toString()
toString
in class java.lang.Object
public void toFile(java.io.File output) throws java.io.IOException
output
- The wile wherein the matrix must be writtenjava.io.IOException
- If happens any problem during the writingpublic void serialize(java.io.File output) throws java.io.IOException
output
- The file wherein the matrix will be savedjava.io.IOException
public void add(int row, int col, double value)
value
to the current value of the position given by
row
and col
row
- Row indexcol
- Column indexvalue
- Value to addpublic void div(int row, int col, double value)
row
and
col
by the indicated value
row
- Row indexcol
- Column indexvalue
- Divisorpublic void setSimilarity(int row, int col, float value)
row
and
col
.row
- Index of the rowcol
- Index of the columnvalue
- New value for the given positionpublic void setMatrix(double[][] matrix)
matrix
- the new similarity matrixpublic static SimilarityMatrix getFromFile(java.io.File file, boolean binary) throws java.lang.ClassNotFoundException, java.io.IOException
file
- File wherein the matrix is savedbinary
- Indicates if the matrix is saved as binary data (
binary = true
) or as text (binary = false
)file
java.lang.ClassNotFoundException
java.io.IOException
public double getSimilarity(int row, int col)
row
- Index of the rowcol
- Index of the columnrow
and col
public int getNRows()
public int getNCols()
public int getSize()
public SimilarityMatrixIterator iterator()
public double[][] getMatrix()