33#include "acl/aclStdIncludes.h"
48 template <
typename T>
inline std::string
numToStr(T i)
60 s << std::setfill(
'0') << std::setw(
numberOf0) << i;
66 template <
typename T> T
strToNum(std::string
s);
69 template <
int I>
class I2T{
public:
static const int i =
I;};
72 template <
int I>
inline const double P(
const double&
a){
return P<
I-1>(
a)*
a;}
73 template <
int I>
inline const float P(
const float&
a){
return P<
I-1>(
a)*
a;}
74 template <
int I>
inline const int P(
const int&
a){
return P<
I-1>(
a)*
a;}
77 template <>
inline const double P<1>(
const double&
a){
return a;}
78 template <>
inline const float P<1>(
const float&
a){
return a;}
79 template <>
inline const int P<1>(
const int&
a){
return a;}
84 template <
typename T>
inline bool in(
const T&
xx,
const T&
x1,
const T&
x2)
90 template <
typename T>
inline bool inO(
const T&
xx,
const T&
x1,
const T&
x2)
92 return (((
x1 -
xx) * (
x2 -
xx)) < 0);
95 static const double pi=4.*
atan(1.);
98 inline const double deg(
double a){
return a/pi*180.;}
99 inline const float deg(
float a){
return a/pi*180.;}
101 inline const double rad(
double a){
return a*pi/180.;}
102 inline const float rad(
float a){
return a*pi/180.;}
105 inline const bool approxEqual(
const double &
a,
const double &b,
const double p_ = 1e-6)
110 inline const bool approxEqual(
const float &
a,
const float &b,
const float p_ = 1e-6)
146 const std::vector<T> & vector);
151 const std::vector<T> &
vector2);
155 template <
class T,
int N>
inline void output1OfN(
const std::string &
s);
158 template <
class T>
inline void setupAll(std::vector<std::shared_ptr<T> > & v);
161 template <
class T>
inline void computeAll(std::vector<std::shared_ptr<T> > & v);
164 template <
class T1,
class T2>
inline void sortTwoVectors(std::vector<T1> & v1, std::vector<T2> &
v2);
167 template <
class T>
inline void reorderVector(std::vector<unsigned int> &
ind, std::vector<T> & v);
173 template <
typename T> std::ostream &
operator<<(std::ostream &
output,
const std::vector<T> & vector)
175 typename std::vector<T>::const_iterator
iter;
177 for (
iter = vector.begin();
iter != vector.end(); ++
iter)
186 const std::vector<T> &
vector2)
204 template <
class T,
int N>
inline void output1OfN(
const std::string &
s)
208 std::cout <<
s << std::endl;
212 template <
class T>
void setupAll(std::vector<std::shared_ptr<T> > &v)
214 for (
unsigned int i(0); i < v.size(); ++i)
218 template <
class T>
void computeAll(std::vector<std::shared_ptr<T> > &v)
220 for (
unsigned int i(0); i < v.size(); ++i)
224 template <
typename T1>
class comparatorIndeces {
226 std::vector<T1> & v1;
229 inline bool operator()(
unsigned int i,
unsigned int j) {
return v1[i]<v1[
j];}
232 template <
typename T1,
typename T2>
inline void sortTwoVectors(std::vector<T1> & v1, std::vector<T2> &
v2)
234 if(v1.size()!=
v2.size())
235 errorMessage(
"sortTwoVectors: the vectors have different sizes");
238 std::vector<unsigned int>
ind(v1.size());
239 for(
unsigned int i(0); i<v1.size(); ++i)
247 template <
class T>
inline void reorderVector(std::vector<unsigned int> &
ind, std::vector<T> & v)
249 if(
ind.size()!=v.size())
250 errorMessage(
"reorderVector: the vectors have different sizes");
252 unsigned int n(v.size());
254 for(
unsigned int i(0); i<n; ++i)
comparatorIndeces(std::vector< T1 > &v)
bool operator()(unsigned int i, unsigned int j)
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
void warningMessage(const char *warningMessage)
Prints warningMessage.
std::string warningString(const char *warningMessage)
Returns warningMessage.
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
std::string numToStr(T i)
Converts numbers or another type to string.
Advanced Simulation Library.
void output1OfN(const std::string &s)
Makes output 1 of n times.
const double P(const double &a)
Realization of .
void sortTwoVectors(std::vector< T1 > &v1, std::vector< T2 > &v2)
sorts two vectors with respect of the fist one
bool in(const T &xx, const T &x1, const T &x2)
Checks the belonging to a closed interval [x1,x2], .
std::ostream & operator<<(std::ostream &output, const std::vector< T > &vector)
Prints elements of the vector separated by space.
bool inO(const T &xx, const T &x1, const T &x2)
Checks the belonging to an open interval (x1,x2), .
const double rad(double a)
Translation degrees to radians.
bool operator==(const std::vector< T > &vector1, const std::vector< T > &vector2)
Compares two vectors.
T strToNum(std::string s)
Converts string to number, exits if not able to convert.
const double deg(double a)
Translation radians to degrees.
void reorderVector(std::vector< unsigned int > &ind, std::vector< T > &v)
reorders vector according to indeces
void setupAll(std::vector< std::shared_ptr< T > > &v)
const bool approxEqual(const double &a, const double &b, const double p_=1e-6)
Approximately equal; the precision is defined as p_.
void computeAll(std::vector< std::shared_ptr< T > > &v)