I require a function to print out the elements of a vector in a format that I'd like to see. As of now, I have separate functions for vector<double>
and vector<std::complex>
, as follows:
void printvd(boost::ublas::vector<double> V) {
for( int i=0;i<V.size();i++ )
std::cout << V(i) << " ";
}
void printvc(boost::ublas::vector<std::complex> V) {
for( int i=0;i<V.size();i++ )
std::cout << V(i) << " ";
}
I've tried templating with,
template<typename T>
void printv(boost::ublas::vector<T > V) {
for( int i=0;i<V.size();i++ )
std::cout << V(i) << " ";
}
but any calls (like printv<double>(V);
) invariably ends up with an undefined reference error.
I am facing similar issues with matrices too - any help would be appreciated. It would also be good if somebody could quip in about how to make use of matrix expressions in boost.