Skip to content

Commit

Permalink
restore constprop
Browse files Browse the repository at this point in the history
  • Loading branch information
Jutho committed Dec 19, 2024
1 parent 8745fcc commit 6112b35
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/tensors/indexmanipulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,19 @@ If `copy=false`, `tdst` might share data with `tsrc` whenever possible. Otherwis
See also [`insertrightunit`](@ref) and [`removeunit`](@ref).
"""
function insertleftunit(t::AbstractTensorMap, i::Int=numind(t) + 1;
copy::Bool=true, conj::Bool=false, dual::Bool=false)
@constprop :aggressive function insertleftunit(t::AbstractTensorMap, i::Int=numind(t) + 1;
copy::Bool=true, conj::Bool=false,
dual::Bool=false)
W = insertleftunit(space(t), i; conj, dual)
tdst = similar(t, W)
for (c, b) in blocks(t)
copy!(block(tdst, c), b)
end
return tdst
end
function insertleftunit(t::TensorMap, i::Int=numind(t) + 1;
copy::Bool=false, conj::Bool=false, dual::Bool=false)
@constprop :aggressive function insertleftunit(t::TensorMap, i::Int=numind(t) + 1;
copy::Bool=false, conj::Bool=false,
dual::Bool=false)
W = insertleftunit(space(t), i; conj, dual)
return TensorMap{scalartype(t)}(copy ? Base.copy(t.data) : t.data, W)
end
Expand All @@ -329,15 +331,17 @@ If `copy=false`, `tdst` might share data with `tsrc` whenever possible. Otherwis
See also [`insertleftunit`](@ref) and [`removeunit`](@ref).
"""
function insertrightunit(t::AbstractTensorMap, i::Int=numind(t); copy::Bool=true, kwargs...)
@constprop :aggressive function insertrightunit(t::AbstractTensorMap, i::Int=numind(t);
copy::Bool=true, kwargs...)
W = insertrightunit(space(t), i; kwargs...)
tdst = similar(t, W)
for (c, b) in blocks(t)
copy!(block(tdst, c), b)
end
return tdst
end
function insertrightunit(t::TensorMap, i::Int=numind(t); copy::Bool=false, kwargs...)
@constprop :aggressive function insertrightunit(t::TensorMap, i::Int=numind(t);
copy::Bool=false, kwargs...)
W = insertrightunit(space(t), i; kwargs...)
return TensorMap{scalartype(t)}(copy ? Base.copy(t.data) : t.data, W)
end
Expand All @@ -352,11 +356,11 @@ If `copy=false`, `tdst` might share data with `tsrc` whenever possible. Otherwis
This operation undoes the work of [`insertunit`](@ref).
"""
function removeunit(t::TensorMap, i::Int; copy::Bool=false)
@constprop :aggressive function removeunit(t::TensorMap, i::Int; copy::Bool=false)
W = removeunit(space(t), i)
return TensorMap{scalartype(t)}(copy ? Base.copy(t.data) : t.data, W)
end
function removeunit(t::AbstractTensorMap, i::Int; copy::Bool=true)
@constprop :aggressive function removeunit(t::AbstractTensorMap, i::Int; copy::Bool=true)
W = removeunit(space(t), i)
tdst = similar(t, W)
for (c, b) in blocks(t)
Expand Down

0 comments on commit 6112b35

Please sign in to comment.