Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
kmp5VT committed Oct 23, 2023
1 parent 297aaa2 commit 3fc526c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
21 changes: 12 additions & 9 deletions NDTensors/src/UnallocatedArrays/src/unallocatedfill.jl
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
## TODO All constructors not fully implemented but so far it matches the
## constructors found in `FillArrays`. Need to fix io
struct UnallocatedFill{ElT,N,Axes,Alloc<:AbstractArray} <: FillArrays.AbstractFill{ElT,N,Axes}
f::FillArrays.Fill{ElT, N, Axes}
struct UnallocatedFill{ElT,N,Axes,Alloc<:AbstractArray} <:
FillArrays.AbstractFill{ElT,N,Axes}
f::FillArrays.Fill{ElT,N,Axes}

function UnallocatedFill{ElT,N,Axes,Alloc}(x::ElT,inds::Tuple)where{ElT,N,Axes,Alloc}
function UnallocatedFill{ElT,N,Axes,Alloc}(x::ElT, inds::Tuple) where {ElT,N,Axes,Alloc}
f = FillArrays.Fill(x, inds)
ax = typeof(FillArrays.axes(f))
new{ElT,N,ax,Alloc}(f)
return new{ElT,N,ax,Alloc}(f)
end

function UnallocatedFill{ElT,0,Tuple{},Alloc}(x::ElT, inds::Tuple{}) where{ElT,Alloc}
f = FillArrays.Fill{ElT,0,Tuple{}}(x,inds)
new{ElT,0,Tuple{},Alloc}(f)
function UnallocatedFill{ElT,0,Tuple{},Alloc}(x::ElT, inds::Tuple{}) where {ElT,Alloc}
f = FillArrays.Fill{ElT,0,Tuple{}}(x, inds)
return new{ElT,0,Tuple{},Alloc}(f)
end
end

function UnallocatedFill{ElT, Alloc}(x::ElT, inds::Tuple) where {ElT<:Number, Alloc<:AbstractArray}
function UnallocatedFill{ElT,Alloc}(
x::ElT, inds::Tuple
) where {ElT<:Number,Alloc<:AbstractArray}
N = length(inds)
Ax = Base.axes(inds)
return UnallocatedFill{ElT, N, Ax,Alloc}(x, inds)
return UnallocatedFill{ElT,N,Ax,Alloc}(x, inds)
end

alloctype(::UnallocatedFill{ElT,N,Axes,Alloc}) where {ElT,N,Axes,Alloc} = Alloc
Expand Down
9 changes: 4 additions & 5 deletions NDTensors/src/UnallocatedArrays/src/unallocatedzeros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ struct UnallocatedZeros{ElT,N,Axes,Alloc<:AbstractArray{ElT,N}} <:
FillArrays.AbstractZeros{ElT,N,Axes}
z::FillArrays.Zeros{ElT,N,Axes}

function UnallocatedZeros{ElT,N,Axes,Alloc}(inds::Tuple) where{ElT,N,Axes,Alloc}
function UnallocatedZeros{ElT,N,Axes,Alloc}(inds::Tuple) where {ElT,N,Axes,Alloc}
z = FillArrays.Zeros(inds)
ax = typeof(FillArrays.axes(z))
new{ElT,N,ax,Alloc}(z)
return new{ElT,N,ax,Alloc}(z)
end

function UnallocatedZeros{ElT,0,Tuple{},Alloc}(inds::Tuple{}) where{ElT,Alloc}
function UnallocatedZeros{ElT,0,Tuple{},Alloc}(inds::Tuple{}) where {ElT,Alloc}
z = FillArrays.Zeros(inds)
new{ElT,0,Tuple{},Alloc}(z)
return new{ElT,0,Tuple{},Alloc}(z)
end
end


alloctype(::UnallocatedZeros{ElT,N,Axes,Alloc}) where {ElT,N,Axes,Alloc} = Alloc
function alloctype(::Type{<:UnallocatedZeros{ElT,N,Axes,Alloc}}) where {ElT,N,Axes,Alloc}
return Alloc
Expand Down

0 comments on commit 3fc526c

Please sign in to comment.