Skip to content

Commit

Permalink
Merge pull request #5291 from JuliaLang/anj/dotu
Browse files Browse the repository at this point in the history
Change complex dot to use cblas to avoid problem with complex return type
  • Loading branch information
staticfloat committed Jan 3, 2014
2 parents af66fc4 + 4720e92 commit 756a34a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions base/linalg/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ for (fname, elty) in ((:ddot_,:Float64),
end
end
end
for (fname, elty) in ((:zdotc_,:Complex128),
(:cdotc_,:Complex64))
for (fname, elty) in ((:cblas_zdotc_sub,:Complex128),
(:cblas_cdotc_sub,:Complex64))
@eval begin
# DOUBLE PRECISION FUNCTION DDOT(N,DX,INCX,DY,INCY)
# * .. Scalar Arguments ..
Expand All @@ -112,14 +112,16 @@ for (fname, elty) in ((:zdotc_,:Complex128),
# * .. Array Arguments ..
# DOUBLE PRECISION DX(*),DY(*)
function dotc(n::Integer, DX::Union(Ptr{$elty},Array{$elty}), incx::Integer, DY::Union(Ptr{$elty},Array{$elty}), incy::Integer)
result = Array($elty, 1)
ccall(($(string(fname)),libblas), $elty,
(Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}),
&n, DX, &incx, DY, &incy)
(BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}),
n, DX, incx, DY, incy, result)
result[1]
end
end
end
for (fname, elty) in ((:zdotu_,:Complex128),
(:cdotu_,:Complex64))
for (fname, elty) in ((:cblas_zdotu_sub,:Complex128),
(:cblas_cdotu_sub,:Complex64))
@eval begin
# DOUBLE PRECISION FUNCTION DDOT(N,DX,INCX,DY,INCY)
# * .. Scalar Arguments ..
Expand All @@ -128,9 +130,11 @@ for (fname, elty) in ((:zdotu_,:Complex128),
# * .. Array Arguments ..
# DOUBLE PRECISION DX(*),DY(*)
function dotu(n::Integer, DX::Union(Ptr{$elty},Array{$elty}), incx::Integer, DY::Union(Ptr{$elty},Array{$elty}), incy::Integer)
result = Array($elty, 1)
ccall(($(string(fname)),libblas), $elty,
(Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}),
&n, DX, &incx, DY, &incy)
(BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}),
n, DX, incx, DY, incy, result)
result[1]
end
end
end
Expand Down

0 comments on commit 756a34a

Please sign in to comment.