Hi,

PDL is rocking. It's great to do in a real language what I could
previously do only in MATLAB.

That said, I've run into what appears to be a bug with svd() in PDL
2.4.6 (built using the included cpan client) under Strawberry 5.10.0
(Windows XP SP3). Searching in the mailing list archive appears to be
broken and Google is not turning up anything recent, so I am seeking
advice on this problem here.

I constructed a minimal pair. svd() succeeds here:


use PDL;

my $A = pdl(
[1,2,3],
[4,5,6]
);
print $A;

my ($u, $s_diag, $v) = svd($A);
my $s = zeroes($v);
$s->diagonal(0,1) .= $s_diag;
my $vt = transpose($v);

my $matcopy = $u x $s x $vt;
print $matcopy;


Output:
[
 [1 2 3]
 [4 5 6]
]

[
 [1 2 3]
 [4 5 6]
]

The original matrix has been restored (cf.
http://www.mail-archive.com/[email protected]/msg00302.html
)

But svd() fails if the matrix's second row is also [1,2,3]:


(snip)
my $A = pdl(
[1,2,3],
[1,2,3]
);
(snip)

Output:
[
 [1 2 3]
 [1 2 3]
]

[
 [-1.#IND -1.#IND -1.#IND]
 [-1.#IND -1.#IND -1.#IND]
]

What?? :)

It also fails with matrices with only a single row (apparently, any
single row EXCEPT a 1x1 matrix):

(snip)

my $A = pdl(
[4,5,6],
);
(snip)

Output:
[4 5 6]
[
 [-1.#IND -1.#IND -1.#IND]
]


It seems like the single row case (but not the multi-row case) is also
broken under the same version of PDL under Perl 5.10.0 on my i7 Mac
laptop (running OS X 10.6.4). Output:

[4 5 6]
[
 [nan nan nan]
]


Singular value decomposition is a great tool and it would be great to
have it working at full strength in PDL even on the "less commonly
used" platforms. ;)


Thanks for your time,


Nathan

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to