Skip to content

Commit 2639bac

Browse files
committed
Merge pull request #15258 from JuliaLang/anj/scale
Deprecate scale
2 parents e01b357 + dfbbedd commit 2639bac

22 files changed

+62
-123
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ Deprecated or removed
128128

129129
* `issym` is deprecated in favor of `issymmetric` to match similar functions (`ishermitian`, ...) ([#15192])
130130

131+
* `scale` is deprecated in favor of either `α*A`, `Diagonal(x)*A`, or `A*Diagonal(x)`. ([#15258])
132+
131133
Julia v0.4.0 Release Notes
132134
==========================
133135

base/deprecated.jl

+6
Original file line numberDiff line numberDiff line change
@@ -993,3 +993,9 @@ export call
993993

994994
# Changed issym to issymmetric. #15192
995995
@deprecate issym issymmetric
996+
997+
# 15258
998+
@deprecate scale::Number, A::AbstractArray) α*A
999+
@deprecate scale(A::AbstractArray, α::Number) A*α
1000+
@deprecate scale(A::AbstractMatrix, x::AbstractVector) A*Diagonal(x)
1001+
@deprecate scale(x::AbstractVector, A::AbstractMatrix) Diagonal(x)*A

base/docs/helpdb/Base.jl

+3-18
Original file line numberDiff line numberDiff line change
@@ -4382,20 +4382,6 @@ i-th dimension of `A` should be repeated.
43824382
"""
43834383
repeat
43844384

4385-
"""
4386-
scale(A, b)
4387-
scale(b, A)
4388-
4389-
Scale an array `A` by a scalar `b`, returning a new array.
4390-
4391-
If `A` is a matrix and `b` is a vector, then `scale(A,b)` scales each column `i` of `A` by
4392-
`b[i]` (similar to `A*diagm(b)`), while `scale(b,A)` scales each row `i` of `A` by `b[i]`
4393-
(similar to `diagm(b)*A`), returning a new array.
4394-
4395-
Note: for large `A`, `scale` can be much faster than `A .* b` or `b .* A`, due to the use of BLAS.
4396-
"""
4397-
scale
4398-
43994385
"""
44004386
ReentrantLock()
44014387
@@ -6680,12 +6666,11 @@ issetuid
66806666
scale!(A, b)
66816667
scale!(b, A)
66826668
6683-
Scale an array `A` by a scalar `b`, similar to [`scale`](:func:`scale`) but overwriting `A`
6684-
in-place.
6669+
Scale an array `A` by a scalar `b` overwriting `A` in-place.
66856670
66866671
If `A` is a matrix and `b` is a vector, then `scale!(A,b)` scales each column `i` of `A` by
6687-
`b[i]` (similar to `A*diagm(b)`), while `scale!(b,A)` scales each row `i` of `A` by `b[i]`
6688-
(similar to `diagm(b)*A`), again operating in-place on `A`.
6672+
`b[i]` (similar to `A*Diagonal(b)`), while `scale!(b,A)` scales each row `i` of `A` by `b[i]`
6673+
(similar to `Diagonal(b)*A`), again operating in-place on `A`.
66896674
66906675
"""
66916676
scale!

base/linalg.jl

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ export
111111
lqfact!,
112112
lqfact,
113113
rank,
114-
scale,
115114
scale!,
116115
schur,
117116
schurfact!,

base/linalg/dense.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function ^(A::Matrix, p::Number)
179179
v, X = eig(A)
180180
any(v.<0) && (v = complex(v))
181181
Xinv = ishermitian(A) ? X' : inv(X)
182-
scale(X, v.^p)*Xinv
182+
(X * Diagonal(v.^p)) * Xinv
183183
end
184184

185185
# Matrix exponential
@@ -483,7 +483,7 @@ function pinv{T}(A::StridedMatrix{T}, tol::Real)
483483
index = SVD.S .> tol*maximum(SVD.S)
484484
Sinv[index] = one(Stype) ./ SVD.S[index]
485485
Sinv[find(!isfinite(Sinv))] = zero(Stype)
486-
return SVD.Vt'scale(Sinv, SVD.U')
486+
return SVD.Vt' * (Diagonal(Sinv) * SVD.U')
487487
end
488488
function pinv{T}(A::StridedMatrix{T})
489489
tol = eps(real(float(one(T))))*maximum(size(A))

base/linalg/diagonal.jl

+6-4
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ end
106106
/{T<:Number}(D::Diagonal, x::T) = Diagonal(D.diag / x)
107107
*(Da::Diagonal, Db::Diagonal) = Diagonal(Da.diag .* Db.diag)
108108
*(D::Diagonal, V::AbstractVector) = D.diag .* V
109-
*(A::AbstractMatrix, D::Diagonal) = scale(A,D.diag)
110-
*(D::Diagonal, A::AbstractMatrix) = scale(D.diag,A)
109+
*(A::AbstractMatrix, D::Diagonal) =
110+
scale!(similar(A, promote_op(MulFun(), eltype(A), eltype(D.diag))), A, D.diag)
111+
*(D::Diagonal, A::AbstractMatrix) =
112+
scale!(similar(A, promote_op(MulFun(), eltype(A), eltype(D.diag))), D.diag, A)
111113

112114
A_mul_B!(A::Diagonal,B::AbstractMatrix) = scale!(A.diag,B)
113115
At_mul_B!(A::Diagonal,B::AbstractMatrix)= scale!(A.diag,B)
@@ -181,8 +183,8 @@ function A_ldiv_B!(D::Diagonal, B::StridedVecOrMat)
181183
end
182184
return B
183185
end
184-
(\)(D::Diagonal, B::AbstractMatrix) = scale(1 ./ D.diag, B)
185-
(\)(D::Diagonal, b::AbstractVector) = reshape(scale(1 ./ D.diag, reshape(b, length(b), 1)), length(b))
186+
(\)(D::Diagonal, A::AbstractMatrix) = D.diag .\ A
187+
(\)(D::Diagonal, b::AbstractVector) = D.diag .\ b
186188
(\)(Da::Diagonal, Db::Diagonal) = Diagonal(Db.diag ./ Da.diag)
187189

188190
function inv{T}(D::Diagonal{T})

base/linalg/generic.jl

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
## linalg.jl: Some generic Linear Algebra definitions
44

5-
scale(X::AbstractArray, s::Number) = X*s
6-
scale(s::Number, X::AbstractArray) = s*X
7-
85
# For better performance when input and output are the same array
96
# See https://github.com/JuliaLang/julia/issues/8415#issuecomment-56608729
107
function generic_scale!(X::AbstractArray, s::Number)

base/linalg/matmul.jl

-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ function scale!(C::AbstractMatrix, b::AbstractVector, A::AbstractMatrix)
3838
end
3939
C
4040
end
41-
scale(A::AbstractMatrix, b::AbstractVector) = scale!(similar(A, promote_op(MulFun(),eltype(A),eltype(b))), A, b)
42-
scale(b::AbstractVector, A::AbstractMatrix) = scale!(similar(b, promote_op(MulFun(),eltype(b),eltype(A)), size(A)), b, A)
4341

4442
# Dot products
4543

base/sparse.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Base: @get!, acos, acosd, acot, acotd, acsch, asech, asin, asind, asinh,
2121
exp, expm1, factorize, find, findmax, findmin, findnz, float, full, getindex,
2222
hcat, hvcat, imag, indmax, ishermitian, kron, length, log, log1p, max, min,
2323
maximum, minimum, norm, one, promote_eltype, real, reinterpret, reshape, rot180,
24-
rotl90, rotr90, round, scale, scale!, setindex!, similar, size, transpose, tril,
24+
rotl90, rotr90, round, scale!, setindex!, similar, size, transpose, tril,
2525
triu, vcat, vec
2626

2727
import Base.Broadcast: eltype_plus, broadcast_shape

base/sparse/cholmod.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ function sparse(F::Factor)
10201020
else
10211021
LD = sparse(F[:LD])
10221022
L, d = getLd!(LD)
1023-
A = scale(L, d)*L'
1023+
A = (L * Diagonal(d)) * L'
10241024
end
10251025
SparseArrays.sortSparseMatrixCSC!(A)
10261026
p = get_perm(F)

base/sparse/linalg.jl

-6
Original file line numberDiff line numberDiff line change
@@ -826,12 +826,6 @@ end
826826
scale!(A::SparseMatrixCSC, b::Number) = (scale!(A.nzval, b); A)
827827
scale!(b::Number, A::SparseMatrixCSC) = (scale!(b, A.nzval); A)
828828

829-
scale{Tv,Ti,T}(A::SparseMatrixCSC{Tv,Ti}, b::Vector{T}) =
830-
scale!(similar(A, promote_type(Tv,T)), A, b)
831-
832-
scale{T,Tv,Ti}(b::Vector{T}, A::SparseMatrixCSC{Tv,Ti}) =
833-
scale!(similar(A, promote_type(Tv,T)), b, A)
834-
835829
function factorize(A::SparseMatrixCSC)
836830
m, n = size(A)
837831
if m == n

base/sparse/sparsevector.jl

+5-12
Original file line numberDiff line numberDiff line change
@@ -1191,18 +1191,11 @@ scale!(x::AbstractSparseVector, a::Complex) = (scale!(nonzeros(x), a); x)
11911191
scale!(a::Real, x::AbstractSparseVector) = scale!(nonzeros(x), a)
11921192
scale!(a::Complex, x::AbstractSparseVector) = scale!(nonzeros(x), a)
11931193

1194-
scale(x::AbstractSparseVector, a::Real) =
1195-
SparseVector(length(x), copy(nonzeroinds(x)), scale(nonzeros(x), a))
1196-
scale(x::AbstractSparseVector, a::Complex) =
1197-
SparseVector(length(x), copy(nonzeroinds(x)), scale(nonzeros(x), a))
1198-
1199-
scale(a::Real, x::AbstractSparseVector) = scale(x, a)
1200-
scale(a::Complex, x::AbstractSparseVector) = scale(x, a)
1201-
1202-
*(x::AbstractSparseVector, a::Number) = scale(x, a)
1203-
*(a::Number, x::AbstractSparseVector) = scale(x, a)
1204-
.*(x::AbstractSparseVector, a::Number) = scale(x, a)
1205-
.*(a::Number, x::AbstractSparseVector) = scale(x, a)
1194+
# *(x::AbstractSparseVector, a::Real) = SparseVector(length(x), copy(nonzeroinds(x)), scale(nonzeros(x), a))
1195+
# *(x::AbstractSparseVector, a::Complex) = SparseVector(length(x), copy(nonzeroinds(x)), scale(nonzeros(x), a))
1196+
# *(a::Number, x::AbstractSparseVector) = xa)
1197+
# .*(x::AbstractSparseVector, a::Number) = scale(x, a)
1198+
# .*(a::Number, x::AbstractSparseVector) = scale(x, a)
12061199

12071200

12081201
# dot

doc/stdlib/linalg.rst

+2-13
Original file line numberDiff line numberDiff line change
@@ -823,25 +823,14 @@ Linear algebra functions in Julia are largely implemented by calling functions f
823823
824824
Construct a diagonal matrix and place ``v`` on the ``k``\ th diagonal.
825825

826-
.. function:: scale(A, b)
827-
scale(b, A)
828-
829-
.. Docstring generated from Julia source
830-
831-
Scale an array ``A`` by a scalar ``b``\ , returning a new array.
832-
833-
If ``A`` is a matrix and ``b`` is a vector, then ``scale(A,b)`` scales each column ``i`` of ``A`` by ``b[i]`` (similar to ``A*diagm(b)``\ ), while ``scale(b,A)`` scales each row ``i`` of ``A`` by ``b[i]`` (similar to ``diagm(b)*A``\ ), returning a new array.
834-
835-
Note: for large ``A``\ , ``scale`` can be much faster than ``A .* b`` or ``b .* A``\ , due to the use of BLAS.
836-
837826
.. function:: scale!(A, b)
838827
scale!(b, A)
839828

840829
.. Docstring generated from Julia source
841830
842-
Scale an array ``A`` by a scalar ``b``\ , similar to :func:`scale` but overwriting ``A`` in-place.
831+
Scale an array ``A`` by a scalar ``b`` overwriting ``A`` in-place.
843832

844-
If ``A`` is a matrix and ``b`` is a vector, then ``scale!(A,b)`` scales each column ``i`` of ``A`` by ``b[i]`` (similar to ``A*diagm(b)``\ ), while ``scale!(b,A)`` scales each row ``i`` of ``A`` by ``b[i]`` (similar to ``diagm(b)*A``\ ), again operating in-place on ``A``\ .
833+
If ``A`` is a matrix and ``b`` is a vector, then ``scale!(A,b)`` scales each column ``i`` of ``A`` by ``b[i]`` (similar to ``A*Diagonal(b)``\ ), while ``scale!(b,A)`` scales each row ``i`` of ``A`` by ``b[i]`` (similar to ``Diagonal(b)*A``\ ), again operating in-place on ``A``\ .
845834

846835
.. function:: Tridiagonal(dl, d, du)
847836

test/blas.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ for elty in [Float32, Float64, Complex64, Complex128]
113113

114114
# scal
115115
α = rand(elty)
116-
@test BLAS.scal(n,α,a,1) scale(α,a)
116+
@test BLAS.scal(n,α,a,1) α * a
117117

118118
# trsv
119119
A = triu(rand(elty,n,n))

test/linalg/eigen.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ debug && println("symmetric generalized eigenproblem")
5050
asym_sg = asym[1:n1, 1:n1]
5151
a_sg = a[:,n1+1:n2]
5252
f = eigfact(asym_sg, a_sg'a_sg)
53-
@test_approx_eq asym_sg*f[:vectors] scale(a_sg'a_sg*f[:vectors], f[:values])
53+
@test_approx_eq asym_sg*f[:vectors] (a_sg'a_sg*f[:vectors]) * Diagonal(f[:values])
5454
@test_approx_eq f[:values] eigvals(asym_sg, a_sg'a_sg)
5555
@test_approx_eq_eps prod(f[:values]) prod(eigvals(asym_sg/(a_sg'a_sg))) 200ε
5656
@test eigvecs(asym_sg, a_sg'a_sg) == f[:vectors]
@@ -66,7 +66,7 @@ debug && println("Non-symmetric generalized eigenproblem")
6666
a1_nsg = a[1:n1, 1:n1]
6767
a2_nsg = a[n1+1:n2, n1+1:n2]
6868
f = eigfact(a1_nsg, a2_nsg)
69-
@test_approx_eq a1_nsg*f[:vectors] scale(a2_nsg*f[:vectors], f[:values])
69+
@test_approx_eq a1_nsg*f[:vectors] (a2_nsg*f[:vectors]) * Diagonal(f[:values])
7070
@test_approx_eq f[:values] eigvals(a1_nsg, a2_nsg)
7171
@test_approx_eq_eps prod(f[:values]) prod(eigvals(a1_nsg/a2_nsg)) 50000ε
7272
@test eigvecs(a1_nsg, a2_nsg) == f[:vectors]

test/linalg/generic.jl

+9-29
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,6 @@ let aa = reshape([1.:6;], (2,3))
105105
a = sub(aa, 1:2, 1:2)
106106
end
107107

108-
# 2-argument version of scale
109-
@test scale(a, 5.) == a*5
110-
@test scale(5., a) == a*5
111-
@test scale([1.; 2.], a) == a.*[1; 2]
112-
@test scale([1; 2], a) == a.*[1; 2]
113-
@test scale(eye(Int, 2), 0.5) == 0.5*eye(2)
114-
@test scale([1; 2], sub(a, :, :)) == a.*[1; 2]
115-
@test scale(sub([1; 2], :), a) == a.*[1; 2]
116-
@test_throws DimensionMismatch scale(ones(3), a)
117-
118-
if atype == "Array"
119-
@test scale(a, [1.; 2.; 3.]) == a.*[1 2 3]
120-
@test scale(a, [1; 2; 3]) == a.*[1 2 3]
121-
@test_throws DimensionMismatch scale(a, ones(2))
122-
else
123-
@test scale(a, [1.; 2.]) == a.*[1 2]
124-
@test scale(a, [1; 2]) == a.*[1 2]
125-
@test_throws DimensionMismatch scale(a, ones(3))
126-
end
127-
128108
# 2-argument version of scale!
129109
@test scale!(copy(a), 5.) == a*5
130110
@test scale!(5., copy(a)) == a*5
@@ -168,15 +148,15 @@ end
168148

169149
# scale real matrix by complex type
170150
@test_throws InexactError scale!([1.0], 2.0im)
171-
@test isequal(scale([1.0], 2.0im), Complex{Float64}[2.0im])
172-
@test isequal(scale(2.0im, [1.0]), Complex{Float64}[2.0im])
173-
@test isequal(scale(Float32[1.0], 2.0f0im), Complex{Float32}[2.0im])
174-
@test isequal(scale(Float32[1.0], 2.0im), Complex{Float64}[2.0im])
175-
@test isequal(scale(Float64[1.0], 2.0f0im), Complex{Float64}[2.0im])
176-
@test isequal(scale(Float32[1.0], big(2.0)im), Complex{BigFloat}[2.0im])
177-
@test isequal(scale(Float64[1.0], big(2.0)im), Complex{BigFloat}[2.0im])
178-
@test isequal(scale(BigFloat[1.0], 2.0im), Complex{BigFloat}[2.0im])
179-
@test isequal(scale(BigFloat[1.0], 2.0f0im), Complex{BigFloat}[2.0im])
151+
@test isequal([1.0] * 2.0im, Complex{Float64}[2.0im])
152+
@test isequal(2.0im * [1.0], Complex{Float64}[2.0im])
153+
@test isequal(Float32[1.0] * 2.0f0im, Complex{Float32}[2.0im])
154+
@test isequal(Float32[1.0] * 2.0im, Complex{Float64}[2.0im])
155+
@test isequal(Float64[1.0] * 2.0f0im, Complex{Float64}[2.0im])
156+
@test isequal(Float32[1.0] * big(2.0)im, Complex{BigFloat}[2.0im])
157+
@test isequal(Float64[1.0] * big(2.0)im, Complex{BigFloat}[2.0im])
158+
@test isequal(BigFloat[1.0] * 2.0im, Complex{BigFloat}[2.0im])
159+
@test isequal(BigFloat[1.0] * 2.0f0im, Complex{BigFloat}[2.0im])
180160

181161
# test scale and scale! for non-commutative multiplication
182162
q = Quaternion([0.44567, 0.755871, 0.882548, 0.423612])

test/linalg/lapack.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let # syevr
1616
A = convert(Array{elty, 2}, A)
1717
Asym = A'A
1818
vals, Z = LAPACK.syevr!('V', copy(Asym))
19-
@test_approx_eq Z*scale(vals, Z') Asym
19+
@test_approx_eq Z * (Diagonal(vals) * Z') Asym
2020
@test all(vals .> 0.0)
2121
@test_approx_eq LAPACK.syevr!('N','V','U',copy(Asym),0.0,1.0,4,5,-1.0)[1] vals[vals .< 1.0]
2222
@test_approx_eq LAPACK.syevr!('N','I','U',copy(Asym),0.0,1.0,4,5,-1.0)[1] vals[4:5]

test/linalg/svd.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ debug && println("\ntype of a: ", eltya, "\n")
3030
debug && println("singular value decomposition")
3131
usv = svdfact(a)
3232
@test usv[:S] === svdvals(usv)
33-
@test usv[:U]*scale(usv[:S],usv[:Vt]) a
33+
@test usv[:U] * (Diagonal(usv[:S]) * usv[:Vt]) a
3434
@test full(usv) a
3535
@test usv[:Vt]' usv[:V]
3636
@test_throws KeyError usv[:Z]

test/linalg/triangular.jl

-6
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,6 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa
207207
end
208208
end
209209

210-
@test scale(A1,0.5) == 0.5*A1
211-
@test scale(0.5,A1) == 0.5*A1
212-
@test scale(A1,0.5im) == 0.5im*A1
213-
@test scale(0.5im,A1) == 0.5im*A1
214-
215-
216210
# Binary operations
217211
@test A1*0.5 == full(A1)*0.5
218212
@test 0.5*A1 == 0.5*full(A1)

test/sparsedir/sparse.jl

+13-13
Original file line numberDiff line numberDiff line change
@@ -228,20 +228,20 @@ sA = sprandn(3, 7, 0.5)
228228
sC = similar(sA)
229229
dA = full(sA)
230230
b = randn(7)
231-
@test scale(dA, b) == scale(sA, b)
232-
@test scale(dA, b) == scale!(sC, sA, b)
233-
@test scale(dA, b) == scale!(copy(sA), b)
231+
@test dA * Diagonal(b) == sA * Diagonal(b)
232+
@test dA * Diagonal(b) == scale!(sC, sA, b)
233+
@test dA * Diagonal(b) == scale!(copy(sA), b)
234234
b = randn(3)
235-
@test scale(b, dA) == scale(b, sA)
236-
@test scale(b, dA) == scale!(sC, b, sA)
237-
@test scale(b, dA) == scale!(b, copy(sA))
238-
239-
@test scale(dA, 0.5) == scale(sA, 0.5)
240-
@test scale(dA, 0.5) == scale!(sC, sA, 0.5)
241-
@test scale(dA, 0.5) == scale!(copy(sA), 0.5)
242-
@test scale(0.5, dA) == scale(0.5, sA)
243-
@test scale(0.5, dA) == scale!(sC, sA, 0.5)
244-
@test scale(0.5, dA) == scale!(0.5, copy(sA))
235+
@test Diagonal(b) * dA == Diagonal(b) * sA
236+
@test Diagonal(b) * dA == scale!(sC, b, sA)
237+
@test Diagonal(b) * dA == scale!(b, copy(sA))
238+
239+
@test dA * 0.5 == sA * 0.5
240+
@test dA * 0.5 == scale!(sC, sA, 0.5)
241+
@test dA * 0.5 == scale!(copy(sA), 0.5)
242+
@test 0.5 * dA == 0.5 * sA
243+
@test 0.5 * dA == scale!(sC, sA, 0.5)
244+
@test 0.5 * dA == scale!(0.5, copy(sA))
245245
@test scale!(sC, 0.5, sA) == scale!(sC, sA, 0.5)
246246

247247
# copy!

test/sparsedir/sparsevector.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,10 @@ let x = sprand(16, 0.5), x2 = sprand(16, 0.4)
580580

581581
# scale
582582
let sx = SparseVector(x.n, x.nzind, x.nzval * 2.5)
583-
@test exact_equal(scale(x, 2.5), sx)
584-
@test exact_equal(scale(x, 2.5 + 0.0*im), complex(sx))
585-
@test exact_equal(scale(2.5, x), sx)
586-
@test exact_equal(scale(2.5 + 0.0*im, x), complex(sx))
583+
@test exact_equal(x * 2.5, sx)
584+
@test exact_equal(x * (2.5 + 0.0*im), complex(sx))
585+
@test exact_equal(2.5 * x, sx)
586+
@test exact_equal((2.5 + 0.0*im) * x, complex(sx))
587587
@test exact_equal(x * 2.5, sx)
588588
@test exact_equal(2.5 * x, sx)
589589
@test exact_equal(x .* 2.5, sx)

test/sparsedir/umfpack.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ for Tv in (Float64, Complex128)
1919
lua = lufact(A)
2020
@test nnz(lua) == 18
2121
L,U,p,q,Rs = lua[:(:)]
22-
@test_approx_eq scale(Rs,A)[p,q] L*U
22+
@test_approx_eq (Diagonal(Rs) * A)[p,q] L * U
2323

2424
@test_approx_eq det(lua) det(full(A))
2525

@@ -45,15 +45,15 @@ for Ti in Base.SparseArrays.UMFPACK.UMFITypes.types
4545
Ac = convert(SparseMatrixCSC{Complex128,Ti}, Ac0)
4646
lua = lufact(Ac)
4747
L,U,p,q,Rs = lua[:(:)]
48-
@test_approx_eq scale(Rs,Ac)[p,q] L*U
48+
@test_approx_eq (Diagonal(Rs) * Ac)[p,q] L * U
4949
end
5050

5151
for elty in (Float64, Complex128)
5252
for (m, n) in ((10,5), (5, 10))
5353
A = sparse([1:min(m,n); rand(1:m, 10)], [1:min(m,n); rand(1:n, 10)], elty == Float64 ? randn(min(m, n) + 10) : complex(randn(min(m, n) + 10), randn(min(m, n) + 10)))
5454
F = lufact(A)
5555
L, U, p, q, Rs = F[:(:)]
56-
@test_approx_eq scale(Rs,A)[p,q] L*U
56+
@test_approx_eq (Diagonal(Rs) * A)[p,q] L * U
5757
end
5858
end
5959

0 commit comments

Comments
 (0)