Hi Ed, On Thu, Dec 05, 2024 at 07:15:39AM +0000, Ed . wrote:
> If an input parameter gets modified, it absolutely needs to be > marked [io]. Please could you open an issue on the repo noting at > least that operation, and any others you spot that have the same > problem? Sorry for missing that here. Sure. Some routines modify its input to give some information back. Some modify its input only to save memory, and give no useful information back. So in both cases, they should be marked 'io'. > More conceptually, I feel that LAPACK bindings should not make > copies of their inputs, that is for higher-level wrappings to do. Agreed. > In your case I believe that's in Photonic::Util? Yes. I actually don't fully understand the current version of Photonic::Util::cgtsv, as it makes copies only of inplace ndarrays and marks them not inplace, but lapack's cgtsv modifies them anyway. Now I have a more general doubt. Consider some class that has a ndarray field, say ndarray, and an immutable object $obj of that class. After I get the ndarray my $pdl=$obj->ndarray; if I modify $pdl using any of the operator-assignments .=, *=, +=,... or by incrementing/decrementing, or by using some inplace operation, I guess I would be modifying the data within the object violating its immutability! What is the best way to protect the class and avoid this risk? I guess the object might return a copy of the ndarray, but that could be unnecessarily costly. It could also 'sever' the return value, but I still haven't understood the 'sever' method, and I'm not sure it would always protect the object's data. Is there, or could there be, some flag to mark a pdl as immutable, so that an error is raised whenever an attempt is made to modify it. I guess this would be easy to implement for the PDL operators, but I'm not sure if it would work when an external routine, such as those from lapack, are fed with pointers to the pdl's data. Regards, Luis -- o W. Luis Mochán, | tel:(52)(777)329-1734 /<(*) Instituto de Ciencias Físicas, UNAM | fax:(52)(777)317-5388 `>/ /\ Av. Universidad s/n CP 62210 | (*)/\/ \ Cuernavaca, Morelos, México | moc...@fis.unam.mx /\_/\__/ GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16 C2DF 5F0A C52B 791E B9EB _______________________________________________ pdl-devel mailing list pdl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-devel