Giter Site home page Giter Site logo

twhaolee / numswift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dboyliao/numswift

0.0 2.0 0.0 42.92 MB

Basic Numeric Operations and Functions for Swift (Based on Accelerate Framework)

License: MIT License

Makefile 4.63% Swift 91.23% Python 3.06% Ruby 0.78% Objective-C 0.31%

numswift's Introduction

Numeric Operations for Swift

This project is just a simple practice on Swift and Accelerate framework. The swift files contain some basic function used in numeric computation. The main functionality is build upon Accelearate framework which leaverages SIMD of the CPU, which make the codes run faster than native Swift code.

I am a big fan of python. In this project, you can find many of the functions mimic the API from numpy which is a popular package for scientific computation.

I hope you enjoy this package. Cheers.

Dependency

  • Accelerate framework
  • Foundation framework

Testing

First, change working directory to NumSwift.

Setup Testing Environment

We use numpy (python package for numeric computation) as reference. Please setup the python environment by following steps:

  • Instll python and virtualenv.
    • See this guide for detail of virtualenv
  • Activate a testing virtual environment.
    virtualenv venv_test
    source venv_test/bin/activate
    
  • Install required python packages
    • run pip install -r requirements.txt

You are ready to go!

Running Tests for Swift

  • Run make test-osx on Mac OSX.

Build

Importable Module

  • change working directory to NumSwift
  • Run make module
  • You will see a directory named NumSwiftModule
    • There are three files in that directory: NumSwift.swiftmodule, NumSwift.swiftdoc and libNumSwift.dylib
  • Include files generated in NumSwiftModule in you Xcode Project.
    • If you hate Xcode just like me, you can use swiftc instead with flags -I and -L
    • ex: Suppose you have a main.swift and import NumSwift in it, you can run xcrun -sdk macosx swiftc -I /path/to/NumSwiftModule -L /path/to/NumSwiftModule -lNumSwift -o main.

Importable Framework

  • Open NumSwift.xcodeproj under NumSwift/NumSwift/ directory.
  • Press Build.
  • You should be able to see NumSwift.framework under NumSwift/NumSwift/. Drag the framework file to any project you'd like to use it.
  • You should be able to import NumSwift in your project.

References

Accelerate Framework

Fourier Transform

  • DFT v.s FFT
  • vDSP Guide - DFT
    • That is why we use vDSP_DFT_XXX rather than vDSP_fft_XXX.
    • The header file which states you should prefer DFT over fft is located in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Kernel.framework/Versions/Current/Headers/vecLib on my computer. Go see it for yourself.

Matrix

Licence

MIT

numswift's People

Contributors

dboyliao avatar readmecritic avatar twhaolee avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.