Skip to content

Commit

Permalink
LinearAlgebra: delete _rand_pm1! in favor of rand!
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Aug 13, 2018
1 parent bb0d78a commit 1594a1c
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions stdlib/SparseArrays/src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -735,12 +735,6 @@ function opnormestinv(A::SparseMatrixCSC{T}, t::Integer = min(2,maximum(size(A))

S = zeros(T <: Real ? Int : Ti, n, t)

function _rand_pm1!(v)
for i in eachindex(v)
v[i] = rand()<0.5 ? 1 : -1
end
end

function _any_abs_eq(v,n::Int)
for vv in v
if abs(vv)==n
Expand All @@ -755,7 +749,7 @@ function opnormestinv(A::SparseMatrixCSC{T}, t::Integer = min(2,maximum(size(A))
X[1:n,1] .= 1
for j = 2:t
while true
_rand_pm1!(view(X,1:n,j))
rand!(view(X,1:n,j), (-1, 1))
yaux = X[1:n,j]' * X[1:n,1:j-1]
if !_any_abs_eq(yaux,n)
break
Expand Down Expand Up @@ -816,7 +810,7 @@ function opnormestinv(A::SparseMatrixCSC{T}, t::Integer = min(2,maximum(size(A))
end
end
if repeated
_rand_pm1!(view(S,1:n,j))
rand!(view(S,1:n,j), (-1, 1))
else
break
end
Expand Down

0 comments on commit 1594a1c

Please sign in to comment.