finds.dev

jph00/BaseMath

Basic math functions for float and double in Swift

View on GitHub

★ 201Swiftupdated May 2019

// the take

A Swift library that adds vectorized math operations to arrays of floats and doubles by going through raw pointers rather than Swift's value-type machinery. It's a building block for numerical computing in Swift, notably used by SwiftyMKL as a lower-level foundation. Aimed at Swift developers doing ML or signal processing work who need more than stdlib offers.

The 3-5x speedup claim is credible — bypassing copy-on-write checking and using pointer arithmetic genuinely does avoid overhead Swift can't elide. The GYB (Generate Your Boilerplate) templating approach is the right call for this kind of repetitive math binding; it keeps the actual source manageable. The in-place (`_` suffix) and reduction (`sum` prefix) naming convention is consistent and easy to remember once you've seen it once. AlignedStorage as an explicit alternative to Array is a thoughtful escape hatch for users who want predictable memory layout without CoW surprises.

Last commit was May 2019 — seven years ago. Swift has changed substantially (Swift 5.9+ actors, typed throws, borrowing/consuming ownership) and this predates all of it; whether it even compiles cleanly on a modern Swift toolchain is an open question. The README flags that tests won't run on Mac due to XCTest/Objective-C issues, which is a significant red flag for a library that bypasses safety checks around memory — you want tests to run where you deploy. No SIMD intrinsics or Accelerate framework usage; Apple's own vDSP would likely outperform this on ARM Mac hardware, making the performance story weaker for the primary Swift platform today. The article linked for implementation details is still marked TBA after seven years.

We read the README, the directory tree and a key source file in July 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
201
Forks
15
Language
Swift
Last commit
23 May 2019

// nearby

If BaseMath isn't quite it.

All repos →