@@ -3,7 +3,8 @@ module FillArrays
3
3
using LinearAlgebra, SparseArrays
4
4
import Base: size, getindex, setindex!, IndexStyle, checkbounds, convert,
5
5
+ , - , * , / , \ , diff, sum, cumsum, maximum, minimum, sort, sort!,
6
- any, all, axes, isone, iterate, unique, allunique, permutedims, inv
6
+ any, all, axes, isone, iterate, unique, allunique, permutedims, inv,
7
+ copy
7
8
8
9
import LinearAlgebra: rank, svdvals!, tril, triu, tril!, triu!, diag
9
10
@@ -74,6 +75,8 @@ convert(::Type{AbstractFill}, F::AbstractFill) = F
74
75
convert (:: Type{AbstractFill{T}} , F:: AbstractFill ) where T = convert (AbstractArray{T}, F)
75
76
convert (:: Type{AbstractFill{T,N}} , F:: AbstractFill ) where {T,N} = convert (AbstractArray{T,N}, F)
76
77
78
+ copy (F:: Fill ) = Fill (copy (F. value), F. axes)
79
+
77
80
""" Throws an error if `arr` does not contain one and only one unique value. """
78
81
function unique_value (arr:: AbstractArray )
79
82
if isempty (arr) error (" Cannot convert empty array to Fill" ) end
@@ -174,6 +177,8 @@ for (Typ, funcs, func) in ((:Zeros, :zeros, :zero), (:Ones, :ones, :one))
174
177
convert (:: Type{AbstractArray{T}} , F:: $Typ ) where T = AbstractArray {T} (F)
175
178
convert (:: Type{AbstractArray{T,N}} , F:: $Typ ) where {T,N} = AbstractArray {T,N} (F)
176
179
180
+ copy (F:: $Typ ) = F
181
+
177
182
getindex (F:: $Typ{T,0} ) where T = getindex_value (F)
178
183
function getindex (F:: $Typ{T} , kj:: Vararg{AbstractVector{II},N} ) where {T,II<: Integer ,N}
179
184
checkbounds (F, kj... )
0 commit comments