Skip to content

Add sinc (sinus cardinalis)#3856

Merged
jl-wynen merged 1 commit intomainfrom
sinc
Mar 5, 2026
Merged

Add sinc (sinus cardinalis)#3856
jl-wynen merged 1 commit intomainfrom
sinc

Conversation

@jl-wynen
Copy link
Copy Markdown
Member

@jl-wynen jl-wynen commented Mar 4, 2026

Fixes #3855

I went with the mathematics and physics definition because that is our target audience. This means that we deviate from NumPy which focusses more on signal processing in this case.

Comment on lines +303 to +304
The input must have unit ``rad`` or be dimensionless.
In either case, the output is dimensionless.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the 1/rad one would naively get from the denominator is not included?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I figured that since rad is just a special case of dimensionless and this is not a pure angle-based sine, it makes more sense to return the latter.

}

Unit sinc(const Unit &a) {
if (a == rad || a == dimensionless)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we support dimensionless in sin? What is the motivation here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My motivation was that sinc is not a pure trigonometric function and strictly sticking to rad would make it more difficult to compose sinc with other functions. I doubt that people normally consider the input or output of sinc to be dimensionful.

constexpr auto sinc(const ValueAndVariance<T> a) noexcept {
using std::sin, std::cos;
if (a.value == 0) {
// multiply by 0 in case a.variance is NaN or inf
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaning we get NaN?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@jl-wynen jl-wynen merged commit 41043bb into main Mar 5, 2026
4 checks passed
@jl-wynen jl-wynen deleted the sinc branch March 5, 2026 10:02
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.

Implement sinc(x) = sin(x)/x

2 participants