Skip to content

Commit eded94d

Browse files
committed
[Type] Extern template specialization of MatSym
1 parent 3f2478e commit eded94d

3 files changed

Lines changed: 71 additions & 4 deletions

File tree

Sofa/framework/Type/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ set(SOURCE_FILES
5858
${SOFATYPESRC_ROOT}/Frame.cpp
5959
${SOFATYPESRC_ROOT}/Mat.cpp
6060
${SOFATYPESRC_ROOT}/Material.cpp
61+
${SOFATYPESRC_ROOT}/MatSym.cpp
6162
${SOFATYPESRC_ROOT}/PrimitiveGroup.cpp
6263
${SOFATYPESRC_ROOT}/Quat.cpp
6364
${SOFATYPESRC_ROOT}/RGBAColor.cpp
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/******************************************************************************
2+
* SOFA, Simulation Open-Framework Architecture *
3+
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify it *
6+
* under the terms of the GNU Lesser General Public License as published by *
7+
* the Free Software Foundation; either version 2.1 of the License, or (at *
8+
* your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, but WITHOUT *
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
13+
* for more details. *
14+
* *
15+
* You should have received a copy of the GNU Lesser General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
*******************************************************************************
18+
* Authors: The SOFA Team and external contributors (see Authors.txt) *
19+
* *
20+
* Contact information: contact@sofa-framework.org *
21+
******************************************************************************/
22+
#define SOFA_TYPE_MATSYM_CPP
23+
24+
#include <sofa/type/MatSym.h>
25+
26+
namespace sofa::type
27+
{
28+
29+
template class SOFA_TYPE_API MatSym< 1, float>;
30+
template class SOFA_TYPE_API MatSym< 2, float>;
31+
template class SOFA_TYPE_API MatSym< 3, float>;
32+
template class SOFA_TYPE_API MatSym< 4, float>;
33+
template class SOFA_TYPE_API MatSym< 6, float>;
34+
template class SOFA_TYPE_API MatSym< 9, float>;
35+
template class SOFA_TYPE_API MatSym<12, float>;
36+
template class SOFA_TYPE_API MatSym<24, float>;
37+
38+
template class SOFA_TYPE_API MatSym< 1, double>;
39+
template class SOFA_TYPE_API MatSym< 2, double>;
40+
template class SOFA_TYPE_API MatSym< 3, double>;
41+
template class SOFA_TYPE_API MatSym< 4, double>;
42+
template class SOFA_TYPE_API MatSym< 6, double>;
43+
template class SOFA_TYPE_API MatSym< 9, double>;
44+
template class SOFA_TYPE_API MatSym<12, double>;
45+
template class SOFA_TYPE_API MatSym<24, double>;
46+
47+
} // namespace sofa::type

Sofa/framework/Type/src/sofa/type/MatSym.h

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ class MatSym : public VecNoInit<D * (D + 1) / 2, real>
106106
/// Sets each element to r.
107107
void fill(real r)
108108
{
109-
for (sofa::Size i = 0; i < NumberStoredValues; i++)
110-
{
111-
this->elems[i].fill(r);
112-
}
109+
std::fill(this->elems.begin(), this->elems.end(), r);
113110
}
114111

115112
/// Write access to element (i,j).
@@ -667,4 +664,26 @@ inline real scalarProduct(const Mat<D,D,real>& left, const MatSym<D,real>& right
667664
return scalarProduct(right, left);
668665
}
669666

667+
#if !defined(SOFA_TYPE_MATSYM_CPP)
668+
669+
extern template class SOFA_TYPE_API MatSym< 1, float>;
670+
extern template class SOFA_TYPE_API MatSym< 2, float>;
671+
extern template class SOFA_TYPE_API MatSym< 3, float>;
672+
extern template class SOFA_TYPE_API MatSym< 4, float>;
673+
extern template class SOFA_TYPE_API MatSym< 6, float>;
674+
extern template class SOFA_TYPE_API MatSym< 9, float>;
675+
extern template class SOFA_TYPE_API MatSym<12, float>;
676+
extern template class SOFA_TYPE_API MatSym<24, float>;
677+
678+
extern template class SOFA_TYPE_API MatSym< 1, double>;
679+
extern template class SOFA_TYPE_API MatSym< 2, double>;
680+
extern template class SOFA_TYPE_API MatSym< 3, double>;
681+
extern template class SOFA_TYPE_API MatSym< 4, double>;
682+
extern template class SOFA_TYPE_API MatSym< 6, double>;
683+
extern template class SOFA_TYPE_API MatSym< 9, double>;
684+
extern template class SOFA_TYPE_API MatSym<12, double>;
685+
extern template class SOFA_TYPE_API MatSym<24, double>;
686+
687+
#endif
688+
670689
} // namespace sofa::type

0 commit comments

Comments
 (0)