ERROR: expected primary-expression before »>« token | Eigen2-Lib
-
Hallo,
ich versuche grad eine Klasse mit Eigen2-libs zu schreiben. In jeder Zeile in der ich Casten will bekomme ich Fehler angezeigt.Source:
#ifndef ROOTCONE_H_ #define ROOTCONE_H_ #include "Eigen/Core" #include <boost/rational.hpp> #include <iostream> USING_PART_OF_NAMESPACE_EIGEN template<int N, class T = boost::rational<int> > class RootCone { private: Matrix<int, N, N> A; Matrix<int, N, N> B; Matrix<T, N, N> M; public: RootCone(Matrix<int, N, N> a, Matrix<int, N, N> b, Matrix<T, N, N> m) : A(a), B(b), M(m) {} Matrix<T, N, 1> project(int to_project, int project_along) { Matrix<T, N, 1> to_proj(A.col(to_project).cast<T>()); //HIER Matrix<T, N, 1> proj_along(A.col(project_along).cast<T>()); //HIER Matrix<T, N, N> scalar_product = B.cast<T>(); //HIER scalar_product.col(project_along) = proj_along; scalar_product = scalar_product.inverse(); scalar_product *= scalar_product.adjoint(); return to_proj - (proj_along.transpose() * scalar_product * to_proj)[0]*proj_along; } }; #endifFehler:
In member function »Eigen::Matrix<T, N, 1, 2, N, 1> RootCone<N, T>::project(int, int)«:| 24|Fehler: expected primary-expression before »>« token 24|Fehler: expected primary-expression before »)« token 25|Fehler: expected primary-expression before »>« token 25|Fehler: expected primary-expression before »)« token 26|Fehler: expected primary-expression before »>« token 26|Fehler: expected primary-expression before »)« token ||=== Build finished: 6 errors, 0 warnings ===|Bei folgendem Code bekomme ich keine Fehler:
#include <iostream> #include <boost/rational.hpp> #include "Eigen/Core" typedef boost::rational<int> Rational; template<class T> void test(Matrix<int, 3, 3> mat) { std::cout << mat.cast<T>(); } int main() { int arr[] = {1,2,3,4,5,6,7,8,9}; Matrix<int, 3,3> mat(arr); test< Rational >(mat); return 0; }Das ist wahrscheinlich ein kleiner Fehler, aber ich komm da grad echt nich drauf. Wenn einer Antwort weiß, bin ich sehr dankbar.
mfg
MamboKurt
-
Mir fehlen da noch ein paar Informationen über die Klasse Matrix, aber ich würde mal vermuten, dass hier der Fehler liegt:
Matrix<T, N, 1> to_proj(A.col(to_project).template cast<T>()); //HIER Matrix<T, N, 1> proj_along(A.col(project_along).template cast<T>()); //HIER Matrix<T, N, N> scalar_product = B.template cast<T>(); //HIEREs fehlt also ein
templatevor der Funktion. Das ist nötig, damit der Parser weiss, dass eine Templatefunktion folgt, sonst sieht ercastals Variable und '<' als "Operator Kleiner Als". Sowas ist nur nötig, wenn man eine Templatefunktion aufruft von einem Objekt, welches selber von einem Templateparameter abhängig ist.Grüssli
-
danke. das wars