Frage

I have a function that uses PDL. The final step is a dot product so it returns a scalar. However, when I try to print this scalar, it is clearly still a piddle and prints like this on screen:

[
  [ 3 ]
]

I'm wondering how I can convert it back to the regular Perl scalar so that it prints like:

3 

More importantly, what is the consequence if I don't convert and take that piddle on to further arithmetic manipulations in a pure Perl context (that does not involve PDL). Thx!

War es hilfreich?

Lösung

Use the sclr method, which converts a single-element PDL matrix with any number of dimensions into a simple Perl scalar

my $dotp = sclr($mata x $matb);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top