diff --git a/src/TensorValues/SymTensorValueTypes.jl b/src/TensorValues/SymTensorValueTypes.jl index a3a12ba35..b76e7417b 100644 --- a/src/TensorValues/SymTensorValueTypes.jl +++ b/src/TensorValues/SymTensorValueTypes.jl @@ -61,7 +61,7 @@ SymTensorValue{D,T1,L}(data::Number...) where {D,T1,L} = SymTensorValue{D,T1}(da str = "" for i in 1:D for j in i:D - str *= "data[i,j], " + str *= "data[$i,$j], " end end Meta.parse("($str)") @@ -154,4 +154,3 @@ length(::SymTensorValue{D}) where {D} = length(SymTensorValue{D}) num_components(::Type{<:SymTensorValue{D}}) where {D} = length(SymTensorValue{D}) num_components(::SymTensorValue{D}) where {D} = num_components(SymTensorValue{D}) - diff --git a/test/TensorValuesTests/TypesTests.jl b/test/TensorValuesTests/TypesTests.jl index 1a4958b5f..c86d8391e 100644 --- a/test/TensorValuesTests/TypesTests.jl +++ b/test/TensorValuesTests/TypesTests.jl @@ -429,6 +429,14 @@ a = SymTensorValue(11,21,22) @test change_eltype(a,Float64) == SymTensorValue{2,Float64,3} @test isa(Tuple(a),Tuple) @test Tuple(a) == a.data +b = Matrix{Int64}(undef,2,2) +b[1,1] = a[1,1] +b[1,2] = a[1,2] +b[2,1] = a[2,1] +b[2,2] = a[2,2] +bt = SymTensorValue{2,Int64}(b) +@test bt .== a + a = SymFourthOrderTensorValue(1111,1121,1122, 2111,2121,2122, 2211,2221,2222) @test change_eltype(a,Float64) == SymFourthOrderTensorValue{2,Float64,9}