Package edu.cmu.tetrad.util
Class Matrix2
java.lang.Object
edu.cmu.tetrad.util.Matrix2
- 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:
- josephramsey
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
assignColumn
(int col, Vector doubles) void
copy()
double
det()
diag()
boolean
double
get
(int i, int j) org.apache.commons.math3.linear.RealMatrix
getColumn
(int j) int
int
getPart
(int i, int j, int k, int l) getRow
(int i) getSelection
(int[] rows, int[] cols) ginverse()
static Matrix2
identity
(int rows) inverse()
boolean
isSquare()
boolean
isSymmetric
(double tolerance) like()
double
norm1()
int
rank()
scalarMult
(double scalar) static Matrix2
Generates a simple exemplar of this class to test serialization.void
set
(int i, int j, double v) static Matrix2
sparseMatrix
(int m, int n) sqrt()
sum
(int direction) double[][]
toArray()
toString()
double
trace()
double
zSum()
-
Constructor Details
-
Matrix2
public Matrix2(double[][] data) -
Matrix2
public Matrix2(org.apache.commons.math3.linear.RealMatrix data) -
Matrix2
public Matrix2(int m, int n) -
Matrix2
-
-
Method Details
-
identity
-
sparseMatrix
-
serializableInstance
Generates a simple exemplar of this class to test serialization. -
assign
-
getNumColumns
public int getNumColumns() -
diag
-
getSelection
-
copy
-
getColumn
-
times
-
times
-
toArray
public double[][] toArray() -
getApacheData
public org.apache.commons.math3.linear.RealMatrix getApacheData() -
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
-
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() -
getNumRows
public int getNumRows() -
scalarMult
-
sqrt
-
sum
-
zSum
public double zSum() -
toString
-