commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject Re: [math] Adding a new class to handle Matrix with 3 columns/rows
Date Wed, 27 Jul 2011 15:52:33 GMT
On 7/27/11 7:30 AM, Gilles Sadowski wrote:
> Hello.
>
>>>> In project SIRIUS (CNES), we have some need for a Matrix33 (3 columns, 
>>>> 3
>>>> rows) object. It is very common to use this kind of matrix to apply 
>>>> rotation to a position vector (vector3D).
>>>>
>>>> The incompatibility between the Vector3D of geometry package and the 
>>>> matrix/vectors of the linear package is a lack that we propose to fill 
>>>> by creating a "Matrix33" in the geometry.threed package.
>>> Looks finie to me.
> Except for the name: "Matrix33" -> "Matrix3D".
>
>> [...]
>>
>>>> We will also propose some new constructors to build gaps between this
>>>> new matrix and the matrix of linear package.
>>> Yes, having a way to change from one view to the other is a clear need.
>> Yes, we prefer to add a constructor from Array2DRowRealMatrix and a getter
>> (that returns a Array2DRowRealMatrix) than to implement the whole interface
>> RealMatrix
> There are not that many methods. It's preferable to implement "RealMatrix"
> lest there will be two API eveolving independently.

+1

> I'm sure that somebody will help implement the missing bits if necessary.
>
>> (or inherit the AbstractMatrix).
> At the moment, I tend to agree on this point, given what I've just observed
> with this benchmark:

+1 - the difference is expected, since AbstractRealMatrix has to use
getters/setters and Array2DRowRealMatrix can do direct array
access.  I guess to maximize reuse a) the array-based operations
could be extracted into a static utils class somewhere and used by
both impls or b) the new class could extend Array2DRowRealMatrix.

Phil
> ---CUT---
>     public void testAddPerf() {
>         final Array2DRowRealMatrix mAR = new Array2DRowRealMatrix(testData);
>         final RealMatrix mR = mAR;
>         final Array2DRowRealMatrix mInv = new Array2DRowRealMatrix(testDataInv);
>
>         PerfTestUtils.timeAndReport("add",
>                                     200,
>                                     10000,
>                                     new PerfTestUtils.RunTest("RealMatrix") {
>                                         RealMatrix mPlusMInv;
>                                         public void run() {
>                                             mPlusMInv = mR.add(mInv);
>                                         }},
>                                     new PerfTestUtils.RunTest("Array2DRowRealMatrix")
{
>                                         RealMatrix mPlusMInv;
>                                         public void run() {
>                                             mPlusMInv = mAR.add(mInv);
>                                         }});
>     }
> ---CUT---
>
> The result is:
> ---CUT---
> add
> RealMatrix: 5.722274034999992E-4 ms
> Array2DRowRealMatrix: 4.3001998499999885E-4 ms
> ---CUT---
>
> Thus, in the first "RunTest", it is the (slower) "AbtractRealMatrix.add"
> method that is used, although "mR" is the same object as "mAR" (and an
> instance of "Array2DRowRealMatrix").
>
>> [...]
>
> Regards,
> Gilles
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message