You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The intrinsic conjg() accepts only arguments of type complex. However, there are numerous instances in linear algebra and machine learning where a generic algorithm must work for data types of real and complex (and possibly integer).
This limited functionality of the current conjg() leads to the mushroom-like growth of non-standard preprocessor macro definitions in such generic algorithms.
As an example, this conjg() functionality extension could reduce the size of the original BLAS/LAPACK codebase to almost half (by removing separate duplicated routines for complex and real data types (along with perhaps a few other algorithmic changes)).
The proposed extension would lead to the following trivial behavior: conjg(x) := x if x is of type integer or real.
The text was updated successfully, but these errors were encountered:
You can extend generic intrinsic functions to handle more types.
module m
interface conjg
module procedure rconjg
module procedure iconjg
end interface
contains
real elemental function rconjg(x)
real, intent(in) :: x
rconjg = x
end
integer elemental function iconjg(x)
integer, intent(in) :: x
iconjg = x
end
end
use m
print *, conjg(1.), conjg(2), conjg((3.,4.))
end
Why did the standard introduce conjg() in the first place when it can be so easily implemented as a user-defined function?
module m
contains
complex elemental function conjg(x)
complex, intent(in) :: x
conjg = cmplx(real(x), -aimag(x))
end
end
print *, conjg((3.,4.))
block
use m
print *, conjg((3.,4.))
end block
end
The intrinsic
conjg()
accepts only arguments of typecomplex
. However, there are numerous instances in linear algebra and machine learning where a generic algorithm must work for data types ofreal
andcomplex
(and possiblyinteger
).This limited functionality of the current
conjg()
leads to the mushroom-like growth of non-standard preprocessor macro definitions in such generic algorithms.As an example, this
conjg()
functionality extension could reduce the size of the original BLAS/LAPACK codebase to almost half (by removing separate duplicated routines forcomplex
andreal
data types (along with perhaps a few other algorithmic changes)).The proposed extension would lead to the following trivial behavior:
conjg(x) := x
ifx
is of typeinteger
orreal
.The text was updated successfully, but these errors were encountered: