No matching function for call to ...
-
Hallo.
Ich habe ein eigentlich simples Problem aber ich finde einfach keine Lösung dafür.
Ich will eine Template-Library für Matrizen an den Umfpack solver via Boost Numeric Bindings anbinden, aber irgendwie findet der die passenden Methoden nicht.Vielleicht sieht jemand von euch was da fehlt.
Ich will die Methode aufrufen:In umfpack.hpp - einem Header aus dem Boost Numeric Bindings package
template <typename MatrA> inline int symbolic (MatrA const& A, symbolic_type< typename traits::sparse_matrix_traits<MatrA>::value_type >& Symbolic, double const* Control = 0, double* Info = 0) { #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK BOOST_STATIC_ASSERT((boost::is_same< typename traits::sparse_matrix_traits<MatrA>::matrix_structure, traits::general_t >::value)); BOOST_STATIC_ASSERT((boost::is_same< typename traits::sparse_matrix_traits<MatrA>::ordering_type, traits::column_major_t >::value)); BOOST_STATIC_ASSERT(traits::sparse_matrix_traits<MatrA>::index_base == 0); #endif typedef typename traits::sparse_matrix_traits<MatrA>::storage_format storage_f; #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK BOOST_STATIC_ASSERT( (boost::is_same<storage_f, traits::compressed_t>::value || boost::is_same<storage_f, traits::coordinate_t>::value )); #endif return detail::symbolic (storage_f(), A, &Symbolic.ptr, Control, Info); }und zwar habe ich mir das so gedacht:
test_umfpack.cpp - Meiner Testfunktion, die das ganze aufrufen soll
#include <iostream> #include <boost/numeric/mtl/mtl.hpp> #include <boost/numeric/bindings/traits/traits.hpp> #include <boost/numeric/bindings/umfpack/umfpack.hpp> using namespace mtl; using namespace boost::numeric::bindings::traits; namespace umf = boost::numeric::bindings::umfpack; int main() { compressed2D<double, matrix::parameters<tag::col_major> > matrix(5, 5); diagonal_setup(matrix, 1.); { matrix::inserter<compressed2D<double, matrix::parameters<tag::col_major> > > ins(matrix); ins[2][2] = -2.; ins[3][1] = -1.; ins[1][3] = -1.; } std::cout << "Test matrix is\n" << matrix << '\n'; dense_vector<double> vector(5); for(unsigned i=0; i<5; ++i) vector[i] = 5-i/2.; std::cout << "Test vector is\n" << vector << '\n'; // 1. Symbolic analysis of coefficient matrix umf::symbolic_type<double> Symbolic; umf::symbolic(matrix, Symbolic); // 2. Numeric factorization // TODO // 3. Backward substitution // TODO return 0; }Beim Aufruf der Funktion "symbolic" kommt dieser Compilerfehler:
test_umfpack.cpp:33: error: no matching function for call to ‘symbolic(mtl::matrix::compressed2D<double, mtl::matrix::parameters<mtl::tag::col_major, mtl::index::c_index, mtl::non_fixed::dimensions, false> >&, boost::numeric::bindings::umfpack::symbolic_type<double>&)’Ich versteh es irgendwie nicht. Das erste Argument ist templatisiert und müsste passen, das zweite ist genau das was ich als Symbolic definiert habe. Die anderen beiden sind optional.
Wäre über jede Hilfe unendlich dankbar.
Schönen Gruß
Max
-
Lass dir doch mal
typeid(typename traits::sparse_matrix_traits< compressed2D<double, matrix::parameters<tag::col_major> > >::value_type)).name()ausgeben, dann weißt du was er erwartet.
-
Ok also irgendwie funktioniert das mit dem typeid nicht, weil der sagt dass er value_type nicht kennt. Aber immerhin weiß ich jetzt, dass die Spezialisierung der sparse_matrix_detail_traits nicht geklappt hat. Aber irgendwie finde ich auch hier den fehler nicht. Meine Spezialisierung ist:
namespace boost{ namespace numeric{ namespace bindings{ namespace traits{ template <typename T, typename P, typename M> struct sparse_matrix_detail_traits<mtl::compressed2D<T,P>, M> { // Typedefs typedef general_t matrix_structure; typedef compressed_t storage_format; typedef typename boost::mpl::if_<mtl::traits::is_row_major<P>, row_major_t, column_major_t>::type ordering_type; typedef T value_type; typedef value_type* value_pointer; typedef unsigned long* index_pointer; typedef M matrix_type; static ptrdiff_t num_rows(matrix_type& matrix) { using mtl::num_rows; return static_cast<ptrdiff_t>(num_rows(matrix)); } static ptrdiff_t num_columns(matrix_type& matrix) { using mtl::num_cols; std::cout << "TEst"; return static_cast<ptrdiff_t>(num_cols(matrix)); } static index_pointer index1_storage(matrix_type &matrix) { return &matrix.starts[0]; } static index_pointer index2_storage(matrix_type &matrix) { return &matrix.indices[0]; } static value_pointer value_storage(matrix_type &matrix) { return &matrix.data[0]; } static ptrdiff_t leading_dimension(matrix_type& matrix) { using mtl::num_cols; return static_cast<ptrdiff_t>(num_cols(matrix)); } static ptrdiff_t num_nonzeros(matrix_type &matrix) { return num_cols(matrix)*num_rows(matrix)-1; } }; } } } }Wenn ich jetzt auf dieser Spezialisierung die methoden aufrufen will kommt allerdings immer ein Fehler:
typedef compressed2D<double, matrix::parameters<tag::col_major> > matrix_type; matrix_type matrix(5, 5); diagonal_setup(matrix, 1.); { matrix::inserter<compressed2D<double, matrix::parameters<tag::col_major> > > ins(matrix); ins[2][2] = -2.; ins[3][1] = -1.; ins[1][3] = -1.; } dense_vector<double> vector(5); for(unsigned i=0; i<5; ++i) vector[i] = 5-i/2.; sparse_matrix_detail_traits<matrix_type, matrix_type>::num_columns(matrix); // test for num_columns method std::cout << typeid(sparse_matrix_detail_traits<matrix_type, matrix_type>::value_type).name(); // test for value_type definitionEs kommt jedesmal der Fehler: test_umfpack.cpp:35: error: ‘num_columns’ is not a member of ‘boost::numeric::bindings::traits::sparse_matrix_detail_traits<mtl::matrix::compressed2D<double, mtl::matrix::parameters<mtl::matrix::parameters<mtl::tag::col_major> mtl::index::c_index, mtl::non_fixed::dimensions, false> >, mtl::matrix::compressed2D<double, mtl::matrix::parameters<mtl::tag::col_major, mtl::index::c_index, mtl::non_fixed::dimensions, false> > >’ make: *** [test_umfpack] Fehler 1Und das selbe entsprechend auch für value_type.
Ich komm leider nicht weiter. Ich hab jetzt alles probiert, und ich weiß nicht was falsch ist.Vielen Dank für eure Hilfe.
Grüße
Max
-
Oh man... immer wenn ich hier ins Forum schreibe finde ich die Lösung kurz danach selber :D.
Ich hab nur vergessen den Header zu includen, wo meine spezialisierung drin ist.
Danke trotzdem fürs lesen ;).