Hi,

I've tried to create a PP function to calculate the Hankel matrix from a vector. I used Inline pdlpp. Whenever I run the function, I get an out of memory error. I tried explicit for loops as well. There is no good example in the book or the docs where output dimensions are calculated based on input. In this case l depends on n and m.

pp_def ('fid_to_hankel2',
        Pars=>'v(n); [o]hankel(l,m)',
        OtherPars=>'int ms => m',
        Code => pp_line_numbers(__LINE__, q{
                PDL_Indx ns = $SIZE(n);
                PDL_Indx m,l;
                l=ns-m+1;
                printf ("size n %d , l %d , m %d\n",ns,l,m);
                loop(n) %{
                loop(l) %{
                        loop(m) %{
                                $hankel()=$v(n=>l+m);
                                printf ("n %d = l %d + m %d\n",l+m,l,m);
                        %}
                %}
                %}
        }), # line_numbers
        );

I know that the Hankel matrix can be created efficiently using xvals, yvals and index.

sub hankel {
        my $fid=shift;
        my $rank=shift;
        my $size=($rank,$fid->dim(0)-$rank+1);
        my $ind=xvals($size)+yvals($size);
        $fid->index($ind);
}

Nonetheless I would like to understand what's going on. Btw., that's with pdl 2.019 on linux 64 bit. Other PP functions work alright.

Best wishes

Ingo


_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to