Skip to content
/ whmath Public

C++ SIMD header-only math library targeting game/engine development

License

Notifications You must be signed in to change notification settings

jopadan/whmath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

whmath

C++ SIMD header-only math library targeting game/engine development mixing features of:

Description

file description
math.hpp template prototypes describe intended implementations

Sources

get clone --recurse-submodules --recursive http://github.com/jopadan/whmath
cd whmath

Building

cmake . --install-prefix=/usr
make install

Optimization

Change CMakeLists.txt compile flags to fit your needs:

add_compile_options(-march=native -mfpmath=sse+387 -mveclibabi=svml -O3)

Usage

#include <whmath/math.hpp>

using namespace math;

/* single float scalar */
sca::f32          s = 213.0f;

/* unsigned byte vector of size 4 */
vec::u8<4>        a = { 43, 52, 32, 53 };

/* single float vector of size 4 */
vec::f32<4>       b = { 32.0, 54.0, 43.0, 34.0 };

/* unsigned short integer bitfield with 3 color components */
col::u16<5,6,5>   c = { 24, 12, 12 };

/* unsigned short integer bitfield with 4 color components */
col::u16<4,4,4,4> d = { 24, 12, 12, 8 };

/* unsigned char integer vector with 4 color components */
col::u8<4>        e = { 24, 12, 12, 8 };

/* floating point vector with 4 color components */
col::f32<4>       f = { 24.0f, 12.0f, 12.0f, 8.0f };

/* 3d vector product */
mat::f32<3, 3> m3 = mat::f32<3,3>::identity();
m3[2] = prd::cross<sca::f32, 3>(m3[0], m3[1]);

/* 4d vector product */
mat::f32<4, 4> m4 = mat::f32<4,4>::identity();
m4[3] = prd::cross<sca::f32, 4>(m4[0], m4[1], m4[2]);

Links