-
Notifications
You must be signed in to change notification settings - Fork 185
[stdlib_linalg] Issue with maxval(abs(B-eye(k))
where B
is a complex matrix.
#920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
maxval(abs(B-eye(k)) where
B` is a complex matrix.maxval(abs(B-eye(k))
where B
is a complex matrix.
@loiseaujc I copy-pasted your mwe into Compiler Explorer and changed the gfortran versions, I saw that this error happens with version 13.1, not with 13.2, comes back with gfortran 14.1. I suspect this to be related with temporary arrays being created in the first case. I would say this is a compiler bug and not an issue with stdlib per-se. Would have to check with ifort/ifx to cross check. |
It would seem like a bug with gfortran, because printing A slightly deeper look highlights that if the single precision version of
so it looks like gfortran is mismatching something in the conversion (default |
All our tests failed since shortly before Christmas despite not changing a single line in our CI. I had not seen #902, but I suppose this is the culprit. I'll fix our tests with the Thanks. |
It really looks unrelated to stdlib: Compiler explorer. It seems the issue is only present if Now, @loiseaujc if you find a safe way (i.e., changing the default return type for |
Yep, came to the same conclusion indeed.
At the moment, I simply do |
Description
I have a surprising issue when combining fortran intrinsic functions
maxval
andabs
with some functions fromstdlib
.Consider the code below.
This is an extremely simplified version of what we're doing in a library we're working on where the call to
qr
followed byB = matmul(transpose(conjg(Q)), Q)
basically emulates a complicated function that should return an orthonormal set of vectors. In our unit tests, we then simply usemaxval(abs(B - eye(k)))
which should be of the order of the machine precision to ensure thatB
is indeed the Gram matrix of an orthonormal set of vectors.When compiling this code with
fpm run --compiler "gfortran"
, here is the outputWhile the second print statement is correct, the first one is not.
For comparison, if I compile with
fpm run --compiler "ifx"
, I get the expected outputI'm running with
gfortran 13.3
btw. To me, the error comes fromgfortran
(possible type conversion) rather thanstdlib
but I just wanted to raise the issue here to see if anyone can reproduce before reporting this possiblegfortran
bug.Expected Behaviour
The two statements
maxval(abs(B - eye(k)))
andmaxval(abs(C))
should return the same value.Version of stdlib
latest
Platform and Architecture
Ubuntu 22.04, Linux ,gfortran 13.3
Additional Information
No response
The text was updated successfully, but these errors were encountered: