My belatedly reply to this. I don’t have any improvements to suggest over 
Jörg’s ideas, just a general observation.

The tests in PLplot are also demos of its capabilities. I recently updated 
PDL::Graphics::PLplot’s tests, because I was copying from them to make a modest 
demo. The demo now exists as part of P:G:PLplot’s distro, so if you have a 
recent PDL and the latest P:G:PLplot, you can do “demo” to see it in the list, 
and “demo plplot” to see the demo itself.

I mention this because previously the PDL versions of the tests were quite 
literal translations of the C code, with lots of for loops, ->at(), and 
->set(). A way to immediately eliminate many for loops (or, here, maps) is to 
make a sequence as Jörg did, possibly with a dummy dim (if you have two nested 
for-loops). Often you will find you can just use that sequence instead of the 
value variable in a map, thanks to the power of array programming.

Speaking of dummy dims, I’m currently updating Tuomas’s excellent 
contour_segments operation, having moved it out of the PDL::Graphics::TriD into 
PDL::ImageND so it will always be available (the algorithm isn’t even 
inherently 3d). Looking up how MATLAB does contouring, the docs mentioned 
“meshgrid” (which would be useful to replace small bits of code in those PLplot 
tests). It annoyed me that PDL didn’t have that, so now it does (which will be 
in the next release). The contouring stuff is because I’m updating 
PDL::Graphics::Simple to have contouring for all 4 of its supported engines, 
and Prima and Gnuplot don’t have suitable support currently so I’m making PDL 
able to back-fill that. (Yes, Gnuplot does have contours but only for a 3d 
plot, and I didn’t want to break the paradigm of 2d plots just for that)

Best regards,
Ed

From: Jörg Sommrey<mailto:[email protected]>
Sent: 21 April 2024 13:51
To: [email protected]<mailto:[email protected]>
Subject: Re: [Pdl-general] [Pdl-devel] histogram data-flow version?

Or:

($a x (abs($b->dummy(0) - (sequence(7) - 3)) < $delta))->reshape(-1)

-jo

On Sun 21 Apr 2024 01:42:06 PM CEST, Jörg Sommrey <[email protected]> wrote:

> Hi Guillermo,
>
> if you really dislike "map", here is something "pure PDL". I don't
> think it's faster.
>
> sumover((abs($b - (sequence(7) - 3)->dummy(0)) < $delta) * $a)
>
> Regards,
> -jo
>
> On Sun 21 Apr 2024 03:59:38 AM CEST, "Guillermo P. Ortiz"
> <[email protected]> wrote:
>
>> Hello Ed, and everybody
>>
>> Thanks you for your support. It seems that my hugly version run fine.
>> for example if you say:
>>
>> @step=(-3..3);
>> $delta=0.2;
>> $a= random 10 ;
>> p $a
>> [0.14131203 0.47726154 0.82804992  0.2434997 0.85820099 0.96016326
>> 0.27934906 0.86615821 0.0021721009 0.40816451]
>>
>> $b=6 * (random(10) - 0.5);
>> p $b
>> [-0.9238657 -0.36773012  1.5925504  2.3318518  2.3221372  0.6427431
>> -2.5881474 -1.1867935 -0.49514867 -2.4092028]
>>
>> p map {$a->index(which(abs($_-$b)<$delta))} @step ;
>>
>> Empty[0] Empty[0] [0.14131203 0.86615821] Empty[0] Empty[0] Empty[0]
>> Empty[0]
>>
>> Meaning that the only case of @step that is near of $b in less than $delta
>> is the first and the eighth value of $b. Then , I want the cumulant from $a
>> which have the same index than $b.
>>
>> p map {$a->index(which(abs($_-$b)<$delta))->sum} @step
>>
>> 0 0 1.00747024047426 0 0 0 0
>>
>> In agreement to my desired result for this example.
>> Maybe PDL has yet a dataflows version like or some better tricks for this
>> task?
>>
>>
>> Regards
>>
>>
>> El vie., 19 de abril de 2024 19:01, Ed . <[email protected]> escribió:
>>
>>> Hi Guillermo,
>>>
>>>
>>>
>>> The two Sourceforge lists are still in operation; the JACH one went away
>>> years ago so I’ve removed it from the “To” list.
>>>
>>>
>>>
>>> Please can you expand on this by giving a small amount of sample data
>>> input, with the output you’d like?
>>>
>>>
>>>
>>> Best regards,
>>>
>>> Ed
>>>
>>>
>>> ------------------------------
>>> *From:* Guillermo P. Ortiz <[email protected]>
>>> *Sent:* Friday, April 19, 2024 9:49:46 PM
>>> *To:* PDL Forum <[email protected]>;
>>> [email protected] <[email protected]>;
>>> [email protected] <[email protected]>
>>> *Subject:* [Pdl-devel] histogram data-flow version?
>>>
>>> Dear Perl Folks,
>>> Maybe did you have solved this kind of question?
>>>
>>> I have to use two related $a. $b ndarray performing
>>> some computation on $b that could be
>>> used to map with $a
>>>
>>> I have a horrible solution for my specifique problem
>>> but it is sure that PDL has a cleaver version for solving it
>>>
>>> @step=(-3..3);
>>> $delta=0.2;
>>> @res= map {$a->index(which(abs($_-$b)<$delta))->sum} @step ;
>>>
>>> Then, the list @res cumulates data of $a for which $b are
>>> in a desire intervals
>>>
>>> Regards
>>>
>>> PS: sorry if I sent my post to a wrong email list
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>>
>>>
>>> Dr. Guillermo P. Ortiz
>>> Electromagnetismo Aplicado
>>> Dto. Física, Facultad de Ciencias Exactas
>>> Universidad Nacional del Nordeste
>>> Avda Libertad 5460, Campus UNNE.
>>> W3404AAS Corrientes, Argentina.
>>> (+54) 379-4424678 interno 4613
>>> gortiz* at *unne edu ar
>>>
>
>
>
>
> _______________________________________________
> pdl-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pdl-general




_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to