This provides a Julia interface to some of OS X's Accelerate framework. At the moment, the package consists mostly of an interface to the array-oriented functions, which provide a vectorised form of many common mathematical functions, however the package does provide access to several other vectorized operations and more are being added on a regular basis. In general, the performance is significantly better than using standard libm functions, though there does appear to be some reduced accuracy.

The following functions are supported:

*Rounding*:`ceil`

,`floor`

,`trunc`

,`round`

*Logarithmic*:`exp`

,`exp2`

,`expm1`

,`log`

,`log1p`

,`log2`

,`log10`

*Trigonometric*:`sin`

,`sinpi`

,`cos`

,`cospi`

,`tan`

,`tanpi`

,`asin`

,`acos`

,`atan`

,`atan2`

,`cis`

*Hyperbolic*:`sinh`

,`cosh`

,`tanh`

,`asinh`

,`acosh`

,`atanh`

*Convolution*:`conv`

,`xcorr`

*Other*:`sqrt`

,`copysign`

,`exponent`

,`abs`

,`rem`

Note there are some slight differences from behaviour in Base:

- No
`DomainError`

s are raised, instead`NaN`

values are returned. `round`

breaks ties (values with a fractional part of 0.5) by choosing the nearest even value.`exponent`

returns a floating point value of the same type (instead of an`Int`

).

Some additional functions that are also available:

`rec(x)`

: reciprocal (`1.0 ./ x`

)`rsqrt(x)`

: reciprocal square-root (`1.0 ./ sqrt(x)`

)`pow(x,y)`

: power (`x .^ y`

in Base)`fdiv(x,y)`

: divide (`x ./ y`

in Base)`sincos(x)`

: returns`(sin(x), cos(x))`

To avoid naming conflicts with Base, methods are not exported and so need to be accessed via the namespace:

```
using AppleAccelerate
X = randn(1_000_000)
@time Y = exp(X) # standard libm function
@time Y = AppleAccelerate.exp(X) # Accelerate array-oriented function
```

The `@replaceBase`

macro replaces the relevant Base methods directly

```
AppleAccelerate.@replaceBase sin cos tan
AppleAccelerate.@replaceBase(.^, ./) # use parenthesised form for infix ops
@time sin(X) # will use AppleAccelerate methods for vectorised operations
```

Output arrays can be specified as first arguments of the functions suffixed
with `!`

:

```
out = Array(Float64,1_000_000)
@time AppleAccelerate.exp!(out, X)
```

**Warning**: no dimension checks are performed on the `!`

functions, so ensure
your input and output arrays are of the same length.

Operations can be performed in-place by specifying the output array as the
input array (e.g. `AppleAccelerate.exp!(X,X)`

). This is not mentioned in the
Accelerate docs, but this comment by one of the authors indicates that it is safe.

11/05/2014

4 months ago

87 commits