Vuckt is Swift library providing Obj-C-compatible integral & floating vector struct types with zero-cost SIMD vector bridging, and convenience methods to bridge to/from other vector-ish types throughout Cocoa. Vuckt is designed to be a “plumbing-level” vector library, that is, it makes as little distinction as possible about the intended purpose or usage of its types (such as a vector3 being used as a position, or as an offset, or as a normal, or as a scale, or as an euler-angles or rotor rotation, etc.) and instead focuses on just providing vector types and every vector math method could could want to operator on those vectors. (A specialized quaternion type is present because it's not a true uniform vector4, but really a imaginary-vector3 & real-vector1, so the math is significantly different). Also, Vuckt is built on optimized C underpinnings, and is significantly faster than Swift's native SIMD library.
It was born out of frustration with Swift/Cocoa's built-in SIMD types not being fully Objective-C compatible (particularly, they cause major problems when used with KVC, NSInvocation, or any other situation requiring NSValue-boxing), and has grown to try to cover as much of what native-SIMD can do with modern Swift syntax, and to be easily convertable to/from any other vector type you might be using in Swift (e.g. SCNVector3, CGVector, etc.).
I might add more documentation here, but I don't really expect anyone else to find/use this lib— I built it for my own use when Swift's native SIMD library wasn't meeting my needs, so I said “f*ck it; I'll write my own library“. If there are SIMD types or operations that you need that haven't been implemented in Vuckt yet, I'm happy to add them for you— just create an issue on GitHub, GitLab, or BitBucket and if it's plausible (packed types are a notable exception) and mirrors what SIMD does, I'll do it. There's a good chance I already need the same feature you'd request, I just haven't added it yet.
Vuckt currently offers the following types:
See also: Vuckt's full documentation
Vuckt is fast. Vuckt performs significantly faster than Swift-native SIMD, both in Release builds:
| iPhone 13 Pro Geekbench 6 CPU single-core score: 2364 |
iPad Pro M4 11" Geekbench 6 CPU single-core score: 3744 |
Mac Studio M2 Max Geekbench 6 CPU single-core score: 2727 |
|
|---|---|---|---|
Vuckt Float3 |
0.277 s | 0.265 s | 0.286 s |
Swift SIMD3<Float> |
0.803 s (+190%) | 0.465 s (+75%) | 0.497 s (+74%) |
C/Obj-C GLKVector3 |
0.275 s (-1%) | 0.271 s (+2%) | 0.273 s (-5%) |
C/Obj-C simd_float3 |
0.927 s (+235%) | 0.540 s (+104%) | 0.581 s (+103%) |
and Debug builds:
| iPhone 13 Pro Geekbench 6 CPU single-core score: 2364 |
iPad Pro M4 11" Geekbench 6 CPU single-core score: 3744 |
Mac Studio M2 Max Geekbench 6 CPU single-core score: 2727 |
|
|---|---|---|---|
Vuckt Float3 |
3.323 s | 2.176 s | 2.979 s |
Swift SIMD3<Float> |
18.005 s (+442%) | 9.556 s (+339%) | 14.038 s (+371%) |
C/Obj-C GLKVector3 |
2.712 s (-18%) | 1.858 s (-15%) | 2.319 s (-22%) |
C/Obj-C simd_float3 |
1.615 s (-51%) | 1.108 s (-49%) | 1.287 s (-57%) |
(Lower seconds and percentages are better. Tests performed with VucktPerformanceTests.swift and VucktCPerformanceTests.m using Xcode 26.4.1 and Swift 6.3.1.)
Vuckt is provided with a fully-permissive Public Domain license, because it really should've been built-into Swift. I'm not one to claim rights over something so straight-forward and essential as a solid, interoperable, effecient vector library.
- Implement
Float2x2 - Make the
Package.swiftuse the C backend (which is significantly faster), eliminating the…_NoObjCBridge.swiftvariants
‣ Perhaps still offer “…_NoObjCBridge” as an alternate target, for cases/platforms where Obj-C isn't available. - More unit test coverage
- More thorough performance tests
- Double & Half floating vectors
- Char, UChar, Short, UShort, UInt, Long, & ULong integer vectors
- Add conversions to/from Spatial types
- Add performance tests for Spatial Vector3D operations, and add perf results to README
- Implement Penner easing functions for each type?