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

Reply via email to