@@ -97,4 +97,45 @@ function approximate_eigenvalues(A, tol, maxiter, symmetric, v0)
9797end
9898
9999find_breakdown (:: Type{Float64} ) = eps (Float64) * 10 ^ 6
100- find_breakdown (:: Type{Float32} ) = eps (Float64) * 10 ^ 3
100+ find_breakdown (:: Type{Float32} ) = eps (Float64) * 10 ^ 3
101+
102+ using Base. Threads
103+ #= function mul!(α::Number, A::SparseMatrixCSC, B::StridedVecOrMat, β::Number, C::StridedVecOrMat)
104+ A.n == size(B, 1) || throw(DimensionMismatch())
105+ A.m == size(C, 1) || throw(DimensionMismatch())
106+ size(B, 2) == size(C, 2) || throw(DimensionMismatch())
107+ nzv = A.nzval
108+ rv = A.rowval
109+ if β != 1
110+ β != 0 ? scale!(C, β) : fill!(C, zero(eltype(C)))
111+ end
112+ for k = 1:size(C, 2)
113+ for col = 1:A.n
114+ αxj = α*B[col,k]
115+ for j = A.colptr[col]:(A.colptr[col + 1] - 1)
116+ C[rv[j], k] += nzv[j]*αxj
117+ end
118+ end
119+ end
120+ C
121+ end
122+ spmatvec(A::SparseMatrixCSC{TA,S}, x::StridedVector{Tx}) where {TA,S,Tx} =
123+ (T = promote_type(TA, Tx); mul!(one(T), A, x, zero(T), similar(x, T, A.m)))=#
124+
125+ # export spmatvec
126+
127+ @static if haskey (ENV , " JULIA_NUM_THREADS" )
128+ import Base: *
129+ function * (A:: SparseMatrixCSC{T,V} , b:: Vector{T} ) where {T,V}
130+ m, n = size (A)
131+ ret = zeros (T, m)
132+ @threads for i = 1 : n
133+ for j in nzrange (A, i)
134+ row = A. rowval[j]
135+ val = A. nzval[j]
136+ ret[row] += val * b[i]
137+ end
138+ end
139+ ret
140+ end
141+ end
0 commit comments