@@ -344,6 +344,50 @@ for (fname, elty) in ((:cblas_zdotu_sub,:ComplexF64),
344
344
end
345
345
end
346
346
347
+ @inline function _dot_length_check (x,y)
348
+ n = length (x)
349
+ if n != length (y)
350
+ throw (DimensionMismatch (" dot product arguments have lengths $(length (x)) and $(length (y)) " ))
351
+ end
352
+ n
353
+ end
354
+
355
+ for (elty, f) in ((Float32, :dot ), (Float64, :dot ),
356
+ (ComplexF32, :dotc ), (ComplexF64, :dotc ),
357
+ (ComplexF32, :dotu ), (ComplexF64, :dotu ))
358
+ @eval begin
359
+ function $f (x:: DenseArray{$elty} , y:: DenseArray{$elty} )
360
+ n = _dot_length_check (x,y)
361
+ $ f (n, x, 1 , y, 1 )
362
+ end
363
+
364
+ function $f (x:: StridedVector{$elty} , y:: DenseArray{$elty} )
365
+ n = _dot_length_check (x,y)
366
+ xstride = stride (x,1 )
367
+ ystride = stride (y,1 )
368
+ x_delta = xstride < 0 ? n : 1
369
+ GC. @preserve x $ f (n,pointer (x,x_delta),xstride,y,ystride)
370
+ end
371
+
372
+ function $f (x:: DenseArray{$elty} , y:: StridedVector{$elty} )
373
+ n = _dot_length_check (x,y)
374
+ xstride = stride (x,1 )
375
+ ystride = stride (y,1 )
376
+ y_delta = ystride < 0 ? n : 1
377
+ GC. @preserve y $ f (n,x,xstride,pointer (y,y_delta),ystride)
378
+ end
379
+
380
+ function $f (x:: StridedVector{$elty} , y:: StridedVector{$elty} )
381
+ n = _dot_length_check (x,y)
382
+ xstride = stride (x,1 )
383
+ ystride = stride (y,1 )
384
+ x_delta = xstride < 0 ? n : 1
385
+ y_delta = ystride < 0 ? n : 1
386
+ GC. @preserve x y $ f (n,pointer (x,x_delta),xstride,pointer (y,y_delta),ystride)
387
+ end
388
+ end
389
+ end
390
+
347
391
function dot (DX:: Union{DenseArray{T},AbstractVector{T}} , DY:: Union{DenseArray{T},AbstractVector{T}} ) where T<: BlasReal
348
392
require_one_based_indexing (DX, DY)
349
393
n = length (DX)
0 commit comments