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.
> 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)
> and for subsequent iterations
> 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 ?
> Ronan Pairceir
Date Index |
Thread Index |
Problems or questions? Contact firstname.lastname@example.org