[math] RealMatrixPreservingVisitor and RealMatrixChangingVisitor the same?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[math] RealMatrixPreservingVisitor and RealMatrixChangingVisitor the same?

ole ersoy
Hi,

RealMatrixPreservingVisitor and RealMatrixChangingVisitor files look identical with the exception of a single @see Default... annotation (Which I think is redundant...same as > All known implementing classes...?).  Would it make sense to remove the annotation and have one RealMatrixChangingVisitor extend RealMatrixPreservingVisitor?

Cheers,
Ole

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [math] RealMatrixPreservingVisitor and RealMatrixChangingVisitor the same?

Luc Maisonobe-2
Le 30/12/2015 06:18, Ole Ersoy a écrit :
> Hi,

Hi Ole,

>
> RealMatrixPreservingVisitor and RealMatrixChangingVisitor files look
> identical with the exception of a single @see Default... annotation
> (Which I think is redundant...same as > All known implementing
> classes...?).  Would it make sense to remove the annotation and have one
> RealMatrixChangingVisitor extend RealMatrixPreservingVisitor?

No. They are different and used for different things.
The visit method returns void in one case and double in another
case. When it returns double, this double is used to update
the matrix that is visited, hence the "Changing" nature of the
visitor.

best regards,
Luc

>
> Cheers,
> Ole
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [math] RealMatrixPreservingVisitor and RealMatrixChangingVisitor the same?

ole ersoy
Hi Luc,

On 12/30/2015 03:55 AM, Luc Maisonobe wrote:

> Le 30/12/2015 06:18, Ole Ersoy a écrit :
>> Hi,
> Hi Ole,
>
>> RealMatrixPreservingVisitor and RealMatrixChangingVisitor files look
>> identical with the exception of a single @see Default... annotation
>> (Which I think is redundant...same as > All known implementing
>> classes...?).  Would it make sense to remove the annotation and have ons
>> RealMatrixChangingVisitor extend RealMatrixPreservingVisitor?
> No. They are different and used for different things.
> The visit method returns void in one case and double in another
> case. When it returns double, this double is used to update
> the matrix that is visited, hence the "Changing" nature of the
> visitor.
Aha - Figured I was missing something - thanks for explaining.  What do you think about removing the @see annotation (IIUC javadoc generates a link to implementing classes) and having the changing visitor extend the preserving one while overriding `visit()`?

Also could you help me understand what the start() and() end methods are for?  Is there some test code I can look at (I did scan BlockRealMatrixTest)?

Cheers,
Ole

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [math] RealMatrixPreservingVisitor and RealMatrixChangingVisitor the same?

Luc Maisonobe-2
Le 30/12/2015 20:18, Ole Ersoy a écrit :

> Hi Luc,
>
> On 12/30/2015 03:55 AM, Luc Maisonobe wrote:
>> Le 30/12/2015 06:18, Ole Ersoy a écrit :
>>> Hi,
>> Hi Ole,
>>
>>> RealMatrixPreservingVisitor and RealMatrixChangingVisitor files look
>>> identical with the exception of a single @see Default... annotation
>>> (Which I think is redundant...same as > All known implementing
>>> classes...?).  Would it make sense to remove the annotation and have ons
>>> RealMatrixChangingVisitor extend RealMatrixPreservingVisitor?
>> No. They are different and used for different things.
>> The visit method returns void in one case and double in another
>> case. When it returns double, this double is used to update
>> the matrix that is visited, hence the "Changing" nature of the
>> visitor.
> Aha - Figured I was missing something - thanks for explaining.  What do
> you think about removing the @see annotation (IIUC javadoc generates a
> link to implementing classes) and having the changing visitor extend the
> preserving one while overriding `visit()`?

This would defeat the purpose of the overloaded signatures for the
various walk methods in RealMatrix.
There would also be an ambiguity when calling visit and ignoring the
returned value: would it be a call to the void method in the super
interface or a call to the new method in the lower interface? I don't
even think it is possible to override something based only on the return
type.

>
> Also could you help me understand what the start() and() end methods are
> for?  Is there some test code I can look at (I did scan
> BlockRealMatrixTest)?

These methods are used before and after the walk. They are typically
used for initialization for the first one and to gather some results
for the second one.
You can see an exemple in the Adams-Moulton ODE integrator (package
org.apache.commons.math[34].ode.nonstiff. There is an internal class
named Corrector that implements RealMatrixPreservingVisitor.

best regards,
Luc

>
> Cheers,
> Ole
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [math] RealMatrixPreservingVisitor and RealMatrixChangingVisitor the same?

ole ersoy


On 12/30/2015 03:28 PM, Luc Maisonobe wrote:

> Le 30/12/2015 20:18, Ole Ersoy a écrit :
>> Hi Luc,
>>
>> On 12/30/2015 03:55 AM, Luc Maisonobe wrote:
>>> Le 30/12/2015 06:18, Ole Ersoy a écrit :
>>>> Hi,
>>> Hi Ole,
>>>
>>>> RealMatrixPreservingVisitor and RealMatrixChangingVisitor files look
>>>> identical with the exception of a single @see Default... annotation
>>>> (Which I think is redundant...same as > All known implementing
>>>> classes...?).  Would it make sense to remove the annotation and have ons
>>>> RealMatrixChangingVisitor extend RealMatrixPreservingVisitor?
>>> No. They are different and used for different things.
>>> The visit method returns void in one case and double in another
>>> case. When it returns double, this double is used to update
>>> the matrix that is visited, hence the "Changing" nature of the
>>> visitor.
>> Aha - Figured I was missing something - thanks for explaining.  What do
>> you think about removing the @see annotation (IIUC javadoc generates a
>> link to implementing classes) and having the changing visitor extend the
>> preserving one while overriding `visit()`?
> This would defeat the purpose of the overloaded signatures for the
> various walk methods in RealMatrix.
> There would also be an ambiguity when calling visit and ignoring the
> returned value: would it be a call to the void method in the super
> interface or a call to the new method in the lower interface? I don't
> even think it is possible to override something based only on the return
> type.
Ah - You're right - thanks - I guess I could have just tried it :).

Cheers,
Ole

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [math] RealMatrixPreservingVisitor and RealMatrixChangingVisitor the same?

Gilles Sadowski
In reply to this post by Luc Maisonobe-2
On Wed, 30 Dec 2015 10:55:44 +0100, Luc Maisonobe wrote:

> Le 30/12/2015 06:18, Ole Ersoy a écrit :
>> Hi,
>
> Hi Ole,
>
>>
>> RealMatrixPreservingVisitor and RealMatrixChangingVisitor files look
>> identical with the exception of a single @see Default... annotation
>> (Which I think is redundant...same as > All known implementing
>> classes...?).  Would it make sense to remove the annotation and have
>> one
>> RealMatrixChangingVisitor extend RealMatrixPreservingVisitor?
>
> No. They are different and used for different things.
> The visit method returns void in one case and double in another
> case. When it returns double, this double is used to update
> the matrix that is visited, hence the "Changing" nature of the
> visitor.

The "visitor" itself is not "preserving" or "changing" anything.
It can't even know that its computation is related to a matrix
(it's only in the caller's mind that its 3 inputs are row, column,
and corresponding entry of a matrix).
It's the matrix that decides what it wants to do with the result
of the "visitor" instance.
So the interfaces' names are somewhat misleading.

IIUC, the current design is based on the fact that only the matrix
class at hand knows the best way to iterate over its elements.
Hence the loop for visiting entries must be located there, at least
for "walkInOptimizedOrder".

There is a single usage of this "visitor" functionality within CM.
Hence I wonder how useful all the repetitive code (in all the other
"walk..." methods) really is.
I'd leave them out from the refactored matrix implementations.
I recall that there was a "complaint" that the CM matrix interface
was much too heavy for some usage, as it requires the implementation
of many methods that are useless in some applications (e.g. geometry
IIRC).

I'd advise that you have a look at other libraries if you want to
try to improve this area of CM (others have tried...).


Regards,
Gilles

> best regards,
> Luc
>
>>
>> Cheers,
>> Ole


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]