3 ms·
Swift matrix use looks pretty gross compared to Julia, R or Python (NumPy) https://developer.apple.com/documentation/accelerate/simd/working_with_matrices https
by make3 8y ago
Swift matrix use looks pretty gross compared to Julia, R or Python (NumPy) https://developer.apple.com/documentation/accelerate/simd/working_with_matrices https://developer.apple.com/documentation/accelerate/simd/wo...
Is there an other way?
- saagarjha 8y agoAnother way to do what?
- make3 8y agomatrix computations in swift as in numpy
- dlivingston 8y agoThis looks promising: https://github.com/hollance/Matrix https://github.com/hollance/Matrix
- stephencanon 8y agoThat's not Swift matrices. Swift hasn't defined a language-level numeric matrix type. That's a C library type imported into Swift. You can alternatively import Python and use NumPy directly, as well as any other C library, or you can define numeric operations in Swift. (On the other hand, if you are using fixed-size 3x3 or 4x4 matrices, the simd_floatNxN types deliver vastly better performance than NumPy can. So it depends on what your goals are.)
- make3 8y agothe point of using swift is to be faster than Python. if your computations are using numpy and most of your time is spent in these computations, passing through the python interpreter every time, it's going to have performance similar Python
- make3 8y agoplus numpy is apparently 3x slower than pure simd optimized c++ with something like eigen. I was hoping to get something faster (than numpy, not eigen) with swift
- zapzupnz 8y ago> the point of using swift is to be faster than Python There are plenty of other compelling reasons to prefer Swift over Python such as its type system or its easy, somewhat native, integration with existing Swift, Objective-C, and C frameworks available for macOS, iOS, watchOS, and tvOS. Speed isn't the only driver, and I'm sure not it's not "the [only] point".
- make3 8y agono I meant for data science applications specifically, sorry