commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arne Ploese <>
Subject Re: [math] Read-only RealVector
Date Thu, 11 Aug 2011 18:11:44 GMT
Am Donnerstag, den 11.08.2011, 10:55 +0200 schrieb S├ębastien Brisard: 
> 2011/8/11 Arne Ploese <>:
> > So you not only want to observe the result, but you want a read only
> > RealVector.
> >
> That's right. I'm sorry, my first message was not clear, especially if
> you did not follow the thread on iterative solvers.
> I want to observe the *solver*, and the current state of the solver is
> a *RealVector*, which should by no means be modified by the observer.
> The safest way to do that would be for the solver to have a method
> like
> public RealVector getCurrentSolution(){
>     return x.copy();
> }
> but that takes both time and memory. So I was thinking of something more like
> public RealVector getCurrentSolution(){
>     return new ReadOnlyRealVector(x);
> }
> which takes virtually no additional memory (and presumably very little
> time). The two advantages of this approach are
> * it does not jeopardize the whole hierarchy tree, since you do not
> have to create a new interface,
That is true, but you dont get a compile time error if you pass the
instance by accident to somewhere and that one tries to do an xxxToSelf,
which will result in a RuntimeError - not a very clean solution ... more
a hot fix. Having an interface would clear state what you can do and
what not.
> * it is quite general, and could be adopted for any base object (not
> only RealVector).
> The downside is that some methods throw exceptions, which might be
> deemed dirty. I don't really know.
> S

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message