diff --git a/Sofa/framework/Type/CMakeLists.txt b/Sofa/framework/Type/CMakeLists.txt
index 17f9a6e724b..c231cb1b2f0 100644
--- a/Sofa/framework/Type/CMakeLists.txt
+++ b/Sofa/framework/Type/CMakeLists.txt
@@ -58,6 +58,7 @@ set(SOURCE_FILES
${SOFATYPESRC_ROOT}/Frame.cpp
${SOFATYPESRC_ROOT}/Mat.cpp
${SOFATYPESRC_ROOT}/Material.cpp
+ ${SOFATYPESRC_ROOT}/MatSym.cpp
${SOFATYPESRC_ROOT}/PrimitiveGroup.cpp
${SOFATYPESRC_ROOT}/Quat.cpp
${SOFATYPESRC_ROOT}/RGBAColor.cpp
diff --git a/Sofa/framework/Type/src/sofa/type/MatSym.cpp b/Sofa/framework/Type/src/sofa/type/MatSym.cpp
new file mode 100644
index 00000000000..e43bd13a21b
--- /dev/null
+++ b/Sofa/framework/Type/src/sofa/type/MatSym.cpp
@@ -0,0 +1,47 @@
+/******************************************************************************
+* SOFA, Simulation Open-Framework Architecture *
+* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
+* *
+* This program is free software; you can redistribute it and/or modify it *
+* under the terms of the GNU Lesser General Public License as published by *
+* the Free Software Foundation; either version 2.1 of the License, or (at *
+* your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, but WITHOUT *
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
+* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
+* for more details. *
+* *
+* You should have received a copy of the GNU Lesser General Public License *
+* along with this program. If not, see . *
+*******************************************************************************
+* Authors: The SOFA Team and external contributors (see Authors.txt) *
+* *
+* Contact information: contact@sofa-framework.org *
+******************************************************************************/
+#define SOFA_TYPE_MATSYM_CPP
+
+#include
+
+namespace sofa::type
+{
+
+template class SOFA_TYPE_API MatSym< 1, float>;
+template class SOFA_TYPE_API MatSym< 2, float>;
+template class SOFA_TYPE_API MatSym< 3, float>;
+template class SOFA_TYPE_API MatSym< 4, float>;
+template class SOFA_TYPE_API MatSym< 6, float>;
+template class SOFA_TYPE_API MatSym< 9, float>;
+template class SOFA_TYPE_API MatSym<12, float>;
+template class SOFA_TYPE_API MatSym<24, float>;
+
+template class SOFA_TYPE_API MatSym< 1, double>;
+template class SOFA_TYPE_API MatSym< 2, double>;
+template class SOFA_TYPE_API MatSym< 3, double>;
+template class SOFA_TYPE_API MatSym< 4, double>;
+template class SOFA_TYPE_API MatSym< 6, double>;
+template class SOFA_TYPE_API MatSym< 9, double>;
+template class SOFA_TYPE_API MatSym<12, double>;
+template class SOFA_TYPE_API MatSym<24, double>;
+
+} // namespace sofa::type
diff --git a/Sofa/framework/Type/src/sofa/type/MatSym.h b/Sofa/framework/Type/src/sofa/type/MatSym.h
index acc3a5f21ad..445009a8975 100644
--- a/Sofa/framework/Type/src/sofa/type/MatSym.h
+++ b/Sofa/framework/Type/src/sofa/type/MatSym.h
@@ -120,10 +120,7 @@ class MatSym : public VecNoInit
/// Sets each element to r.
void fill(real r)
{
- for (sofa::Size i = 0; i < NumberStoredValues; i++)
- {
- this->elems[i].fill(r);
- }
+ std::fill(this->elems.begin(), this->elems.end(), r);
}
/// Write access to element (i,j).
@@ -708,4 +705,26 @@ inline real scalarProduct(const Mat& left, const MatSym& right
return scalarProduct(right, left);
}
+#if !defined(SOFA_TYPE_MATSYM_CPP)
+
+extern template class SOFA_TYPE_API MatSym< 1, float>;
+extern template class SOFA_TYPE_API MatSym< 2, float>;
+extern template class SOFA_TYPE_API MatSym< 3, float>;
+extern template class SOFA_TYPE_API MatSym< 4, float>;
+extern template class SOFA_TYPE_API MatSym< 6, float>;
+extern template class SOFA_TYPE_API MatSym< 9, float>;
+extern template class SOFA_TYPE_API MatSym<12, float>;
+extern template class SOFA_TYPE_API MatSym<24, float>;
+
+extern template class SOFA_TYPE_API MatSym< 1, double>;
+extern template class SOFA_TYPE_API MatSym< 2, double>;
+extern template class SOFA_TYPE_API MatSym< 3, double>;
+extern template class SOFA_TYPE_API MatSym< 4, double>;
+extern template class SOFA_TYPE_API MatSym< 6, double>;
+extern template class SOFA_TYPE_API MatSym< 9, double>;
+extern template class SOFA_TYPE_API MatSym<12, double>;
+extern template class SOFA_TYPE_API MatSym<24, double>;
+
+#endif
+
} // namespace sofa::type