1 #ifndef VIENNACL_TOOLS_TOOLS_HPP_
2 #define VIENNACL_TOOLS_TOOLS_HPP_
41 template <
class SCALARTYPE,
typename F,
unsigned int ALIGNMENT>
47 template <
class SCALARTYPE,
typename F,
unsigned int ALIGNMENT>
59 typedef typename T::ERROR_SCALAR_MUST_HAVE_TEMPLATE_ARGUMENT_FLOAT_OR_DOUBLE
ResultType;
70 struct CHECK_SCALAR_TEMPLATE_ARGUMENT<double>
85 std::ifstream f(filename.c_str());
86 if (!f)
return std::string();
88 std::stringstream result;
90 while (std::getline(f, tmp))
91 result << tmp << std::endl;
103 inline std::string
strReplace(
const std::string & text, std::string to_search, std::string to_replace)
105 std::string::size_type pos = 0;
107 std::string::size_type found;
108 while( (found = text.find(to_search, pos)) != std::string::npos )
110 result.append(text.substr(pos,found-pos));
111 result.append(to_replace);
112 pos = found + to_search.length();
114 if (pos < text.length())
115 result.append(text.substr(pos));
126 template <
class INT_TYPE>
129 if (to_reach % base == 0)
return to_reach;
130 return ((to_reach / base) + 1) * base;
141 template <
class INT_TYPE>
144 if (to_reach % base == 0)
return to_reach;
145 return (to_reach / base) * base;
154 int inline find_and_replace(std::string & source, std::string
const & find, std::string
const & replace)
159 for (
vcl_size_t pos=0; (pos=source.find(find, pos))!=std::string::npos; pos+=rLen)
162 source.replace(pos, fLen, replace);
175 std::stringstream ss;
176 ss <<
"#pragma OPENCL EXTENSION " << fp_extension <<
" : enable\n\n";
178 std::string result = ss.str();
179 result.append(
strReplace(source,
"float",
"double"));
185 template <
typename T>
192 template <
typename T>
206 template <
typename T>
217 typedef float ResultType;
221 struct CPU_SCALAR_TYPE_DEDUCER< double >
223 typedef double ResultType;
226 template <
typename T>
227 struct CPU_SCALAR_TYPE_DEDUCER<
viennacl::scalar<T> >
229 typedef T ResultType;
232 template <
typename T,
unsigned int A>
233 struct CPU_SCALAR_TYPE_DEDUCER<
viennacl::vector<T, A> >
235 typedef T ResultType;
238 template <
typename T,
typename F,
unsigned int A>
239 struct CPU_SCALAR_TYPE_DEDUCER<
viennacl::matrix<T, F, A> >
241 typedef T ResultType;
245 template <
typename T,
typename F,
unsigned int A>
246 struct CPU_SCALAR_TYPE_DEDUCER<
viennacl::matrix_expression<const matrix<T, F, A>, const matrix<T, F, A>, op_trans> >
248 typedef T ResultType;
256 template <
typename HostScalarType>
259 template <
typename HostScalarType>
264 const viennacl::scalar<HostScalarType>,
267 template <
typename HostScalarType>
270 template <
typename HostScalarType>
273 template <
typename HostScalarType>
276 template <
typename HostScalarType>
279 template <
typename HostScalarType>
282 template <
typename HostScalarType>
std::size_t vcl_size_t
Definition: forwards.h:58
Adapter classes for sparse matrices made of the STL type std::vector >
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type...
Definition: forwards.h:172
A dense matrix class.
Definition: forwards.h:293
This file provides the forward declarations for the main types used within ViennaCL.
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
A proxy for scalar expressions (e.g. from inner vector products)
Definition: forwards.h:175
vector_expression< const matrix_base< NumericT, F >, const unsigned int, op_row > row(const matrix_base< NumericT, F > &A, unsigned int i)
Definition: matrix.hpp:910
Definition: forwards.h:211
A tag class representing sign flips (for scalars only. Vectors and matrices use the standard multipli...
Definition: forwards.h:168