From c15a86c06d0692fdd11c5df0ac93f7247f9ddd16 Mon Sep 17 00:00:00 2001 From: Rafael Fourquet Date: Mon, 25 Dec 2017 16:21:04 +0100 Subject: [PATCH] LinearAlgebra: delete _rand_pm1! in favor of rand! --- stdlib/SparseArrays/src/linalg.jl | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/stdlib/SparseArrays/src/linalg.jl b/stdlib/SparseArrays/src/linalg.jl index 6e9a751dd4306..846a0e7bd3abc 100644 --- a/stdlib/SparseArrays/src/linalg.jl +++ b/stdlib/SparseArrays/src/linalg.jl @@ -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 @@ -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 @@ -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 @@ -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