Conversation
3bed38d to
8665c4a
Compare
eabfce9 to
0c903ac
Compare
|
Let's make this a draft too to cut down on CI thrash |
f5857b3 to
32e182d
Compare
f5faaf6 to
2359d28
Compare
lkdvos
left a comment
There was a problem hiding this comment.
Left some comment throughout, there are some things that I am not entirely convinced by but the rest looks great, thanks for working through all of this!
For the similarstoragetype(tensor, storagetype) calls that you added, this seems like something we should probably discuss over a separate PR, and it would be great if we could consolidate this one to get the remainder of the fixes in.
Would you be up for splitting these two things, and then getting this merged?
The same kind of holds for some of the comments I made too, if we can just postpone the things that are not obvious, but already get the other parts in, that would probably be helpful.
(Note that I am very much aware that none of this is your fault and this PR has lived for too long so the design shifts a bit, for which I do apologize!)
|
It's completely fine!! This has stayed open as I work through adding more tests for MPSKit, so I think we can pare off the simpler stuff we agree on, and then discuss things that are more contentious. |
|
Your PR no longer requires formatting changes. Thank you for your contribution! |
8a12178 to
ad62dad
Compare
a3f4bfc to
5259ba2
Compare
d29251a to
3c5a575
Compare
There was a problem hiding this comment.
I guess the changes here are no longer necessary since BraidingTensor now knows its own storagetype?
There was a problem hiding this comment.
I'm checking this now with MPSKit!
| W = insertleftunit(space(t), Val(i); conj, dual) | ||
| if t isa TensorMap | ||
| return TensorMap{scalartype(t)}(copy ? Base.copy(t.data) : t.data, W) | ||
| return TensorMapWithStorage{scalartype(t), storagetype(t)}(copy ? Base.copy(t.data) : t.data, W) |
There was a problem hiding this comment.
This doesn't look necessary, isn't the storagetype automatically deduced from the provided data vector?
| W = insertrightunit(space(t), Val(i); conj, dual) | ||
| if t isa TensorMap | ||
| return TensorMap{scalartype(t)}(copy ? Base.copy(t.data) : t.data, W) | ||
| return TensorMapWithStorage{scalartype(t), storagetype(t)}(copy ? Base.copy(t.data) : t.data, W) |
| W = removeunit(space(t), Val(i)) | ||
| if t isa TensorMap | ||
| return TensorMap{scalartype(t)}(copy ? Base.copy(t.data) : t.data, W) | ||
| return TensorMapWithStorage{scalartype(t), storagetype(t)}(copy ? Base.copy(t.data) : t.data, W) |
| function similarstoragetype(::Type{<:AbstractTensorMap{T, S, N₁, N₂}}, ::Type{TA}) where {T <: Number, TA <: DenseVector, S, N₁, N₂} | ||
| return similarstoragetype(TA, T) | ||
| end | ||
| function similarstoragetype(t::AbstractTensorMap{T, S, N₁, N₂}, ::Type{TA}) where {T <: Number, TA <: DenseVector, S, N₁, N₂} | ||
| return similarstoragetype(typeof(t), TA) | ||
| end | ||
|
|
||
| # implement on arrays | ||
| similarstoragetype(::Type{A}) where {A <: DenseVector{<:Number}} = A | ||
| similarstoragetype(::Type{A}, ::Type{A}) where {A <: DenseVector{<:Number}} = A |
There was a problem hiding this comment.
Are we using these somewhere? I'm slightly confused about the meaning of these functions with last argument A <: DenseVector. In general, I thought this function mostly meant: for given tensor T1 (and possibly T2), create a new storagetype that is compatible with T1 but has scalartype T. In the case where we pass in a storagetype to begin with, doesn't that mean we already know that the answer has to be A?.
| space(t::AdjointTensorMap) = adjoint(space(parent(t))) | ||
| dim(t::AdjointTensorMap) = dim(parent(t)) | ||
| storagetype(::Type{AdjointTensorMap{T, S, N₁, N₂, TT}}) where {T, S, N₁, N₂, TT} = storagetype(TT) | ||
| similarstoragetype(::AdjointTensorMap{T, S, N₁, N₂, TT}, ::Type{T′}) where {T, S, N₁, N₂, TT, T′ <: Number} = similarstoragetype(TT, T′) |
There was a problem hiding this comment.
Isn't this also automatic from the definition of similarstoragetype(t::AbstractTensorMap, T) = similarstoragetype(storagetype(t), T) along with storagetype the line above?
| dim(t::AdjointTensorMap) = dim(parent(t)) | ||
| storagetype(::Type{AdjointTensorMap{T, S, N₁, N₂, TT}}) where {T, S, N₁, N₂, TT} = storagetype(TT) | ||
| similarstoragetype(::AdjointTensorMap{T, S, N₁, N₂, TT}, ::Type{T′}) where {T, S, N₁, N₂, TT, T′ <: Number} = similarstoragetype(TT, T′) | ||
| similarstoragetype(::AdjointTensorMap{T, S, N₁, N₂, TT}, ::Type{TA}) where {T, S, N₁, N₂, TT, TA <: DenseVector} = similarstoragetype(TT, TA) |
There was a problem hiding this comment.
Same comment here about why the second argument would already be a <:DenseVector.
| $promote_op(::Type{TA}, ::Type{I}) where {TA <: DenseVector, I <: Sector} = | ||
| similarstoragetype(TA, $promote_op(eltype(TA), I)) |
There was a problem hiding this comment.
This is also not really used I guess?
Needed to get more MPSKit examples working