nazywamsiepawel / Algae

SIMD/GPU support for Matrix operations in Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

algae

Algae is a fast matrix processing library written in Swift. Uses Accelerate and Metal.

##features

  • Constructors
  • Extractors
  • Element-wise operations (e.g. trig functions, abs)
  • Column or row-wise operators
  • Matrix-wide operations.
  • Basic Linear Algebra Subprograms (e.g. scalar multiplication, matrix multiplication, dot products)
  • GPU support using Metal

##examples

  • Multilayer perceptron.
  • Speed-test

Vector

Constructing a Vector

  /* 5-dimension vector. By default filled with zeros */
  let v = Vector(size:5)
  /* 5-dimensional vector. Filled with given data */
  let v2 = Vector(data:[1.0, 2.0, 3.0, 4.0, 5.0])

Copying a Vector

  let m = m2.copy()

Matrix

Constructing a matrix

  /* 2x2 Matrix. By default filled with zeros */
  let m = Matrix(rows:2, columns:2)
  /* 2x2 Matrix. Filled with given data */
  let m2 = Matrix(rows:2, columns:2, data:[1.0, 2.0, 3.0, 4.0])

Constructing an identity matrix

  /* 2x2 Matrix. By default filled with zeros */
  let m = Algae.eye(size:2, fill:1.0)

Copying a matrix

  let m = m2.copy()

Basic operations

Element-wise sum and difference

Element-wise multiplication and division

Maximum and minimum

Mean, median, standard deviation and variance

Vector dot product

Matrix vector product

Matrix matrix product

Element-wise mathematical operations

Negation

Element wise abs, sin, cos, tan, pow, sqrt, tanh etc.

Custom operators

About

SIMD/GPU support for Matrix operations in Swift


Languages

Language:Swift 98.5%Language:Objective-C 1.5%