Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

PDL How to create/initialise a large byte piddle directly.

by BrowserUk (Patriarch)
on Oct 19, 2006 at 21:44 UTC ( [id://579474]=perlquestion: print w/replies, xml ) Need Help??

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

I can initialise a large 2D piddle using zeroes and then convert that to a byte piddle:

perldl> $a = zeroes 1000, 1000 perldl> $b = byte $a perldl> help vars PDL variables in package main:: Name Type Dimension Flow State Mem ---------------------------------------------------------------- $a Double D [1000,1000] P 7.63Mb $b Byte D [1000,1000] P 0.95Mb

I can then undef $a to discard the default Double piddle and recover space

perldl> undef $a perldl> help vars PDL variables in package main:: Name Type Dimension Flow State Mem ---------------------------------------------------------------- $b Byte D [1000,1000] P 0.95Mb

And I can do that all in one line:

perldl> $c = byte zeroes 1000,1000 perldl> help vars PDL variables in package main:: Name Type Dimension Flow State Mem ---------------------------------------------------------------- $c Byte D [1000,1000] P 0.95Mb $b Byte D [1000,1000] P 0.95Mb

but it appears as if the latter still creates the 8-times bigger intermediary before automatically discarding it.

Is there a way to create a large 2D byte piddle directly?

I'm just starting to find my way around the PDL docs and I seem to be missing this example.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re: PDL How to create/initialise a large byte piddle directly.
by explorer (Chaplain) on Oct 19, 2006 at 23:03 UTC

    From PDL::Core:

    $c = zeroes( byte, 1000, 1000);
    Update: Is VITAL for you to subscribe to pdl mailing list!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2025-06-18 21:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.