Skip to content

Commit

Permalink
rename -> AppleAccelerate.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne committed Nov 13, 2014
1 parent df1e32a commit cf36f5b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -11,4 +11,4 @@ before_install:
- curl http://julialang.org/install-julia.sh | sh -s $JULIAVERSION
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
script:
- julia -e 'versioninfo(); Pkg.init(); Pkg.clone(pwd()); Pkg.clone("FactCheck"); Pkg.test("OSXAccelerate")'
- julia -e 'versioninfo(); Pkg.init(); Pkg.clone(pwd()); Pkg.clone("FactCheck"); Pkg.test("AppleAccelerate")'
2 changes: 1 addition & 1 deletion LICENSE.md
@@ -1,4 +1,4 @@
The Accelerate.jl package is licensed under the MIT "Expat" License:
The AppleAccelerate.jl package is licensed under the MIT "Expat" License:

> Copyright (c) 2014: Simon Byrne.
>
Expand Down
20 changes: 10 additions & 10 deletions README.md
@@ -1,6 +1,6 @@
# OSXAccelerate.jl
# AppleAccelerate.jl

[![Build Status](https://travis-ci.org/simonbyrne/OSXAccelerate.jl.svg?branch=master)](https://travis-ci.org/simonbyrne/OSXAccelerate.jl)
[![Build Status](https://travis-ci.org/simonbyrne/AppleAccelerate.jl.svg?branch=master)](https://travis-ci.org/simonbyrne/AppleAccelerate.jl)

This provides a Julia interface to some of
[OS X's Accelerate framework](https://developer.apple.com/library/mac/documentation/Accelerate/Reference/AccelerateFWRef/). At
Expand Down Expand Up @@ -36,29 +36,29 @@ Some additional functions that are also available:
To avoid naming conflicts with Base, methods are not exported and so need to
be accessed via the namespace:
```julia
using OSXAccelerate
using AppleAccelerate
X = randn(1_000_000)
@time Y = exp(X) # standard libm function
@time Y = OSXAccelerate.exp(X) # OSXAccelerate array-oriented function
@time Y = AppleAccelerate.exp(X) # AppleAccelerate array-oriented function
```

The `@replaceBase` macro replaces the relevant Base methods directly
```julia
OSXAccelerate.@replaceBase sin cos tan
OSXAccelerate.@replaceBase(.^, ./) # use parenthesised form for infix ops
@time sin(X) # will use OSXAccelerate methods for vectorised operations
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 `!`:
```julia
out = Array(Float64,1_000_000)
@time OSXAccelerate.exp!(out, X)
@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. `OSXAccelerate.exp!(X,X)`), but this is not mentioned in the
OSXAccelerate docs, so do this at your own risk!
input array (e.g. `AppleAccelerate.exp!(X,X)`), but this is not mentioned in the
AppleAccelerate docs, so do this at your own risk!
2 changes: 1 addition & 1 deletion src/OSXAccelerate.jl → src/AppleAccelerate.jl
@@ -1,4 +1,4 @@
module OSXAccelerate
module AppleAccelerate

const libacc = "/System/Library/Frameworks/Accelerate.framework/Accelerate"

Expand Down
52 changes: 26 additions & 26 deletions test/runtests.jl
@@ -1,4 +1,4 @@
using OSXAccelerate
using AppleAccelerate
using FactCheck

srand(7)
Expand All @@ -9,7 +9,7 @@ facts("Rounding") do
X = 100*randn(N)
for f in [:floor,:ceil,:trunc,:round]
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X) => fb(X) "Mismatch for $f"
end
end
Expand All @@ -19,19 +19,19 @@ facts("Logarithmic/exponential") do
X = 100*randn(N)
for f in [:exp,:exp2,:expm1]
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X) => roughly(fb(X)) "Mismatch for $f"
end
X = exp(10*randn(N))
for f in [:log,:log2,:log10]
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X) => roughly(fb(X)) "Mismatch for $f"
end
X = expm1(10*randn(N))
for f in [:log1p]
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X) => roughly(fb(X)) "Mismatch for $f"
end
end
Expand All @@ -40,21 +40,21 @@ facts("Trigonometric") do
X = 10*randn(N)
for f in [:sin,:sinpi,:cos,:cospi,:tan,:atan] # tanpi not defined in Base
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X) => roughly(fb(X)) "Mismatch for $f"
end

Y = 10*randn(N)
for f in [:atan2]
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X,Y) => roughly(fb(X,Y)) "Mismatch for $f"
end

X = 2*rand(N)-1
for f in [:asin,:acos] # tanpi not defined in Base
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X) => roughly(fb(X)) "Mismatch for $f"
end
end
Expand All @@ -64,21 +64,21 @@ facts("Hyperbolic") do
X = 10*randn(N)
for f in [:sinh,:cosh,:tanh,:asinh]
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X) => roughly(fb(X)) "Mismatch for $f"
end

X = exp(10*randn(N))+1
for f in [:acosh]
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X) => roughly(fb(X)) "Mismatch for $f"
end

X = 2*rand(N)-1
for f in [:atanh]
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X) => roughly(fb(X)) "Mismatch for $f"
end
end
Expand All @@ -88,49 +88,49 @@ facts("Misc.") do
X = exp(10*randn(N))
for f in [:sqrt]
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X) => roughly(fb(X)) "Mismatch for $f"
end

X = 10*randn(N)
for f in [:exponent, :abs]
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X) => roughly(fb(X)) "Mismatch for $f"
end

Y = 10*randn(N)
for f in [:copysign]
@eval fb = $f
@eval fa = OSXAccelerate.$f
@eval fa = AppleAccelerate.$f
@fact fa(X,Y) => roughly(fb(X,Y)) "Mismatch for $f"
end
@fact OSXAccelerate.rem(X,Y) => [rem(X[i], Y[i]) for i=1:length(X)] # no vectorized rem
@fact AppleAccelerate.rem(X,Y) => [rem(X[i], Y[i]) for i=1:length(X)] # no vectorized rem
end

facts("Extra") do
X = randn(N)
Y = abs(randn(N))

@fact OSXAccelerate.rec(X) => roughly(1./X)
@fact OSXAccelerate.rsqrt(Y) => roughly(1./sqrt(Y))
@fact OSXAccelerate.pow(Y,X) => roughly(Y.^X)
@fact OSXAccelerate.div(X,Y) => roughly(X./Y)
@fact AppleAccelerate.rec(X) => roughly(1./X)
@fact AppleAccelerate.rsqrt(Y) => roughly(1./sqrt(Y))
@fact AppleAccelerate.pow(Y,X) => roughly(Y.^X)
@fact AppleAccelerate.div(X,Y) => roughly(X./Y)

@fact [OSXAccelerate.sincos(X)...] => roughly([sin(X),cos(X)])
@fact OSXAccelerate.cosisin(X) => roughly(cos(X)+im*sin(X))
@fact [AppleAccelerate.sincos(X)...] => roughly([sin(X),cos(X)])
@fact AppleAccelerate.cosisin(X) => roughly(cos(X)+im*sin(X))
end


facts("Replace Base") do
X = randn(N)
Y = abs(randn(N))

OSXAccelerate.@replaceBase(sin,atan2,./,.^)
@fact sin(X) => OSXAccelerate.sin(X)
@fact atan2(X,Y) => OSXAccelerate.atan2(X,Y)
@fact X ./ Y => OSXAccelerate.div(X,Y)
@fact Y ./ X => OSXAccelerate.div(Y,X)
AppleAccelerate.@replaceBase(sin,atan2,./,.^)
@fact sin(X) => AppleAccelerate.sin(X)
@fact atan2(X,Y) => AppleAccelerate.atan2(X,Y)
@fact X ./ Y => AppleAccelerate.div(X,Y)
@fact Y ./ X => AppleAccelerate.div(Y,X)
end

FactCheck.exitstatus()

0 comments on commit cf36f5b

Please sign in to comment.