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
For the user API, maybe all needed is a consistent way to export them? One way this is present in stdlib (codata module) is to use a mold parameter and function.
For development (linear algebra routines will be easier to read), maybe the best approach would be to template them directly in fypp? this works well:
#! Return the unitary numeric constant for a given type and kind
#!
#! Args:
#! type (string): an intrinsic type (complex, real, integer)
#!
#! Returns:
#! Parameter value string
#!
#! E.g.,
#! one('complex(dp)') -> (1.0_dp, 0.0_dp)
#! one('real(sp)') -> 1.0_sp
#! one('integer') -> 1
#!
#:def one(type)
#:assert 'integer'in type or 'real'in type or 'complex'in type
#:if'('in type and ')'in type
#:set kind="_"+ type.split('(')[1].split(')')[0]
#:else
#:set kind=""
#:endif
#:if'integer'in type
${"1"+kind}$
#:elif 'real'in type
${"1.0"+kind}$
#:elif 'complex'in type
${"(1.0"+kind+",0.0"+kind+')'}$
#:endif
#:enddef
The text was updated successfully, but these errors were encountered:
perazz
added
the
idea
Proposition of an idea and opening an issue to discuss it
label
Dec 24, 2024
Motivation
As pointed out in #902, it is often tedious to read through templated numeric constants through the code.
Prior Art
#800
Additional Information
codata
module) is to use amold
parameter and function.The text was updated successfully, but these errors were encountered: