commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz" <>
Subject RE: [math] API changes for RC2
Date Mon, 27 Sep 2004 17:08:19 GMT
I see your point re RealMatrix immutability and I now understand (and agree with, I think)
what you mean about accessors.  Can anyone else see reasons why  matrices should *not* be
publicly immutable?  Would you also remove the getData, getDataRef methods?
>> Think of it more as "Iterators" or "Enumerations", These classes
>> provide the same sort of functionality for the Collections API. Yes,
>> there are "copy semantics" and "concurrent modification rules" that
>> need to be employed the same as Collections. As well, I would suggest
>> the idea that a Matrix be "final" and "Immutable" in the same way as
>> any java.lang.Number implementation, and if not possible in all cases,
>> then the mutability should possibly be done internally in the
>> implementation.
> I agree with the usefulness and how you are thinking about this. The
> question is, shouldn't these factory/iterator-type thingies be in
> separate classes -- i.e., does this stuff really belong in the
> RealMatrix interface itself?  Unless the answer is yes, we can add these
> in 1.1

I recommend that they be return types in that Interface. Ultimately
because if the Matrix Interface is well defined in this regard, we can
make minor version releases without breaking it.

One of my chief concerns is that there are methods which allow write
access to the underlying double[][] in RealMatrix which concern me. I
would recommend that methods such as

setEntry(int, int, double)

Be removed from the interface (made protected in the Implementation) as
they break the idea of the internal matrix being publically immutable.

This change would allow us to Return RealMatrix types which use the
internal column and row of the original matrix for their datastore for
the following methods:

RealMatrix getColumn(int)
RealMatrix getRow(int)

If the original matrix is immutable and the RealMatrix implementations
returned from these methods are immutable the API should be safe

View raw message