9 #include <aliceVision/numeric/numeric.hpp>
13 template<
typename TMat>
14 size_t CountElements(
const TMat& A)
16 static_assert(
sizeof(TMat) !=
sizeof(TMat),
"CountElements must be specialized");
21 size_t CountElements<Mat2X>(
const Mat2X& A);
23 size_t CountElements<Mat3X>(
const Mat3X& A);
25 size_t CountElements<Mat>(
const Mat& A);
27 size_t CountElements<std::vector<Vec2>>(
const std::vector<Vec2>& A);
29 template<
typename TMat>
30 size_t ElementSize(
const TMat& A)
32 static_assert(
sizeof(TMat) !=
sizeof(TMat),
"CountElements must be specialized");
37 size_t ElementSize<Mat2X>(
const Mat2X& A);
39 size_t ElementSize<Mat3X>(
const Mat3X& A);
41 size_t ElementSize<Mat>(
const Mat& A);
43 size_t ElementSize<std::vector<Vec2>>(
const std::vector<Vec2>& A);
51 typedef Mat2X::ConstColXpr const_type;
52 typedef Mat2X::ColXpr type;
54 static Mat2X create(
size_t elementSize,
size_t count) {
return Mat2X(elementSize, count); }
60 typedef Mat3X::ConstColXpr const_type;
61 typedef Mat3X::ColXpr type;
63 static Mat3X create(
size_t elementSize,
size_t count) {
return Mat3X(elementSize, count); }
69 typedef Mat::ConstColXpr const_type;
70 typedef Mat::ColXpr type;
72 static Mat create(
size_t elementSize,
size_t count) {
return Mat(elementSize, count); }
78 typedef const Vec2& const_type;
81 static std::vector<Vec2> create(
size_t elementSize,
size_t count) {
return std::vector<Vec2>(count); }
84 template<
typename TMat>
87 static_assert(
sizeof(TMat) !=
sizeof(TMat),
"CountElements must be specialized");
91 template<
typename TMat>
92 typename Element<TMat>::type getElement(TMat& A,
size_t index)
94 static_assert(
sizeof(TMat) !=
sizeof(TMat),
"CountElements must be specialized");
99 typename Element<Mat2X>::const_type getElement<Mat2X>(
const Mat2X& A,
size_t index);
101 typename Element<Mat3X>::const_type getElement<Mat3X>(
const Mat3X& A,
size_t index);
103 typename Element<Mat>::const_type getElement<Mat>(
const Mat& A,
size_t index);
105 typename Element<std::vector<Vec2>>::const_type getElement<std::vector<Vec2>>(
const std::vector<Vec2>& A,
size_t index);
108 typename Element<Mat2X>::type getElement<Mat2X>(Mat2X& A,
size_t index);
110 typename Element<Mat3X>::type getElement<Mat3X>(Mat3X& A,
size_t index);
112 typename Element<Mat>::type getElement<Mat>(Mat& A,
size_t index);
114 typename Element<std::vector<Vec2>>::type getElement<std::vector<Vec2>>(std::vector<Vec2>& A,
size_t index);
123 template<
typename TMat,
typename TCols>
127 TMat compressed = T::create(ElementSize(A), columns.size());
128 for (std::size_t i = 0; i < static_cast<std::size_t>(columns.size()); ++i)
131 assert(columns[i] < CountElements(A));
132 getElement(compressed, i) = getElement(A, columns[i]);