Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

PDL newbie question

by genecutl (Beadle)
on Sep 17, 2004 at 19:03 UTC ( #391875=perlquestion: print w/replies, xml ) Need Help??

genecutl has asked for the wisdom of the Perl Monks concerning the following question:

I'm just getting started with PDL and I have a very dumb question, but I can't figure this out from the docs. How do I extract a pdl into a regular perl data structure, such as a 1 dimensional pdl array into a regular perl array?

All I can find is the 'at' command which will pull out a single scalar at a time, but I believe firmly that the perl that I know and love wouldn't make me manually iterate over all the elements of a pdl to extract the data.

Replies are listed 'Best First'.
Re: PDL newbie question
by duff (Parson) on Sep 17, 2004 at 20:25 UTC
    #!/usr/bin/perl use PDL; my $s = sequence 10; my @s = list $s; # or @s = $s->list; print "@s"; __END__

    A very useful thing to do (well, I think so anyway) is to type "perldl" at your command prompt and from the PDL shell, query the PDL docs with ? and ??

Re: PDL newbie question
by etj (Chaplain) on Jun 22, 2022 at 20:39 UTC
    In 2013, the mighty Joel Berger added unpdl which was first released in PDL 2.006. Not very surprisingly, it does the reverse operation of pdl.
Re: PDL newbie question
by genecutl (Beadle) on Sep 20, 2004 at 21:11 UTC
    Thanks. I have been going through the PDL docs. While I'm finding lots of information for working with data in pdls, I'm seeing little on getting data in and out. So let give you my specific situation:

    I'm working with a 3d perl array containing data that I'm pulling out of a database. I calculate various statistics and do some transformations of the data before re-inserting it into the database in a different table. I want to try using PDL for doing the statistics and transformations steps.

    I'm coming across things in the PDL docs that look like the could be taking me in the right direction, but it seems like it mostly already assumes a high level of knowledge. The more basic sections of the documentation (e.g. PDL::Impatient) don't cover the input/output stuff that I need in any kind of detail.

Re: PDL newbie question
by ccn (Vicar) on Sep 17, 2004 at 19:06 UTC

    did you search PDL on cpan?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://391875]
Approved by ccn
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2022-09-24 16:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (114 votes). Check out past polls.

    Notices?