Perl 6 - the future is here, just unevenly distributed

IRC log for #pdl, 2012-12-10

| Channels | #pdl index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
03:35 Molaf joined #pdl
10:29 Molaf joined #pdl
16:14 run4flat Mithaldu, sorry I didn't notice your questions before
16:14 run4flat I've been busy with work, of all things!
16:14 run4flat So, you have a pdl with 280000 values
16:14 run4flat you want 400 values starting at 56000
16:15 run4flat I would use NiceSlice because it makes all of this expressible in a single line
16:15 run4flat if you use the "slice" method, you can do it with a temporary variable
16:15 Mithaldu run4flat: i'm aware of slices, i was asking for a specific slice apu
16:16 Mithaldu *api
16:16 run4flat Here are some lines of code you can run at the perldl prompt
16:16 run4flat $pdl = sequence(280000)
16:16 Mithaldu run4flat: stop stop
16:16 run4flat $slice = $pdl(56000:56000+400-1)
16:16 Mithaldu i'm a newbie, but not *that* newbie :)
16:17 run4flat that's your api
16:17 run4flat :-)
16:17 run4flat I didn't think you were that newbie
16:17 run4flat :-)
16:17 Mithaldu and yeah, i kinda figured out already there is no better way
16:17 Mithaldu more importantly
16:17 Mithaldu can i dump a string of bytes into piddles?
16:17 run4flat yes
16:18 * run4flat digs around
16:18 run4flat the functions you would use are get_dataref and upd_data
16:19 run4flat their documentation is not stellar, but you can get a good idea from the PDL::IO::FastRaw code
16:20 run4flat start reading in this vicinity: https://github.com/PDLPorters/pdl/blob/master/IO/FastRaw/FastRaw.pm#L385
16:21 run4flat It's not *entirely* what you want out of the box, but you can use this to get there
16:21 Mithaldu hrm
16:21 Mithaldu that's all some pdl-specific serialization
16:21 run4flat no
16:21 run4flat it's a load from disk
16:21 run4flat as a straight dump to file
16:21 run4flat of the C array
16:21 Mithaldu well it mentiones some kind of header there
16:21 run4flat look at writefraw a few lines up
16:21 run4flat that's because it needs to know the datatype and size
16:22 Mithaldu ok
16:23 run4flat The take away: 1) load data into a Perl scalar, in this case from a file
16:23 run4flat 2) copy those values into the dereferenced scalar returned by $pdl->get_dataref
16:23 Mithaldu why does pdl depend on opengl? that's kind of odd
16:23 run4flat In your case
16:23 run4flat ... I didn't think it did anymore
16:24 run4flat I thought that dependency is only there temporarily for a few rounds of testing releases
16:24 run4flat does it still?
16:24 Mithaldu on metacpan it says it does
16:24 run4flat Hrm
16:24 Mithaldu anyhow, i got a very rough idea now. thank you :)
16:24 run4flat you're welcome!
16:25 run4flat Basically, PDL uses Perl scalars to manage the data allocation; those methods allow you to access those scalars
16:25 run4flat I think you can figure out everything else from there
16:25 run4flat If you need to *set* the scalar to something you've already allocated, I think that'll require some XS cod
16:26 run4flat but I know how to do it, so just let me know
16:26 run4flat :-)
16:27 Mithaldu all i wanna do is load a long array without unpacking it in perl first
16:31 run4flat oh, then writing a header that FastRaw knows how to read may be exactly what you need
16:32 run4flat In fact, if it's *really* long, you could even use memory mapping
16:47 Mithaldu i'm on windows and it's not that long
16:47 Mithaldu just 100mb or so
16:48 Mithaldu well, since i used a MUCH lower sample rate to cross-correlate faster it's more like 2 mb, but whatever :P
18:02 run4flat I believe that, as of 2.4.11, memory mapping now works on windows. :-)
18:05 run4flat but you're right, you don't need to memory map 2 mb
18:59 Mithaldu run4flat: if anything, i'd most benefit from simple example scripts of such techniques ;)
19:29 run4flat long array == 32 bit?
19:29 * run4flat fires up github's gist
19:33 Mithaldu run4flat: i'm actually working with signed 16 bit integers
19:34 Mithaldu but really, whatever is fine :)
19:34 run4flat ok, I think that'll work
19:34 run4flat gimme a sec
19:35 run4flat perfect, short is the datatype we need
19:38 shadowpaste "run4flat" at 217.168.150.38 pasted "Basic loading of a direct dump of a C array of signed short integers" (18 lines) at http://paste.scsys.co.uk/218007
19:39 run4flat not tested, as I don't have any signed short integer data lying around
19:39 run4flat presumably NDims => 1
19:41 run4flat then you could calculate the (one) number in dims with: $n_elements = (-s $filename) / length(pack 's', 0);
19:44 shadowpaste "run4flat" at 217.168.150.38 pasted "Basic loading of a direct dump of a C array of signed short integers; autocompute the dimension" (19 lines) at http://paste.scsys.co.uk/218008

| Channels | #pdl index | Today | | Search | Google Search | Plain-Text | summary