Skip to content

Commit

Permalink
Use BLAS copy for small arrays and memcpy otherwise.
Browse files Browse the repository at this point in the history
Threshold needs to be tuned better.
Close #121.
  • Loading branch information
ViralBShah committed Aug 5, 2011
1 parent 0ccfdca commit d9aa71f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions j/linalg_blas.j
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ end
@jl_blas_copy_macro :zcopy_ Complex128
@jl_blas_copy_macro :ccopy_ Complex64

function copy_to{T<:Union(Float64,Float32,Complex128,Complex64)}(dest::Array{T}, src::Array{T})
n = numel(src)
if n < 200
jl_blas_copy(n, pointer(src), 1, pointer(dest), 1)
else
copy_to(pointer(dest), pointer(src), ulong(numel(src)*sizeof(T)))
end
return dest
end

# DOUBLE PRECISION FUNCTION DDOT(N,DX,INCX,DY,INCY)
macro jl_blas_dot_macro(fname, eltype)
quote
Expand Down
5 changes: 5 additions & 0 deletions test/unittests.j
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ a = rand(n,n)
(l,u,p) = lu(a)
@assert sum(l[p,:]*u - a) < 1e-8
# arpack
asym = a+a'
(d,v) = eigs(asym, 3)
@assert sum(asym*v[:,1]-d[1]*v[:,1]) < 1e-8

# hash table
h = HashTable()
for i=1:100
Expand Down

0 comments on commit d9aa71f

Please sign in to comment.