# Using symmetry with TensorKit: ERROR: LoadError: MethodError: no method matching similarstructure_from_indices

I tried to utilize symmetry in tensor contraction ` A[a,b]*B[b,c,d] = C[a,c,d]` with `B[b,c,d] = B[b,d,c]`.
Based on Tutorial · TensorKit.jl
I tried the following code

``````using TensorKit
using BenchmarkTools

#using TensorOperations
# A[a,b]*B[b,c,d]  = C[a,c,d]
na = nb = nc = nd = 12
A = Tensor(randn, ℝ^na ⊗ ℝ^nb)
println(A)
#TensorMap((ℝ^na ⊗ ℝ^nb) ← ProductSpace{CartesianSpace, 0}()):
#A = rand(na, nb)
B = rand(nb, nc, nd)
C = zeros(na, nc, nd)
# symmetrize
for c in 1:nc
for d in 1:c
B[:,c,d] = B[:,d,c]
end
end

print("test symm",B[1,2,3], B[1,3,2] )

#@btime  @tensor  \$C[a,c,d] := \$A[a,b] * \$B[b,c,d]
@btime  @tensor  C[a,c,d] := A[a,b] * B[b,c,d]
``````

I got

``````7ERROR: LoadError: MethodError: no method matching similarstructure_from_indices(::Type{Float64}, ::Tuple{Int64}, ::Tuple{Int64, Int64}, ::Tuple{Int64, Int64, Int64}, ::Tuple{}, ::Tensor{CartesianSpace, 2, Trivial, Matrix{Float64}, Nothing, Nothing}, ::Array{Float64, 3}, ::Symbol, ::Symbol)
Closest candidates are:
similarstructure_from_indices(::Type, ::Tuple{Vararg{Int64, N}} where N, ::Tuple{Vararg{Int64, N}} where N, ::Tuple{Vararg{Int64, N}} where N, ::Tuple{Vararg{Int64, N}} where N, ::AbstractArray, ::AbstractArray, ::Symbol, ::Symbol) at /home/cwang/.julia/packages/TensorOperations/Ydu0m/src/implementation/stridedarray.jl:33
similarstructure_from_indices(::Type, ::Tuple{Vararg{Int64, N}} where N, ::Tuple{Vararg{Int64, N}} where N, ::Tuple{Vararg{Int64, N}} where N, ::Tuple{Vararg{Int64, N}} where N, ::AbstractTensorMap, ::AbstractTensorMap, ::Symbol, ::Symbol) at /home/cwang/.julia/packages/TensorKit/GctVn/src/tensors/tensoroperations.jl:353
similarstructure_from_indices(::Type, ::Tuple{Vararg{Int64, N}} where N, ::Tuple{Vararg{Int64, N}} where N, ::Tuple{Vararg{Int64, N}} where N, ::Tuple{Vararg{Int64, N}} where N, ::AbstractArray, ::AbstractArray, ::Symbol)
``````

error message. How to program it properly In general, if there are many symmetries in tensors, will it speed up the contraction?

I managed to work it out. I need to define

``````B = Tensor(randn, ℝ^nb ⊗ ℝ^nc⊗ ℝ^nd)
``````