Skip to content

Expose additional math functions in dace/math.h#2418

Open
romanc wants to merge 6 commits into
spcl:mainfrom
romanc:romanc/dace-math-functions
Open

Expose additional math functions in dace/math.h#2418
romanc wants to merge 6 commits into
spcl:mainfrom
romanc:romanc/dace-math-functions

Conversation

@romanc

@romanc romanc commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Description

dace/math.h re-exposes a couple of math functions from cmath, e.g. std::sin(x), which has overloads for e.g. float and double. Some functions, e.g. asin(x), were not exposed in this way. This leads to precision issues when asin(x) is called with a float because in the generated code, asin will be mapped to the C version, which is only defined for doubles. There is thus an implicit cast happening of the argument and the computation is done in double precision. Worse, the return type is always a double, which will force the rest of the calculation to be up-casted to double precision if asin() is used in an expression.

This is a re-hash (including the missing test) of #2364, which grew way too big and is now plucked apart into smaller, more meaningful PRs.

@alexnick83 would you mind giving this another look? I've added a simple test for asin() as you asked in #2364 (review).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant