Multi-dimensional Swift math

Related tags

Math swift math
Overview

Upsurge

Upsurge implements multi-dimensional data structures and operations. It brings numpy-like operations to Swift.

Upsurge no longer supports DSP and other linear operations, please use Surge for that. Surge and Upsurge play nice together.

Features

  • Tensor and tensor slicing: tensor.asMatrix(1, 1, 0...4, 0...4)
  • Matrix and matrix operations: let result = A * B′
  • ValueArrays with explicit copying and numeric operators: let result = A • B

Installation

Upsurge supports both CocoaPods (pod 'Upsurge') and Carthage (github "aleph7/Upsurge"). For macOS apps you can use the Swift Package Manager to install Upsurge by adding the proper description to your Package.swift file:

import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    targets: [],
    dependencies: [
        .Package(url: "https://github.com/aleph7/Upsurge.git", Version(0,8,.max)),
    ]
)

Usage

Arrays and vector operations

All of Upsurge's linear (1-dimensional) operations can be performed on anything that conforms to LinearType. Swift's built-in arrays and array slices conform to LinearType, of course. But Upsurge also defines the ValueArray class to store a one-dimensional collection of values. ValueArray is very similar to Swift's Array but it is optimized to reduce unnecessary memory allocation. These are the most important differences:

  • Its instances have a fixed size defined on creation. When you create a ValueArray you can define a capacity var a = ValueArray<Double>(capacity: 100) and then append elements up to that capacity. Or you can create it with specific elements var a: ValueArray = [1.0, 2.0, 3.0] but then you can't add any more elements after.
  • It is a class. That means that creating a new variable will only create a reference and modifying the reference will also modify the original. For instance doing var a: ValueArray = [1, 2, 3]; var b = a and then b[0] = 5 will result in a being [5, 2, 3]. If you want to create a copy you need to do var b = ValueArray(a) or var b = a.copy().
  • You can create an uninitialized ValueArray by doing var a = ValueArray<Double>(capacity: n) or var a = ValueArray<Doube>(count: n). This is good for when you are going to fill up the array yourself. But you can also use var a = ValueArray(count: n, repeatedValue: 0.0) if you do want to initialize all the values.

Creating arrays

Create a ValueArray with specific literal elements when you know ahead of time what the contents are, and you don't need to add more elements at a later time:

let a: ValueArray = [1.0, 3.0, 5.0, 7.0]

Create a ValueArray with a capacity and then fill it in when you are loading the contents from an external source or have a very large array:

let a = ValueArray<Double>(capacity: 100)
for v in intputSource {
    a.append(v)
}

Finally there is a way of initializing both the capacity and the count of a ValueArray. You should rarely need this but it's there for when you are doing operations on existing arrays using low-level APIs that take pointers:

func operation(a: ValueArray<Double>) {
    let N = a.count
    let b = ValueArray<Double>(count: N)
    // ...
}

Vector arithmetic

You can perform operations on ValueArray in an intuitive manner:

let a: ValueArray = [1.0, 3.0, 5.0, 7.0]
let b: ValueArray = [2.0, 4.0, 6.0, 8.0]
let addition = a + b // [3.0, 7.0, 11.0, 15.0]
let product  = a  b // 100.0

Matrix operations

import Upsurge

let A = Matrix<Double>([
    [1,  1],
    [1, -1]
])
let C = Matrix<Double>([
    [3],
    [1]
])

// find B such that A*B=C
let B = inv(A) * C // [2.0, 1.0]′

// Verify result
let r = A*B - C    // zero   

Tiling

A block Matrix can be formed by repeating a 1-D ValueArray or 2-D Matrix mxn times.

import Upsurge

let a = ValueArray = [1.0, 2.0]
// Tile source array 2 times in each directon,
// returning a 2X4 block matrix
let A = a.tile(2, 2)

let B = Matrix<Double>([
    [1.0,  2.0],
    [3.0,  4.0]
)]
// Tile source matrix 2 times in each directon,
// returning a 4x4 block matrix
let r = B.tile(2, 2)

Tensors

The Tensor class makes it easy to manipulate multi-dimensional data. You can easily slice or flatten a tensor to get matrices and vectors that you can operate on.


License

Upsurge is available under the MIT license. See the LICENSE file for more info.

Comments
  • Failing to compile in Xcode 9

    Failing to compile in Xcode 9

    Hello, I've just upgraded to Xcode 9 where Upsurge fails to install - either through Carthage or cocoapods giving these compilation errors:

    Upsurge/Source/LinearOperators.swift:58:15: error: generic parameter 'ML' is not used in function signature public func +<ML: LinearType, MR: LinearType>(lhs: Double, rhs: MR) -> ValueArray where ML.Element == Double, MR.Element == Double { ^ Upsurge/Source/LinearOperators.swift:227:15: error: generic parameter 'ML' is not used in function signature public func +<ML: LinearType, MR: LinearType>(lhs: Float, rhs: MR) -> ValueArray where ML.Element == Float, MR.Element == Float { ^ Upsurge/Source/Span.swift:22:15: error: 'Sequence' requires the types 'Span.Element' (aka 'CountableClosedRange') and '[Int]' be equivalent public struct Span: ExpressibleByArrayLiteral, Sequence { ^

    Upsurge/Source/Span.swift:22:15: error: 'Sequence' requires the types 'Span.Element' (aka 'CountableClosedRange') and '[Int]' be equivalent

    opened by jhristov 7
  • Potential bug in FFTFloat?

    Potential bug in FFTFloat?

    Hi, thanks for the library!

    I couldn't really spot the exact problem here but these are what I've observed. I'm currently using FFT to compute short-time Fourier transform which is windowing subarray (frame) of a 1D signal and use real(FFT)[:half] of it. It was fine when it's ValueArray<Double>/FFTDouble but not with ValueArray<Float> and FFTFloat.

        let fft_calculator = FFTFloat(inputLength: NSP_FFT)
        let fft_d = FFTDouble(inputLength: NSP_FFT)
    
        var x2 = ValueArray<Double>((0..< NSP_FFT).map({ sin(0.01 * Double($0)) }))
        var x3 = ValueArray<Float>((0..< NSP_FFT).map({ sin(0.01 * Float($0)) }))
        
        for fr_idx in 0..<n_fr { 
            fft_d.forwardMags(x2)
            fft_calculator.forwardMags(x3)    
        }
    

    I think there's a hint in my error message. I've seen two error cases.

    1.

    In this case, although I was using FFTFloat the error often occurs at FFTDouble during de-allocating the FFT setup after finishing the computation Thread 1: signal SIGABRT at FFT.swift, line 41, which is part of FFTDouble class:

        deinit {
            vDSP_destroy_fftsetupD(setup)
        }
    

    and the error message is

    UpsurgeTest2(93049,0x1068813c0) malloc: *** error for object 0x3fef168f3fef2dc9: pointer being freed was not allocated
    *** set a breakpoint in malloc_error_break to debug
    
    

    2

    Some other times, I got this message.

    UpsurgeTest2(93867,0x10c5533c0) malloc: *** error for object 0x7fb62f84a200: incorrect checksum for freed object - object was probably modified after being freed.
    *** set a breakpoint in malloc_error_break to debug
    

    in ValueArray.swift line 82.

     public required init(count: IndexDistance) {
            mutablePointer = UnsafeMutablePointer.allocate(capacity: count) // Thread 1: signal SIGABRT
            self.capacity = count
            self.count = count
        }
    

    Notes

    both .forward and .forwardMags have this problem.

    opened by keunwoochoi 4
  • ComplexArray Infix operator *= causing crash

    ComplexArray Infix operator *= causing crash

    I am attempting to run a project with a real to complex forward FFT operation, and it has a 100% repro EXC_BAD_ACCESS crash on the scaling at the end of the the function.

        let count = 64
        let frequency = 4.0
        let step = 2.0 * Double.pi / Double(count)
        let x = ValueArray<Double>((0..<count).map({ step * Double($0) * frequency }))
        let fft = FFTDouble(inputLength: x.count)
        let complex = fft.forward(sin(x))  // EXC_BAD_ACCESS here
        for value in complex {
            print(value)
        }
    

    The crash is found on line 75 of FFT.swift, on the results *= scale. As of now this means that real to complex FFTs are broken.

    t1: defect 
    opened by willrichman 4
  • How do you edit a whole row of a Matrix?

    How do you edit a whole row of a Matrix?

    I'm aware that there are custom subscripts available for the Matrix class, but I'm not quite sure how to edit a specific row (all of it's values). How do I accomplish this?

    question 
    opened by Somnibyte 4
  • tile feature

    tile feature

    @aleph7

    I would like to propose adding a tile feature to both ValueArray and Matrix. This would provide similar functionality to tile found in Numpy and repmat found in Matlab. Below is the code I have implemented in ValueArray.swift

        open func toMatrix(rows: Int, columns:Int) -> Matrix<Element> {
            precondition(rows*columns == count, "Element count must equal rows*columns")
            return Matrix(rows: rows, columns: columns, elements: self)
        }
        
        open func tile(m: Int, n: Int) -> Matrix<Element> {
            precondition(m+n >= 1, "Minimum of 1 repeat is required")
            let newCount = (m+1)*(n+1)*count
            let newElements = ValueArray<Element>(count: newCount, repeatedValue: self[0])
            let numberOfCopies = (m+1)*(n+1)
            
            withUnsafeBufferPointer { src in
                newElements.withUnsafeMutableBufferPointer { dest in
                    var ptr = dest.baseAddress
                    for i in 0..<numberOfCopies {
                        ptr = dest.baseAddress?.advanced(by: i*count)
                        cblas_ccopy(Int32(count), src.baseAddress, 1, ptr, 1)
                    }
                }
            }
            return newElements.toMatrix(rows: (m+1), columns: (n+1)*count)
        }
    

    And the unit test I added to ValueArrayTests.swift

        func testTile() {
            let a: ValueArray<Double> = [1.0, 2.0]
            let b = a.tile(m: 1, n: 1)
            
            XCTAssertEqual(b.count, 8)
            XCTAssertEqual(b.elements, [1.0, 2.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0])
        }
    

    Is this something you would consider, and would I be able to contribute to Upsurge.

    Regards,

    Brian

    opened by loudinb 4
  • Remove build warnings.

    Remove build warnings.

    Remove warnings when building with XCode by:

    • change typealias declared in protocols to associatedtype
    • fix var parameter. var parameter is deprecated.
    opened by dboyliao 4
  • Creating a sub matrix

    Creating a sub matrix

    Hi,

    Thanks for continuing the work on this library.

    I have a question. Given a number of rows and columns, how do you create a sub matrix from a matrix using Upsurge?

    Thanks!

    question 
    opened by Isuru-Nanayakkara 3
  • Build error with the Playground file

    Build error with the Playground file

    Adding Upsurge to a Cartfile results in this error during build

    --- xcodebuild: WARNING: Unable to open project file '/Users/primet/tmp/rnnSwift/BrainCore/Carthage/Checkouts/Upsurge/Upsurge.playground' in workspace '/Users/primet/tmp/rnnSwift/BrainCore/Carthage/Checkouts/Upsurge/Upsurge.xcworkspace'.
    
    s1: awaiting input 
    opened by maelp 3
  • Added normalization feature for matrices and fixed issue where ValueArraySlice could not be converted property to a ValueArray

    Added normalization feature for matrices and fixed issue where ValueArraySlice could not be converted property to a ValueArray

    I'm currently working on an implementation of Lasso Regression for a machine learning framework I'm working on and I stumbled upon an issue where UpSurge didn't have the ability to normalize my feature vectors. So I added the ability to normalize an entire matrix. I had stumbled upon an issue recently where whenever I tried to convert a ValueArraySlice to a ValueArray, the ValueArray class automatically adopts it's own step field rather than utilizing the original step field of the ValueArraySlice.

    Here is an example:

    let inputMatrix = Matrix<Float>(x)
    let vectorSlice = inputMatrix .column(i)  // [3,4]
    // The base of 'vectorSlice' is [3,5,8,4,12,15]
    

    Now if I were to do the following I would get [3,5] instead of a ValueArray that has the elements 3,4 like the slice originally had:

    let vectorSlice = ValueArray(inputMatrix .column(i)) // [3,5] This is becuase within the ValueArray class the step size provided within the class, which is set to 1, is always adopted by this method:

    Line 37 of ValueArray class:

        public var step: Index {
            return 1
        }
    
    
    

    Problematic area (Line 88):

        /// Construct a ValueArray from contiguous memory
        public required init<C: LinearType where C.Element == Element>(_ values: C) {
            mutablePointer = UnsafeMutablePointer<Element>.alloc(values.count)
            capacity = values.count
            count = values.count
            values.withUnsafeBufferPointer { pointer in
                for i in 0..<count {
                    mutablePointer[i] = pointer[values.startIndex + i * step]
                }
            }
        }
    

    Above you see that in this line here, we are only using the step provided by the class. Instead we need the step provided by the ValueArraySlice (which in my example originally had a step of 3):

    Original: mutablePointer[i] = pointer[values.startIndex + i * step]

    To fix this I use the 'values' parameters step field.

    mutablePointer[i] = pointer[values.startIndex + i * values.step]

    The normalize functions I implemented work as expected and have been tested.

    opened by Somnibyte 3
  • Converting ValueArraySlice to ValueArray gives me incorrect data

    Converting ValueArraySlice to ValueArray gives me incorrect data

    My goal was to convert a ValueArraySlice to a ValueArray, but instead of receiving the exact contents of the slice, I received a couple of different values. Here is an example I came across.

    let inputMatrix = Matrix<Float>(x)
    let vectorSlice = inputMatrix .column(i)  // [3,4]
    // The base of 'vectorSlice' is [3,5,8,4,12,15]
    
    
    

    Now if I were to do the following I would get [3,5] instead of a ValueArray that has the elements 3,4 like the slice originally had:

    let vectorSlice = ValueArray(inputMatrix .column(i)) // [3,5]

    I need the slice to perform a vital operation. My first couple of attempts included what you see above, and something like:

            let vectorSlice = inputMatrix .column(i)
            var vector:Array<Float> = []
            for i in vector.startIndex.stride(to: vector.endIndex, by: vector.step) {
               vector.append(vectorSlice.base[i])
            }
    

    But this code would be contained in another loop which would result in a higher time complexity.

    How do I successfully convert a ValueArraySlice to a ValueArray?

    The cblas_snrm2 function, which calculates L2-norm, requires a parameter of type UnsafePointer. ValueArraySlice does not provide a pointer field and so I could not satisfy this requirement. This prompted me to proceed to converting it into a ValueArray which has that field.

    opened by Somnibyte 3
  • Why fixed size? Some problems require unknowable-sized arrays.

    Why fixed size? Some problems require unknowable-sized arrays.

    I was going to leave a request to add some additional operations that use two+ arrays: vDSP_vmulD, vDSP_vmmaD, and vDSP_vmmsbD. However, I realized that as-is I can't even use this project because the arrays are fixed size. For the arrays I use, the ultimate length is unknowable at initiation. I can see the performance benefits to using a fixed size array, but it removes a lot of flexibility.

    opened by adammj 3
  • Missing Argument

    Missing Argument

    Can't seem to figure out why this is missing. Any ideas? Can't build the app.

    Running Xcode 9.2, target Swift 4.0

    Upsurge/ValueArray.swift:134:35: error: missing argument for parameter 'capacity' in call mutablePointer.deallocate() ^

    Thank you.

    opened by FrenchBully 4
  • Thoughts on architecture update (slicing, etc.)

    Thoughts on architecture update (slicing, etc.)

    Followup of our twitter conversation.

    You'll find a gist with a rethinking of the basic types to make them more similar to NumPy's:

    • make Matrix and MatrixSlice a single type (also remove Slices for Array and Tensor).
    • more powerful slicing, (more like NumPy, including step and reverse direction). Taking some distance from Swift's conventions (ArraySlice have same index as their Array, I don't think this is suitable in this use case: 0-based indexes for slices make more sense IMO)
    • removal of [Int] as index type when dimension is known (Matrix is 2D -> 2 values). Keep [Int] for unknown dimensions (generic N-D Tensor)
    • interaction with external memory storage (good for memory managed by Metal for instance), including non compact layout (offset between rows).

    What's not done is reflection about mutability (everything is mutable).

    https://gist.github.com/rsebbe/fb2ac50c0cfaa9f2228822eeabf9e659

    Feel free to let me know what you think, and if that's a direction you'd like to try for Upsurge.

    opened by rsebbe 0
  • question: need help with interpolation

    question: need help with interpolation

    I need help with an interpolation algorithm for my app. I have a couple of arrays: (1) my measurements array (days versus weights) (2) a reference array with minimum weights (3) a reference array with maximum weights (4) a reference array with average weights

    First I have to fill the gaps in my measurement array (weights for the missing days). After that, I want to do a prediction of the coming days (day 45 up to 120) making use of the reference data (array 2 t/m 4). The assumption is that the measurement weights will be up to par… but can take a couple of days longer.

    I included a line graph of what the final results should look like.

    Can this be done with Swift or should I use a framework like Accelerate or Upsurge?

    My measurements: [ (0.0 , 25.4) , (5.0 , 30.3) , (6.0 , 33.5) , (9.0 , 51.2) , (12.0 , 83.1) , (16.0 , 143.0) , (21.0 , 238.6) , (24.0 , 311.7) , (25.0 , 322.8) , (29.0 , 460.9) , (31.0 , 520.4) , (35.0 , 642.2) , (36.0 , 694.0) , (43.0 , 988.3) , (44.0 , 1018.4) ]

    Reference average: [ (0.0 , 20.0) , (1.0 , 22.5), (2.0 , 27.0), (3.0 , 32.0), (4.0 , 37.2), (5.0 , 44.1), (6.0 , 68.4), (7.0 , 76.7), (8.0 , 101.4), (9.0 , 117.7), (10.0 , 148.8), (11.0 , 172.6), (12.0 , 212.6), (13.0 , 238.4), (14.0 , 272.3), (15.0 , 304.8), (16.0 , 335.6), (17.0 , 369.8), (18.0 , 405.3), (19.0 , 444.3), (20.0 , 476.3), (21.0 , 509.1), (22.0 , 546.5), (23.0 , 583.7), (24.0 , 620.8), (25.0 , 657.0), (26.0 , 698.2), (27.0 , 735.3), (28.0 , 769.7), (29.0 , 810.3), (30.0 , 848.2), (31.0 , 885.0), (32.0 , 921.2), (33.0 , 956.4), (34.0 , 984.2), (35.0 , 1012.1), (36.0 , 1038.8), (37.0 , 1069.8), (38.0 , 1096.4), (39.0 , 1119.1), (40.0 , 1145.5), (41.0 , 1162.1), (42.0 , 1179.6), (43.0 , 1204.0), (44.0 , 1222.8), (45.0 , 1240.6), (46.0 , 1255.7), (47.0 , 1269.6), (48.0 , 1277.5), (49.0 , 1290.5), (50.0 , 1300.6), (51.0 , 1312.4), (52.0 , 1317.3), (53.0 , 1324.6), (54.0 , 1332.1), (55.0 , 1339.6), (56.0 , 1340.2), (57.0 , 1346.8), (58.0 , 1347.4), (59.0 , 1349.6), (60.0 , 1348.0), (61.0 , 1348.4), (62.0 , 1345.4), (63.0 , 1340.2), (64.0 , 1333.3), (65.0 , 1329.0), (66.0 , 1325.3), (67.0 , 1324.8), (68.0 , 1313.7), (69.0 , 1301.1), (70.0 , 1297.5), (71.0 , 1292.2), (72.0 , 1287.1), (73.0 , 1277.5), (74.0 , 1271.9), (75.0 , 1262.2), (76.0 , 1250.3), (77.0 , 1242.9), (78.0 , 1225.5), (79.0 , 1220.5), (80.0 , 1200.8), (81.0 , 1184.4), (82.0 , 1178.4), (83.0 , 1163.1), (84.0 , 1149.5), (85.0 , 1135.4), (86.0 , 1117.2), (87.0 , 1109.1), (88.0 , 1092.1), (89.0 , 1088.8), (90.0 , 1079.4), (91.0 , 1067.8), (92.0 , 1065.0), (93.0 , 1060.7), (94.0 , 1058.9), (95.0 , 1055.5), (96.0 , 1055.1), (97.0 , 1050.1), (98.0 , 1051.4), (99.0 , 1041.4), (100.0 , 1050.9), (101.0 , 1051.6) , (102.0 , 1048.1), (103.0 , 1057.2), (104.0 , 1060.5), (105.0 , 1062.4), (106.0 , 1069.4), (107.0 , 1072.0), (108.0 , 1077.0), (109.0 , 1068.1), (110.0 , 1077.7), (111.0 , 1071.0), (112.0 , 1060.0), (113.0 , 1058.9), (114.0 , 1050.6), (115.0 , 1047.2), (116.0 , 1052.2), (117.0 , 1051.8), (118.0 , 1024.1), (119.0 , 1041.6), (120.0 , 1048.4) ] Reference minimum and maximum also available.

    I tried to fill the gaps with the following code:

    typealias Weights = (Double, Double) var myArray1: [Weights] = [ (0.0 , 25.4) , (5.0 , 30.3) , (6.0 , 33.5) , (9.0 , 51.2) , (12.0 , 83.1) , (16.0 , 143.0) , (21.0 , 238.6) , (24.0 , 311.7) , (25.0 , 322.8) , (29.0 , 460.9) , (31.0 , 520.4) , (35.0 , 642.2) , (36.0 , 694.0) , (43.0 , 988.3) , (44.0 , 1018.4) ] var myArray2: [Weights] = [] for i in 0..<45 { myArray2.append( (Double(i), 0.00)) } let mergedArrays = myArray2.map({ calculated->Weights in if let measured = myArray1.first(where: { $0.0 == calculated.0 }) { return measured } else { // interpolate weight?? return calculated } }) For the calculations, it would be something like:

    (1) 30.3 - 25.4 = 4.9 (2) 4.9 / 5 days = 0.98 per day so: [(0.0 , 25.4) , (1.0 , 26.4) , (2.0 , 27.4) , (3.0 , 28.4) , (4.0 , 28.3) , (5.0 , 30.3) (3) move on to the next weight after a 'weight with value 0.00'

    But how do I implement those calculations? And then after that... the predictions...

    linegraph

    question 
    opened by arakweker 0
  • How can I compute sum of a slice of matrix?

    How can I compute sum of a slice of matrix?

    // S is a Matrix
    sum(S[0..<1, 5..<10])? // doesn't work because MatrixSlice is not LinearType
    

    Is there a workaround for it?

    Ultimately, it would be easier to maintain I guess if there are less number of data types, e.g., everything is ndarray in numpy.. until then, hopefully more documents to come! ReadTheDocs would be perfect, but simple readme.mds would do the work pretty well, too, for APIs/inheritance/etc. I'm up for contributing to it if there's anything I can.

    opened by keunwoochoi 2
  • Call for collaborating a helper document!

    Call for collaborating a helper document!

    Since it was pretty hard for me to understand how to use Upsurge only with the source codes, I thought of creating a markdown file for easier landing for people like me.

    https://hackmd.io/MYFhDYQEwMwBgLQFNxUSOwkIEYFYo8EAOKARhmJGLhzgGYyg?both

    Unfortunately, I couldn't really fill it much because I don't know.. So, please feel free to add whatever you can think of!

    opened by keunwoochoi 4
Releases(0.10.0)
  • 0.10.0(Sep 23, 2017)

  • 0.9.0(Sep 23, 2017)

  • 0.8.1(Mar 28, 2017)

    • Add SwiftLint build phase and fix linter issues
    • Fix Xcode 8.3 warnings
    • Add support for Swift Package Manager @loudinb
    • Added tile function to ValueArray and Matrix classes @loudinb
    • Fix bug in subtraction operator for scalar - VectorArray
    • Fix ValueArraySlice problems
    Source code(tar.gz)
    Source code(zip)
  • 0.7.0(Apr 4, 2016)

    We changed the way we expose a TensorType extent. It is now called its span and is consistent across all types. Also updated for Swift 2.2 (Xcode 7.3).

    Source code(tar.gz)
    Source code(zip)
  • 0.6.0(Apr 4, 2016)

    The problem with having a pointer property is that it's too easy to get the pointer and have the object be destroyed immediately, before getting a chance of even using the pointer. Therefore switched to the Swift's array way of doing it: withUsafePointer methods. Also added pointer utility methods to avoid having nested withUsafePointer calls.

    Source code(tar.gz)
    Source code(zip)
  • 0.5.0(Feb 4, 2016)

    Reconsidered the decision to support only Double, now all containers, functions and operators support Float as well. This means that RealArray is no more. You need to choose either ValueArray<Double> or ValueArray<Float>.

    Source code(tar.gz)
    Source code(zip)
  • 0.4.5(Nov 17, 2015)

  • 0.4.4(Oct 31, 2015)

    This is a major overhaul of the array classes and interfaces. Most of the changes are related to being able to operate on slices. For instance 2 * a[0...2] + b[4...6]. There are also major updates to the playground examples and the Readme file.

    Source code(tar.gz)
    Source code(zip)
Owner
Alejandro Isaza
Alejandro Isaza
SwiftMath is a Swift framework providing some useful math constructs and functions

SwiftMath is a Swift framework providing some useful math constructs and functions, like complex numbers, vectors, matrices, quaternions, and polynomials.

Matteo Battaglio 175 Dec 2, 2022
Math expression parser built with Point•Free's swift-parsing package

swift-math-parser Basic math expression parser built with Point•Free's swift-parsing package. NOTE: currently, this uses a fork of that fixes a parsin

Brad Howes 36 Dec 14, 2022
Beautiful math equation rendering on iOS and MacOS

iosMath iosMath is a library for displaying beautifully rendered math equations in iOS and MacOS applications. It typesets formulae written using the

Kostub Deshmukh 1.3k Dec 21, 2022
Oovium's math engine

OoviumEngine The function parser and math engine of the iOS / macOS app Oovium, including a command line version: oov. Swift Package Manager It is pos

Joe Charlier 0 Aug 24, 2022
Arbitrary-precision arithmetic in pure Swift

Overview API Documentation License Requirements and Integration Implementation Notes Full-width multiplication and division primitives Why is there no

null 707 Dec 19, 2022
A collection of functions for statistical calculation written in Swift.

σ (sigma) - statistics library written in Swift This library is a collection of functions that perform statistical calculations in Swift. It can be us

Evgenii Neumerzhitckii 658 Jan 5, 2023
Swift Matrix Library

Swift Matrix and Machine Learning Library Note: tensorflow/swift and apple/swift-numerics/issues/6 have or will have more complete support for NumPy-l

Scott Sievert 591 Sep 5, 2022
Overload +-*/ operator for Swift, make it easier to use (and not so strict)

Easy-Cal-Swift Overview This file is an overloading of +-*/ operator for Swift, to make it easier to use (and not so strict) It can make your life wit

Wei Wang 272 Jun 29, 2022
Swift Custom Operators for Mathematical Notation

Euler Euler uses custom operators in the "Math Symbols" character set to implement functions using traditional mathematical notation. Please keep in m

Mattt 1.1k Jan 4, 2023
VectorMath is a Swift library for Mac and iOS that implements common 2D and 3D vector and matrix functions

Purpose VectorMath is a Swift library for Mac and iOS that implements common 2D and 3D vector and matrix functions, useful for games or vector-based g

Nick Lockwood 341 Dec 31, 2022
A cross-platform Swift library for evaluating mathematical expressions at runtime

Introduction What? Why? How? Usage Installation Integration Symbols Variables Operators Functions Arrays Performance Caching Optimization Standard Lib

Nick Lockwood 738 Jan 7, 2023
Numeric facilities for Swift

NumericAnnex NumericAnnex supplements the numeric facilities provided in the Swift standard library. Features The exponentiation operator ** and the c

Xiaodi Wu 69 Nov 3, 2022
Swift Matrix Library

Swift Matrix and Machine Learning Library Note: tensorflow/swift and apple/swift-numerics/issues/6 have or will have more complete support for NumPy-l

Scott Sievert 591 Sep 5, 2022
MRFoundation - A library to complement the Swift Standard Library

MRFoundation MRFoundation is a library to complement the Swift Standard Library.

Roman Mogutnov 2 Feb 12, 2022
Numpy-like library in swift. (Multi-dimensional Array, ndarray, matrix and vector library)

Matft Matft is Numpy-like library in Swift. Function name and usage is similar to Numpy. Matft Feature & Usage Declaration MfArray MfType Subscription

null 80 Dec 21, 2022
Handling dimensional numbers with physical units in Swift made easy.

Dimensional arithmetics in Swift This package provides an easy and natural way of dealing with physical sizes. Performing complex arithmetics or unit

Niklas Nickel 1 May 27, 2022
zekunyan 608 Dec 30, 2022
LOL Champions app: a small Multi-Module demo application to demonstrate modern iOS application tech-stacks with a Multi-module and MVVM architecture

LOL Champions app: a small Multi-Module demo application to demonstrate modern iOS application tech-stacks with a Multi-module and MVVM architecture

Ahmed Nasser 5 Jun 9, 2022
SwiftMath is a Swift framework providing some useful math constructs and functions

SwiftMath is a Swift framework providing some useful math constructs and functions, like complex numbers, vectors, matrices, quaternions, and polynomials.

Matteo Battaglio 175 Dec 2, 2022
Math expression parser built with Point•Free's swift-parsing package

swift-math-parser Basic math expression parser built with Point•Free's swift-parsing package. NOTE: currently, this uses a fork of that fixes a parsin

Brad Howes 36 Dec 14, 2022