Fwd: Re: Fwd: An Exception occurs for getS() in Jama


Sender: Tobias Weimer <tobias.weimer@tu-dortmund.de>
Subject: Re: Fwd: An Exception occurs for getS() in Jama


Hi,
The modifications seem to be correct. If we ran beyond s.length, then we
are getting an exception.

I did not test any more of the code yet, but it seems to make sense to
apply his fix for now.

Regards
Tobias Weimer

PS: The inner loop for (int j = 0; j < *s.length*; j++) seems to be
unneeded, because java initializes the array with zeros anyways.

PPS: Reading the code snippet without the whole class code, using a big
S as a local variable and an small s as a class variable is very
confusing :D

Am 11.3.2013 20:49, schrieb Bruce Miller:
> Hi Ali;
>    Your modifications appear to avoid the exception,
> but may cause other problems;
>   I'm not that fluent in SVG, so I've forwarded your
> message to the Jama list to get their feedback.
>
> bruce
>
> -------- Original Message --------
> Subject:     An Exception occurs for getS() in Jama
> Date:     Mon, 11 Mar 2013 15:27:05 -0400
> From:     Ali Pesaranghader <alipsgh@gmail.com>
> To:     Miller, Bruce R <bruce.miller@nist.gov>
>
>
>
> Dear Dr. Miller,
>
>      My name is Ali. I'm a computer science student and for my final
> project I'm
>      using Jama and SVD class for LSI (Latent Semantic Index). During
> using this
>      package I figured out that an exception occurs when the number of
> input
>      matrix's rows is less than its columns, for example 14x16. Thus, I
> changed
>      the getS() function and I ran some examples and checked the result
> with
>      Octave. The result was same. Just now before sending this email I
> saw that
>      the assumption of Jama is that rows must be bigger than columns
> (most above
>      comment on SVD class), but it works right as Octave when I changed
> it. Is
>      there anything that I may missed?!
>
>          /*Jama code:*/
>
>              public Matrix getS () {
>
>                 Matrix X = new Matrix(n,n);
>
>                 double[][] S = X.getArray();
>
>                 for (int i = 0; i < *n*; i++) {
>
>                    for (int j = 0; j < *n*; j++) {
>
>                       S[i][j] = 0.0;
>
>                    }
>
>                    S[i][i] = this.s[i];
>
>                 }
>
>                 return X;
>
>              }
>
>
>          /*After my modification:*/
>
>              public Matrix getS () {
>
>                 Matrix X = new Matrix(n,n);
>
>                 double[][] S = X.getArray();
>
>                 for (int i = 0; i < *s.length*; i++) {
>
>                    for (int j = 0; j < *s.length*; j++) {
>
>                       S[i][j] = 0.0;
>
>                    }
>
>                    S[i][i] = this.s[i];
>
>                 }
>
>                 return X;
>
>              }
>
>
>      Thank you for this great package, it helps me a lot to build my ideas.
>
> Sincerely,
> Ali.







Date Index | Thread Index | Problems or questions? Contact list-master@nist.gov