A Swift version of Eigen?

Currently, no. mainly it’s because of 2 reasons

  • Swift doesn’t have explicit loop vectorization and it’s probably a non-goal (though it tries to be aggressive about implicit vectorization). we do have SIMD types which presumably use SIMD instructions though you’d probably have to bend the type system to avoid copying matrices in order to use them.
  • We don’t have fixed-size arrays. This has been discussed for years but has been effectively stalled for various reasons. avoiding dynamic memory allocations (for variable-size structures) in Swift is v difficult,, you can dodge it in simple programs if the lifetime of your array/matrix never exceeds a single scope (i.e. it never gets passed around), but of course this gets harder when you’re trying to expose an interface.

this doesn’t really count as a technical reason, but there are also unlikely to be many potential library authors who have the domain expertise to write a reliable linear algebra library. outside of official Apple Frameworks, there are only a handful of people who have the time to write these “infrastructure building blocks”, and most of them are concentrated around projects that benefit the most users, i.e. server infrastructure, tooling, etc.

7 Likes