Re: bug in plus method ?
The operator = is a pointer assignment in Java.
Use Omatrix = Rmatrix.copy() instead in the
first iteration. For the rest, A=A.plus(B) generates
a temporary matrix each time through the loop.
Use A.pluseq(B) instead.
RONAN PAI
RCEIR wrote:
>
> I've been using JAMA to build statistical models which iterate
> through a method and add the resulting matrix (Rmatrix) from each
> iteration to an overall matrix (Omatrix) at the end of each iteration.
>
> At the end of the first iteration
>
> if (iteration ==0)
>
> Omatrix=Rmatrix;
>
> and for subsequent iterations
>
> else
>
> Omatrix=Omatrix.plus(Rmatrix);
>
> However I have noticed that the first time the "else" statement runs,
> Omatrix becomes twice the second Rmatrix rather than the sum of
> the first Rmatrix and the second Rmatrix. In subsequent iterations
> it works properly.
>
> I've had some other people look at the code and we couldn't see
> any problems.
>
> Could you tell me if this problem has occurred before and if there is
> a solution ?
>
> Thanks,
>
> Ronan Pairceir
Date Index |
Thread Index |
Problems or questions? Contact list-master@nist.gov