Skip to content

Commit

Permalink
* Bug-fixed _flatten_upper_triangle generated function
Browse files Browse the repository at this point in the history
* Added a test that reproduces the BUG before the fix
  • Loading branch information
amartinhuertas committed Feb 5, 2022
1 parent ddd087c commit 26cdba1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/TensorValues/SymTensorValueTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down Expand Up @@ -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})

8 changes: 8 additions & 0 deletions test/TensorValuesTests/TypesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 26cdba1

Please sign in to comment.