GrandFather has asked for the wisdom of the Perl Monks concerning the following question:
I'm testing some module code I'm working on and need a way to visualise a surface. PDL seems a pretty natural fit for manipulating the data. However I would like to initialise a 2D structure with values that are a function of grid location. Ideally I'd be able to do something like:
use warnings; use strict; use PDL; my @funcs = ( '1/(0.5 + 0.02 * $i*$i) * cos($i)', '1/(0.5 + 0.02 * $i*$i) * cos($i)', ); my $surface = initPDL (\&shape, (10) x @funcs); ... sub shape { my @values = @_; my $sum = 0; for my $idx (0 .. $#values) { my $i = $values[$idx]; my $value = eval $funcs[$idx]; $sum += $value * $value; } return sqrt ($sum); }
The "tricky/cool" bit is the putative my $surface = initPDL (\&shape, (10) x @funcs); line. Does PDL provide a way do do something of that sort?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I need a liddle piddle advice
by plobsing (Friar) on Oct 14, 2008 at 07:49 UTC | |
by GrandFather (Saint) on Oct 14, 2008 at 09:53 UTC |