org.jmat.data
Class AbstractDoubleArray

java.lang.Object
  |
  +--org.jmat.data.AbstractDoubleArray
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
AbstractMatrix

public abstract class AbstractDoubleArray
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Description : Class designed to implement manipulation of arrays of doubles

Copyright : LGPL

See Also:
Serialized Form

Field Summary
protected  int m
          Row and column dimensions.
protected  int n
          Row and column dimensions.
 
Constructor Summary
AbstractDoubleArray(int _m, int _n)
          Construct an m-by-n matrix of zeros.
 
Method Summary
 void checkColumnDimension(AbstractDoubleArray B)
          Check if number of Columns(A) == number of Columns(B).
 void checkColumnDimension(int column)
          Check if number of Columns(A) == column.
 void checkDiagonal()
          Check if A is Diagonal.
 void checkDimensions(AbstractDoubleArray B)
          Check if size(A) == size(B).
 void checkDimensions(int m2, int n2)
          Check if size(A) == m2*n2.
 void checkRowDimension(AbstractDoubleArray B)
          Check if number of Rows(A) == number of Rows(B).
 void checkRowDimension(int row)
          Check if number of Rows(A) == row.
 void checkSymetric()
          Check if A is Symetric.
 void deleteColumnEquals(int J)
          Delete a Column to Matrix.
 void deleteColumnsEquals(int[] J)
          Delete a Column to Matrix.
 void deleteColumnsEquals(int j0, int j1)
          Delete a Column to Matrix.
 void deleteRowEquals(int I)
          delete a Row to Matrix.
 void deleteRowsEquals(int[] I)
          delete a Row to Matrix.
 void deleteRowsEquals(int i0, int i1)
          delete a Row to Matrix.
abstract  double get(int i, int j)
           
 double[][] getArrayCopy()
           
 double[] getColumnArrayCopy(int j)
           
 int getColumnDimension()
          Get column dimension.
abstract  AbstractDoubleArray getDoubleArrayCopy()
           
 double[] getRowArrayCopy(int i)
           
 int getRowDimension()
          Get row dimension.
 void insertColumnsEquals(int J, AbstractDoubleArray B)
          Insert a Column into Matrix.
 void insertRowsEquals(int I, AbstractDoubleArray B)
          Insert a Row into Matrix.
 boolean isDiagonal()
          Test if A is Diagonal.
 boolean isEqual(AbstractDoubleArray B)
          Test if A == B.
 boolean isSymetric()
          Test if A is Symetric.
 void mergeColumnsEquals(AbstractDoubleArray B)
          Matrix merge.
 void mergeRowsEquals(AbstractDoubleArray B)
          Matrix merge.
protected  void putColumnIn(int j, AbstractDoubleArray X)
          Set columns
protected  void putColumnsIn(int[] J, AbstractDoubleArray X)
          Set columns
protected  void putColumnsIn(int j0, int j1, AbstractDoubleArray X)
          Set columns
protected  void putDiagonalIn(AbstractDoubleArray X)
          Set diagonal
protected  void putDiagonalIn(int num, AbstractDoubleArray X)
          Set diagonal
protected  void putRowIn(int i, AbstractDoubleArray X)
          Set a row
protected  void putRowsIn(int[] I, AbstractDoubleArray X)
          Set rows
protected  void putRowsIn(int i0, int i1, AbstractDoubleArray X)
          Set rows
protected  void putSubMatrixIn(int i0, int i1, int j0, int j1, AbstractDoubleArray X)
          Set the submatrix
protected abstract  void reset(int _m, int _n)
          Construct an m-by-n matrix of zeros.
 void reshapeColumnsEquals(int m2, int n2)
          Matrix reshape by Column.
 void reshapeRowsEquals(int m2, int n2)
          Matrix reshape by Row.
 void resizeEquals(int m2, int n2)
          Matrix resize.
abstract  void set(int i, int j, double s)
           
protected  void setAllConstant(double v)
          Set all elements of the matrix to constant values
protected  void setAllDiagonal(double[] d)
          Set the matrix to diagonal
protected  void setAllIdentity()
          Set the matrix to identity
protected  void setAllIncrementColumns(double[] begin, double[] pitch)
          Set the matrix to increment columns
protected  void setAllIncrementColumns(double begin, double pitch)
          Set the matrix to increment columns
protected  void setAllIncrementRows(double[] begin, double[] pitch)
          Set the matrix to increment rows
protected  void setAllIncrementRows(double begin, double pitch)
          Set the matrix to increment rows
protected  void setAllMergeColumns(AbstractDoubleArray[] Xs)
          Set matrix to merge columns
protected  void setAllMergeRows(AbstractDoubleArray[] Xs)
          Set matrix to merge rows
protected  void setAllRandom()
          Set all elements of the matrix to random values
 void setColumn(int j, AbstractDoubleArray B)
          Set a column to an internal one-dimensional Column.
 void setColumn(int j, double B)
          Set a column to an internal one-dimensional Column.
 void setColumns(int[] J, AbstractDoubleArray B)
          Copy an internal one-dimensional array from a column.
 void setColumns(int j0, AbstractDoubleArray B)
          Set a column to an internal one-dimensional Column.
 void setRow(int i, AbstractDoubleArray B)
          Copy an internal one-dimensional array from a row.
 void setRow(int i, double B)
          Copy an internal one-dimensional array from a row.
 void setRows(int[] I, AbstractDoubleArray B)
          Copy an internal one-dimensional array from many rows.
 void setRows(int i0, AbstractDoubleArray B)
          Copy an internal one-dimensional array from a row.
 void setSubMatrix(int i0, int j0, AbstractDoubleArray X)
          Set a submatrix.
 void setSubMatrix(int i0, int i1, int j0, int j1, double v)
          Set a submatrix.
 double toDouble()
          convert the Matrix into a double value if the matrix is 1*1.
 double[][] toDouble2DArray()
          convert the Matrix into a double value if the matrix is 1*1.
 double[] toDoubleArray()
           
 double[] toDoubleColumnArray(int j)
          convert the Matrix into a double value if the matrix is 1*1.
 double[] toDoubleRowArray(int i)
          convert the Matrix into a double value if the matrix is 1*1.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m

protected int m
Row and column dimensions.


n

protected int n
Row and column dimensions.

Constructor Detail

AbstractDoubleArray

public AbstractDoubleArray(int _m,
                           int _n)
Construct an m-by-n matrix of zeros.

Parameters:
_m - Number of rows.
_n - Number of colums.
Method Detail

getDoubleArrayCopy

public abstract AbstractDoubleArray getDoubleArrayCopy()

getRowDimension

public int getRowDimension()
Get row dimension.

Returns:
m the number of rows.

getColumnDimension

public int getColumnDimension()
Get column dimension.

Returns:
n the number of columns.

get

public abstract double get(int i,
                           int j)

set

public abstract void set(int i,
                         int j,
                         double s)

setSubMatrix

public void setSubMatrix(int i0,
                         int j0,
                         AbstractDoubleArray X)
Set a submatrix.

Parameters:
i0 - Initial row index
j0 - Initial column index
X - subMatrix to set
Throws:
java.lang.ArrayIndexOutOfBoundsException - Submatrix indices

setSubMatrix

public void setSubMatrix(int i0,
                         int i1,
                         int j0,
                         int j1,
                         double v)
Set a submatrix.

Parameters:
i0 - Initial row index
i1 - Final row index
j0 - Initial column index
j1 - Final column index
v - Value to set in the submatrix
Throws:
java.lang.ArrayIndexOutOfBoundsException - Submatrix indices

setRow

public void setRow(int i,
                   AbstractDoubleArray B)
Copy an internal one-dimensional array from a row.

Parameters:
i - Row index
B - Row-matrix

setRow

public void setRow(int i,
                   double B)
Copy an internal one-dimensional array from a row.

Parameters:
i - Row index
B - Row-matrix

setRows

public void setRows(int[] I,
                    AbstractDoubleArray B)
Copy an internal one-dimensional array from many rows.

Parameters:
I - Rows indexes
B - Rows-matrix

setRows

public void setRows(int i0,
                    AbstractDoubleArray B)
Copy an internal one-dimensional array from a row.

Parameters:
i0 - First Row index
B - Row-matrix

setColumn

public void setColumn(int j,
                      AbstractDoubleArray B)
Set a column to an internal one-dimensional Column.

Parameters:
j - Column index
B - Column-matrix

setColumn

public void setColumn(int j,
                      double B)
Set a column to an internal one-dimensional Column.

Parameters:
j - Column index
B - Column-matrix

setColumns

public void setColumns(int[] J,
                       AbstractDoubleArray B)
Copy an internal one-dimensional array from a column.

Parameters:
J - Columns indexes
B - Columns-matrix

setColumns

public void setColumns(int j0,
                       AbstractDoubleArray B)
Set a column to an internal one-dimensional Column.

Parameters:
j0 - First Column index
B - Column-matrix

setAllRandom

protected void setAllRandom()
Set all elements of the matrix to random values


setAllConstant

protected void setAllConstant(double v)
Set all elements of the matrix to constant values

Parameters:
v - value to set

setAllDiagonal

protected void setAllDiagonal(double[] d)
Set the matrix to diagonal

Parameters:
d - diagonal

setAllIdentity

protected void setAllIdentity()
Set the matrix to identity


setAllIncrementRows

protected void setAllIncrementRows(double begin,
                                   double pitch)
Set the matrix to increment rows

Parameters:
begin - begining value to increment
pitch - increment

setAllIncrementRows

protected void setAllIncrementRows(double[] begin,
                                   double[] pitch)
Set the matrix to increment rows

Parameters:
begin - begining values to increment
pitch - increments

setAllIncrementColumns

protected void setAllIncrementColumns(double begin,
                                      double pitch)
Set the matrix to increment columns

Parameters:
begin - begining value to increment
pitch - increment

setAllIncrementColumns

protected void setAllIncrementColumns(double[] begin,
                                      double[] pitch)
Set the matrix to increment columns

Parameters:
begin - begining values to increment
pitch - increments

setAllMergeRows

protected void setAllMergeRows(AbstractDoubleArray[] Xs)
Set matrix to merge rows

Parameters:
Xs - rows to merge

setAllMergeColumns

protected void setAllMergeColumns(AbstractDoubleArray[] Xs)
Set matrix to merge columns

Parameters:
Xs - columns to merge

putSubMatrixIn

protected void putSubMatrixIn(int i0,
                              int i1,
                              int j0,
                              int j1,
                              AbstractDoubleArray X)
Set the submatrix

Parameters:
i0 - begining row of the submatrix
i1 - ending row of the submatrix
j0 - begining column of the submatrix
j1 - ending column of the submatrix
X - matrix to set

putRowIn

protected void putRowIn(int i,
                        AbstractDoubleArray X)
Set a row

Parameters:
i - row index
X - matrix to set

putRowsIn

protected void putRowsIn(int[] I,
                         AbstractDoubleArray X)
Set rows

Parameters:
I - row indices
X - matrix to set

putRowsIn

protected void putRowsIn(int i0,
                         int i1,
                         AbstractDoubleArray X)
Set rows

Parameters:
i0 - begining index of rows to set
i1 - ending index of rows to set
X - matrix to set

putColumnIn

protected void putColumnIn(int j,
                           AbstractDoubleArray X)
Set columns

Parameters:
j - column index
X - matrix to set

putColumnsIn

protected void putColumnsIn(int[] J,
                            AbstractDoubleArray X)
Set columns

Parameters:
J - row indices
X - matrix to set

putColumnsIn

protected void putColumnsIn(int j0,
                            int j1,
                            AbstractDoubleArray X)
Set columns

Parameters:
j0 - begining index of columns to set
j1 - ending index of columns to set
X - matrix to set

putDiagonalIn

protected void putDiagonalIn(AbstractDoubleArray X)
Set diagonal

Parameters:
X - matrix to set

putDiagonalIn

protected void putDiagonalIn(int num,
                             AbstractDoubleArray X)
Set diagonal

Parameters:
num - numbre of diagonal
X - matrix to set

reset

protected abstract void reset(int _m,
                              int _n)
Construct an m-by-n matrix of zeros.

Parameters:
_m - Number of rows.
_n - Number of colums.

resizeEquals

public void resizeEquals(int m2,
                         int n2)
Matrix resize.

Parameters:
m2 - number of rows
n2 - number of columns

reshapeRowsEquals

public void reshapeRowsEquals(int m2,
                              int n2)
Matrix reshape by Row.

Parameters:
m2 - number of rows
n2 - number of columns

reshapeColumnsEquals

public void reshapeColumnsEquals(int m2,
                                 int n2)
Matrix reshape by Column.

Parameters:
m2 - number of rows
n2 - number of columns

mergeRowsEquals

public void mergeRowsEquals(AbstractDoubleArray B)
Matrix merge.

Parameters:
B - matrix to merge

mergeColumnsEquals

public void mergeColumnsEquals(AbstractDoubleArray B)
Matrix merge.

Parameters:
B - matrix to merge

insertRowsEquals

public void insertRowsEquals(int I,
                             AbstractDoubleArray B)
Insert a Row into Matrix.

Parameters:
I - first row to add index
B - rows to add

insertColumnsEquals

public void insertColumnsEquals(int J,
                                AbstractDoubleArray B)
Insert a Column into Matrix.

Parameters:
J - first column to add index
B - column to add

deleteRowEquals

public void deleteRowEquals(int I)
delete a Row to Matrix.

Parameters:
I - row number to delete

deleteColumnEquals

public void deleteColumnEquals(int J)
Delete a Column to Matrix.

Parameters:
J - column number to delete

deleteRowsEquals

public void deleteRowsEquals(int[] I)
delete a Row to Matrix.

Parameters:
I - row number to delete

deleteRowsEquals

public void deleteRowsEquals(int i0,
                             int i1)
delete a Row to Matrix.

Parameters:
i0 - first row index to delete
i1 - last row index to delete

deleteColumnsEquals

public void deleteColumnsEquals(int[] J)
Delete a Column to Matrix.

Parameters:
J - column numbers to delete

deleteColumnsEquals

public void deleteColumnsEquals(int j0,
                                int j1)
Delete a Column to Matrix.

Parameters:
j0 - first column index to delete
j1 - last column index to delete

toDouble

public double toDouble()
convert the Matrix into a double value if the matrix is 1*1.

Returns:
A(0,0).

toDoubleArray

public double[] toDoubleArray()

toDouble2DArray

public double[][] toDouble2DArray()
convert the Matrix into a double value if the matrix is 1*1.

Returns:
A(0,0).

getArrayCopy

public double[][] getArrayCopy()

toDoubleRowArray

public double[] toDoubleRowArray(int i)
convert the Matrix into a double value if the matrix is 1*1.

Returns:
A(0,0).

getRowArrayCopy

public double[] getRowArrayCopy(int i)

toDoubleColumnArray

public double[] toDoubleColumnArray(int j)
convert the Matrix into a double value if the matrix is 1*1.

Returns:
A(0,0).

getColumnArrayCopy

public double[] getColumnArrayCopy(int j)

isEqual

public boolean isEqual(AbstractDoubleArray B)
Test if A == B.

Parameters:
B - Matrix to compare.
Returns:
boolean

isDiagonal

public boolean isDiagonal()
Test if A is Diagonal.

Returns:
boolean

isSymetric

public boolean isSymetric()
Test if A is Symetric.

Returns:
boolean

checkDiagonal

public void checkDiagonal()
Check if A is Diagonal.

Throws:
java.lang.IllegalArgumentException - All rows must have the same length

checkSymetric

public void checkSymetric()
Check if A is Symetric.

Throws:
java.lang.IllegalArgumentException - All rows must have the same length

checkDimensions

public void checkDimensions(AbstractDoubleArray B)
Check if size(A) == size(B).

Parameters:
B - Matrix to test.
Throws:
java.lang.IllegalArgumentException - All rows must have the same length

checkDimensions

public void checkDimensions(int m2,
                            int n2)
Check if size(A) == m2*n2.

Parameters:
m2 - Number of rows.
n2 - Number of columns.
Throws:
java.lang.IllegalArgumentException - All rows must have the same length

checkRowDimension

public void checkRowDimension(AbstractDoubleArray B)
Check if number of Rows(A) == number of Rows(B).

Parameters:
B - Matrix to test.
Throws:
java.lang.IllegalArgumentException - All rows must have the same length

checkRowDimension

public void checkRowDimension(int row)
Check if number of Rows(A) == row.

Parameters:
row - number of rows.
Throws:
java.lang.IllegalArgumentException - All rows must have the same length

checkColumnDimension

public void checkColumnDimension(AbstractDoubleArray B)
Check if number of Columns(A) == number of Columns(B).

Parameters:
B - Matrix to test.
Throws:
java.lang.IllegalArgumentException - All rows must have the same length

checkColumnDimension

public void checkColumnDimension(int column)
Check if number of Columns(A) == column.

Parameters:
column - number of columns.
Throws:
java.lang.IllegalArgumentException - All rows must have the same length