quentinc.geom
Class Matrix

java.lang.Object
  extended by quentinc.geom.Matrix

public class Matrix
extends java.lang.Object

Class for manipulating matrix of arbitrary size


Constructor Summary
Matrix(double[][] d)
          Create a new matrix with the 2D array given.
Matrix(int w, int h)
          Create a new matrix with given number of rows and columns
Matrix(Vector v)
          Create a new 3x1 matrix representing the given vector.
 
Method Summary
 Matrix add(Matrix m)
          Add the given matrix to this one.
 Matrix clone()
           
 Matrix divide(double d)
          Divide this matrix by a scalar value
 boolean equals(java.lang.Object o)
           
 double get(int row, int col)
          Get the value at the given position
 int getColumnCount()
          Get the number of columns
 int getRowCount()
          Get the number of rows
 int hashCode()
           
 Matrix multiply(double d)
          Multiply this matrix by a scalar value
 Matrix multiply(Matrix m)
          Multiply this matrix with the one given.
 void set(int row, int col, double value)
          Set the value at the given position
 Matrix subtract(Matrix m)
          Subtract the given matrix to this one
 java.lang.String toString()
          Return a string representation of this matrix.
 Vector toVector()
          Convert this matrix to a vector, using the first column as coefficiants.
 Matrix transpose()
          Create a new matrix which is the transposition of this one.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix

public Matrix(int w,
              int h)
Create a new matrix with given number of rows and columns


Matrix

public Matrix(double[][] d)
Create a new matrix with the 2D array given.


Matrix

public Matrix(Vector v)
Create a new 3x1 matrix representing the given vector.

Method Detail

get

public double get(int row,
                  int col)
Get the value at the given position


set

public void set(int row,
                int col,
                double value)
Set the value at the given position


getColumnCount

public int getColumnCount()
Get the number of columns


getRowCount

public int getRowCount()
Get the number of rows


toVector

public Vector toVector()
Convert this matrix to a vector, using the first column as coefficiants.


toString

public java.lang.String toString()
Return a string representation of this matrix. This representation is like CSV.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

add

public Matrix add(Matrix m)
Add the given matrix to this one.


subtract

public Matrix subtract(Matrix m)
Subtract the given matrix to this one


multiply

public Matrix multiply(double d)
Multiply this matrix by a scalar value


divide

public Matrix divide(double d)
Divide this matrix by a scalar value


clone

public Matrix clone()
Overrides:
clone in class java.lang.Object

transpose

public Matrix transpose()
Create a new matrix which is the transposition of this one.


multiply

public Matrix multiply(Matrix m)
Multiply this matrix with the one given. Return a new matrix.