Commit 2b452e36 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

Add method for completing a Tensor that is partially filled and supposed

to be symmetric.
parent 92e95d00
......@@ -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<unsigned int>& 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 */
/**********************************************/
......
......@@ -134,6 +134,21 @@ Tensor<SIZE, REAL>::getIndex(std::vector<unsigned int> p) const
return res ;
}
template <unsigned int SIZE, typename REAL>
void
Tensor<SIZE, REAL>::completeSymmetricTensor()
{
std::vector<unsigned int> p ;
p.resize(order(), 0) ;
do
{
std::vector<unsigned int> sorted_p = p ;
std::sort(sorted_p.begin(), sorted_p.begin() + (*this).order()) ;
(*this)(p) = (*this)(sorted_p) ;
} while (incremIndex(p)) ;
}
template <unsigned int SIZE, typename REAL>
const unsigned int&
Tensor<SIZE, REAL>::order() const
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment