-
Notifications
You must be signed in to change notification settings - Fork 192
Open
Labels
ideaProposition of an idea and opening an issue to discuss itProposition of an idea and opening an issue to discuss it
Description
Motivation
As pointed out in #902, it is often tedious to read through templated numeric constants through the code.
Prior Art
Additional Information
- 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 amold
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
jalvesz
Metadata
Metadata
Assignees
Labels
ideaProposition of an idea and opening an issue to discuss itProposition of an idea and opening an issue to discuss it
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity