com.kutsyy.util
Class La

java.lang.Object
  |
  +--com.kutsyy.util.La

public final class La
extends Object

La class contains some helpful linear algebra functions that
requre JAMA package
Created by Vadim Kutsyy

Author:
Vadim Kutsyy

Constructor Summary
La()
           
 
Method Summary
static double[] changeI(double[] a, int i, double x)
          Returns vector b[]=a[], except for x[i]=x
static int[] changeI(int[] a, int i, int x)
          Returns vector b[]=a[], except for x[i]=x
static double[][] choldc(double[][] A)
          Cholestky decomposition.
private static void choldc(double[][] a, double[] p)
          main method for Cholestky decomposition.
static double[][] choldcsl(double[][] A)
          Inverse of Cholestky decomposition.
static double choldet(double[][] a)
          Computation of Determinant of the matrix using Cholevsky decomposition
static double choldet(double[][] a, double[][] c)
          Computation of Determinant of the matrix using Cholevsky decomposition, and Cholevsky decomposition
static double[][] cholsl(double[][] A)
          Matrix inverse using Cholevsky decomposition
static double[] cholsl(double[][] A, double[] b)
          Solves Ax=b, using Cholesky decomposition
private static double[] cholsl(double[][] a, double[] p, double[] b)
          Internal method for Cholestky decomposition.
static double[][] getArray(double[][] A, int iFirst, int iLast)
          Get a subarray.
static double[][] getArray(double[][] A, int iFirst, int iLast, int jFirst, int jLast)
          Get a subarray.
static double[] getArray(double[] A, int[] index)
          Get sub array
static double[] getArray(double[] A, int iFirst, int iLast)
          Get a subarray.
static double[] insertI(double[] a, int i, double x)
          Insert element x at the position i;
static int[] insertI(int[] a, int i, int x)
          Insert element x at the position i;
static double max(double[] a)
          Find maximum value of the vector
static double min(double[] a)
          Find minimum value of the vector
static double[][] minus(double[][] a, double[][] b)
          Return x[i][j]=a[i][j]-b[i][j] for i,j=0..(n-1)
static double[] minus(double[] a, double[] b)
          Return x[i]=a[i]-b[i] for i=0..(n-1)
static void mult(double[][] A, double[][] B, double[][] C, double alpha, double beta)
          Linear algebraic matrix-matrix multiplication; C = alpha * A x B + beta*C .
static double[][] negativeI(double[][] a, int i)
          Returns x=a, exceept for x[i][j]=-a[i][j], i!=j;
static double[] negativeI(double[] a, int i)
          Returns x=a, except for x[i]=-a[i];
static double[][] plus(double[][] a, double[][] b)
          Return x[i][j]=a[i][j]+b[i][j] for i,j=1..(n-1)
static double[] plus(double[] a, double b)
          Return x[i]=a[i]+b for i=1..(n-1)
static double[] plus(double[] a, double[] b)
          Return x[i]=a[i]+b[i] for i=1..(n-1)
static double[][] removeI(double[][] a, int i)
          Returns x, such that x[j][k]=a[j][k], j,k=i if j,k less then i, ir i+1
static double[] removeI(double[] a, int i)
          Returns x such that x[j]=a[j], j
static int[] removeI(int[] a, int i)
          return x, such that x[j]=a[j], j
static double[][] solve(double[][] A)
          return inverse of the matrix.
static double[] solve(double[][] A, double[] b)
          Solves Ax=b for general A, using JAMA package ;
static double[] solveLS(double[][] x, double[] y)
          Finds Least square solution of y=b*x
static double[] sub(double[] x, int end)
          Get subarray
static double[] sub(double[] x, int start, int end)
          Get subarray
static double sum(double[] x)
          Returns sum of array
static double[][] t(double[][] A)
          Return transpose of the matrix
static int[][] t(int[][] A)
          Return transpose of the matrix
static double times(double[] A)
          Return A'A, where A is n dimentional vector;
static double[][] times(double[][] A)
          Linear algebraic matrix multiplication, C = A * A
static double[][] times(double[][] a, double b)
          Linear algebraic matrix multiplication, C = A * b
static double[] times(double[][] A, double[] B)
          Linear algebraic matrix multiplication, C = A * b
static double[][] times(double[][] A, double[][] B)
          Linear algebraic matrix multiplication, C = A * B
static double[] times(double[] A, double b)
          Linear algebraic matrix multiplication, C = A * b
static double times(double[] A, double[] B)
          Linear algebraic matrix multiplication, C = A * B
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

La

public La()
Method Detail

getArray

public static double[][] getArray(double[][] A,
                                  int iFirst,
                                  int iLast,
                                  int jFirst,
                                  int jLast)
Get a subarray. Creation date: (2/4/00 2:13:25 PM)
Parameters:
A - array
iFirst - start of fist dimention ofsubarray
iLast - end of fist dimention ofsubarray
jFirst - start of second dimention ofsubarray
jLast - end of second dimention ofsubarray
Returns:
double[][] A[i0:i1][j0:j1]

getArray

public static double[][] getArray(double[][] A,
                                  int iFirst,
                                  int iLast)
Get a subarray.
Parameters:
A - array
iFirst - start of subarray
iLast - end of subarray
Returns:
double A[i0:i1][i0:i1]

getArray

public static double[] getArray(double[] A,
                                int iFirst,
                                int iLast)
Get a subarray.
Parameters:
A - array
iFirst - start of subarray
iLast - end of subarray
Returns:
A[i0:i1]

getArray

public static double[] getArray(double[] A,
                                int[] index)
Get sub array
Parameters:
A - array
index - index of fields for subarray
Returns:
A[index]

changeI

public static double[] changeI(double[] a,
                               int i,
                               double x)
Returns vector b[]=a[], except for x[i]=x
Parameters:
a - input vector
i - position of the change
x - new value for replasment
Returns:
output vector

changeI

public static int[] changeI(int[] a,
                            int i,
                            int x)
Returns vector b[]=a[], except for x[i]=x
Parameters:
a - input vector
i - position of the change
x - new value for replasment
Returns:
output vector

choldc

public static double[][] choldc(double[][] A)
Cholestky decomposition.
Parameters:
A - Symetric Positive def matrix
Returns:
lower deomposed matrix
See Also:
choldc(double[][], double[])

choldcsl

public static double[][] choldcsl(double[][] A)
Inverse of Cholestky decomposition.
Parameters:
A - Symetric Positive def matrix
Returns:
inverse of lower deomposed matrix
See Also:
choldc(double[][], double[])

choldet

public static double choldet(double[][] a)
Computation of Determinant of the matrix using Cholevsky decomposition
Parameters:
a - A
Returns:
det(A)
See Also:
choldc(double[][], double[])

choldet

public static double choldet(double[][] a,
                             double[][] c)
Computation of Determinant of the matrix using Cholevsky decomposition, and Cholevsky decomposition
Parameters:
a - A
c - Cholevsky decomposition of A
Returns:
det(A)
See Also:
choldc(double[][], double[])

cholsl

public static double[][] cholsl(double[][] A)
Matrix inverse using Cholevsky decomposition
Parameters:
A - Symetric Positive def matrix
Returns:
inverse of A
See Also:
choldc(double[][], double[])

cholsl

public static double[] cholsl(double[][] A,
                              double[] b)
Solves Ax=b, using Cholesky decomposition
Parameters:
A - A
b - b
Returns:
x
See Also:
choldc(double[][], double[])

insertI

public static double[] insertI(double[] a,
                               int i,
                               double x)
Insert element x at the position i;
Parameters:
a - input vector [n]
i - position
x - value of inserted element
Returns:
output vector (a[0:i-1],x,a[i:a.length])

insertI

public static int[] insertI(int[] a,
                            int i,
                            int x)
Insert element x at the position i;
Parameters:
a - input vector [n]
i - position
x - value of inserted element
Returns:
output vector (a[0:i-1],x,a[i:a.length])

max

public static double max(double[] a)
Find maximum value of the vector
Parameters:
a - a
Returns:
max(a)

min

public static double min(double[] a)
Find minimum value of the vector
Parameters:
a - a
Returns:
min(a)

minus

public static double[][] minus(double[][] a,
                               double[][] b)
Return x[i][j]=a[i][j]-b[i][j] for i,j=0..(n-1)
Parameters:
a - a
b - b
Returns:
x

minus

public static double[] minus(double[] a,
                             double[] b)
Return x[i]=a[i]-b[i] for i=0..(n-1)
Parameters:
a - a
b - b
Returns:
x

negativeI

public static final double[][] negativeI(double[][] a,
                                         int i)
Returns x=a, exceept for x[i][j]=-a[i][j], i!=j;
Parameters:
a - a
i - index
Returns:
x

negativeI

public static double[] negativeI(double[] a,
                                 int i)
Returns x=a, except for x[i]=-a[i];
Parameters:
a - a
i - index
Returns:
x

plus

public static double[][] plus(double[][] a,
                              double[][] b)
Return x[i][j]=a[i][j]+b[i][j] for i,j=1..(n-1)
Parameters:
a - a
b - b
Returns:
x

plus

public static double[] plus(double[] a,
                            double[] b)
Return x[i]=a[i]+b[i] for i=1..(n-1)
Parameters:
a - a
b - b
Returns:
x

plus

public static double[] plus(double[] a,
                            double b)
Return x[i]=a[i]+b for i=1..(n-1)
Parameters:
a - a
b - b
Returns:
x

removeI

public static double[][] removeI(double[][] a,
                                 int i)
Returns x, such that x[j][k]=a[j][k], j,k=i if j,k less then i, ir i+1
Parameters:
a - a
i - index
Returns:
x

removeI

public static double[] removeI(double[] a,
                               int i)
Returns x such that x[j]=a[j], j
Parameters:
a - a
i - index
Returns:
x

removeI

public static int[] removeI(int[] a,
                            int i)
return x, such that x[j]=a[j], j
Parameters:
a - a
i - index
Returns:
x

solve

public static double[][] solve(double[][] A)
return inverse of the matrix. Use JAMA package
Parameters:
A - Matrix
Returns:
Inverse

solve

public static double[] solve(double[][] A,
                             double[] b)
Solves Ax=b for general A, using JAMA package ;
Parameters:
A - A
b - b
Returns:
x

solveLS

public static double[] solveLS(double[][] x,
                               double[] y)
Finds Least square solution of y=b*x
Parameters:
x - x
y - y
Returns:
b

sub

public static double[] sub(double[] x,
                           int end)
Get subarray
Parameters:
x - array
end - end of subarray
Returns:
x[1:end]

sub

public static double[] sub(double[] x,
                           int start,
                           int end)
Get subarray
Parameters:
x - array
start - start of subarray
end - end of subarray
Returns:
x[start:end]

t

public static double[][] t(double[][] A)
Return transpose of the matrix
Parameters:
A - A
Returns:
transpose(A)

t

public static int[][] t(int[][] A)
Return transpose of the matrix
Parameters:
A - A
Returns:
transpose(A)

times

public static double[][] times(double[][] A)
Linear algebraic matrix multiplication, C = A * A
Parameters:
A - matrix
Returns:
product, A * A

times

public static double[][] times(double[][] A,
                               double[][] B)
Linear algebraic matrix multiplication, C = A * B
Parameters:
A - Description of Parameter
B - Description of Parameter
Returns:
product, A * B

times

public static double[] times(double[][] A,
                             double[] B)
Linear algebraic matrix multiplication, C = A * b
Parameters:
A - Description of Parameter
B - Description of Parameter
Returns:
product, A * b

times

public static double[][] times(double[][] a,
                               double b)
Linear algebraic matrix multiplication, C = A * b
Parameters:
a - A
b - b
Returns:
product, A * b

times

public static double times(double[] A)
Return A'A, where A is n dimentional vector;
Parameters:
A - n dimentional vector;
Returns:
A'A

times

public static double times(double[] A,
                           double[] B)
Linear algebraic matrix multiplication, C = A * B
Parameters:
A - matrix
B - matrix
Returns:
product, A * b

times

public static double[] times(double[] A,
                             double b)
Linear algebraic matrix multiplication, C = A * b
Parameters:
A - matrix
b - parameter
Returns:
product, A * b

mult

public static final void mult(double[][] A,
                              double[][] B,
                              double[][] C,
                              double alpha,
                              double beta)
Linear algebraic matrix-matrix multiplication; C = alpha * A x B + beta*C . C[i,j] = alpha*Sum(A[i,k] * B[k,j]) + beta*C[i,j], k=0..n-1 .
Matrix shapes: A(m x n), B(n x p), C(m x p) .
Creation date: (11/22/2000 3:08:04 PM)
Parameters:
A - first source matrix.
B - the second source matrix.
C - the matrix where results are to be stored. Set this parameter to null to indicate that a new result matrix shall be constructed.
alpha - double
beta - double
Throws:
IllegalArgumentException - if B.length != A[0].length .
IllegalArgumentException - if C.length != A.length || C[0].length != B[0].length .
IllegalArgumentException - if A == C || B == C .

sum

public static double sum(double[] x)
Returns sum of array
Parameters:
x - array
Returns:
sum(x)

choldc

private static void choldc(double[][] a,
                           double[] p)
main method for Cholestky decomposition.
Parameters:
a - matrix
p - vector of resulting diag of a

cholsl

private static double[] cholsl(double[][] a,
                               double[] p,
                               double[] b)
Internal method for Cholestky decomposition.
Parameters:
b - double[]
a - double[]
p - double[]
Returns:
double[]