public class CA2DFloat
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private float[][] |
fullMatrix
2D array contains the full matrix
|
private float[] |
lineNum
Array of unique numbers for compression
|
private int[] |
lineRep
Array of number of repetitions for compression
|
private static long |
serialVersionUID
serialVersionUID
|
private int |
sizeX
Number of rows
|
private int |
sizeY
Number of columns
|
Constructor and Description |
---|
CA2DFloat(int sizeX,
int sizeY,
float defaultValue)
Constructor of compress 2D array
|
Modifier and Type | Method and Description |
---|---|
void |
add(float value,
int x,
int y)
Add a value to a single location in the array
|
void |
add(float value,
int fromX,
int fromY,
int toX,
int toY)
Add a value to a region in the array
|
void |
addColumn(int beforeColumn,
int numColumns,
float defaultValue)
Add one or more columns to array
|
void |
addRow(int beforeRow,
int numRows,
float defaultValue)
Add one or more rows to array
|
private void |
compressMatrix()
Prepare compressed data from full matrix to write out
|
void |
deepCopyFrom(CA2DFloat matrix)
Initialize a compressed matrix by creating a deep copy
|
private void |
expandMatrix()
Expand compressed data to full matrix
|
float |
get(int x,
int y)
Get a single value from the array
|
int |
getSizeX()
Getter for number of rows
|
int |
getSizeY()
Getter for the number of columns
|
void |
multiply(float value,
int x,
int y)
Multiply a value to a single location in the array
|
void |
multiply(float value,
int fromX,
int fromY,
int toX,
int toY)
Multiply a value to a region in the array
|
private void |
readObject(java.io.ObjectInputStream in)
Read object from input stream
|
void |
removeColumn(int column)
Remove a single column from array
|
void |
removeColumn(int fromColumn,
int toColumn)
Remove multiple columns from array
|
void |
removeRow(int row)
Remove a single row from array
|
void |
removeRow(int fromRow,
int toRow)
Remove multiple rows from array
|
void |
set(float value,
int x,
int y)
Set a value to a single location in the array
|
void |
set(float value,
int fromX,
int fromY,
int toX,
int toY)
Set a value to a region in the array
|
private void |
writeObject(java.io.ObjectOutputStream out)
Write object to output stream
|
private static final long serialVersionUID
private int sizeX
private int sizeY
private float[][] fullMatrix
private float[] lineNum
private int[] lineRep
public CA2DFloat(int sizeX, int sizeY, float defaultValue)
sizeX
- Number of rowssizeY
- Number of columnsdefaultValue
- Default value in the arraypublic void set(float value, int x, int y)
value
- new valuex
- row indexy
- column indexpublic void set(float value, int fromX, int fromY, int toX, int toY)
value
- new valuefromX
- from row index (inclusive)fromY
- from column index (inclusive)toX
- to row index (inclusive)toY
- to column index (inclusive)public void add(float value, int x, int y)
value
- value to be addedx
- row indexy
- column indexpublic void add(float value, int fromX, int fromY, int toX, int toY)
value
- value to be addedfromX
- from row index (inclusive)fromY
- from column index (inclusive)toX
- to row index (inclusive)toY
- to column index (inclusive)public void multiply(float value, int x, int y)
value
- value to be multipliedx
- row indexy
- column indexpublic void multiply(float value, int fromX, int fromY, int toX, int toY)
value
- value to be multipliedfromX
- from row index (inclusive)fromY
- from column index (inclusive)toX
- to row index (inclusive)toY
- to column index (inclusive)public void addRow(int beforeRow, int numRows, float defaultValue)
beforeRow
- row index before which new rows to be addednumRows
- number of new rows to be addeddefaultValue
- default value for new added rowspublic void addColumn(int beforeColumn, int numColumns, float defaultValue)
beforeColumn
- column index before which new columns to be addednumColumns
- number of new columns to be addeddefaultValue
- default value for new added columnspublic void removeRow(int row)
row
- row to be removedpublic void removeRow(int fromRow, int toRow)
fromRow
- first row to be removed (inclusive)toRow
- last row to be removed (inclusive)public void removeColumn(int column)
column
- column to be removedpublic void removeColumn(int fromColumn, int toColumn)
fromColumn
- first column to be removed (inclusive)toColumn
- last column to be removed (inclusive)public float get(int x, int y)
x
- row indexy
- column indexpublic int getSizeX()
public int getSizeY()
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
out
- object output streamjava.io.IOException
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
in
- object input streamjava.io.IOException
java.lang.ClassNotFoundException
private void compressMatrix()
private void expandMatrix()
public void deepCopyFrom(CA2DFloat matrix)
matrix
- matrix to be copied from