Skip to content

feat: generic vector math (sin, log, asin, acos, atan, atan2, xor_) - #6

Open
ShrutheeshIR wants to merge 1 commit into
mainfrom
vector-math
Open

ShrutheeshIR wants to merge 1 commit into
mainfrom
vector-math

Conversation

@ShrutheeshIR

Copy link
Copy Markdown

Move sin and log out of per-ISA backends into the shared Vector interface, so avx, neon and wasm use one implementation.

Add asin, acos, atan, atan2 and xor_ (operator^). math.hh gains asin/acos/atan/atan2 and the scalar-or-vector free functions fabs, min, max and blend that generated robot code uses.

@ShrutheeshIR
ShrutheeshIR added this pull request to stack #13 November 7, 2026 06:43
inline static constexpr auto sqrt(VectorT v) noexcept -> VectorT
{
return _mm256_mul_ps(v, _mm256_rsqrt_ps(v));
return _mm256_sqrt_ps(v);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

i have to do this since it messes with sqrt atan /acos operations, happy to have two versions, the proper sqrt operations for inverse trig, and retain this version for low-precision tasks

inline constexpr auto sqrt(const DataT &v) -> DataT
{
return v.sqrt();
if constexpr (std::is_arithmetic_v<DataT>)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

A bunch of ops just to support scalar and vector math

}

template <typename DataA, typename DataB, typename DataC>
inline constexpr auto blend(const DataA &a, const DataB &b, const DataC &mask) -> DataA

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Need this for conditional statements that cricket spits out

Base automatically changed from vector-min to main November 20, 2026 20:39
…nd free min/max/fabs/blend

Move sin and log out of the per-ISA backends into the shared Vector interface, so avx, neon
and wasm use one implementation, and add asin, acos, atan, atan2 and xor_ (operator^).
math.hh gains asin/acos/atan/atan2 and the scalar-or-vector free functions fabs, min, max
and blend that generated robot code uses.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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