in reply to Re^6: first stumbling steps in PDL
in thread first stumbling steps in PDL
Either I don't understand how ctricpy is supposed to work, or it is broken, or both. If a complex matrix is fed to ctricpy, the result, its type and dimensions look strange. OTOH, with a "matrix" representing Re and Im, the result looks good, but it can be achieved using tricpy as well (after reordering dims).
#!/usr/bin/perl use v5.24; use warnings; use PDL; use PDL::LinearAlgebra::Complex; my $m1 = pdl '[[0, i], [1, 1+i]]'; ctricpy($m1, 0, my $c = null); say $c->info; say "complex: $c"; my $m2 = sequence 2, 3, 3; ctricpy($m2, 0, $c = null); say $c->info; say "Re + Im:", $c->reorder(1, 2, 0); say "tricpy:", $m2->reorder(1, 2, 0)->tricpy(0); __DATA__ PDL: LDouble D [2,2,1] complex: [ [ [0 0] [1 1] ] ] PDL: Double D [2,3,3] Re + Im: [ [ [ 0 2 4] [ 0 8 10] [ 0 0 16] ] [ [ 1 3 5] [ 0 9 11] [ 0 0 17] ] ] tricpy: [ [ [ 0 2 4] [ 0 8 10] [ 0 0 16] ] [ [ 1 3 5] [ 0 9 11] [ 0 0 17] ] ]
Adding complex as type to the input and output arguments in tricpy's signature makes it complex-aware and it works for real and complex matrices. Thus ctricpy might be superfluous. The result from an accordingly modified tricpy on the complex matrix $m1 is:
[ [ 0 i] [ 0 1+i] ]
Greetings,
-jo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: first stumbling steps in PDL
by etj (Priest) on Feb 08, 2024 at 02:07 UTC |