c++ - How to call function defined in template -
i'm in process of trying find polynomial regression set of x , y data. downloaded template below so, have no idea how call it, , attempts met error lnk2019: unresolved external symbol.
#pragma once #ifdef boost_ublas_type_check # undef boost_ublas_type_check #endif #define boost_ublas_type_check 0 #ifndef _use_math_defines # define _use_math_defines #endif #include <boost/numeric/ublas/matrix.hpp> #include <boost/numeric/ublas/lu.hpp> #include <vector> #include <stdexcept> /* finds coefficients of polynomial p(x) of degree n fits data, p(x(i)) y(i), in least squares sense. result p row vector of length n+1 containing polynomial coefficients in incremental powers. param: ox x axis values oy y axis values ndegree polynomial degree including constant return: coefficients of polynomial starting @ constant coefficient , ending coefficient of power ndegree. c++0x-compatible compilers make returning locally created vectors efficient. */ template<typename t> std::vector<t> polyfit( const std::vector<t>& ox, const std::vector<t>& oy, int ndegree ) { ... }
i don't think ya'll need rest of template me out, post if necessary. (it's site http://vilipetek.com/2013/10/07/polynomial-fitting-in-c-using-boost/) if there's better/easier tool out there, let me know it.
this how tried run it: declaration
std::vector<int> polyfit( const std::vector<int> xsplinevector, const std::vector<int> ysplinevector,
function call
polynomial = polyfit((xsplinevector), (ysplinevector), 4); int ndegree );
here example:
#include <vector> #include <polyfit.hpp> int main() { std::vector<int> xsplinevector; std::vector<int> ysplinevector; std::vector<int> poly; // fill both xsplinevector , ysplinevector poly = polyfit(xsplinevector, ysplinevector, 4); }
Comments
Post a Comment