The "clip" operators in PDL::Primitive (lclip, hclip, clip) are very
close to this in functionality, so maybe extending them to provide both
a level trigger and a value?
e.g.,
$pdl = pdl( 0, 0.25, 0.5, 1 );
# current
lclip($pdl, 0.25 ) => [ 0.25, 0.25, 0.5, 1]
# proposed
lclip( $pdl, 0.25, 0 ) => [ 0, 0, 0.5, 1 ]
On 5/6/22 14:35, Ed . wrote:
I believe Ingo’s solution is closest to what Guillermo was asking for,
though Zaki’s idea may offer a different approach to whatever
Guillermo’s actual problem is.
This is also a function that would be useful in a couple of places in
PDL::LinearAlgebra. What do people think of a new
PDL::Primitive::ismembertol (named after the MATLAB function), which
you could use here like:
$pdl *= !$pdl->ismembertol(0, $epsilon); # still three operations:
ismembertol, not, mult
And/or “tol0” which could be used like this:
$pdl->inplace->tol0($epsilon); # one operation
Does that seem like a good idea, and/or the correct names for these?
Best regards,
Ed
*From: *Ingo Schmid <mailto:ingo...@gmx.at>
*Sent: *05 May 2022 16:30
*To: *pdl-general@lists.sourceforge.net
*Subject: *Re: [Pdl-general] [Pdl-devel] replace very small numbers
HI,
Use the comparison operator to create a mask and multiply it onto your
data.
$gr= abs (grandom (5,5))
p $gr*($gr>0.1)
[
[ 1.1689305 1.2499314 0.71939273 0 0.73171201]
[0.31795298 1.0656512 0.32072078 0.58750721 0.36339994]
[ 0 2.0256596 1.1261147 1.0729967 1.7958531]
[0.28044179 0.45181403 1.3248066 0.97292087 0.29573919]
[ 0 0.29361551 1.0373939 0.25552433 0.10957606]
Ingo
On 5/5/22 17:21, Zakariyya Mughal wrote:
On 2022-05-05 at 10:57:53 -0300, Guillermo P. Ortiz wrote:
Hello,
somebody know if there are a quick way
to set all very small number to zero into a ndarray?
Hello,
If I understand correctly, I believe that you can achieve this using the
`where` function<https://metacpan.org/pod/PDL::Primitive#where>
<https://metacpan.org/pod/PDL::Primitive#where> to
create a mask.
Cheers,
- Zaki Mughal
Regards
--
Dr. Guillermo P. Ortiz
Electromagnetismo Aplicado
Dto. Física, Facultad de Ciencias Exactas
Universidad Nacional del Nordeste
Avda Libertad 5460, W3404AAS Corrientes,
Argentina.
(+54) 379-4424678 interno 4613
gortiz* at *unne edu ar
_______________________________________________
pdl-devel mailing list
pdl-de...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-devel
_______________________________________________
pdl-general mailing list
pdl-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-general
_______________________________________________
pdl-general mailing list
pdl-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-general
_______________________________________________
pdl-general mailing list
pdl-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-general