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 c15a86c
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 @@ -735,12 +736,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 +750,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 +811,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 c15a86c

Please sign in to comment.