[Jprogramming] Matrix reshaping (newbie)
Devon McCormick
devonmcc at gmail.com
Wed Jan 16 01:00:56 HKT 2008
Given that the shapes returned by the SVD are already conformable for matrix
multiplication, do you really need to get "M" involved at all?
You can just multiply the result "s" simply like this:
>mp&.>/s
Be aware that this multiplies in the order "a mp (b mp c)" where 'a b c'=.
s.
On 1/15/08, Yoel Jacobsen <yoel.jacobsen at gmail.com> wrote:
>
> Hello,
>
> I want to implement matrix approximation using SVD.
> The SVD algorithm returns three boxed matrices of the shapes x x ; x y ;
> y y
> I want to chop and multiply back:
> Step 1: reshape as - x M; M M ; M y where M is a small value
> Step 2: Unbox and multiply (x M * M M * M y => x y)
>
> My current implementation is:
>
> s =. dgesvd ...
> a =. M {. "1 (> 0 { s)
> b =. M {. "1 (M {. (> 1 { s))
> c =. M {. (> 2 { s)
>
> mp =: +/ . *
> approximated =. a mp b mp c
>
> Now this is 1) ugly (for me) and 2) slow as hell.
>
> Suggestions?
>
> Thanks,
> Yoel
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
More information about the Programming
mailing list