|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.physics.fluids.dynamics.util.Matrix
public class Matrix
Sparse Matrix, simetric or not. This class is in charge of the data and methods related to matrix operations.
The disperse storage is a technique that allows storing large matrices in memory by using much less RAM. The method consists in working only with the non null elements: the matrices used in finite elements, finite differences, and other numerical methods have many elements as nulls. TheMatrix is stored in three vectors: elem,
ipos and jpos. They are public to allow other
classes to implement optimized algorithms.
For more information about sparse matrices consult the program
manual.
Revised for ADFC v2.0
| Field Summary | |
|---|---|
double[] |
elem
Contains the value of the elements not null. |
int[] |
ipos
ipos[n] indicates in which position of elem
and jpos starts the row n-esima of the matrix. |
int[] |
jpos
elem[n] indicates in which column it is found the element
not null n-esimo. |
boolean |
simetric
Indicates if the matrix is stored using its simetry. |
| Constructor Summary | |
|---|---|
Matrix(double[] as,
int[] aipos,
int[] ajpos,
boolean sim)
constructor. |
|
Matrix(Matrix matrix,
boolean swallow)
copy constructor. |
|
| Method Summary | |
|---|---|
void |
applyFactor(double factor)
multiply all the elements by a real number. |
void |
assignElement(int i,
int j,
double value)
assigns the value of a element. |
void |
checkRigidityMatrix()
checks that the matrix of rigidity is more or less correct in structure. |
int |
getRows()
returns the number of rows. |
double[] |
multipliy(double[] vector)
multiply this matrix by a vector. |
double[] |
multiply(double[] result,
double[] vector)
multiply the matrix by a vector. |
double[] |
multiply(double[] result,
double[] vector,
int rowSize)
multiply simetric/asimetric matrix by vector. |
double[] |
multiply(double[] vector,
int rowSize)
multiply simetric/asimetric matrix by vector. |
void |
printMatrix()
show matrix in the console. |
double |
readElement(int i,
int j)
returns the value of a element. |
void |
saveToFile(java.lang.String name,
java.lang.String title)
Saves the content of the matrix to a file. |
double |
scalarProductOfMatrixProduct(double[] a,
double[] b)
this function carries out the product a(Mb) |
void |
sumElement(int i,
int j,
double value)
sums the specified value in the position (i, j). |
void |
sumMatrix(Matrix m,
double factor)
sums element by element the content of other matrix, which is supposed with identical Ipos y Jpos. |
void |
sumParallel(int i,
int j,
double value,
Matrix sister,
double value2)
sums in the position (i, j) the given value, and at the same position of the sister matrix, sum value2. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public double[] elem
elem[n] is the value of element not null n-esimo.
public int[] jpos
elem[n] indicates in which column it is found the element
not null n-esimo.
public int[] ipos
ipos[n] indicates in which position of elem
and jpos starts the row n-esima of the matrix.
public boolean simetric
| Constructor Detail |
|---|
public Matrix(double[] as,
int[] aipos,
int[] ajpos,
boolean sim)
as is null, means that the
constructor should reserve the memory for as (so in this
case, a new empty matrix).
as - elements in compact format.aipos - vector Ipos (NVPN)ajpos - vector Jpos (NNVI)sim - simetric or not
public Matrix(Matrix matrix,
boolean swallow)
swallow, the copy of
ipos and jpos is not by value, but by
reference. This way, we can have two identical matrices without
duplicating RAM in those vectors. Elem is always
duplicated, to allow modifications without lateral effects.
matrix - matrix to copy.swallow - copy swallow (no duplication of RAM for the structure
ipos/jpos)| Method Detail |
|---|
public void applyFactor(double factor)
factor - real number.
public void assignElement(int i,
int j,
double value)
i - rowj - columnvalue - new valuepublic void checkRigidityMatrix()
public void printMatrix()
public int getRows()
public double readElement(int i,
int j)
i - rowj - column
public double[] multiply(double[] result,
double[] vector)
result - where to store the solution. It can be null.vector - vector to multiply.
public double[] multipliy(double[] vector)
vector - vector to multiply.
public double[] multiply(double[] vector,
int rowSize)
vector - column.rowSize - size of the row (and of the solution too)
public double[] multiply(double[] result,
double[] vector,
int rowSize)
result - where to store the result.vector - column.rowSize - size of the row (and of the solution too)
public double scalarProductOfMatrixProduct(double[] a,
double[] b)
a - vectorb - vector
public void sumElement(int i,
int j,
double value)
i - row of the position to be summed.j - column of the position to be summed.value - value to be summed in the specified position.
public void sumParallel(int i,
int j,
double value,
Matrix sister,
double value2)
i - row of the position to be summed.j - column of the position to be summed.value - value to be summed in the given position of
this.sister - the other matrix in which we are summing in parallel.value2 - value to be summed in the given position of
sister.
public void sumMatrix(Matrix m,
double factor)
m - matrix to be summed to thisfactor - factor to be applied to the term. For example, -1
differentiates.
public void saveToFile(java.lang.String name,
java.lang.String title)
name - path to the file in which to save the matrix.title - string as title in the first line of the file
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||