org.jmatrices.dbl.operator
Class MatrixOperator

java.lang.Object
  extended byorg.jmatrices.dbl.operator.MatrixOperator

public final class MatrixOperator
extends java.lang.Object

MatrixOperator provides important operations that can be performed on two or more matrices

Given two matrices A,B -yields-> C ,where C is another matrix.

All operations on a matrix fitting this pattern can be found here!

Author: purangp

Date: 07.03.2004 Time: 18:09:51


Method Summary
static Matrix add(Matrix a, Matrix b)
          Matrix Addition

Matrices must be of the same dimensions!

static Matrix applyEBEOperation(Matrix a, Matrix b, MatrixEBEOperation mo)
          Applies element-by-element operation combining the elements of the two matrices
Note: Matrix a's underlying implementation is propogated in the resulting matrix
Usage: from add(org.jmatrices.dbl.Matrix, org.jmatrices.dbl.Matrix) public static Matrix add(Matrix a, Matrix b) { return applyEBEOperation(a, b, new MatrixEBEOperation() { public double apply(double a, double b) { return a + b; } }); } Hypothetical Usage: public static Matrix doSomeThing(Matrix a, Matrix b, final double n) { return applyEBEOperation(a, b, new MatrixEBEOperation() { public double apply(double a, double b) { return (a^2 + b^2)^n; } }); }
static Matrix divideEBE(Matrix a, Matrix b)
          Element-by-elemnt Matrix division

Matrices must be of the same dimensions!

static Matrix horizontalConcatenation(Matrix a, Matrix b)
          Concatenates a and b horizontally with b's columns attached to the end of a

rows of a must be equal to rows of b
Note: Matrix a's underlying implementation is propogated in the resulting matrix

static Matrix horizontalDirectProduct(Matrix a, Matrix b)
          Gets the Horizontal Direct Product.
static Matrix kroneckerProduct(Matrix a, Matrix b)
          Gets the Kronecker (tensor) product of the two matrices, every element of a has been multiplied (scalar multilication) by the matrix b a = 1 2 3 4 b = 4 5 6 7 8 9 kroneckerProduct(a, b)= 4 5 6 8 10 12 7 8 9 14 16 18 12 15 18 16 20 24 21 24 27 28 32 36
static Matrix multiply(Matrix a, Matrix b)
          Matrix multiplication
Note: Matrix a's underlying implementation is propogated in the resulting matrix

Matrix dimensions must conform with the rules of matrix multiplication!

static Matrix multiplyEBE(Matrix a, Matrix b)
          Element-by-elemnt Matrix Multiplication

Matrices must be of the same dimensions!

static Matrix solve(Matrix x, Matrix b)
          Solves the system of equations.
static Matrix subtract(Matrix a, Matrix b)
          Matrix Subtraction

Matrices must be of the same dimensions!

static Matrix verticalConcatenation(Matrix a, Matrix b)
          Concatenates a and b vertically with b's rows following the a's rows

cols of a must be equal to colss of b
Note: Matrix a's underlying implementation is propogated in the resulting matrix

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

applyEBEOperation

public static Matrix applyEBEOperation(Matrix a,
                                       Matrix b,
                                       MatrixEBEOperation mo)
Applies element-by-element operation combining the elements of the two matrices
Note: Matrix a's underlying implementation is propogated in the resulting matrix
Usage: from add(org.jmatrices.dbl.Matrix, org.jmatrices.dbl.Matrix)
 public static Matrix add(Matrix a, Matrix b) {
       return applyEBEOperation(a, b, new MatrixEBEOperation() {
           public double apply(double a, double b) {
               return a + b;
           }
       });
   }
 
Hypothetical Usage:
 public static Matrix doSomeThing(Matrix a, Matrix b, final double n) {
       return applyEBEOperation(a, b, new MatrixEBEOperation() {
           public double apply(double a, double b) {
               return (a^2 + b^2)^n;
           }
       });
   }
 

Parameters:
a - Matrix
b - Matrix
mo - Class
Returns:
resultant Matrix

solve

public static Matrix solve(Matrix x,
                           Matrix b)
Solves the system of equations. Matrix x doesn't need to be square!

Please pay attention to the dimensions of the two matrices!

Parameters:
x - The coefficient matrix
b - The constant vector
Returns:
The solution matrix or c = x / b

add

public static Matrix add(Matrix a,
                         Matrix b)
Matrix Addition

Matrices must be of the same dimensions!

Parameters:
a - Matrix
b - Matrix
Returns:
c = a + b

subtract

public static Matrix subtract(Matrix a,
                              Matrix b)
Matrix Subtraction

Matrices must be of the same dimensions!

Parameters:
a - Matrix
b - Matrix
Returns:
c = a - b

multiply

public static Matrix multiply(Matrix a,
                              Matrix b)
Matrix multiplication
Note: Matrix a's underlying implementation is propogated in the resulting matrix

Matrix dimensions must conform with the rules of matrix multiplication!

Parameters:
a - Matrix
b - Matrix
Returns:
c = a * b

multiplyEBE

public static Matrix multiplyEBE(Matrix a,
                                 Matrix b)
Element-by-elemnt Matrix Multiplication

Matrices must be of the same dimensions!

Parameters:
a - Matrix
b - Matrix
Returns:
c = a .* b

divideEBE

public static Matrix divideEBE(Matrix a,
                               Matrix b)
Element-by-elemnt Matrix division

Matrices must be of the same dimensions!

Parameters:
a - Matrix
b - Matrix
Returns:
c = a ./ b

horizontalConcatenation

public static Matrix horizontalConcatenation(Matrix a,
                                             Matrix b)
Concatenates a and b horizontally with b's columns attached to the end of a

rows of a must be equal to rows of b
Note: Matrix a's underlying implementation is propogated in the resulting matrix

Parameters:
a - Matrix
b - Matrix
Returns:
c = a~b //gauss syntax

verticalConcatenation

public static Matrix verticalConcatenation(Matrix a,
                                           Matrix b)
Concatenates a and b vertically with b's rows following the a's rows

cols of a must be equal to colss of b
Note: Matrix a's underlying implementation is propogated in the resulting matrix

Parameters:
a - Matrix
b - Matrix
Returns:
c = a|b //gauss syntax

kroneckerProduct

public static Matrix kroneckerProduct(Matrix a,
                                      Matrix b)
Gets the Kronecker (tensor) product of the two matrices, every element of a has been multiplied (scalar multilication) by the matrix b
 a =
 1 2
 3 4

 b =
 4 5 6
 7 8 9

 kroneckerProduct(a, b)=
 4  5  6   8  10 12
 7  8  9   14 16 18
 12 15 18  16 20 24
 21 24 27  28 32 36
 

Parameters:
a -
b -
Returns:

horizontalDirectProduct

public static Matrix horizontalDirectProduct(Matrix a,
                                             Matrix b)
Gets the Horizontal Direct Product.
Note Both matrices must have the same number of rows.
 a =
 1 2
 3 4

 b =
 5 6
 7 8

 horizontalDirectProduct(a, b)=
  5  6 10 12
 21 24 28 32
 

Parameters:
a -
b -
Returns: