public class FloatMatrix extends Object implements Cloneable, Serializable
Constructor and Description |
---|
FloatMatrix(float[][] A)
Construct a matrix from a 2-D array.
|
FloatMatrix(float[][] A,
int m,
int n)
Construct a matrix quickly without checking arguments.
|
FloatMatrix(float[] vals,
int m)
Construct a matrix from a one-dimensional packed array
|
FloatMatrix(int m,
int n)
Construct an m-by-n matrix of zeros.
|
FloatMatrix(int m,
int n,
float s)
Construct an m-by-n constant matrix.
|
Modifier and Type | Method and Description |
---|---|
FloatMatrix |
arrayLeftDivide(FloatMatrix B)
Element-by-element left division, C = A.
|
FloatMatrix |
arrayLeftDivideEquals(FloatMatrix B)
Element-by-element left division in place, A = A.
|
FloatMatrix |
arrayRightDivide(FloatMatrix B)
Element-by-element right division, C = A.
|
FloatMatrix |
arrayRightDivideEquals(FloatMatrix B)
Element-by-element right division in place, A = A.
|
FloatMatrix |
arrayTimes(FloatMatrix B)
Element-by-element multiplication, C = A.
|
FloatMatrix |
arrayTimesEquals(FloatMatrix B)
Element-by-element multiplication in place, A = A.
|
Object |
clone()
Clone the FloatMatrix object.
|
static FloatMatrix |
constructWithCopy(float[][] A)
Construct a matrix from a copy of a 2-D array.
|
FloatMatrix |
copy()
Make a deep copy of a matrix
|
boolean |
equals(Object obj) |
float |
get(int i,
int j)
Get a single element.
|
float[][] |
getArray()
Access the internal two-dimensional array.
|
float[][] |
getArrayCopy()
Copy the internal two-dimensional array.
|
int |
getColumnDimension()
Get column dimension.
|
float[] |
getColumnPackedCopy()
Make a one-dimensional column packed copy of the internal array.
|
FloatMatrix |
getFloatMatrix(int[] r,
int[] c)
Get a submatrix.
|
FloatMatrix |
getFloatMatrix(int[] r,
int j0,
int j1)
Get a submatrix.
|
FloatMatrix |
getFloatMatrix(int i0,
int i1,
int[] c)
Get a submatrix.
|
FloatMatrix |
getFloatMatrix(int i0,
int i1,
int j0,
int j1)
Get a submatrix.
|
int |
getRowDimension()
Get row dimension.
|
float[] |
getRowPackedCopy()
Make a one-dimensional row packed copy of the internal array.
|
int |
hashCode() |
static FloatMatrix |
identity(int m,
int n)
Generate identity matrix
|
FloatMatrix |
minus(FloatMatrix B)
C = A - B
|
FloatMatrix |
minusEquals(FloatMatrix B)
A = A - B
|
float |
norm1()
One norm
|
float |
normInf()
Infinity norm
|
FloatMatrix |
plus(FloatMatrix B)
C = A + B
|
FloatMatrix |
plusEquals(FloatMatrix B)
A = A + B
|
void |
print(int w,
int d)
Print the matrix to stdout.
|
void |
print(NumberFormat format,
int width)
Print the matrix to stdout.
|
void |
print(PrintWriter output,
int w,
int d)
Print the matrix to the output stream.
|
void |
print(PrintWriter output,
NumberFormat format,
int width)
Print the matrix to the output stream.
|
static FloatMatrix |
random(int m,
int n)
Generate matrix with random elements
|
void |
set(int i,
int j,
float s)
Set a single element.
|
void |
setFloatMatrix(int[] r,
int[] c,
FloatMatrix X)
Set a submatrix.
|
void |
setFloatMatrix(int[] r,
int j0,
int j1,
FloatMatrix X)
Set a submatrix.
|
void |
setFloatMatrix(int i0,
int i1,
int[] c,
FloatMatrix X)
Set a submatrix.
|
void |
setFloatMatrix(int i0,
int i1,
int j0,
int j1,
FloatMatrix X)
Set a submatrix.
|
FloatMatrix |
times(float s)
Multiply a matrix by a scalar, C = s*A
|
FloatMatrix |
times(FloatMatrix B)
Linear algebraic matrix multiplication, A * B
|
FloatMatrix |
timesEquals(float s)
Multiply a matrix by a scalar in place, A = s*A
|
Matrix |
toMatrix()
Note: This method creates a Matrix object which needs almost doubled
memory size.
|
float |
trace()
FloatMatrix trace.
|
FloatMatrix |
transpose()
FloatMatrix transpose.
|
FloatMatrix |
uminus()
Unary minus
|
public FloatMatrix(int m, int n)
m
- Number of rows.n
- Number of colums.public FloatMatrix(int m, int n, float s)
m
- Number of rows.n
- Number of colums.s
- Fill the matrix with this scalar value.public FloatMatrix(float[][] A)
A
- Two-dimensional array of floats.IllegalArgumentException
- All rows must have the same lengthconstructWithCopy(float[][])
public FloatMatrix(float[][] A, int m, int n)
A
- Two-dimensional array of floats.m
- Number of rows.n
- Number of colums.public FloatMatrix(float[] vals, int m)
vals
- One-dimensional array of floats, packed by columns (ala
Fortran).m
- Number of rows.IllegalArgumentException
- Array length must be a multiple of m.public static FloatMatrix constructWithCopy(float[][] A)
A
- Two-dimensional array of floats.IllegalArgumentException
- All rows must have the same lengthpublic FloatMatrix copy()
public float[][] getArray()
public float[][] getArrayCopy()
public float[] getColumnPackedCopy()
public float[] getRowPackedCopy()
public int getRowDimension()
public int getColumnDimension()
public float get(int i, int j)
i
- Row index.j
- Column index.ArrayIndexOutOfBoundsException
public FloatMatrix getFloatMatrix(int i0, int i1, int j0, int j1)
i0
- Initial row indexi1
- Final row indexj0
- Initial column indexj1
- Final column indexArrayIndexOutOfBoundsException
- Submatrix indicespublic FloatMatrix getFloatMatrix(int[] r, int[] c)
r
- Array of row indices.c
- Array of column indices.ArrayIndexOutOfBoundsException
- Submatrix indicespublic FloatMatrix getFloatMatrix(int i0, int i1, int[] c)
i0
- Initial row indexi1
- Final row indexc
- Array of column indices.ArrayIndexOutOfBoundsException
- Submatrix indicespublic FloatMatrix getFloatMatrix(int[] r, int j0, int j1)
r
- Array of row indices.i0
- Initial column indexi1
- Final column indexArrayIndexOutOfBoundsException
- Submatrix indicespublic void set(int i, int j, float s)
i
- Row index.j
- Column index.s
- A(i,j).ArrayIndexOutOfBoundsException
public void setFloatMatrix(int i0, int i1, int j0, int j1, FloatMatrix X)
i0
- Initial row indexi1
- Final row indexj0
- Initial column indexj1
- Final column indexX
- A(i0:i1,j0:j1)ArrayIndexOutOfBoundsException
- Submatrix indicespublic void setFloatMatrix(int[] r, int[] c, FloatMatrix X)
r
- Array of row indices.c
- Array of column indices.X
- A(r(:),c(:))ArrayIndexOutOfBoundsException
- Submatrix indicespublic void setFloatMatrix(int[] r, int j0, int j1, FloatMatrix X)
r
- Array of row indices.j0
- Initial column indexj1
- Final column indexX
- A(r(:),j0:j1)ArrayIndexOutOfBoundsException
- Submatrix indicespublic void setFloatMatrix(int i0, int i1, int[] c, FloatMatrix X)
i0
- Initial row indexi1
- Final row indexc
- Array of column indices.X
- A(i0:i1,c(:))ArrayIndexOutOfBoundsException
- Submatrix indicespublic FloatMatrix transpose()
public float norm1()
public float normInf()
public FloatMatrix uminus()
public FloatMatrix plus(FloatMatrix B)
B
- another matrixpublic FloatMatrix plusEquals(FloatMatrix B)
B
- another matrixpublic FloatMatrix minus(FloatMatrix B)
B
- another matrixpublic FloatMatrix minusEquals(FloatMatrix B)
B
- another matrixpublic FloatMatrix arrayTimes(FloatMatrix B)
B
- another matrixpublic FloatMatrix arrayTimesEquals(FloatMatrix B)
B
- another matrixpublic FloatMatrix arrayRightDivide(FloatMatrix B)
B
- another matrixpublic FloatMatrix arrayRightDivideEquals(FloatMatrix B)
B
- another matrixpublic FloatMatrix arrayLeftDivide(FloatMatrix B)
B
- another matrixpublic FloatMatrix arrayLeftDivideEquals(FloatMatrix B)
B
- another matrixpublic FloatMatrix times(float s)
s
- scalarpublic FloatMatrix timesEquals(float s)
s
- scalarpublic FloatMatrix times(FloatMatrix B)
B
- another matrixIllegalArgumentException
- FloatMatrix inner dimensions must
agree.public float trace()
public Matrix toMatrix()
public static FloatMatrix random(int m, int n)
m
- Number of rows.n
- Number of colums.public static FloatMatrix identity(int m, int n)
m
- Number of rows.n
- Number of colums.public void print(int w, int d)
w
- Column width.d
- Number of digits after the decimal.public void print(PrintWriter output, int w, int d)
output
- Output stream.w
- Column width.d
- Number of digits after the decimal.public void print(NumberFormat format, int width)
format
- A Formatting object for individual elements.width
- Field width for each column.DecimalFormat.setDecimalFormatSymbols(java.text.DecimalFormatSymbols)
public void print(PrintWriter output, NumberFormat format, int width)
output
- the output stream.format
- A formatting object to format the matrix elementswidth
- Column width.DecimalFormat.setDecimalFormatSymbols(java.text.DecimalFormatSymbols)
Copyright © 2012. All Rights Reserved.