|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectSciLib.Math.matrix
public class matrix
This class contains some methods to handle the matrix problems
| Constructor Summary | |
|---|---|
matrix()
Allocates a 0x0 matrix. |
|
matrix(double[][] ma)
Make a matrix from a two-dimensional array. |
|
matrix(int rows,
int columns)
Allocates a m x n matrix. |
|
matrix(matrix ma)
Make a copy of a matrix ma. |
|
| Method Summary | |
|---|---|
double |
elementAt(int i,
int j)
return the value element of matrix at row i and column j. |
vector |
getColumn(int j)
return a vector that contains all elements of the jth column. |
int |
getColumns()
return the number of columns. |
double[][] |
getData()
return a two-dimensional array that contains all elements of matrix. |
vector |
getRow(int i)
return a vector that contains all elements of the ith row. |
int |
getRows()
return the number of rows. |
static matrix |
identity(int n)
Make the n x n identity mattrix |
double |
max()
Return the maximum value of the matrix |
double |
min()
Return the minimum value of the matrix |
void |
minus(matrix x)
minus this matrix with the matrix x and store the result in this matrix |
static matrix |
minus(matrix x,
matrix y)
minus two matrices x, y. |
static matrix |
mult(matrix x,
matrix y)
Make a matrix A = x*y |
static vector |
mult(matrix A,
vector x)
compute Ax |
void |
plus(matrix x)
plus this matrix with the matrix x and store the result in this matrix |
static matrix |
plus(matrix x,
matrix y)
plus two matrices x, y. |
void |
print()
Print all elements of the matrix using System.out. |
void |
random(double a,
double b)
Fill this matrix with random values between a and b. |
void |
read(java.lang.String fileName)
Read data from a file to a matrix. |
void |
resize(int rows,
int columns)
Change the size of the matrix. |
void |
scale(double s)
Scaling all elements of the matrix with a factor s. |
void |
scaling(double a,
double b)
scaling |
matrix |
scaling(matrix m,
double a,
double b)
scaling |
void |
setColumn(int i,
vector v)
set column(i) = v |
void |
setElementAt(double x,
int i,
int j)
Change the value element of matrix at row i and column j. |
void |
setRow(int i,
vector v)
set row(i) = v |
matrix |
transpose()
Make the transpose matrix of this matrix |
static matrix |
transpose(matrix ma)
Make the transpose matrix of a matrix ma |
void |
write(java.lang.String fileName)
Write all elements of the matrix to a file. |
void |
write(java.lang.String fileName,
int n)
Write all elements of the matrix to a file with the n deimal digits format. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public matrix()
public matrix(int rows,
int columns)
rows - The number of rowscolumns - The number of columnspublic matrix(double[][] ma)
ma - A two-dimensional arraypublic matrix(matrix ma)
ma - A matrix| Method Detail |
|---|
public double elementAt(int i,
int j)
throws java.lang.ArrayIndexOutOfBoundsException
i - An integerj - An integer
java.lang.ArrayIndexOutOfBoundsException
public void setElementAt(double x,
int i,
int j)
throws java.lang.ArrayIndexOutOfBoundsException
i - An integerj - An integerx - A double value
java.lang.ArrayIndexOutOfBoundsExceptionpublic final int getRows()
public final int getColumns()
public double[][] getData()
public void resize(int rows,
int columns)
rows - The new numbers of rowscolumns - The new numbers of columnspublic vector getRow(int i)
public vector getColumn(int j)
public final double min()
public final double max()
public void scale(double s)
s - A double value that is the sacling factor
public void random(double a,
double b)
a - A double valueb - A double value
public void plus(matrix x)
throws SizeException
x - A vector
SizeException
public static matrix plus(matrix x,
matrix y)
throws SizeException
x - A matrixy - A matrix
SizeException
public void minus(matrix x)
throws SizeException
x - A vector
SizeException
public static matrix minus(matrix x,
matrix y)
throws SizeException
x - A matrixy - A matrix
SizeException
public static matrix mult(matrix x,
matrix y)
throws SizeException
x - A matrixy - A matrix
SizeException
public static vector mult(matrix A,
vector x)
A - A matrixx - A vector
public static matrix identity(int n)
n - An integer
public static matrix transpose(matrix ma)
ma - A matrix
public matrix transpose()
public void write(java.lang.String fileName)
fileName - A String
public void write(java.lang.String fileName,
int n)
fileName - A Stringpublic void read(java.lang.String fileName)
fileName - a Stringpublic final void print()
public void setRow(int i,
vector v)
i - An integer value, the row indexv - A vector
public void setColumn(int i,
vector v)
i - An integer value, the column indexv - A vector
public matrix scaling(matrix m,
double a,
double b)
m - A matrix that will be scaleda - A double, the lower bound of all elements in the matrixb - A double, the upper bound of all elements in the matrix
public void scaling(double a,
double b)
a - A double, the lower bound of all elements in the matrixb - A double, the upper bound of all elements in the matrix
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||