Skip to content

Commit 5d8be62

Browse files
committed
[Type] Extern template specialization of MatSym
1 parent 6ac7d85 commit 5d8be62

File tree

3 files changed

+71
-4
lines changed

3 files changed

+71
-4
lines changed

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
@@ -120,10 +120,7 @@ class MatSym : public VecNoInit<D * (D + 1) / 2, real>
120120
/// Sets each element to r.
121121
void fill(real r)
122122
{
123-
for (sofa::Size i = 0; i < NumberStoredValues; i++)
124-
{
125-
this->elems[i].fill(r);
126-
}
123+
std::fill(this->elems.begin(), this->elems.end(), r);
127124
}
128125

129126
/// Write access to element (i,j).
@@ -708,4 +705,26 @@ inline real scalarProduct(const Mat<D,D,real>& left, const MatSym<D,real>& right
708705
return scalarProduct(right, left);
709706
}
710707

708+
#if !defined(SOFA_TYPE_MATSYM_CPP)
709+
710+
extern template class SOFA_TYPE_API MatSym< 1, float>;
711+
extern template class SOFA_TYPE_API MatSym< 2, float>;
712+
extern template class SOFA_TYPE_API MatSym< 3, float>;
713+
extern template class SOFA_TYPE_API MatSym< 4, float>;
714+
extern template class SOFA_TYPE_API MatSym< 6, float>;
715+
extern template class SOFA_TYPE_API MatSym< 9, float>;
716+
extern template class SOFA_TYPE_API MatSym<12, float>;
717+
extern template class SOFA_TYPE_API MatSym<24, float>;
718+
719+
extern template class SOFA_TYPE_API MatSym< 1, double>;
720+
extern template class SOFA_TYPE_API MatSym< 2, double>;
721+
extern template class SOFA_TYPE_API MatSym< 3, double>;
722+
extern template class SOFA_TYPE_API MatSym< 4, double>;
723+
extern template class SOFA_TYPE_API MatSym< 6, double>;
724+
extern template class SOFA_TYPE_API MatSym< 9, double>;
725+
extern template class SOFA_TYPE_API MatSym<12, double>;
726+
extern template class SOFA_TYPE_API MatSym<24, double>;
727+
728+
#endif
729+
711730
} // namespace sofa::type

0 commit comments

Comments
 (0)