11module ContinuumArrays
22using IntervalSets, LinearAlgebra, LazyArrays, FillArrays, BandedMatrices, QuasiArrays, InfiniteArrays
3- import Base: @_inline_meta , @_propagate_inbounds_meta , axes, getindex, convert, prod, * , / , \ , + , - , == ,
3+ import Base: @_inline_meta , @_propagate_inbounds_meta , axes, getindex, convert, prod, * , / , \ , + , - , == , ^ ,
44 IndexStyle, IndexLinear, == , OneTo, tail, similar, copyto!, copy, diff,
55 first, last, show, isempty, findfirst, findlast, findall, Slice, union, minimum, maximum, sum, _sum,
66 getproperty, isone, iszero, zero, abs, < , ≤ , > , ≥ , string
@@ -9,7 +9,7 @@ import LazyArrays: MemoryLayout, Applied, ApplyStyle, flatten, _flatten, colsupp
99 adjointlayout, arguments, _mul_arguments, call, broadcastlayout, layout_getindex,
1010 sublayout, sub_materialize, ApplyLayout, BroadcastLayout, combine_mul_styles, applylayout,
1111 simplifiable, _simplify
12- import LinearAlgebra: pinv
12+ import LinearAlgebra: pinv, dot, norm2
1313import BandedMatrices: AbstractBandedLayout, _BandedMatrix
1414import FillArrays: AbstractFill, getindex_value, SquareEye
1515import ArrayLayouts: mul
@@ -79,6 +79,17 @@ Inclusion(d::AbstractInterval{T}) where T = Inclusion{float(T)}(d)
7979first (S:: Inclusion{<:Any,<:AbstractInterval} ) = leftendpoint (S. domain)
8080last (S:: Inclusion{<:Any,<:AbstractInterval} ) = rightendpoint (S. domain)
8181
82+ norm2 (x:: Inclusion{T,<:AbstractInterval} ) where T = sqrt (dot (x,x))
83+
84+ function dot (x:: Inclusion{T,<:AbstractInterval} , y:: Inclusion{V,<:AbstractInterval} ) where {T,V}
85+ x == y || throw (DimensionMismatch (" first quasivector has axis $(x) which does not match the axis of the second, $(y) ." ))
86+ TV = promote_type (T,V)
87+ isempty (x) && return zero (TV)
88+ a,b = endpoints (x. domain)
89+ convert (TV, b^ 3 - a^ 3 )/ 3
90+ end
91+
92+
8293for find in (:findfirst , :findlast )
8394 @eval $ find (f:: Base.Fix2{typeof(isequal)} , d:: Inclusion ) = f. x in d. domain ? f. x : nothing
8495end
0 commit comments