Skip to content

Commit

Permalink
Fix deprecations (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
femtocleaner[bot] authored and andreasnoack committed Aug 18, 2017
1 parent fa377a4 commit 29ba93b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions benchmark/advection_diffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function advection_dominated(;N = 50, β = 1000.0)
A, b
end

function laplace_matrix{T}(::Type{T}, n, dims)
function laplace_matrix(::Type{T}, n, dims) where T
D = second_order_central_diff(T, n)
A = copy(D)

Expand All @@ -40,7 +40,7 @@ function laplace_matrix{T}(::Type{T}, n, dims)
A
end

second_order_central_diff{T}(::Type{T}, dim) = convert(
second_order_central_diff(::Type{T}, dim) where {T} = convert(
SparseMatrixCSC{T, Int},
SymTridiagonal(fill(2 * one(T), dim), fill(-one(T), dim - 1))
)
4 changes: 2 additions & 2 deletions benchmark/benchmark-linear-systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ using IterativeSolvers
include("advection_diffusion.jl")

# A DiagonalMatrix that doesn't check whether it is singular in the \ op.
immutable DiagonalPreconditioner{T}
struct DiagonalPreconditioner{T}
diag::Vector{T}
end

function A_ldiv_B!{T}(y::AbstractVector{T}, A::DiagonalPreconditioner{T}, b::AbstractVector{T})
function A_ldiv_B!(y::AbstractVector{T}, A::DiagonalPreconditioner{T}, b::AbstractVector{T}) where T
for i = 1 : length(b)
@inbounds y[i] = A.diag[i] \ b[i]
end
Expand Down
4 changes: 2 additions & 2 deletions test/laplace_matrix.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function laplace_matrix{T}(::Type{T}, n, dims)
function laplace_matrix(::Type{T}, n, dims) where T
D = second_order_central_diff(T, n);
A = copy(D);

Expand All @@ -9,4 +9,4 @@ function laplace_matrix{T}(::Type{T}, n, dims)
A
end

second_order_central_diff{T}(::Type{T}, dim) = convert(SparseMatrixCSC{T, Int}, SymTridiagonal(fill(2 * one(T), dim), fill(-one(T), dim - 1)))
second_order_central_diff(::Type{T}, dim) where {T} = convert(SparseMatrixCSC{T, Int}, SymTridiagonal(fill(2 * one(T), dim), fill(-one(T), dim - 1)))
14 changes: 7 additions & 7 deletions test/lsmr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import Base.LinAlg: norm
# Type used in Dampenedtest
# solve (A'A + diag(v).^2 ) x = b
# using LSMR in the augmented space A' = [A ; diag(v)] b' = [b; zeros(size(A, 2)]
type DampenedVector{Ty, Tx}
mutable struct DampenedVector{Ty, Tx}
y::Ty
x::Tx
end

eltype(a::DampenedVector) = promote_type(eltype(a.y), eltype(a.x))
norm(a::DampenedVector) = sqrt(norm(a.y)^2 + norm(a.x)^2)

function copy!{Ty, Tx}(a::DampenedVector{Ty, Tx}, b::DampenedVector{Ty, Tx})
function copy!(a::DampenedVector{Ty, Tx}, b::DampenedVector{Ty, Tx}) where {Ty, Tx}
copy!(a.y, b.y)
copy!(a.x, b.x)
a
Expand All @@ -38,7 +38,7 @@ end
similar(a::DampenedVector, T) = DampenedVector(similar(a.y, T), similar(a.x, T))
length(a::DampenedVector) = length(a.y) + length(a.x)

type DampenedMatrix{TA, Tx}
mutable struct DampenedMatrix{TA, Tx}
A::TA
diagonal::Tx
end
Expand All @@ -52,8 +52,8 @@ function size(A::DampenedMatrix, dim::Integer)
dim == 2 ? n : 1
end

function A_mul_B!{TA, Tx, Ty}::Number, mw::DampenedMatrix{TA, Tx}, a::Tx,
β::Number, b::DampenedVector{Ty, Tx})
function A_mul_B!::Number, mw::DampenedMatrix{TA, Tx}, a::Tx,
β::Number, b::DampenedVector{Ty, Tx}) where {TA, Tx, Ty}
if β != 1.
if β == 0.
fill!(b, 0.)
Expand All @@ -66,8 +66,8 @@ function A_mul_B!{TA, Tx, Ty}(α::Number, mw::DampenedMatrix{TA, Tx}, a::Tx,
return b
end

function Ac_mul_B!{TA, Tx, Ty}::Number, mw::DampenedMatrix{TA, Tx}, a::DampenedVector{Ty, Tx},
β::Number, b::Tx)
function Ac_mul_B!::Number, mw::DampenedMatrix{TA, Tx}, a::DampenedVector{Ty, Tx},
β::Number, b::Tx) where {TA, Tx, Ty}
if β != 1.
if β == 0.
fill!(b, 0.)
Expand Down

0 comments on commit 29ba93b

Please sign in to comment.