Hi

I am trying to write a function using thread_define that does some
conditional checks and creates a PDL with the output. I know I can use
PDL::PP to do this but that is not what I want here. I want to
auto-generate some  PDL code at runtime to be used like apply()/sapply()
in R.

However, I am getting stuck at a trivial point and I keep getting an
error that says "multielement piddle in conditional expression".

Here is an  example that reproduces the error:

    use PDL;
    use PDL::NiceSlice;

    my $ohlc = ones(100, 4) + sequence(100, 4) * 0.05;

    thread_define 'myfunc($o(n);$h(n);$l(n); $c(n); [o]$e(n))', over {
        $_[4] .= ($_[1] - $_[2]) > ($_[3] - $_[0]) ? 1 : 0;
    };

    my $b = null;
    myfunc($ohlc(,(0)), $ohlc(,(1)), $ohlc(,(2)), $ohlc(,(3)), $b);
    print $b, "\n";


I am not able to understand why there is a multielement piddle problem.
Each piddle is of the same dimension except for the output $b which is
null() and hence can grow in size as needed.

Please advise.

Thanks
Vikas.


_______________________________________________
Perldl mailing list
Perldl@jach.hawaii.edu
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to