Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-05 Thread Sebastien Brisard
It seems a viable option to me, as long as the Javadoc is explicit enough. Sebastien

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-05 Thread Ted Dunning
+1 from me. On Tue, Jul 5, 2011 at 7:09 PM, Greg Sterijevski wrote: > Is the consensus, then, that we leave the interface alone and handle all > possible cases inside the body of the method? >

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-05 Thread Greg Sterijevski
Is the consensus, then, that we leave the interface alone and handle all possible cases inside the body of the method?

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-02 Thread Ted Dunning
It really is hard to avoid runtime checks in this kind of code. You can do some things in types but it is really hard to get the structure right. Requiring a symmetric or positive definite matrix is a lot like requiring a positive real value as a parameter. We *could* define a special type fo

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-02 Thread Greg Sterijevski
Yes, I believe you would have a new tagging interface called BandedSymmetric. Implementing both interfaces would probably open things to many errors... 2011/7/2 Sébastien Brisard > But if you have a method taking as an input a matrix which MUST be both > symmetric and banded, you are bound to de

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-02 Thread Sébastien Brisard
But if you have a method taking as an input a matrix which MUST be both symmetric and banded, you are bound to define a new interface. Am I wrong? Maybe the alternative you are thinking of is testing "instanceof SymmetricMatrix" and "instanceof BandedMatrix" in the implementation of the method,

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-02 Thread Greg Sterijevski
Not a stupid concern in my book. However there is a synchronization mechanism in place. We are taking part in it right now. Whether the new matrix implements both SymmetricMatrix and BandedMatrix or is a new tagging interface (SymmetricBanded) would determined in the list, after a bit of back and f

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-02 Thread Sébastien Brisard
Marker interface seems to be a very elegant solution. I am just wondering about a potential issue. Let us assume we defined two interfaces, say SymmetricMatrix, and BandedMatrix. User A writes a matrix class which implements both interfaces. Meanwhile, user B implements an algorithm which requi

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-02 Thread Greg Sterijevski
The marker interface is definitely the best way to make this a runtime affair. Attempting to do this with methods will be very messy. One can imagine testing a string of calls like isSymmetric(), isDiagonal(), isBanded()... Furthermore, making use of overloading would not be possible.

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-02 Thread Ted Dunning
Marker methods is what we did in Mahout. Marker interfaces is what I think we perhaps should have done. My rationale is that you can always introduce new marker interfaces without changing the API but if you introduce a new marker method and aren't hard-core about never using interfaces where abs

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-02 Thread Luc Maisonobe
Hi all, Le 02/07/2011 18:20, Ted Dunning a écrit : That won't work. That only works for statically declared matrix types, not run-time matrix types. To be usable, the suggested mechanism must work against runtime data-types. I agree with this need to work with runtime data-types. In one of y

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-02 Thread Ted Dunning
That won't work. That only works for statically declared matrix types, not run-time matrix types. To be usable, the suggested mechanism must work against runtime data-types. On Sat, Jul 2, 2011 at 1:38 AM, Matthew Pocock wrote: > You may get more mileage by having a matrix operation interface

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-02 Thread Matthew Pocock
You may get more mileage by having a matrix operation interface that has is parameterised over the two matrix types. It would have things like multiply once and you would have different concrete implementations for different pairs of matrix types. The implementations can even be provided via one of

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Phil Steitz
On 7/1/11 4:26 PM, Gilles Sadowski wrote: > Hi. > >> Luc suggested that I move this discussion to the list. Luc posed the >> question: >> >> "I don't understand how you intend to separate the API. >> Would that mean users would always have to know beforehand the shape of the >> matrix they use and

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Phil Steitz
On 7/1/11 5:31 PM, Ted Dunning wrote: > On Fri, Jul 1, 2011 at 4:59 PM, Greg Sterijevski > wrote: > >> This may be a problem. Type erasure might necessitate some tricky use of >> generics. >> > That won't help. Good coding practice is to declare a variable with as weak > a type as possible so tha

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Ted Dunning
On Fri, Jul 1, 2011 at 4:59 PM, Greg Sterijevski wrote: > This may be a problem. Type erasure might necessitate some tricky use of > generics. > That won't help. Good coding practice is to declare a variable with as weak a type as possible so that libraries have maximum freedom to act. That mea

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Greg Sterijevski
This may be a problem. Type erasure might necessitate some tricky use of generics. On the SVD, if that's a bug, then the method which yields a reference to the data array in realmatrix is also a bug. On Fri, Jul 1, 2011 at 6:53 PM, Ted Dunning wrote: > Actually, the compiler can't do the dispat

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Ted Dunning
Actually, the compiler can't do the dispatch correctly. For instance, given the following approximately real code: Matrix a = new SparseMatrix(...); Matrix b = new DiagonalMatrix(...); This line will not dispatch to a special case method for either SparseMatrix or DiagonalMatrix:

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Ted Dunning
I count that as a bug in the SVD class. On Fri, Jul 1, 2011 at 4:45 PM, Greg Sterijevski wrote: > You are correct that moving these operations to an external class would > expose details of data storage and break encapsulation. However, this is > done consistently throughout math commons-look at

Fwd: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Greg Sterijevski
No sure if this went through originally, sorry if this causes a duplicate to occur. -Greg -- Forwarded message -- From: Greg Sterijevski Date: Fri, Jul 1, 2011 at 6:45 PM Subject: Re: (MATH-608) Remove methods from RealMatrix Interface To: Commons Developers List , d

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Greg Sterijevski
Hi Gilles, There is no magic which will remove the elemental complexity of these things. However, the complexity would be concentrated in the operator classes, where it probably should be. Furthermore, the type matching would be handled by compiler. Finally, the multiplication routines would grow

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Ted Dunning
One concrete example where second argument runtime type dispatching is helpful is the case of multiplying a dense matrix (of any kind) by a sparse vector. It is preferable to put the smarts for how to do this on in the sparse vector rather than in the dense matrix, but object oriented dispatch giv

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Gilles Sadowski
Hi. > Luc suggested that I move this discussion to the list. Luc posed the > question: > > "I don't understand how you intend to separate the API. > Would that mean users would always have to know beforehand the shape of the > matrix they use and manage both the matrix, the data store and the ope

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Ted Dunning
On Fri, Jul 1, 2011 at 2:35 PM, Greg Sterijevski wrote: > My request stems from attempting to build a SymmetricRealMatrix which > stores > its contents in a packed format. I began implementing multiply and so forth > and did not relish having a bunch of case statements. This lead me to the > idea

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Ted Dunning
Double dispatch was the wrong term. I should have said double argument polymorphism. Double dispatch is a sub-optimal answer to the problem of double polymorphism. Apologies for polluting the discussion with a silly error. On Fri, Jul 1, 2011 at 2:35 PM, Greg Sterijevski wrote: > Ted, > > I am

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Greg Sterijevski
Ted, I am not sure why you think there will be double dispatch. If we remove the multiplication method from the interface then there can only be one call to multiply. If we want to keep the interface as is and also have a MatrixOps class, then perhaps that is where we might have such a case. I am

Re: (MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Ted Dunning
Getting double dispatch this way leads to a pretty ugly API interface. There is no reason why Matrix.times can't delegate to MatrixOp.times(this, other), though. That gives you your double dispatch. The real problem with this design is that adding a new matrix type is no longer something that a

(MATH-608) Remove methods from RealMatrix Interface

2011-07-01 Thread Greg Sterijevski
Hello All, Luc suggested that I move this discussion to the list. Luc posed the question: "I don't understand how you intend to separate the API. Would that mean users would always have to know beforehand the shape of the matrix they use and manage both the matrix, the data store and the operator