diff --git a/NEWS.md b/NEWS.md index 444aecd4b..25847eaa9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added +- Implemented addition/subtraction between a `TensorValue` and a `SymTensorValue`. Since PR [#755](https://github.com/gridap/Gridap.jl/pull/755). + ### Fixed - Restrict to the active model the evaluation of a FE function at arbitrary points. Since PR [#752](https://github.com/gridap/Gridap.jl/pull/752). diff --git a/src/TensorValues/Operations.jl b/src/TensorValues/Operations.jl index ac824b79e..db092fe9b 100644 --- a/src/TensorValues/Operations.jl +++ b/src/TensorValues/Operations.jl @@ -53,11 +53,11 @@ for op in (:+,:-) end function ($op)(a::TensorValue,b::SymTensorValue) - @notimplemented + map(($op), a, TensorValue(get_array(b))) end function ($op)(a::SymTensorValue,b::TensorValue) - @notimplemented + map(($op), TensorValue(get_array(a)), b) end end diff --git a/test/TensorValuesTests/OperationsTests.jl b/test/TensorValuesTests/OperationsTests.jl index d2475e739..5e4892132 100644 --- a/test/TensorValuesTests/OperationsTests.jl +++ b/test/TensorValuesTests/OperationsTests.jl @@ -104,6 +104,20 @@ c = a + b r = SymTensorValue(6,8,10) @test c==r +a = TensorValue(1,2,3,4) +b = SymTensorValue(5,6,7) + +c = a + b +r = TensorValue(6,8,9,11) +@test c==r + +a = SymTensorValue(5,6,7) +b = TensorValue(1,2,3,4) + +c = a - b +r = TensorValue(4,4,3,3) +@test c==r + # Matrix Division a = VectorValue(1,2,3)