Reputation: 2441
I am using the itpp library version 4.3.1 in order to compute the skewness of a vector. The library can be downloaded from here.
The library can be install as follows:
mkdir build;
cd build;
cmake ..
make
sudo make install
I am using the following source code to compute the skewness.
#include <itpp/stat/misc_stat.h>
using namespace itpp;
int main(int argc, char* argv[])
{
vector<double> x{2,3,4,5,6};
double skew = skewness (x);
return 0;
}
double itpp::skewness (const vec &x)
Calculate the skewness excess of the input vector x.
error: invalid initialization of reference of type ‘const vec& {aka const itpp::Vec<double>&}’ from expression of type ‘std::vector<double>’
double skew = skewness (x);
^
In file included from main.cpp:3:0:
/usr/local/include/itpp/stat/misc_stat.h:336:20: note: in passing argument 1 of ‘double itpp::skewness(const vec&)’
ITPP_EXPORT double skewness(const vec &x);
I don't understand why am I getting this error.
Thank you.
Upvotes: 0
Views: 1134
Reputation: 5678
skewness()
appears to take a parameter of type const itpp::Vec<double>&
, but you are giving it a std::vector<double>
, which cannot implicitly be converted into the former type. You need to declare x
to be of type itpp::Vec<double>
instead, or maybe you can explicitly convert x
to an object of that type, provided itpp lets you do that (I don't know the library).
Upvotes: 3
Reputation: 8601
A const vec&
is not a const std::vector&
, so the argument does not match.
Upvotes: 3