Skip to content

Commit ccb7c93

Browse files
committed
Specialize to_vec(::DiagonalTensorMap)
1 parent e1fe3be commit ccb7c93

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ext/TensorKitFiniteDifferencesExt.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ function FiniteDifferences.to_vec(t::AbstractTensorMap)
2323
end
2424
FiniteDifferences.to_vec(t::TensorKit.AdjointTensorMap) = to_vec(copy(t))
2525

26+
function FiniteDifferences.to_vec(t::DiagonalTensorMap)
27+
x_vec, back = to_vec(TensorMap(t))
28+
function DiagonalTensorMap_from_vec(x_vec)
29+
return DiagonalTensorMap(back(x_vec))
30+
end
31+
return x_vec, DiagonalTensorMap_from_vec
32+
end
33+
2634
end
2735

2836
# TODO: Investigate why the approach below doesn't work

0 commit comments

Comments
 (0)