Package edu.cmu.tetrad.util
Class Matrix
java.lang.Object
edu.cmu.tetrad.util.Matrix
- All Implemented Interfaces:
TetradSerializable
,Serializable
Wraps the Apache math3 linear algebra library for most uses in Tetrad.
Specialized uses will still have to use the library directly. One issue
this fixes is that a BlockRealMatrix cannot represent a matrix with zero
rows; this uses an Array2DRowRealMatrix to represent that case.
- Author:
- Joseph Ramsey
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
assignColumn
(int col, Vector doubles) void
int
columns()
copy()
double
det()
diag()
boolean
double
get
(int i, int j) getColumn
(int j) getPart
(int i, int j, int k, int l) getRow
(int i) getSelection
(int[] rows, int[] cols) ginverse()
static Matrix
identity
(int rows) inverse()
boolean
isSquare()
boolean
isSymmetric
(double tolerance) like()
double
norm1()
int
rank()
int
rows()
scalarMult
(double scalar) static Matrix
Generates a simple exemplar of this class to test serialization.void
set
(int i, int j, double v) static Matrix
sparseMatrix
(int m, int n) sqrt()
sum
(int direction) double[][]
toArray()
toString()
double
trace()
double
zSum()
-
Constructor Details
-
Matrix
public Matrix(double[][] data) -
Matrix
public Matrix(int m, int n) -
Matrix
-
-
Method Details
-
assign
-
columns
public int columns() -
diag
-
getSelection
-
copy
-
getColumn
-
times
-
times
-
toArray
public double[][] toArray() -
get
public double get(int i, int j) -
like
-
set
public void set(int i, int j, double v) -
getRow
-
getPart
-
inverse
- Throws:
org.apache.commons.math3.linear.SingularMatrixException
-
symmetricInverse
-
ginverse
-
identity
-
assignRow
-
assignColumn
-
trace
public double trace() -
det
public double det() -
transpose
-
equals
-
isSquare
public boolean isSquare() -
isSymmetric
public boolean isSymmetric(double tolerance) -
minus
-
norm1
public double norm1() -
plus
-
rank
public int rank() -
rows
public int rows() -
scalarMult
-
sqrt
-
sparseMatrix
-
sum
-
zSum
public double zSum() -
toString
-
serializableInstance
Generates a simple exemplar of this class to test serialization.
-