diff --git a/include/Geometry/tensor.h b/include/Geometry/tensor.h index 21a0cad09d2cf67bc0c8865eef8fd5fb03b05e89..67b2fc710f073deb015992e60d2b19d04d6a1566 100644 --- a/include/Geometry/tensor.h +++ b/include/Geometry/tensor.h @@ -29,6 +29,9 @@ * \file tensor.h */ +#define CONST_VAL -5212368.54127 // random value + + namespace CGoGN { @@ -192,6 +195,15 @@ class Tensor */ static bool incremIndex(std::vector& p) ; + /*! + * \brief method to complete a symmetric tensor that was + * only filled in its first half (defined by an index that + * is order ascendantly) + * + * \param T the tensor to fill + */ + void completeSymmetricTensor() ; + /**********************************************/ /* STREAM OPERATORS */ /**********************************************/ diff --git a/include/Geometry/tensor.hpp b/include/Geometry/tensor.hpp index 3949a62ffec3899bcd1d53918a3fc6cf53606c5e..a36c3c0165fbeba2aca2232b6984eedd8d4466b5 100644 --- a/include/Geometry/tensor.hpp +++ b/include/Geometry/tensor.hpp @@ -134,6 +134,21 @@ Tensor::getIndex(std::vector p) const return res ; } + +template +void +Tensor::completeSymmetricTensor() +{ + std::vector p ; + p.resize(order(), 0) ; + do + { + std::vector sorted_p = p ; + std::sort(sorted_p.begin(), sorted_p.begin() + (*this).order()) ; + (*this)(p) = (*this)(sorted_p) ; + } while (incremIndex(p)) ; +} + template const unsigned int& Tensor::order() const