Yes Ed, you are right.
I want to perform different operations on $r
depending on its distance to a point $r0 in 2D.
Then, I guess that first, and because for further
manipulation, I decide to center $r-=$r0 in
such a point.

Then in false code,

if ( length ($r)  < $a)
 { return f($r)}
 else
{ return g($r) }

where "length" I am not sure, but it could be inner($r,$r)->sqrt.
Maybe no ternary expression but some subroutine will be fine also.

Regards












El mar, 21 ene 2025 a las 14:16, Ed . (<ej...@hotmail.com>) escribió:

> Hi Guillermo,
>
> That conditional will, for the case you've given, always be false, because
> it has values more than 0.2 away from 0.5. When you use all, you are
> asking a question about the entire ndarray, in other words for every single
> value in it.
>
> I believe that there's some real problem you're trying to solve, but I'm
> afraid I still have absolutely no idea what it is. Please help me help you!
>
> Best regards,
> Ed
>
> ------------------------------
> *From:* Guillermo P. Ortiz <gor...@exa.unne.edu.ar>
> *Sent:* 21 January 2025 01:19
> *To:* Ed . <ej...@hotmail.com>
> *Cc:* pdl-devel@lists.sourceforge.net <pdl-devel@lists.sourceforge.net>;
> perldl <pdl-gene...@lists.sourceforge.net>
> *Subject:* Re: [Pdl-devel] conditional inline
>
> Ok, Ed,
> That example did not work for me.
> The conditional results seems to be allways false. I mean, that it give $x
> also when $x is near to 0.5 than 0.2, where I is expecting the $x**2 result.
>
> Regates
>
>
>
> El El lun, 20 ene 2025 a la(s) 20:39, Ed . <ej...@hotmail.com> escribió:
>
> Hi Guillermo,
>
> You may still be having a problem, but you have yet to tell us what it is.
> The code you sent works fine, including as many dimensions as you like
> (because all acts on the whole ndarray at once).
>
> If there's a problem in there, please share it :-)
>
> Best regards,
> Ed
>
> ------------------------------
> *From:* Guillermo P. Ortiz <gor...@exa.unne.edu.ar>
> *Sent:* 20 January 2025 23:35
> *To:* Ed . <ej...@hotmail.com>
> *Cc:* pdl-devel@lists.sourceforge.net <pdl-devel@lists.sourceforge.net>;
> perldl <pdl-gene...@lists.sourceforge.net>
> *Subject:* Re: [Pdl-devel] conditional inline
>
> Thanks Ed,
> Using ternary conditional expression
> I still have some problem with múltiple disensión case.
> See my example in message befare
>
>
> El El lun, 20 ene 2025 a la(s) 19:31, Ed . <ej...@hotmail.com> escribió:
>
> Hi Guillermo,
>
> You can do that indeed, that's just Perl. If you wanted to do operations
> on a subset of that ndarray, then you'd do e.g.
>
> $pdl->where(($pdl-0.5)->abs < 0.2) *= 5;
>
> An observation is that the above condition could be a bit shorter by using
> the recently-added approx_artol: (which would also mean it ran quicker)
>
> $pdl->approx_artol(0.5, 0.2)
>
> Best regards,
> Ed
>
> ------------------------------
> *From:* Guillermo P. Ortiz <gor...@exa.unne.edu.ar>
> *Sent:* 20 January 2025 19:39
> *To:* pdl-devel@lists.sourceforge.net <pdl-devel@lists.sourceforge.net>;
> perldl <pdl-gene...@lists.sourceforge.net>
> *Subject:* [Pdl-devel] conditional inline
>
> Hello !
>
> I am not sure, but maybe It is possible to do with perl PDL something
> like this?
>
> $ndarray= condition on $ndarray ? assign when true : assign when false
>
> for example:
>
> $x=zeroes(20)->xlinvals(0,1);
>
> $y=(all abs($x-0.5)<0.2)?$x**2:$x;
>
> Thanks in advance
>
> Regards
>
> --
>
>
> Dr. Guillermo P. Ortiz
> Electromagnetismo Aplicado
> Dto. Física, Facultad de Ciencias Exactas
> Universidad Nacional del Nordeste
> Avda Libertad 5460
> <https://www.google.com/maps/search/Avda+Libertad+5460?entry=gmail&source=g>,
> Campus UNNE.
> W3404AAS Corrientes, Argentina.
> (+54) 379-4424678 interno 4613
> gortiz* at *unne edu ar
>
>
_______________________________________________
pdl-devel mailing list
pdl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-devel

Reply via email to