After a whole day of trying to get the Dlib library to run in QT, I finally got in running and thought I was home free. I tried to call the r_squared function and test it on some vectors and it doesn't let me set it equal to a double x to print out, nor did it let me cout(qDebug() << ...) in QT, the function r_squared. Below I have copied my code and also the function from the header can anyone let me know not just what's I'm doing wrong here, but what's goin on? all header/sources have been included properly.
VECTORS:
std::vector<double> avec;
std::vector<double> bvec;
avec.push_back(1);
avec.push_back(2);
avec.push_back(3);
avec.push_back(4);
bvec.push_back(5);
bvec.push_back(6);
bvec.push_back(7);
bvec.push_back(1);
BUILDS AND RUNS OK:
double x;
double r_squared (
const std::vector<double>& avec,
const std::vector<double>& bvec
);
DOES NOT WORK (both the assignment and qDebug() "cout in QT"
double x;
x = r_squared (
const std::vector<double>& avec,
const std::vector<double>& bvec
);
qDebug() << x;
qDebug() << r_squared(enter actual parameters)
erroe C2059 was recieved for the block above
CODE AS DEFINED FROM DLIB
template <
typename T,
typename alloc
>
double r_squared (
const std::vector<T,alloc>& a,
const std::vector<T,alloc>& b
)
{
// make sure requires clause is not broken
DLIB_ASSERT(a.size() == b.size() && a.size() > 1,
"\t double r_squared(a,b)"
<< "\n\t a and b must be the same length and have more than one element."
<< "\n\t a.size(): " << a.size()
<< "\n\t b.size(): " << b.size()
);
return std::pow(correlation(a,b),2.0);
}
also I just tried
x = r_squared (
&avec,
&bvec
);
and received error message C3861: r_squared identifier not found. When I look in the header it is defined.
AND HERES THE TOTAL MAIN.CPP
#include "dlib3.h"
#include <QApplication>
#include <QDebug>
#include "dlib-master/dlib/statistics.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
dlib3 w;
std::vector<double> avec;
std::vector<double> bvec;
avec.push_back(1);
avec.push_back(2);
avec.push_back(3);
avec.push_back(4);
bvec.push_back(5);
bvec.push_back(6);
bvec.push_back(7);
bvec.push_back(1);
double x;
x = r_squared (
&avec,
&bvec
);
w.show();
return a.exec();
}