awsteiner / o2scl

Object-oriented Scientific Computing Library
https://awsteiner.org/code/o2scl
GNU General Public License v3.0
34 stars 14 forks source link

Error in o2scl/vector.h in compilation #6

Closed andrepd closed 7 years ago

andrepd commented 7 years ago

I've the following error message when compiling a program that includes mroot_hybrids.h to solve a system of equations.

In file included from /usr/local/include/o2scl/search_vec.h:34:0,
                 from /usr/local/include/o2scl/interp.h:59,
                 from /usr/local/include/o2scl/table.h:41,
                 from /usr/local/include/o2scl/table_units.h:30,
                 from /usr/local/include/o2scl/test_mgr.h:34,
                 from mix.cpp:22:
/usr/local/include/o2scl/vector.h: In function ‘void o2scl::vector_grid(o2scl::uniform_grid<data_t>, vec_t&)’:
/usr/local/include/o2scl/vector.h:2360:7: error: invalid use of ‘class std::vector<vec_t>’
     g.template vector<vec_t>(v);

Line mix.cpp:22 is #include <o2scl/mroot_hybrids.h>. The relevant code is just

template<size_t something>
using Vectord = Matrix<double, N, 1, 0>;

template<size_t N>
using Matrixd = Matrix<double, N, N, 0>;

// ...

typedef std::function<int(size_t, const Vectord<10>&, Vectord<10>&)> mm_funct_eigen;
typedef std::function<int(size_t, const Vectord<10>&, size_t, Vectord<10>&, Matrixd<10>&)> jac_funct_eigen;

mroot_hybrids<mm_funct_eigen, Vectord<10>, Matrixd<10>,jac_funct_eigen> cr;
int fail = cr.msolve(10, x, f);

I'm thinking this is a bug in the library. I built o2scl with --enable-eigen. Can you comment? Thanks!

awsteiner commented 7 years ago

The error message you quoted refers to a function in vector.h which is not used by the mroot_hybrids class, so I'll need to see more code to see what's going on. It appears to me that the code is trying to use a std::vector but doesn't know at compile time what the associated value type is. I tried using the vector_grid function with an std::vector and it worked for me. Did you run 'make o2scl-test'? That tests both mroot_hybrids with Eigen objects and the vector_grid() function.

awsteiner commented 7 years ago

I haven't heard back regarding this, so I'll mark it as closed for now. Feel free to reopen (or open a new issue) if you get more information.