Please try your example with Jama, and let the list know what is the result. :-)
http://math.nist.gov/javanumerics/jama/ -DaveS > -----Original Message----- > From: Michael Duffy [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 16, 2003 3:39 PM > To: [EMAIL PROTECTED] > Subject: Re: [JAVA3D] javax.vecmath.GMatrix.SVD Not Working Properly > > > Hi Chien, > > Looking at those bugs, I hope the response is better > for mine. It looks to me like this has been a > long-standing problem. Thanks - MOD > > > --- Chien Yang <[EMAIL PROTECTED]> wrote: > > Michael, > > Thanks for your bug report. I'll add your report > > to the existing SVD > > bug report we've received earlier. > > > > 4193466 GMatrix SVD does not work correctly for some > > cases. > > > > > > thanks, > > Chien Yang > > Java 3D, Sun Microsystems Inc. > > > > > > Michael Duffy wrote: > > > > >I don't believe the SVD implementation is working > > >properly. > > > > > >I ran a simple problem from Gil Strang's linear > > >algebra course > > >(http://web.mit.edu/18.06/www/Fall03/ps1.pdf, > > problem > > >3) that has a solution available using LU > > >decomposition. > > > > > >When I ran the problem using the LU solver (see > > >LUTest.java, attached) it gave the correct result. > > > > > >When I ran the problem using the SVD solver (see > > >SVDTest.java, attached) it did not give the correct > > >result. > > > > > >When I run the SVD solver for a matrix that isn't > > >square, I get the following exception: > > > > > >java.lang.ArrayIndexOutOfBoundsException: 2 > > > at > > >javax.vecmath.GMatrix.computeSVD(GMatrix.java:2055) > > > at > > >javax.vecmath.GMatrix.SVD(GMatrix.java:1574) > > > at SVDTest.main(SVDTest.java:107) > > > > > >Please advise. - MOD > > > > > > > > > > > > > > > > > >__________________________________ > > >Do you Yahoo!? > > >The New Yahoo! Shopping - with improved product > > search > > >http://shopping.yahoo.com > > > > > > >------------------------------------------------------------- > ----------- > > > > > >import javax.vecmath.* ; > > > > > >public class LUTest > > >{ > > > // See > > > public static final int nrows = 3; > > > public static final int ncols = 3; > > > public static final double [] aInput = > > > { > > > 1, 1, 0, > > > 4, 6, 1, > > > -2, 2, 0, > > > }; > > > public static final double [] bInput = > > > { > > > 1, 4, -10, > > > }; > > > > > > public static void main (String[] args) > > > { > > > try > > > { > > > // Create the A matrix > > > GMatrix a = new GMatrix(nrows, ncols, > > aInput); > > > System.out.println("a: "); > > > System.out.println(a); > > > > > > // Perform LU decomposition > > > GVector permutation = new > > GVector(nrows); > > > int numExchanges = a.LUD(a, > > permutation); > > > > > > // Create the RHS vector > > > GVector b = new GVector(bInput); > > > System.out.println("b:"); > > > System.out.println(b); > > > > > > // Perform back substitution > > > GVector x = new GVector(nrows); > > > x.LUDBackSolve(a, b, permutation); > > > System.out.println("result:"); > > > System.out.println(x); > > > } > > > catch (Exception e) > > > { > > > e.printStackTrace(System.err); > > > } > > > } > > >} > > > > > > > > > >------------------------------------------------------------- > ----------- > > > > > >import javax.vecmath.* ; > > > > > >public class SVDTest > > >{ > > >// From http://web.mit.edu/18.06/www/Fall03/ps1.pdf > > >// Gil Strang's course Web site. > > >/* > > > public static final int nrows = 3; > > > public static final int ncols = 3; > > > public static final double [] aInput = > > > { > > > 1, 1, 0, > > > 4, 6, 1, > > > -2, 2, 0, > > > }; > > > public static final double [] bInput = > > > { > > > 1, 4, -10, > > > }; > > >*/ > > >/* > > > public static final int nrows = 12; > > > public static final int ncols = 11; > > > public static final double[] aInput = > > > { > > > 0,1,0,1,0,0,0,0, 0, -58, 0, > > > 0,0,0,0,0,1,0,1, 0, -201, 0, > > > 0,1,1,1,0,0,0,0, 0, -53, -53, > > > 0,0,0,0,0,1,1,1, 0, -52, -52, > > > 0,0,0,1,0,0,0,0, 0, 0, 0, > > > 0,0,0,0,0,0,0,1, 0, 0, 0, > > > 0,0,1,1,0,0,0,0, 0, 0, -156, > > > 0,0,0,0,0,0,1,1, 0, 0, -44, > > > 1,0,0,1,0,0,0,0, -263, 0, 0, > > > 0,0,0,0,1,0,0,1, -193, 0, 0, > > > 1,0,1,1,0,0,0,0, -259, 0, -259, > > > 0,0,0,0,1,0,1,1, -45, 0, -45, > > > }; > > > public static final double[] bInput = > > > { > > > > > > 58.,201.,53.,52.,159.,181.,156.,44.,263.,193.,259.,45. > > > }; > > >*/ > > > // From > > > http://www.bluebit.gr/matrix/reference/SVD-Example.htm > > > // Solution vector: x = { 4.089, 3.066, 2.163, > > } > > >/* > > > public static final int nrows = 20; > > > public static final int ncols = 3; > > > public static final double[] aInput = > > > { > > > 6, 5, 5, > > > 3, 3, 7, > > > 0, 7, 7, > > > 6, 0, 4, > > > 8, 7, 3, > > > 9, 8, 1, > > > 9, 3, 5, > > > 7, 0, 5, > > > 4, 3, 6, > > > 6, 2, 3, > > > 7, 7, 5, > > > 9, 8, 2, > > > 6, 9, 2, > > > 5, 1, 9, > > > 6, 0, 5, > > > 1, 1, 7, > > > 3, 0, 3, > > > 3, 3, 9, > > > 9, 4, 3, > > > 1, 1, 6, > > > }; > > > public static final double[] bInput = > > > { > > > 51, 37, 37, 33, 60, 64, 55, 40, 39, 38, 59, > > 65, 58, 43, 35, 24, 21, 39, 57, 20, > > > }; > > >*/ > > > > > > > > >// From > > > http://cs.uakron.edu/~quesada/Courses/LinAlg/Projects/svdpaper.pdf > > > public static final int nrows = 2; > > > public static final int ncols = 3; > > > public static final double [] aInput = > > > { > > > 3, 2, 2, > > > 2, 3, -2, > > > }; > > > public static final double [] bInput = > > > { > > > 3, 2, > > > }; > > > > > > > > > public static void main(String[] args) > > > { > > > try > > > { > > > // Create the A matrix > > > GMatrix a = new GMatrix(nrows, ncols, > > aInput); > > > System.out.println("a:"); > > > System.out.println(a); > > > > > > // Perform the SVD > > > GMatrix u = new GMatrix(nrows, nrows); > > > GMatrix w = new GMatrix(nrows, ncols); > > > GMatrix v = new GMatrix(ncols, ncols); > > > > > > int rank = a.SVD(u,w,v); > > > > > > System.out.println("rank: " + rank); > > > System.out.println("u:"); > > > System.out.println(u); > > > System.out.println("v:"); > > > System.out.println(v); > > > System.out.println("w:"); > > > System.out.println(w); > > > > > > // Check to make sure that > > transpose(U)*U = identity > > > GMatrix utranspose = new GMatrix(u); > > > utranspose.transpose(); > > > GMatrix udelta = new GMatrix(ncols, > > ncols); > > > udelta.mul(utranspose, u); > > > System.out.println("udelta:"); > > > System.out.println(udelta); > > > > > > // Check to make sure that > > transpose(V)*V = identity > > > GMatrix vtranspose = new GMatrix(v); > > > vtranspose.transpose(); > > > GMatrix vdelta = new GMatrix(ncols, > > ncols); > > > vdelta.mul(vtranspose, v); > > > System.out.println("vdelta:"); > > > System.out.println(vdelta); > > > > > > // Create the RHS vector > > > GVector b = new GVector(bInput); > > > System.out.println("b:"); > > > System.out.println(b); > > > > > > // Perform back substitution > > > GVector x = new GVector(nrows); > > > x.SVDBackSolve(u, w, v, b); > > > System.out.println("result:"); > > > System.out.println(x); > > > } > > > catch (Exception e) > > > { > > > e.printStackTrace(System.err); > > > } > > > } > > >} > > > > > > > > > > > > > ============================================================== > ============= > > To unsubscribe, send email to [EMAIL PROTECTED] > > and include in the body > > of the message "signoff JAVA3D-INTEREST". For > > general help, send email to > > [EMAIL PROTECTED] and include in the body of the > > message "help". > > > > > __________________________________ > Do you Yahoo!? > The New Yahoo! Shopping - with improved product search > http://shopping.yahoo.com > > ============================================================== > ============= > To unsubscribe, send email to [EMAIL PROTECTED] and > include in the body > of the message "signoff JAVA3D-INTEREST". For general help, > send email to > [EMAIL PROTECTED] and include in the body of the message "help". > =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".