commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: [math] Do the two vectors in RealVector.outerProduct really have to be the same size?
Date Thu, 12 May 2011 15:01:55 GMT
Hello.

> 
>     thanks in advance for your time and apologies if this has been raised before (I searched
and couldn't find it).
> 
>     I recently wrote something like
> 
> RealMatrix M = x.outerProduct(y);
> 
> and found it throwing an exception and failing one of my tests because x and y were different
sizes. Fair enough in one sense as this is the documented behaviour but not what one expects
mathematically (see e.g. http://en.wikipedia.org/wiki/Outer_product).
> 
>     To deal with this I found myself writing the following (extremely ugly) code:
> 
> RealMatrix M = (x.getDimension() == y.getDimension()) ?
> 
>     x.outerProduct(y) :
> 
>     (new Array2DRowRealMatrix(x.getData())).multiply(new Array2DRowRealMatrix(y.getData()).transpose());
> 
>     So I have a few questions:
> 
>  *
> Can the restriction that the two vectors in RealVector.outerProduct have to be the same
size be removed? If so, should I enter a bug report or feature request?

Yes, please.

> [...]

Thank you,
Gilles

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


Mime
View raw message