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 Nov 30, 2018
1 parent c271362 commit 3ba74d6
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions stdlib/SparseArrays/src/linalg.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

import LinearAlgebra: checksquare
using Random: rand!

## sparse matrix multiplication

Expand Down Expand Up @@ -929,12 +930,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 @@ -949,7 +944,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 @@ -1010,7 +1005,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 3ba74d6

Please sign in to comment.