Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.faceless.graph.math
Class Matrix

    java.lang.Object
      org.faceless.graph.math.Matrix

    public class Matrix

extends Object

A simple class defining a mathematical matrix.

Constructor Summary
`Matrix(int cols, int rows)` Create a new Matrix of the specified number of rows and columns
`Matrix(Matrix m)` Create a new Matrix that's a clone of the specified matrix

Method Summary
`Matrix` | `add(Matrix m)` Return a new matrix that is the sum of this matrix and the specified matrix.
`Matrix` | `appendHorizontal(Matrix m)` Append the specified matrix to the current matrix by extending the number of columns in the current matrix
`Matrix` | `appendVertical(Matrix m)` Append the specified matrix to the current matrix by extending the number of columns in the current matrix
`Matrix` | `div(Matrix m)` Return a new matrix that is the result of this matrix divided by the specified matrix.
`Matrix` | `exchangeRows(int row1, int row2)` Return a duplicate of the current matrix with the specified rows swapped
`double` | `get(int col, int row)` Get the element at the specified row and column.
`int` | `getCols()` Return the number of columns in this matrix
`int` | `getRows()` Return the number of rows in this matrix
`static Matrix` | `identity(int ord)` Return a new Identity Matrix of the specified size
`Matrix` | `inverse()` Return the inverse of the current matrix
`static void` | `main(String[] args)`
`Matrix` | `mul(double fac)` Return a new matrix that is the product of this matrix and the specified factor.
`Matrix` | `mul(Matrix m)` Return a new matrix that is the product of this matrix and the specified matrix.
`Matrix` | `pivot(int col, int row)` Pivot the current matrix around the specified row and column
`void` | `set(int col, int row, double val)` Set the element at the specified row and column to the specified value
`Matrix` | `subMatrix(int col, int row, int numcols, int numrows)` Return a subset of this matrix consisiting of just the specified columns and rows
`String` | `toString()`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Matrix

    public Matrix(int cols,
                  int rows)

  Create a new Matrix of the specified number of rows and columns

### Matrix

    public Matrix(Matrix m)

  Create a new Matrix that's a clone of the specified matrix

Method Detail

### set

    public void set(int col,
                    int row,
                    double val)

  Set the element at the specified row and column to the specified value

  Parameters:
    `col` - the column to set the value in, from 0 to `getCols()-1`
    `row` - the row to set the value in, from 0 to `getRows()-1`
    `val` - the value to set.
  Throws:
    `ArrayIndexOutOfBoundsException` - if the matrix doesn't contain the specified row or column

### get

    public double get(int col,
                      int row)

  Get the element at the specified row and column.

  Parameters:
    `col` - the column to set the value in, from 0 to `getCols()-1`
    `row` - the row to set the value in, from 0 to `getRows()-1`
  Throws:
    `ArrayIndexOutOfBoundsException` - if the matrix doesn't contain the specified row or column

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### exchangeRows

    public Matrix exchangeRows(int row1,
                               int row2)

  Return a duplicate of the current matrix with the specified rows swapped

### identity

    public static Matrix identity(int ord)

  Return a new Identity Matrix of the specified size

  Parameters:
    `ord` - the number of rows and columns in the matrix

### add

    public Matrix add(Matrix m)

  Return a new matrix that is the sum of this matrix and the specified matrix. The current matrix is unmodified

### getRows

    public int getRows()

  Return the number of rows in this matrix

### getCols

    public int getCols()

  Return the number of columns in this matrix

### mul

    public Matrix mul(double fac)

  Return a new matrix that is the product of this matrix and the specified factor. The current matrix is unmodified

### mul

    public Matrix mul(Matrix m)

  Return a new matrix that is the product of this matrix and the specified matrix. The current matrix is unmodified

  Throws:
    `IllegalArgumentException` - if the two matrices are incompatible sizes.

### div

    public Matrix div(Matrix m)

  Return a new matrix that is the result of this matrix divided by the specified matrix. This is the same as multiplying by the inverse of the specified matrix. The current matrix is unmodified.

  Throws:
    `IllegalArgumentException` - if the two matrices are incompatible sizes.
    `ArithmeticException` - if the second matrix has no inverse.

### appendHorizontal

    public Matrix appendHorizontal(Matrix m)

  Append the specified matrix to the current matrix by extending the number of columns in the current matrix

### appendVertical

    public Matrix appendVertical(Matrix m)

  Append the specified matrix to the current matrix by extending the number of columns in the current matrix

### subMatrix

    public Matrix subMatrix(int col,
                            int row,
                            int numcols,
                            int numrows)

  Return a subset of this matrix consisiting of just the specified columns and rows

### inverse

    public Matrix inverse()
                   throws ArithmeticException

  Return the inverse of the current matrix

  Throws:
    `ArithmeticException` - if there is no inverse

### pivot

    public Matrix pivot(int col,
                        int row)

  Pivot the current matrix around the specified row and column

### main

    public static void main(String[] args)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2012 Big Faceless Organization