Reputation: 425
Is there an absolute value function for a complex value in double precision? When I try CABS()
I get
V(1,j) = R(j,j) + (R(j,j)/cabs(R(j,j)))*complexnorm2(R(j:m,j))
"Error: Type of argument 'a' in call to 'cabs' at (1) should be COMPLEX(4), not COMPLEX(8)"
I have read there's a function called CDABS()
but I wasnt sure if that was the same thing?
Upvotes: 3
Views: 5256
Reputation: 724
COMPLEX*8 and complex(KIND=8) are not the same. The first one, is 4 byte real and 4 byte imaginary.
The complex(KIND=8) or COMPLEX(KIND=C_DOUBLE) is actually a double precision real and double precision imaginary... So equivalent to COMPLEX*16.
As mentioned ABS() should be fine.
Upvotes: 0
Reputation: 32406
CABS
is defined by the standard to take an argument of type default complex. In your implementation this looks like complex(kind=4)
. There is no standard function CDABS
, although your implementation may perhaps offer one: read the appropriate documentation.
Further, there is no standard specific function for the generic function ABS
which takes a double complex
argument. Again, your implementation may offer one called something other than CDABS
.
That said, the generic function ABS
takes any integer, real, or complex argument. Use that.
Upvotes: 2
Reputation: 60058
There is no reason using anything else than ABS()
. Generics for intrinsic procedures were already present in FORTRAN 77. You can use them for all intrinsic numeric types.
If you want to see the table of available specific functions of the generic ABS()
, see https://gcc.gnu.org/onlinedocs/gfortran/ABS.html , but they are mostly useful only to be passed as actual arguments. You can see that CDABS()
is a non-standard extension and I do not recommend to use it.
Upvotes: 5