Skip to content

Commit c878317

Browse files
committed
add copy keyword argument
1 parent 781c137 commit c878317

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/tensors/indexmanipulations.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,16 +294,17 @@ function twist!(t::AbstractTensorMap, is; inv::Bool = false)
294294
end
295295

296296
"""
297-
twist(tsrc::AbstractTensorMap, i::Int; inv::Bool=false) -> tdst
298-
twist(tsrc::AbstractTensorMap, is; inv::Bool=false) -> tdst
297+
twist(tsrc::AbstractTensorMap, i::Int; inv::Bool = false, copy::Bool = false) -> tdst
298+
twist(tsrc::AbstractTensorMap, is; inv::Bool = false, copy::Bool = false) -> tdst
299299
300300
Apply a twist to the `i`th index of `tsrc` and return the result as a new tensor.
301-
If `inv=true`, use the inverse twist.
301+
If `inv = true`, use the inverse twist.
302+
If `copy = false`, `tdst` might share data with `tsrc` whenever possible. Otherwise, a copy is always made.
302303
303304
See [`twist!`](@ref) for storing the result in place.
304305
"""
305-
function twist(t::AbstractTensorMap, is; inv::Bool = false)
306-
(BraidingStyle(sectortype(t)) == Bosonic() || isempty(is)) && return t
306+
function twist(t::AbstractTensorMap, is; inv::Bool = false, copy::Bool = false)
307+
!copy && (BraidingStyle(sectortype(t)) == Bosonic() || isempty(is)) && return t
307308
return twist!(copy(t), is; inv)
308309
end
309310

0 commit comments

Comments
 (0)