Skip to content

Commit

Permalink
Use rot! instead of rot
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Mar 16, 2020
1 parent 2a212fb commit c2932e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Standard library changes
* `normalize` now supports multidimensional arrays ([#34239])
* `lq` factorizations can now be used to compute the minimum-norm solution to under-determined systems ([#34350]).
* The BLAS submodule now supports the level-2 BLAS subroutine `spmv!` ([#34320]).
* The BLAS submodule now supports the level-1 BLAS subroutine `rot` ([#35124]).
* The BLAS submodule now supports the level-1 BLAS subroutine `rot!` ([#35124]).
#### Markdown


Expand Down
9 changes: 6 additions & 3 deletions stdlib/LinearAlgebra/src/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ using Base: require_one_based_indexing

export
# Level 1
rot,
asum,
rot!,
axpy!,
axpby!,
blascopy!,
Expand Down Expand Up @@ -203,10 +203,13 @@ end
## rot

"""
rot(n, X, incx, Y, incy, c, s)
rot!(n, X, incx, Y, incy, c, s)
Overwrite `X` with `c*X + s*Y` and `Y` with `-conj(s)*X + c*Y` for the first `n` elements of array `X` with stride `incx` and
first `n` elements of array `Y` with stride `incy`. Returns `X` and `Y`.
!!! compat "Julia 1.5"
`rot!` requires at least Julia 1.5.
"""
function rot end

Expand All @@ -218,7 +221,7 @@ for (fname, elty, cty, sty, lib) in ((:drot_, :Float64, :Float64, :Float64, libb
(:crot_, :ComplexF32, :Float32, :ComplexF32, liblapack))
@eval begin
# SUBROUTINE DROT(N,DX,INCX,DY,INCY,C,S)
function rot(n::Integer, DX::Union{Ptr{$elty},AbstractArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},AbstractArray{$elty}}, incy::Integer, C::$cty, S::$sty)
function rot!(n::Integer, DX::Union{Ptr{$elty},AbstractArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},AbstractArray{$elty}}, incy::Integer, C::$cty, S::$sty)
ccall((@blasfunc($fname), $lib), Cvoid,
(Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}, Ref{$cty}, Ref{$sty}),
n, DX, incx, DY, incy, C, S)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/LinearAlgebra/test/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Random.seed!(100)
y = convert(Vector{elty}, randn(n))
c = rand(elty)
s = rand(elty)
x2, y2 = BLAS.rot(n,copy(x),1,copy(y),1,c,s)
x2, y2 = BLAS.rot!(n,copy(x),1,copy(y),1,c,s)
@test x2 c*x + s*y
@test y2 -s*x + c*y
else
Expand All @@ -94,7 +94,7 @@ Random.seed!(100)
c = rand(cty)
for sty in [cty, elty]
s = rand(sty)
x2, y2 = BLAS.rot(n,copy(x),1,copy(y),1,c,s)
x2, y2 = BLAS.rot!(n,copy(x),1,copy(y),1,c,s)
@test x2 c*x + s*y
@test y2 -conj(s)*x + c*y
end
Expand Down

0 comments on commit c2932e3

Please sign in to comment.