Package pulse.math.linear
Class RectangularMatrix
- java.lang.Object
-
- pulse.math.linear.RectangularMatrix
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SquareMatrix
public class RectangularMatrix extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected double[][]x
-
Constructor Summary
Constructors Modifier Constructor Description protectedRectangularMatrix(double[][] args)protectedRectangularMatrix(double[] data, int n)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandimensionsMatch(RectangularMatrix m)Checks if the dimension ofthis Matrixandmmatch, i.e.booleanequals(Object o)Checks whetherois aSquareMatrixwith matching dimensions and all elements of which are (approximately) equal to the respective elements ofthismatrix}.doubleget(int m, int k)double[][]getData()RectangularMatrixmultiply(double f)Scales thisMatrixbyf, which results in element-wise multiplication byf.RectangularMatrixmultiply(RectangularMatrix m)PerformsMatrixmultiplication.Vectormultiply(Vector v)Multiplies thisMatrixby the vectorv, which is represented by aMatrix, wherenis the dimension ofv.RectangularMatrixsubtract(RectangularMatrix m)Performs an element-wise subtraction ofmfromthisif these matrices have matching dimensions.RectangularMatrixsum(RectangularMatrix m)Performs an element-wise summation ifthisandmhave matching dimensions.StringtoString()Prints out matrix dimensions and all the elements contained in it.RectangularMatrixtranspose()Transposes thisMatrix, i.e.
-
-
-
Method Detail
-
sum
public RectangularMatrix sum(RectangularMatrix m)
Performs an element-wise summation ifthisandmhave matching dimensions.- Parameters:
m- anotherMatrixof the same size asthisone- Returns:
- the result of summation
-
subtract
public RectangularMatrix subtract(RectangularMatrix m)
Performs an element-wise subtraction ofmfromthisif these matrices have matching dimensions.- Parameters:
m- anotherMatrixof the same size asthisone- Returns:
- the result of subtraction
-
multiply
public RectangularMatrix multiply(RectangularMatrix m)
Performs
Matrixmultiplication. Checks whether the dimensions of each matrix are appropriate (number of columns inthismatrix should be equal to the number of rows inm.- Parameters:
m- anotherMatrixsuitable for multiplication- Returns:
- a
Matrix, which is the result of multiplyingthisbym
-
multiply
public RectangularMatrix multiply(double f)
Scales thisMatrixbyf, which results in element-wise multiplication byf.- Parameters:
f- a numeric value- Returns:
- the scaled
Matrix
-
transpose
public RectangularMatrix transpose()
Transposes thisMatrix, i.e. reflects it over the main diagonal.- Returns:
- a transposed
Matrix
-
get
public double get(int m, int k)
-
getData
public double[][] getData()
-
multiply
public Vector multiply(Vector v)
Multiplies this
Matrixby the vectorv, which is represented by aMatrix, wherenis the dimension ofv. Notenshould be equal to the number of rows in thisMatrix.- Parameters:
v- aVector.- Returns:
- the result of multiplication, which is a
Vector.
-
toString
public String toString()
Prints out matrix dimensions and all the elements contained in it.
-
dimensionsMatch
public boolean dimensionsMatch(RectangularMatrix m)
Checks if the dimension ofthis Matrixandmmatch, i.e. if the number of rows is the same and the number of columns is the same- Parameters:
m- anotherMatrix- Returns:
trueif the dimensions match,falseotherwise.
-
-