Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Need some Linear Algebra Packages

Reply
Thread Tools

Need some Linear Algebra Packages

 
 
ckumar
Guest
Posts: n/a
 
      01-12-2005
Hai,

Someone tell me which is the best package for Linear Algebra
Calculations.Currently I came across some packages namely JLAPACK and
JAMA.

With regards
ackumar

 
Reply With Quote
 
 
 
 
Gordon Beaton
Guest
Posts: n/a
 
      01-12-2005
On Wed, 12 Jan 2005 05:07:10 -0500, ckumar wrote:
> Someone tell me which is the best package for Linear Algebra
> Calculations.Currently I came across some packages namely JLAPACK
> and JAMA.


I don't know which is the best package (or how *you* define "best"),
but there are many such packages, for example:

http://math.nist.gov/javanumerics/#libraries

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
 
Reply With Quote
 
 
 
 
ckumar
Guest
Posts: n/a
 
      01-17-2005
Hai,

Thanx. I downloaded two packages from this site JAMA and Matrix Toolkit
for Java(MTJ). I calculated Singular Vector Decomposition using these
packages. On decomposing the input matrix(X) we will get three matrices
namely,

U - Left Singular Matrix
S - Singular values
V - Right singular Matrix

then X=U*S*(VTranspose).

This works fine for JAMA. But in MTJ I not able to get back the input
matrix on multiplying these three matrices.

I downloaded MTJ from following site
http://www.math.uib.no/~bjornoh/mtj/

I like to know whether the problem is on package or in my code.

Regards,
ackumar

CODE:

import mt.*;
import mt.fact.*;
import java.io.*;
import java.lang.*;

class mtjSVD{
public static void main(String args[])
{
String val=new String();
double[][] array={{1.0,2.0},{1.0,1.0},{1.0,3.0}};

DenseMatrix X=new DenseMatrix(array);
System.out.println("Rows="+X.numRows()+"\nCols="+X .numColumns());
System.out.println("\n********************\tX\t*** ****************\n");
printMatrix(X);

SingularvalueComputer svc=new
SingularvalueComputer(X.numRows(),X.numColumns(),t rue);
SVD svd=new SVD(X.numRows(),X.numColumns());
try{
svd=svc.factor(X.copy());
}catch(Exception ee){ee.printStackTrace();}

DenseMatrix U=svd.getU();
System.out.println("********************\tU\t***** **************\n");
printMatrix(U,5);

DenseMatrix V=svd.getVt();
System.out.println("********************\tV\t***** **************\n");
printMatrix(V,5);

DenseMatrix S = new DenseMatrix(X.numRows(),X.numColumns());
double singVal[]=svd.getS();

for(int i=0;i<2;i++)
S.set(i,i,singVal[i]);
System.out.println("********************\tS\t***** **************\n");
printMatrix(S);

System.out.println("********************\tRetained -
X\t*******************\n");
DenseMatrix retainedX=new DenseMatrix(X.numRows(),X.numColumns());
retainedX=(DenseMatrix)U.mult(S,retainedX);
retainedX=(DenseMatrix)retainedX.mult(V.transpose( ),retainedX);
printMatrix(retainedX);

}

static void printMatrix(Matrix M)
{
for(int i=0;i<M.numRows();i++)
{
for(int j=0;j<M.numColumns();j++)
{
System.out.print(M.get(i,j)+"\t");
}
System.out.println("\n");
}
}

static void printMatrix(Matrix M,int val)
{
for(int i=0;i<M.numRows();i++)
{
for(int j=0;j<M.numColumns();j++)
{
System.out.print((Double.toString(M.get(i,j))).sub string(0,val)+" ");
}
System.out.println("\n");
}
}

}



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python linear algebra module -- requesting comments on interface C. Barnes Python 0 09-14-2005 07:00 AM
Python linear algebra module -- requesting comments on interface C. Barnes Python 5 09-11-2005 10:19 AM
Re: Python linear algebra module -- requesting comments on interface Terry Reedy Python 1 09-11-2005 02:17 AM
Python linear algebra module -- requesting comments on interface barnesc@engr.orst.edu Python 0 09-09-2005 02:29 PM
[Lang C]Linear Algebra, Calculus In language C with gnuplot. Bernard Xhumga C Programming 0 11-24-2003 05:38 PM



Advertisments