Skip to content

Commit 7184992

Browse files
authored
Avoid deepcopy (#393)
* Improvements in setindex! and fixorder * Remove deepcopy-ing tables in differentiate and integrate * Improving allocations in arithmetic methods * Avoid deepcopy * Bump patch version
1 parent a30f636 commit 7184992

6 files changed

Lines changed: 235 additions & 142 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TaylorSeries"
22
uuid = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea"
33
repo = "https://github.com/JuliaDiff/TaylorSeries.jl.git"
4-
version = "0.20.9"
4+
version = "0.20.10"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

ext/TaylorSeriesIAExt.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ module TaylorSeriesIAExt
22

33
using TaylorSeries
44

5-
import Base: ^, sqrt, log, asin, acos, acosh, atanh, iszero, ==
5+
import Base: ^, sqrt, log, asin, acos, acosh, atanh, iszero, ==,
6+
power_by_squaring
67

78
import TaylorSeries: _pow, pow!, evaluate, _evaluate, _evaluate!,
89
normalize_taylor, aff_normalize
@@ -64,16 +65,16 @@ for T in (:Taylor1, :TaylorN)
6465
@eval begin
6566
function ^(a::$T{Interval{T}}, n::S) where {T<:NumTypes, S<:Integer}
6667
n == 0 && return one(a)
67-
n == 1 && return deepcopy(a)
68+
n == 1 && return $T(a.coeffs[:], a.order)
6869
n == 2 && return TS.square(a)
6970
n < 0 && return a^float(n)
70-
return Base.power_by_squaring(a, n)
71+
return power_by_squaring(a, n)
7172
end
7273

7374
^(a::$T{Interval{T}}, r::Rational) where {T<:NumTypes} = a^float(r)
7475

7576
function ^(a::$T{Interval{T}}, r::S) where {T<:NumTypes, S<:Real}
76-
isinteger(r) && r 0 && return TS.power_by_squaring(a, Integer(r))
77+
isinteger(r) && r 0 && return power_by_squaring(a, Integer(r))
7778
a0 = _intersect_domain_nonstd(constant_term(a), interval(zero(T), T(Inf)))
7879
@assert !isempty_interval(a0)
7980
aux = one(a0^r)
@@ -92,11 +93,11 @@ for T in (:Taylor1, :TaylorN)
9293
# _pow
9394
function _pow(a::$T{Interval{S}}, n::Integer) where {S<:NumTypes}
9495
n < 0 && return _pow(a, float(n))
95-
return TS.power_by_squaring(a, n)
96+
return power_by_squaring(a, n)
9697
end
9798

9899
function _pow(a::$T{Interval{T}}, r::S) where {T<:NumTypes, S<:Real}
99-
isinteger(r) && r 0 && return TS.power_by_squaring(a, Integer(r))
100+
isinteger(r) && r 0 && return power_by_squaring(a, Integer(r))
100101
a0 = _intersect_domain_nonstd(constant_term(a), interval(zero(T), T(Inf)))
101102
@assert !isempty_interval(a0)
102103
aux = one(a0^r)

0 commit comments

Comments
 (0)