I have a constructor which constructs a matrix, represented by a 2D vector, rows and columns number.
Matrix(const vector<vector<T> >* vect, const size_t rows, const size_t cols) :
matrix(&vect), matrixRows(rows), matrixCols(cols){}
I want to find the transpose of a matrix in one of my functions.
Matrix& trans() const
{
vector<vector<T> > trans(matrixCols, vector<T>(matrixRows));
for(unsigned int i = 0; i < matrixRows; i++)
{
for(unsigned int j = 0; j < matrixCols; j++)
{
trans[j][i] = matrix[i][j];
}
}
return Matrix(&trans, matrixCols, matrixRows);
}
The last line results in an error, because passing a vector this way is wrong.
What is the correct way?
Full error:
Multiple markers at this line
- invalid initialization of non-const reference of type 'Matrix<Complex>&' from an rvalue of type
'Matrix<Complex>'
- required from 'Matrix<T>& Matrix<T>::trans() const [with T = int]'
- invalid initialization of non-const reference of type 'Matrix<double>&' from an rvalue of type
'Matrix<double>'
- invalid initialization of non-const reference of type 'Matrix<int>&' from an rvalue of type 'Matrix<int>'
- required from 'Matrix<T>& Matrix<T>::trans() const [with T = Complex]'
- required from 'Matrix<T>& Matrix<T>::trans() const [with T = double]'
constructor error:
Multiple markers at this line
- invalid conversion from 'const std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >**' to 'std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >::size_type
{aka long long unsigned int}' [-fpermissive]
- candidate expects 3 arguments, 1 provided
- no matching function for call to 'std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >::vector(const std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > >
>**)'
- no known conversion for argument 1 from 'std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >' to 'const std::vector<std::vector<double, std::allocator<double> >,
std::allocator<std::vector<double, std::allocator<double> > > >*'
- candidate: Matrix<T>::Matrix(const std::vector<std::vector<T> >*, size_t, size_t) [with T = double; size_t = long long unsigned int]
- no known conversion for argument 1 from 'std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >' to 'const std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int>
> > >*'
- candidate: Matrix<T>::Matrix(const std::vector<std::vector<T> >*, size_t, size_t) [with T = int; size_t = long long unsigned int]
- no matching function for call to 'std::vector<std::vector<Complex, std::allocator<Complex> >, std::allocator<std::vector<Complex, std::allocator<Complex> > > >::vector(const std::vector<std::vector<Complex, std::allocator<Complex> >,
std::allocator<std::vector<Complex, std::allocator<Complex> > > >**)'
- invalid conversion from 'const std::vector<std::vector<Complex, std::allocator<Complex> >, std::allocator<std::vector<Complex, std::allocator<Complex> > > >**' to 'std::vector<std::vector<Complex, std::allocator<Complex> >,
std::allocator<std::vector<Complex, std::allocator<Complex> > > >::size_type {aka long long unsigned int}' [-fpermissive]
- no matching function for call to 'std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >::vector(const std::vector<std::vector<double, std::allocator<double> >,
std::allocator<std::vector<double, std::allocator<double> > > >**)'
- invalid conversion from 'const std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >**' to 'std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double,
std::allocator<double> > > >::size_type {aka long long unsigned int}' [-fpermissive]
- no known conversion for argument 1 from 'std::vector<std::vector<Complex, std::allocator<Complex> >, std::allocator<std::vector<Complex, std::allocator<Complex> > > >' to 'const std::vector<std::vector<Complex, std::allocator<Complex> >,
std::allocator<std::vector<Complex, std::allocator<Complex> > > >*'
- candidate: Matrix<T>::Matrix(const std::vector<std::vector<T> >*, size_t, size_t) [with T = Complex; size_t = long long unsigned int]
First off, you probably want the Matrix constructor to take the vector by reference instead of address:
Matrix(const vector<vector<T>>& vect, const size_t rows, const size_t cols)
: matrix(vect), matrixRows(rows), matrixCols(cols)
{
}
(Note that this will cause the vector to be copied into matrix. Depending on the size of the vector, this might be fine - it really depends on the performance requirements of your program.)
Secondly, trans() should not return a reference to a Matrix. Since you are returning the value of a local, the variable will be destroyed when execution leaves the function, so the caller would have no way to make use of it.
Combined with the change to the Matrix constructor above, trans() should compile now:
Matrix trans() const
{
vector<vector<T>> trans(matrixCols, vector<T>(matrixRows));
for(unsigned int i = 0; i < matrixRows; i++)
{
for(unsigned int j = 0; j < matrixCols; j++)
{
trans[j][i] = matrix[i][j];
}
}
return Matrix(trans, matrixCols, matrixRows);
}
Related
I'm new to std::threads and I'm trying to figure out what I'm doing wrong.
The idea is having a static function inside a DataUtils class that splits the program in 10 threads, every of which will calculate "a part" of a convolution between two vectors.
For some reason it seems that the compiler can't assign the right function to the thread, but the arguments are correct.
Here is my code (I am sure there is a more elegant way to do this...)
void threadconv (std::vector<double> const &f, std::vector<double> const &g, std::vector<double> &out, int start, int stop,int nf,int ng){
for(auto i(start); i < stop; ++i) {
int const jmn = (i >= ng - 1)? i - (ng - 1) : 0;
int const jmx = (i < nf - 1)? i : nf - 1;
for(auto j(jmn); j <= jmx; ++j) {
out[i] += (f[j] * g[i - j]);
}
}
}
class DataUtils{
static std::vector<double> multiThreadedConvolution(std::vector<double> const &f, std::vector<double> const &g, int divide){
int const nf = f.size();
int const ng = g.size();
int const n = nf + ng - 1;
int i=0;
std::vector<double> out(n, double());
std::thread t1 (threadconv,f,g,out,0,divide,nf,ng);i++;
std::thread t2 (threadconv,f,g,out,divide*i,(divide*i)+divide,nf,ng);i++;
std::thread t3 (threadconv,f,g,out,divide*i,(divide*i)+divide,nf,ng);i++;
std::thread t4 (threadconv,f,g,out,divide*i,(divide*i)+divide, nf,ng);i++;
std::thread t5 (threadconv,f,g,out,divide*i,(divide*i)+divide, nf,ng);i++;
std::thread t6 (threadconv,f,g,out,divide*i,(divide*i)+divide, nf,ng);i++;
std::thread t7 (threadconv,f,g,out,divide*i,(divide*i)+divide, nf,ng);i++;
std::thread t8 (threadconv,f,g,out,divide*i,(divide*i)+divide, nf,ng);i++;
std::thread t9 (threadconv,f,g,out,divide*i,(divide*i)+divide, nf,ng);i++;
std::thread t10 (threadconv,f,g,out,divide*i,out.size(), nf,ng);
t1.join();
t2.join();
t3.join();
t4.join();
t5.join();
t6.join();
t7.join();
t8.join();
t9.join();
t10.join();
return out;
}
}
After trying to compile, this is the error message I receive:
/usr/include/c++/7/thread:240:2: error: no matching function for call to ‘std::thread::_Invoker<std::tuple<void (*)(const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, int, int, int, int), std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> >, int, int, int, int> >::_M_invoke(std::thread::_Invoker<std::tuple<void (*)(const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, int, int, int, int), std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> >, int, int, int, int> >::_Indices)’
operator()()
^~~~~~~~
/usr/include/c++/7/thread:231:4: note: candidate: template<long unsigned int ..._Ind> decltype (std::__invoke((_S_declval<_Ind>)()...)) std::thread::_Invoker<_Tuple>::_M_invoke(std::_Index_tuple<_Ind ...>) [with long unsigned int ..._Ind = {_Ind ...}; _Tuple = std::tuple<void (*)(const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, int, int, int, int), std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> >, int, int, int, int>]
_M_invoke(_Index_tuple<_Ind...>)
^~~~~~~~~
/usr/include/c++/7/thread:231:4: note: template argument deduction/substitution failed:
/usr/include/c++/7/thread: In substitution of ‘template<long unsigned int ..._Ind> decltype (std::__invoke(_S_declval<_Ind>()...)) std::thread::_Invoker<std::tuple<void (*)(const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, int, int, int, int), std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> >, int, int, int, int> >::_M_invoke<_Ind ...>(std::_Index_tuple<_Ind1 ...>) [with long unsigned int ..._Ind = {0, 1, 2, 3, 4, 5, 6, 7}]’:
/usr/include/c++/7/thread:240:2: required from ‘struct std::thread::_Invoker<std::tuple<void (*)(const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, int, int, int, int), std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> >, int, int, int, int> >’
/usr/include/c++/7/thread:127:22: required from ‘std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (&)(const std::vector<double>&, const std::vector<double>&, std::vector<double>&, int, int, int, int); _Args = {const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, int, int&, const int&, const int&}]’
I am trying out a project in C++ and I am trying to enter a value from an integer type vector to a pair type vector.
I have tried emplace_back and push_back but it doesn't work. Most probably due to the pair typed vector.
Note: I am using boost libraries, not sure if that is helpful.
typedef unsigned int objecttype;
typedef string operationtype;
typedef unsigned int checkob;
typedef pair<objecttype, operationtype> objectops;
vector<vector<unsigned int>> parameters;
//lines returning values to “parameters”
vector<checkob> checkParams = parameters.at(0); // works fine
vector<objectops> objectParams = parameters.at(1); // below error
The error message:
error test.cpp:273:30: error: no viable conversion from 'vector<unsigned int, allocator<unsigned int>>' to 'vector<model:: objectops, allocator<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >>>'
stl_vector.h:326:7: note: candidate constructor not viable: no known conversion from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >::value_type' (aka 'std::vector<unsigned int, std::allocator<unsigned int> >') to 'const std::vector<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > &' for 1st argument
stl_vector.h:344:7: note: candidate constructor not viable: no known conversion from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >::value_type' (aka 'std::vector<unsigned int, std::allocator<unsigned int> >') to 'std::vector<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > &&' for 1st argument
stl_vector.h:383:7: note: candidate constructor not viable: no known conversion from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >::value_type' (aka 'std::vector<unsigned int, std::allocator<unsigned int> >') to 'initializer_list<std::vector<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::value_type>' (aka 'initializer_list<std::pair<unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >') for 1st argument
You are trying to assign std::vector<unsigned int> to std::pair<unsigned int, std::string>, which is obviously not possible.
You can either
assign a vector of std::pair<unsigned int, std::string> to
objectParams
or a list initialization using a pair of the element of the vector
of vector of unsigned int egers(i.e. unsigned int) of parameters
and a std::string.
You probably mean this:
vector<objectops> objectParams ={ { parameters.at(0).at(0), "string"} };
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ std::pair<objecttype, operationtype>
// ^^ ^^ for std::vector<objectops>
I have the following code in a script that I am trying to build.
typedef std::vector< typename Sphere::vec_type > VV;
typedef typename Sphere::vec_type vec_type;
VV v( count , s.dimension() );
for ( int ii=0; ii<count; ++ii ) {
v[ii] = randomPointOnSurface( s );
It produces this error:
error: no matching function for call to 'std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >::_M_fill_initialize(size_t, int&)'
/usr/include/c++/4.4/bits/stl_vector.h:1033: note: candidates are: void std::vector<_Tp, _Alloc>::_M_fill_initialize(size_t, const _Tp&) [with _Tp = std::vector<float, std::allocator<float> >, _Alloc = std::allocator<std::vector<float, std::allocator<float> > >]
A workaround is to remove s.dimension() but is there any other way that this can fixed?
You have a nested vector, so you need something like
VV v( count , vec_type(s.dimension()) );
This initializes each of the count inner vectors to have size s.dimension().
I'm trying to create a std::unordered_map, using a user-defined hash function and equality predicate, for matrix rows of integral built-in types. I use std::bind, since I need the hashing and equality functors to work for variable ranges. How would I get the following code to compile and work as intended? I'm guessing that my mistake is towards the bottom of the listing, where I use std::bind and instantiate the std::unordered_map.
Some clarifications:
I can't use boost::hash_combine because I care about individual bits in the integers stored in the matrix row, so unless I create my own iterator, boost::hash_combine would combine whole integers, leading to erroneous results. Also, I need the hash and equality functors to work on ranges from 1 to ~200,000, so specifying the range in template parameters would not be a reasonable option.
template <class T,class F,class A>
struct row_hash_right : std::function<size_t(
ublas::matrix_row<ublas::matrix<T,F,A>>,
unsigned, unsigned)>
{
typedef ublas::matrix_row<ublas::matrix<T,F,A>> row_type;
// I want to use std::bind to bind the last two arguments.
size_t operator()(row_type& a, unsigned s, unsigned e)
{
// Implementation of hash function.
}
};
template <class T,class F,class A>
struct row_equal_right : std::function<bool(
ublas::matrix_row<ublas::matrix<T,F,A>>,
ublas::matrix_row<ublas::matrix<T,F,A>>,
unsigned, unsigned)>
{
typedef ublas::matrix_row<ublas::matrix<T,F,A>> row_type;
bool operator()(row_type& a, row_type& b, unsigned s, unsigned e)
{
// Implementation of equality predicate.
}
};
// Inside a function.
for (unsigned i = 0; i < len; ++i) {
for (unsigned j = i + 1; j < len; ++j) {
auto x = std::bind(r_hash, _1, i, j);
auto y = std::bind(r_equal, _1, _2, i, j);
// ERROR:
std::unordered_map<row_type, unsigned,
decltype(x), decltype(y)> m(256, x, y);
}
}
The error:
Here is (what I think) the most important part of the error produced upon attempted compilation:
/usr/include/c++/4.6/bits/stl_pair.h:92:11: error: ‘std::pair<_T1,
_T2>::first’ has incomplete type
/usr/include/boost/numeric/ublas/fwd.hpp:73:11: error: declaration of ‘const struct
boost::numeric::ublas::matrix_row,
boost::numeric::ublas::unbounded_array > > >’
If you want the see the whole thing, I've dumped it all here:
In file included from /usr/include/c++/4.6/bits/stl_algobase.h:65:0,
from /usr/include/c++/4.6/bits/char_traits.h:41,
from /usr/include/c++/4.6/ios:41,
from /usr/include/c++/4.6/ostream:40,
from /usr/include/c++/4.6/iostream:40,
from src/test/read_test.cpp:1:
/usr/include/c++/4.6/bits/stl_pair.h: In instantiation of ‘std::pair, boost::numeric::ublas::unbounded_array > > >, unsigned int>’:
/usr/include/c++/4.6/bits/stl_function.h:486:12: instantiated from ‘std::_Select1st, boost::numeric::ublas::unbounded_array > > >, unsigned int> >’
/usr/include/c++/4.6/bits/hashtable_policy.h:789:20: instantiated from ‘std::__detail::_Hash_code_base, boost::numeric::ublas::unbounded_array > > >, std::pair, boost::numeric::ublas::unbounded_array > > >, unsigned int>, std::_Select1st, boost::numeric::ublas::unbounded_array > > >, unsigned int> >, std::_Bind, boost::numeric::ublas::unbounded_array > >(std::_Placeholder, std::_Placeholder, unsigned int, unsigned int)>, std::_Bind, boost::numeric::ublas::unbounded_array > >(std::_Placeholder, unsigned int, unsigned int)>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, false>’
/usr/include/c++/4.6/bits/hashtable.h:105:11: instantiated from ‘std::_Hashtable, boost::numeric::ublas::unbounded_array > > >, std::pair, boost::numeric::ublas::unbounded_array > > >, unsigned int>, std::allocator, boost::numeric::ublas::unbounded_array > > >, unsigned int> >, std::_Select1st, boost::numeric::ublas::unbounded_array > > >, unsigned int> >, std::_Bind, boost::numeric::ublas::unbounded_array > >(std::_Placeholder, std::_Placeholder, unsigned int, unsigned int)>, std::_Bind, boost::numeric::ublas::unbounded_array > >(std::_Placeholder, unsigned int, unsigned int)>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, false, false, true>’
/usr/include/c++/4.6/bits/unordered_map.h:44:11: instantiated from ‘std::__unordered_map, boost::numeric::ublas::unbounded_array > > >, unsigned int, std::_Bind, boost::numeric::ublas::unbounded_array > >(std::_Placeholder, unsigned int, unsigned int)>, std::_Bind, boost::numeric::ublas::unbounded_array > >(std::_Placeholder, std::_Placeholder, unsigned int, unsigned int)>, std::allocator, boost::numeric::ublas::unbounded_array > > >, unsigned int> >, false>’
/usr/include/c++/4.6/bits/unordered_map.h:256:11: instantiated from ‘std::unordered_map, boost::numeric::ublas::unbounded_array > > >, unsigned int, std::_Bind, boost::numeric::ublas::unbounded_array > >(std::_Placeholder, unsigned int, unsigned int)>, std::_Bind, boost::numeric::ublas::unbounded_array > >(std::_Placeholder, std::_Placeholder, unsigned int, unsigned int)>, std::allocator, boost::numeric::ublas::unbounded_array > > >, unsigned int> > >’
./sal/alg/ehh.hpp:144:31: instantiated from ‘sal::ehh_results sal::compute_ehh(boost::numeric::ublas::matrix&, unsigned int) [with FloatType = double, T = unsigned int, F = boost::numeric::ublas::basic_row_major, A = boost::numeric::ublas::unbounded_array >]’
src/test/read_test.cpp:11:51: instantiated from here
/usr/include/c++/4.6/bits/stl_pair.h:92:11: error: ‘std::pair::first’ has incomplete type
/usr/include/boost/numeric/ublas/fwd.hpp:73:11: error: declaration of ‘const struct boost::numeric::ublas::matrix_row, boost::numeric::ublas::unbounded_array > > >’
If you want to hash a range of things, you need something like hash_combine(). I usually lift this function from Boost (surprisingly, it wasn't included in the standard!). Here's how I'd use it on std::arrays, and I trust you can manipulate this into something to work on matrix rows:
#include <array>
template <class T>
inline void hash_combine(std::size_t & seed, const T & v)
{
std::hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
namespace std
{
template<typename T, size_t N> struct hash<array<T, N>>
{
inline size_t operator()(const array<T, N> & a) const
{
size_t seed = 0;
for (size_t i = 0; i != N; ++i)
{
::hash_combine(seed, a[i]);
}
return seed;
}
};
}
(The above specialisation allows you to use std::unordered_set<std::array<int, 10>> etc.)
If the matrix rows don't come with an equality predicate, you could also add a specialization of std::equal_to for matrix rows.
I tried to replicate a minimalist example of my problem, with the following code :
http://codepad.org/HjhNSk2S
It does compile perfectly with Visual Studio 2008, just displays some warnings on codepad (about the order of initialization), but fails with g++ on cygwin, giving the following errors, and I just have no clue why :
Interpolator2.cpp:39: error: expected ‘,’ or ‘...’ before numeric constant
Interpolator2.cpp: In constructor ‘Interpolator<DIM, SAMPLESTYPE>::Interpolator(const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&, const std::vector<double, std::allocator<double> >&, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&)’:
Interpolator2.cpp:45: error: ‘_wB’ was not declared in this scope
Interpolator2.cpp:46: error: ‘_sqrDist’ was not declared in this scope
Interpolator2.cpp:47: error: ‘_kernel’ was not declared in this scope
Interpolator2.cpp:48: error: ‘_interpolateBins’ was not declared in this scope
Interpolator2.cpp:49: error: ‘_kNNDist’ was not declared in this scope
Interpolator2.cpp:50: error: ‘_NLevels’ was not declared in this scope
Interpolator2.cpp: At global scope:
Interpolator2.cpp:131: error: expected ‘,’ or ‘...’ before numeric constant
Interpolator2.cpp: In constructor ‘InterpModeData<DIM, SAMPLESTYPE>::InterpModeData(int, double, const std::vector<std::vector<TsFlow, std::allocator<TsFlow> >, std::allocator<std::vector<TsFlow, std::allocator<TsFlow> > > >&, Vector<DIM, SAMPLESTYPE> (*)(const Vector<DIM, SAMPLESTYPE>&, const Vector<DIM, SAMPLESTYPE>&, double), std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, double (*)(const Vector<DIM, SAMPLESTYPE>&, const Vector<DIM, SAMPLESTYPE>&, double), const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&)’:
Interpolator2.cpp:135: error: ‘_sumWA’ was not declared in this scope
Interpolator2.cpp:135: error: ‘_sumWB’ was not declared in this scope
Interpolator2.cpp:135: error: ‘_samples’ was not declared in this scope
Interpolator2.cpp: In function ‘int main()’:
Interpolator2.cpp:206: error: no matching function for call to ‘Interpolator<2, double>::Interpolator(std::vector<Vector<2, double>, std::allocator<Vector<2, double> > >&, std::vector<double, std::allocator<double> >&, std::vector<Vector<2, double>, std::allocator<Vector<2, double> > >&, std::vector<double, std::allocator<double> >&, <unresolved overloaded function type>, <unresolved overloaded function type>, <unresolved overloaded function type>, int, int)’
Interpolator2.cpp:43: note: candidates are: Interpolator<DIM, SAMPLESTYPE>::Interpolator(const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&, const std::vector<double, std::allocator<double> >&, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&) [with int DIM = 2, SAMPLESTYPE = double]
Interpolator2.cpp:36: note: Interpolator<2, double>::Interpolator(const Interpolator<2, double>&)
Interpolator2.cpp: In member function ‘void Interpolator<DIM, SAMPLESTYPE>::interpolate(double, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&, std::vector<double, std::allocator<double> >&) [with int DIM = 2, SAMPLESTYPE = double]’:
Interpolator2.cpp:212: instantiated from here
Interpolator2.cpp:58: error: no matching function for call to ‘InterpModeData<2, double>::InterpModeData(unsigned int&, double&, std::vector<std::vector<TsFlow, std::allocator<TsFlow> >, std::allocator<std::vector<TsFlow, std::allocator<TsFlow> > > >&, Vector<2, double> (*&)(const Vector<2, double>&, const Vector<2, double>&, double), std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, double (*&)(const Vector<2, double>&, const Vector<2, double>&, double), std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, std::vector<Vector<2, double>, std::allocator<Vector<2, double> > >&, std::vector<Vector<2, double>, std::allocator<Vector<2, double> > >&, std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, const std::vector<Vector<2, double>, std::allocator<Vector<2, double> > >&)’
Interpolator2.cpp:133: note: candidates are: InterpModeData<DIM, SAMPLESTYPE>::InterpModeData(int, double, const std::vector<std::vector<TsFlow, std::allocator<TsFlow> >, std::allocator<std::vector<TsFlow, std::allocator<TsFlow> > > >&, Vector<DIM, SAMPLESTYPE> (*)(const Vector<DIM, SAMPLESTYPE>&, const Vector<DIM, SAMPLESTYPE>&, double), std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, double (*)(const Vector<DIM, SAMPLESTYPE>&, const Vector<DIM, SAMPLESTYPE>&, double), const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&, const std::vector<Vector<DIM, SAMPLESTYPE>, std::allocator<Vector<DIM, SAMPLESTYPE> > >&) [with int DIM = 2, SAMPLESTYPE = double]
Interpolator2.cpp:127: note: InterpModeData<2, double>::InterpModeData(const InterpModeData<2, double>&)
Any idea ?
Thanks!!
It is illegal to use identifiers that begin with an underscore followed by an uppercase letter, e.g. _B on line 39.
The compiler has probably #defined that to be an integral constant, which would explain your error. Try changing it to a valid identifier.