Skip to content

chunkyguy/Math-Library-Test

 
 

Repository files navigation

C++ Math Library Test (Apple Devices)

Introduction

This repository contains some simple tests between different C++ math libraries that I wrote during the process of selecting a math library to use for game development.

At the time of writing, the libraries tested are:

Results:

So far I've tested matrix addition and multiplication. src/Main.cpp contains code that will generate two lists of 1 million 4x4 float matrices for each library, populate them with random float values, and then add each one from the first column to the second. It will then do the same for multiplication. It will repeat this step 10 times and print out how long it took for each library.

Results for each library vary greatly with architecture and optimisation level.

Mac - 2.3 GHz 8-Core Intel Core i9 - 32 GB RAM

Library Additions (ns) Multiplications (ns)
Eigen 4049.47 25766.21
GLM 1030.72 11677.72
CML 7265.88 28132.13
GLKit 187.82 394.39
Kazmath 355.63 2863.69
Bullet 757.27 17074.74
simd 642.00 1501.06

Mac - 8-Core Apple M1 - 16 GB RAM

Library Additions (ns) Multiplications (ns)
Eigen 2522.06 7263.56
GLM 773.91 5821.86
CML 3793.53 10119.19
GLKit 126.91 223.10
Kazmath 224.62 360.63
Bullet 508.76 1411.24
simd 307.25 701.55

Requirements

These choices are largely influenced by reading their websites and posts at the Game Development StackExchange site:

My requirements are:

  • C++
  • Matrix operations
  • Vector operations
  • Complex number support
  • Quarternian operations
  • Cross-platform, easy to compile on different platforms with different compilers.
  • Fast. SIMD instruction support is preferred.
  • Easy to use and understand.
  • Permissive license. Accreditation is perfectly fine. Forcing distribution of source code isn't.

Libraries Overview

This section contains my notes to help understand the design choices and advantages and disadvantages of each library. It is fairly long so has been moved to LIBRARIES.md. This section also contains licensing information for each library.

Things Tested

  • Matrix operations - addition, multiplication

Things Yet To Test

This is for gaming applications. Features that I can think of that need testing are:

  • Matrix operations - including addition, subtraction, multiplication, inversion, transposition, translation, rotation, scale
  • Vector operations - cross/dot product, normalisation, zeroing, magnitude, length2, scalar operands, normal calculation
  • Euler angle + Quarternion operations - rotation, interpolation, conversion, inversion, multiplication
  • Coordinate system conversion (Cartesian, spherical)
  • Random numbers - generator speed, period, statistical randomness
  • Possibly noise generation
  • Ease of integration with gl functions like glTranslate()

Change Log

  • Remove Android tests
  • Add GLKMath library.
  • Add kazmath library.
  • Modify the time calculation. Now based on the clock() function.
  • Add bullet vectormath library.

About

A comparison of the various major math libraries for speed and ease of use.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 56.8%
  • C++ 42.6%
  • Makefile 0.2%
  • Objective-C++ 0.2%
  • Perl 0.2%
  • Objective-C 0.0%