Skip to content

Math.sh done right#536

Merged
gewang merged 6 commits intoccrma:mainfrom
everettmcarpenter:main
Feb 26, 2026
Merged

Math.sh done right#536
gewang merged 6 commits intoccrma:mainfrom
everettmcarpenter:main

Conversation

@everettmcarpenter
Copy link
Contributor

I have included a clean push of all changes for Math.sh(), only changing core files.

@gewang

everettmcarpenter and others added 3 commits January 22, 2026 18:38
A cleaned up, minimal push of the spherical harmonic calculator designed for ChucK's math library.
This change implements a ulib_math entry which allows for the function to actually be called by users. Includes documentation of the function.
@everettmcarpenter
Copy link
Contributor Author

This build has been tested and confirmed to be working on an Intel Mac, Ubuntu machine and Windows as of 02/21

everettmcarpenter and others added 3 commits February 23, 2026 15:12
Previously, memory was allocated by SH() which would return a pointer for the ulib function to access. This meant one function allocated memory and the other deleted it. Now ulib will allocate memory and provide a pointer to SH() for it to use, meaning SH() is not responsible for management of memory.
Copy link
Member

@gewang gewang left a comment

Choose a reason for hiding this comment

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

thank you! we will go ahead and merge;
as follow-ups, we would ask for one or more tests examples (with expected output); also, could you provide a link or brief explanation for the "magic constants" used in ck_associated_legendre()

@gewang gewang closed this Feb 26, 2026
@gewang gewang merged commit fd8bf14 into ccrma:main Feb 26, 2026
3 of 4 checks passed
@everettmcarpenter
Copy link
Contributor Author

everettmcarpenter commented Feb 26, 2026

hello @gewang , wonderful! thank you for allowing me to be a part of ChucK. I will open a PR with some examples and display .sh()'s functionality with some calculation examples as well as ambisonic encoding via Gain[].

as for ck_associated_legendre(), here are some explanations of the terms used in it, the definitions are taken from Wolfram (5th order was dervied by myself using their definition containing derivatives of legendre polynomials). the "magic constants" are from the definition of associated legendre polynomials, which can be seen in the above link.

flip is a nifty relation for associated legendre polynomials with negative degrees, which can be read about more here Associated Legendre Polynomials with Negative degree and/or order

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.

2 participants