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