Skip to content

Commit 4b7279a

Browse files
committed
Add scal!(n,a,X) (#40020)
1 parent fc69c9a commit 4b7279a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

stdlib/LinearAlgebra/src/blas.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,22 @@ end
217217
## scal
218218

219219
"""
220+
scal!(n, a, X)
220221
scal!(n, a, X, incx)
221222
222223
Overwrite `X` with `a*X` for the first `n` elements of array `X` with stride `incx`. Returns `X`.
224+
225+
Uses `stride1(X)` as stride if `incx` is not passed.
223226
"""
224227
function scal! end
225228

226229
"""
230+
scal(n, a, X)
227231
scal(n, a, X, incx)
228232
229233
Return `X` scaled by `a` for the first `n` elements of array `X` with stride `incx`.
234+
235+
Uses `stride(X,1)` as stride if `incx` is not passed.
230236
"""
231237
function scal end
232238

@@ -242,9 +248,12 @@ for (fname, elty) in ((:dscal_,:Float64),
242248
n, DA, DX, incx)
243249
DX
244250
end
251+
252+
scal!(n::Integer, DA::$elty, DX::AbstractArray{$elty}) = scal!(n,DA,DX,stride(DX,1))
245253
end
246254
end
247255
scal(n, DA, DX, incx) = scal!(n, DA, copy(DX), incx)
256+
scal(n, DA, DX) = scal!(n, DA, copy(DX))
248257

249258
## dot
250259

0 commit comments

Comments
 (0)