comparison src/LazyTensors/tuple_manipulation.jl @ 1087:423a6442efc3 feature/dissipation_operators

REVIEW: Address documentation
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Sun, 08 May 2022 12:15:32 +0200
parents 0905cec43d2e
children 672610322206
comparison
equal deleted inserted replaced
1078:879cca813cc6 1087:423a6442efc3
73 """ 73 """
74 flatten_tuple(t::NTuple{N, Number} where N) = t 74 flatten_tuple(t::NTuple{N, Number} where N) = t
75 flatten_tuple(t::Tuple) = ((flatten_tuple.(t)...)...,) # simplify? 75 flatten_tuple(t::Tuple) = ((flatten_tuple.(t)...)...,) # simplify?
76 flatten_tuple(ts::Vararg) = flatten_tuple(ts) 76 flatten_tuple(ts::Vararg) = flatten_tuple(ts)
77 77
78 78 # REVIEW: Add documentation
79 function left_pad_tuple(t, val, N) 79 function left_pad_tuple(t, val, N)
80 if N < length(t) 80 if N < length(t)
81 throw(DomainError(N, "Can't pad tuple of length $(length(t)) to $N elements")) 81 throw(DomainError(N, "Can't pad tuple of length $(length(t)) to $N elements"))
82 end 82 end
83 83
84 padding = ntuple(i->val, N-length(t)) 84 padding = ntuple(i->val, N-length(t))
85 return (padding..., t...) 85 return (padding..., t...)
86 end 86 end
87 87
88 # REVIEW: Add documentation
88 function right_pad_tuple(t, val, N) 89 function right_pad_tuple(t, val, N)
89 if N < length(t) 90 if N < length(t)
90 throw(DomainError(N, "Can't pad tuple of length $(length(t)) to $N elements")) 91 throw(DomainError(N, "Can't pad tuple of length $(length(t)) to $N elements"))
91 end 92 end
92 93