use strict; use warnings; use PDL; use Inline Pdlpp => << 'EOPP'; pp_def('FtoC', DefaultFlow => 1, # Mark as a dataflow operator NoPdlThread => 1, # Turn off threadsafe generated code (doesn't work) P2Child => 1, # Declares $PARENT and $CHILD parameters Reversible => 1, # Enable BackCode RedoDims => << 'EORD', # No RedoDims by default - this just copies $PARENT dims to $CHILD. long ii; $SETNDIMS($PARENT(ndims)); for(ii=0; ii<$PARENT(ndims); ii++) { $CHILD(dims[ii]) = $PARENT(dims[ii]); $CHILD(dimincs[ii]) = $PARENT(dimincs[ii]); } $CHILD(datatype) = $PARENT(datatype); $SETDIMS(); EORD Code => '$CHILD() = ($PARENT() - 32) * 5/9; ', BackCode => '$PARENT() = ($CHILD() * 9/5) + 32; ' ); EOPP ; *FtoC = \&PDL::FtoC; use feature 'say'; my $F = pdl(32); my $C = $F->FtoC; say $C; $C++; say "$F F = $C C"; $F++; say "$F F = $C C"; 1;