1 #ifndef VIENNACL_TOOLS_TOOLS_HPP_
2 #define VIENNACL_TOOLS_TOOLS_HPP_
31 #ifdef VIENNACL_HAVE_UBLAS
32 #include <boost/numeric/ublas/matrix_sparse.hpp>
33 #include <boost/numeric/ublas/matrix.hpp>
36 #ifdef VIENNACL_HAVE_EIGEN
38 #include <Eigen/Sparse>
41 #ifdef VIENNACL_HAVE_MTL4
42 #include <boost/numeric/mtl/mtl.hpp>
54 template <
class SCALARTYPE,
typename F,
unsigned int ALIGNMENT>
60 template <
class SCALARTYPE,
typename F,
unsigned int ALIGNMENT>
71 typedef typename T::ERROR_SCALAR_MUST_HAVE_TEMPLATE_ARGUMENT_FLOAT_OR_DOUBLE
ResultType;
95 std::ifstream f(filename.c_str());
96 if (!f)
return std::string();
98 std::stringstream result;
100 while (std::getline(f, tmp))
101 result << tmp << std::endl;
113 inline std::string
strReplace(
const std::string & text, std::string to_search, std::string to_replace)
115 std::string::size_type pos = 0;
117 std::string::size_type found;
118 while( (found = text.find(to_search, pos)) != std::string::npos )
120 result.append(text.substr(pos,found-pos));
121 result.append(to_replace);
122 pos = found + to_search.length();
124 if (pos < text.length())
125 result.append(text.substr(pos));
136 template <
class INT_TYPE>
139 if (to_reach % base == 0)
return to_reach;
140 return ((to_reach / base) + 1) * base;
152 std::stringstream ss;
153 ss <<
"#pragma OPENCL EXTENSION " << fp_extension <<
" : enable\n\n";
155 std::string result = ss.str();
156 result.append(
strReplace(source,
"float",
"double"));
162 template <
typename T>
168 template <
typename T>
180 template <
typename LHS,
typename RHS>
183 typedef typename LHS::ERROR_COULD_NOT_EXTRACT_VECTOR_INFORMATION_FROM_VECTOR_EXPRESSION
ResultType;
186 template <
typename LHS,
typename ScalarType,
unsigned int A>
192 template <
typename RHS,
typename ScalarType,
unsigned int A>
199 template <
typename ScalarType,
unsigned int A>
205 template <
typename LHS,
typename RHS>
218 template <
typename LHS,
typename RHS,
typename OP>
225 template <
typename ScalarType,
unsigned int A,
typename RHS>
229 const RHS & rhs) {
return lhs.
size(); }
232 template <
typename ScalarType,
unsigned int A,
typename RHS>
236 const RHS & rhs) {
return lhs.
size(); }
240 template <
typename ScalarType,
typename F,
unsigned int Amat,
unsigned int A>
247 template <
typename ScalarType,
unsigned int Amat,
unsigned int A>
254 template <
typename ScalarType,
unsigned int Amat,
unsigned int A>
261 template <
typename ScalarType,
unsigned int Amat,
unsigned int A>
269 template <
typename ScalarType,
typename F,
unsigned int Amat,
unsigned int A>
271 const viennacl::matrix<ScalarType, F, Amat>,
290 template <
typename T>
309 template <
typename T>
315 template <
typename T,
unsigned int A>
321 template <
typename T,
typename F,
unsigned int A>
328 template <
typename T,
typename F,
unsigned int A>