Skip to content

Commit 208f309

Browse files
authored
[Type] Mat: explicit instanciations and fix methods (#5634)
explicit instanciations for mat
1 parent 3d55bf9 commit 208f309

File tree

3 files changed

+70
-5
lines changed

3 files changed

+70
-5
lines changed

Sofa/framework/Type/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ set(SOURCE_FILES
5656
${SOFATYPESRC_ROOT}/BoundingBox.cpp
5757
${SOFATYPESRC_ROOT}/DualQuat.cpp
5858
${SOFATYPESRC_ROOT}/Frame.cpp
59+
${SOFATYPESRC_ROOT}/Mat.cpp
5960
${SOFATYPESRC_ROOT}/Material.cpp
6061
${SOFATYPESRC_ROOT}/PrimitiveGroup.cpp
6162
${SOFATYPESRC_ROOT}/Quat.cpp
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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_MAT_CPP
23+
24+
#include <sofa/type/Mat.h>
25+
26+
namespace sofa::type
27+
{
28+
29+
template class SOFA_TYPE_API Mat<2,2,float>;
30+
template class SOFA_TYPE_API Mat<2,2,double>;
31+
32+
template class SOFA_TYPE_API Mat<3,3,float>;
33+
template class SOFA_TYPE_API Mat<3,3,double>;
34+
35+
template class SOFA_TYPE_API Mat<4,4,float>;
36+
template class SOFA_TYPE_API Mat<4,4,double>;
37+
38+
template class SOFA_TYPE_API Mat<6,6,float>;
39+
template class SOFA_TYPE_API Mat<6,6,double>;
40+
41+
template class SOFA_TYPE_API Mat<12,12,float>;
42+
template class SOFA_TYPE_API Mat<12,12,double>;
43+
44+
45+
} // namespace sofa::type

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

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,13 @@ class Mat
346346
/// Cast into a standard C array of lines (read-only).
347347
constexpr const Line* lptr() const noexcept
348348
{
349-
return this->elems;
349+
return this->elems.data();
350350
}
351351

352352
/// Cast into a standard C array of lines.
353353
constexpr Line* lptr() noexcept
354354
{
355-
return this->elems;
355+
return this->elems.data();
356356
}
357357

358358
/// Cast into a standard C array of elements (stored per line) (read-only).
@@ -832,7 +832,7 @@ class Mat
832832
// direct access to data
833833
constexpr const real* data() const noexcept
834834
{
835-
return elems.data();
835+
return elems.data()->data();
836836
}
837837

838838
constexpr typename ArrayLineType::iterator begin() noexcept
@@ -863,11 +863,11 @@ class Mat
863863
}
864864
constexpr reference back()
865865
{
866-
return elems[N - 1];
866+
return elems[L - 1];
867867
}
868868
constexpr const_reference back() const
869869
{
870-
return elems[N - 1];
870+
return elems[L - 1];
871871
}
872872

873873
};
@@ -1385,4 +1385,23 @@ constexpr Mat<3,3,real> multTranspose(const Mat<3,3,real>& m1, const Mat<3,3,rea
13851385
return r;
13861386
}
13871387

1388+
#if not defined(SOFA_TYPE_MAT_CPP)
1389+
1390+
extern template class SOFA_TYPE_API Mat<2,2,float>;
1391+
extern template class SOFA_TYPE_API Mat<2,2,double>;
1392+
1393+
extern template class SOFA_TYPE_API Mat<3,3,float>;
1394+
extern template class SOFA_TYPE_API Mat<3,3,double>;
1395+
1396+
extern template class SOFA_TYPE_API Mat<4,4,float>;
1397+
extern template class SOFA_TYPE_API Mat<4,4,double>;
1398+
1399+
extern template class SOFA_TYPE_API Mat<6,6,float>;
1400+
extern template class SOFA_TYPE_API Mat<6,6,double>;
1401+
1402+
extern template class SOFA_TYPE_API Mat<12,12,float>;
1403+
extern template class SOFA_TYPE_API Mat<12,12,double>;
1404+
1405+
#endif
1406+
13881407
} // namespace sofa::type

0 commit comments

Comments
 (0)