weka.classifiers.m5
Class Matrix

java.lang.Object
  |
  +--weka.classifiers.m5.Matrix

public final class Matrix
extends java.lang.Object

Class for handling a matrix

Author:
Yong Wang (yongwang@cs.waikato.ac.nz)

Constructor Summary
Matrix(int nr, int nc)
          Constructs a matrix
 
Method Summary
 void lubksb(int n, int[] indx, double[] b)
          LU backward substitution
 int[] ludcmp(int n, int[] indx)
          LU decomposition
 Matrix multiply(Matrix b, int l, int m, int n)
          Reurns the multiplication of two matrices
 double[] regression(Matrix y, int n, int m)
          Linear regression
 java.lang.String toString(int nrl, int nrh, int ncl, int nch)
          Converts a matrix to a string
 Matrix transpose(int n, int m)
          Returns the transpose of a matrix [0:n-1][0:m-1]
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Matrix

public Matrix(int nr,
              int nc)
Constructs a matrix
Parameters:
nr - the number of the rows
nc - the number of the columns
Method Detail

toString

public final java.lang.String toString(int nrl,
                                       int nrh,
                                       int ncl,
                                       int nch)
Converts a matrix to a string
Parameters:
nrl - the smallest index of the rows
nrh - the largest index of the rows
ncl - the smallest index of the column
ncl - the largest index of the column
Returns:
the converted string

transpose

public final Matrix transpose(int n,
                              int m)
Returns the transpose of a matrix [0:n-1][0:m-1]
Parameters:
n - the number of rows
m - the number of columns
Returns:
the transposed matrix

multiply

public final Matrix multiply(Matrix b,
                             int l,
                             int m,
                             int n)
Reurns the multiplication of two matrices
Parameters:
b - the multiplication matrix
l - the number of the rows of the instance matrix
m - the number of the columns of the instance matrix, and the number of the rows of matrix b
n - the number of the columns of matrix b
Returns:
the product matrix

regression

public final double[] regression(Matrix y,
                                 int n,
                                 int m)
Linear regression
Parameters:
y - the dependent variable vector
n - the number of the observations
m - the number of the coefficients
Returns:
the coefficients

lubksb

public final void lubksb(int n,
                         int[] indx,
                         double[] b)
LU backward substitution
Parameters:
n - the number of the coefficients
indx - the index
b - the double vector, storing constant terms in the equation sets; it later stores the computed coefficients' values

ludcmp

public final int[] ludcmp(int n,
                          int[] indx)
LU decomposition
Parameters:
n - the number of coefficients
indx - the index
Returns:
the integer vector of the attributes's singularities