commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luc Maisonobe <>
Subject Re: [math] matrix identity, matrix as transformation
Date Mon, 02 Mar 2009 12:35:46 GMT
Jelle Herold a écrit :
> Hi there,
> A question on extending commons-math.
> I'm missing a couple of (basic) functions on the RealMatrix class;
> for example,
>  void identity();    // set to identity matrix

There is a MatrixUtil.createRealIdentityMatrix(int dimension) method.
This method will also probably be rewritten some day when diagonal
matrices (or at least band matrices) will be supported.

>  boolean isIdentity()    // check if this is an identity matrix

This makes sense, with an epsilon threshold argument. For now, you cando
something like the following, but this is a clear memory hog since it
creates two temporary matrices:

  RealMatrix id =
  return m.subtract(id).getNorm() < epsilon;

> Also I'm using them as affine transformations, so I'd like to see generic
>  RealVector getTranslation()
>  void translate(RealVector v);
>  void setTranslation(RealVector v);
> etc. (this works for arbitrary dimensions, matrix must be square though)

I think I miss something obvious here.

For me, generic translations are affine transforms, not vector
transforms. They can be computed by additive vector operations, not by
nxn matrix operations without extension. Do you intend to use the
operate() method from RealMatrix with extended vectors (i.e. by
appending a virtual +1 component after the n-components vector) and a
(n+1)x(n+1) or nx(n+1) matrix as done in computer graphics ?

> So wrote a helper class that works on RealMatrix objects treating them
> as transformations, but I'd prefer to have those methods directly on
> RealMatrix.
> (Extending RealMatrix is not practical as methods such as multiply(..)
> don't return the derived class)
> Better suggestions are welcome.

I'm not sure I understood well, so cannot suggest anything yet.


> Are you interested in implementations of these methods? They might be
> out of scope?
> Regards,
> Jelle.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message