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

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

In reply to Re^7: first stumbling steps in PDL by jo37
in thread first stumbling steps in PDL by Discipulus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.