Verified Commit a03a73f0 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

math/tensor: fix issue when initializing coeffs during resizing

parent e0acacdd
//
// Copyright (c) 2019 INRIA
// Copyright (c) 2019-2020 INRIA
//
#ifndef __pinocchio_math_tensor_hpp__
......@@ -245,12 +245,20 @@ namespace pinocchio
for(i = 0; i < NumIndices; i++)
m_dimensions[i] = dimensions[i];
m_storage.resize(size);
#ifdef EIGEN_INITIALIZE_COEFFS
bool size_changed = size != this->size();
if(size_changed) EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
#endif
bool size_changed = size != this->size();
if(size_changed) m_storage.resize(size);
#ifdef EIGEN_INITIALIZE_COEFFS
if(size_changed)
{
#if defined(EIGEN_INITIALIZE_MATRICES_BY_ZERO)
m_storage.fill(Scalar(0));
#elif defined(EIGEN_INITIALIZE_MATRICES_BY_NAN)
m_storage.fill(std::numeric_limits<Scalar>::quiet_NaN());
#endif
}
#endif
}
EIGEN_DEVICE_FUNC bool operator==(const Tensor & other) const
......
Supports Markdown
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