commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <>
Subject Re: [math] Adding a new class to handle Matrix with 3 columns/rows
Date Wed, 27 Jul 2011 14:30:05 GMT

> >> 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.
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:
    public void testAddPerf() {
        final Array2DRowRealMatrix mAR = new Array2DRowRealMatrix(testData);
        final RealMatrix mR = mAR;
        final Array2DRowRealMatrix mInv = new Array2DRowRealMatrix(testDataInv);

                                    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);

The result is:
RealMatrix: 5.722274034999992E-4 ms
Array2DRowRealMatrix: 4.3001998499999885E-4 ms

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").

> [...]


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

View raw message