1
1
module ContinuumArrays
2
2
using 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, * , / , \ , + , - , == , ^ ,
4
4
IndexStyle, IndexLinear, == , OneTo, tail, similar, copyto!, copy, diff,
5
5
first, last, show, isempty, findfirst, findlast, findall, Slice, union, minimum, maximum, sum, _sum,
6
6
getproperty, isone, iszero, zero, abs, < , ≤ , > , ≥ , string
@@ -9,7 +9,7 @@ import LazyArrays: MemoryLayout, Applied, ApplyStyle, flatten, _flatten, colsupp
9
9
adjointlayout, arguments, _mul_arguments, call, broadcastlayout, layout_getindex,
10
10
sublayout, sub_materialize, ApplyLayout, BroadcastLayout, combine_mul_styles, applylayout,
11
11
simplifiable, _simplify
12
- import LinearAlgebra: pinv
12
+ import LinearAlgebra: pinv, dot, norm2
13
13
import BandedMatrices: AbstractBandedLayout, _BandedMatrix
14
14
import FillArrays: AbstractFill, getindex_value, SquareEye
15
15
import ArrayLayouts: mul
@@ -79,6 +79,17 @@ Inclusion(d::AbstractInterval{T}) where T = Inclusion{float(T)}(d)
79
79
first (S:: Inclusion{<:Any,<:AbstractInterval} ) = leftendpoint (S. domain)
80
80
last (S:: Inclusion{<:Any,<:AbstractInterval} ) = rightendpoint (S. domain)
81
81
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
+
82
93
for find in (:findfirst , :findlast )
83
94
@eval $ find (f:: Base.Fix2{typeof(isequal)} , d:: Inclusion ) = f. x in d. domain ? f. x : nothing
84
95
end
0 commit comments