Thanks Zaki, Following you, if $a is a ndarray with some very small numbers smaller than $tol, then:
my $b=$a->where(abs($a) < $tol); $b.=0; the $a has now zero instead of the very small numbers, but is it possible a better solution ? Let me put a clear context for such situations using PDL::LA::meigen() use PDL::LinearAlgebra; my $a=pdl([1.0,1e-132],[1e-132,1.0]) my ($ev,$le,$re)=meigen($a,1,1); say $re [ [ 0.707106781186547 -0.707106781186547] [ 0.707106781186547 0.707106781186547] ] (It is a non expected result) but, like 1e-132 is very small for a tolerance $tol =1e-10 my $b=$a->where(abs($a) < $tol); $b.=0; say $a [ [1 0] [0 1] ] my ($ev,$le,$re)=meigen($a,1,1); say $re [ [1 0] [0 1] ] Here, we can see also that meigen() is not working like one might expect, I mean that for $a near to the identity case we are expecting also $re near to the identity case. The suggested solution taken by Zaki idea work, but I am afraid for a bug in meigen(). Regards Regards El jue, 5 may 2022 a las 12:21, Zakariyya Mughal (<zaki.mug...@gmail.com>) escribió: > 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> 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-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/pdl-devel > > > > _______________________________________________ > pdl-devel mailing list > pdl-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pdl-devel >
_______________________________________________ pdl-devel mailing list pdl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-devel