Jump to content
  • Advertisement
Sign in to follow this  

Announcing The Tuesday C++ Vector Math and SIMD Library Version 1.0

This topic is 1158 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi GameDev.net!


I've been working on a math and template library on and off since January and I've finally gotten to a point I feel comfortable calling version 1.0.



  • The Tuesday C++ Vector Math and SIMD Library is a library of template classes and math functions with a focus on physics and graphics applications. It provides data types commonly used in games and other simulations such as vectors, quaternions, and matrices, SIMD intrinsic wrapper classes completely separate from (but compatible with) the other types, operator overloads for combining and manipulating all these types, as well as some other common mathematical functions. It was written to match the style of the C++ Standard Library and uses modern C++ features (i.e., C++14) extensively.

Tuesday provides the following unique features over other similar libraries such as GLM:

  • The dimensions of vector and matrix types are template parameters, unlike GLM where, e.g., tvec2, tvec3, and tvec4 are separate types. By making the dimensions template parameters, it's possible to write one template function that can operate on and/or produce vectors or matrices of multiple dimensions. For example, the transformation matrix generation functions (translation_mat, rotation_mat, etc.) can produce matrices of multiple sizes so long as they meet the minimum requirements of each transformation and are, at the largest, 4x4.
  • It makes heavy use of decltype in return types. This makes it possible for composite types to behave much more like their component types when it comes to things like implicit type conversions. For example, fvec3 + dvec3 results in a dvec3 just as float + double results in a double.
  • It uses constexpr whenever possible which, as it turns out, is often.
  • SIMD types are completely separate from vector types. This may seem counter-intuitive, but SIMD vectors aren't very efficient when used as traditional 3D vectors. The fourth component of an SIMD vector would often go to waste, and functions where multiple components interact (such as the length function, dot product, or cross product) would be horribly inefficient with SIMD intrinsics. Instead, SIMD instructions should be used to perform the same logic on multiple vectors in parallel. Tuesday is designed for this use case. For example, vec3<float32x4> v could be thought of as 4 parallel 3D vectors (4 x-values, followed by 4 y-values, and finally 4 z-values). Something like math::dot(v) would then compute a single float32x4 containing the dot products of those 4 parallel vectors without any inefficient component shuffling. See this answer to a naive question I asked on Stack Overflow a few years back for some more rationale.
  • The SIMD system supports a huge number of types. You can create 2, 4, 8, 16, 32, and 64-component vectors of all the major arithmetic types (float, double, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, and uint64_t) along with sized boolean types (bool8, bool16, bool32 and bool64). If SIMD-intrinsic acceleration isn't available for a particular type, there's a standard C++-compliant fallback. If a vector has too many components for acceleration, but a smaller vector with the same component type can be accelerated, then the larger vector is simply the composite of two smaller vectors. For example, if float32x4 is accelerated but float32x8 isn't, then float32x8 will at least be partially-accelerated in that it's made of two float32x4's.


It's licensed under the Boost Software License so it's should be free to use in just about any project.


I've also published the testing framework I wrote for it, "Monday", separately:




Please take a look and let me know what you think!

Edited by Jo Bates

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!