Hi Luis,

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.

More conceptually, I feel that LAPACK bindings should not make copies of their 
inputs, that is for higher-level wrappings to do. In your case I believe that's 
in Photonic::Util?

Best regards,
Ed
________________________________
From: Luis Mochan <moc...@icf.unam.mx>
Sent: 04 December 2024 11:54 PM
To: perldl <pdl-gene...@lists.sourceforge.net>; perldl 
<pdl-devel@lists.sourceforge.net>
Subject: [Pdl-devel] cgtsv

Hi,
I use the routine
    PDL::LinearAlgebra::Complex::cgtsv
to solve systems of linear equations described by a tridiagonal
matrix. The arguments are the sub-diagonal, the diagonal, the
supradiagonal and the right hand side of the equations. I found one of
my programs has a misterious error, as  it uses cgtsv to solve a
symmetric tridiagonal system,

my $sub_diagonal=my $supra_diagonal;
cgstv($sub_diagonal, $diagonal, $supra_diagonal, $right_hand_side);

I didn't realize until today that cgstv modified the contents of the
$sub_diagonal array, and thus, it silently and erroneously modified the
$supra_diagonal, which in my case was an ndarray that shared the
numerical data.

The signature of the function is:

 cgtsv
      Signature: (complex [phys]DL(n);complex  [phys]D(n);complex  
[phys]DU(n);complex  [io,phys]B(n,nrhs); int [o,phys]info())

As the parameter 'DL' is not marked 'io' I erroneously assumed it wouldn't be
modified, although the documentations states further down that it
does.

My questions are: Is the signature above correct? Should parameters
that are modified be marked 'io' or something else? Or would it be better
for routines such as cgtsv to make a copy of their inputs to avoid
modifying the original arguments? Would it be considered too costly in
general?

Best 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
_______________________________________________
pdl-devel mailing list
pdl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-devel

Reply via email to