@@ -22,27 +22,31 @@ import Base: *, +, -, /, \, ==, isinf, isfinite, sign, angle, show, isless,
2222 AbstractArray, AbstractVector, Array, Vector, Matrix,
2323 axes, (:), _sub2ind_recurse, broadcast, promote_eltypeof,
2424 diff, cumsum, show_delim_array, show_circular, Int,
25- similar, _unsafe_getindex, string, zeros, fill, permutedims
25+ similar, _unsafe_getindex, string, zeros, fill, permutedims,
26+ cat_similar, vcat
2627
2728using Base. Broadcast
2829import Base. Broadcast: BroadcastStyle, AbstractArrayStyle, Broadcasted, broadcasted,
2930 @nexprs , @ncall , combine_eltypes, DefaultArrayStyle, instantiate
3031
3132import LinearAlgebra: BlasInt, BlasFloat, norm, diag, diagm, ishermitian, issymmetric,
32- det, logdet, istriu, istril, adjoint, tr, AbstractTriangular
33+ det, logdet, istriu, istril, adjoint, tr, AbstractTriangular,
34+ norm2, norm1, normp
3335
3436import Statistics: mean, median
3537
3638import FillArrays: AbstractFill, getindex_value
3739import LazyArrays: LazyArrayStyle, AbstractBandedLayout, MemoryLayout, LazyLayout,
38- ZerosLayout, @lazymul , AbstractArrayApplyStyle
40+ ZerosLayout, @lazymul , AbstractArrayApplyStyle, CachedArray, CachedVector
3941
4042import DSP: conv
4143
4244export ∞, Hcat, Vcat, Zeros, Ones, Fill, Eye, BroadcastArray, cache
4345
4446
4547
48+
49+
4650include (" Infinity.jl" )
4751include (" infrange.jl" )
4852include (" infarrays.jl" )
@@ -80,8 +84,36 @@ length(::Zeros{<:Any,2,Tuple{OneToInf{Int},OneToInf{Int}}}) = ∞
8084length (:: Zeros{<:Any,2,<:Tuple{OneToInf{Int},<:Any}} ) = ∞
8185length (:: Zeros{<:Any,2,<:Tuple{<:Any,OneToInf{Int}}} ) = ∞
8286
83- vcat (a:: Number , b:: AbstractFill{<:Any,1,<:Tuple{<:OneToInf}} ) = Vcat (a, b)
84- vcat (a:: AbstractVector , b:: AbstractFill{<:Any,1,<:Tuple{<:OneToInf}} ) = Vcat (a, b)
87+ for op in (:norm2 , :norm1 )
88+ @eval $ op (a:: Zeros{T,N,NTuple{N,OneToInf{Int}}} ) where {T,N} = norm (getindex_value (a))
89+ end
90+
91+ normp (a:: Zeros{T,N,NTuple{N,OneToInf{Int}}} , p) where {T,N} = norm (getindex_value (a))
92+
93+ for N= 1 : 3
94+ for op in (:norm2 , :norm1 )
95+ @eval function $op (a:: AbstractFill{T,$N,NTuple{$N,OneToInf{Int}}} ) where {T,N}
96+ z = norm (getindex_value (a))
97+ iszero (z) && return z
98+ typeof (z)(Inf )
99+ end
100+ end
101+ @eval function normp (a:: AbstractFill{T,$N,NTuple{$N,OneToInf{Int}}} , p) where {T,N }
102+ z = norm (getindex_value (a))
103+ iszero (z) && return z
104+ typeof (z)(Inf )
105+ end
106+ end
107+
108+ for Typ in (:Number , :AbstractVector )
109+ @eval begin
110+ vcat (a:: $Typ , b:: AbstractFill{<:Any,1,<:Tuple{<:OneToInf}} ) = Vcat (a, b)
111+ vcat (a:: $Typ , c:: CachedVector{<:Any,<:Any,<:AbstractFill{<:Any,1,<:Tuple{<:OneToInf}}} ) =
112+ CachedArray (vcat (a, view (c. data,1 : c. datasize[1 ])), c. array)
113+ end
114+ end
115+
116+ # cat_similar(A, T, ::Tuple{Infinity}) = zeros(T, ∞)
85117
86118# #
87119# Temporary hacks for base support
@@ -96,4 +128,6 @@ OneTo{T}(::OneToInf) where T<:Integer = OneToInf{T}()
96128Int (:: Infinity ) = ∞
97129
98130
131+
132+
99133end # module
0 commit comments