38 #define iand(a,b) ( (a) & (b) )
45 #define ior(a,b) ( (a) | (b) )
52 #define inor(a,b) ( ~( (a) | (b) ) )
59 #define ixor(a,b) ( (a) ^ (b) ) )
64 #define inot(a) ( 256 - (~(a)) )
75 template <std::
floating_po
int T>
86 (std::is_arithmetic_v<T> || isComplexType<T> );
91 (std::totally_ordered<T>);
96 (std::is_constructible<std::string,T>::value);
101 (std::is_floating_point_v<T>);
107 (std::is_integral_v<T>);
112 (std::is_integral_v<T>) && (std::is_signed_v<T>);
117 (std::is_integral_v<T>) && (!std::is_signed_v<T>);
121 template<
class Base,
class Derived>
122 concept
isBaseOf= std::is_base_of_v<Base, Derived>;
149 template<
class T,
class Q>
161 inline static tString getTypeName(
const T& v) {
162 return typeid(v).name();
169 inline static tString getTypeName() {
170 tString tname=
typeid(T).name();
172 char *demangled_name = abi::__cxa_demangle(tname.c_str(), NULL, NULL, &status);
174 tname = demangled_name;
175 std::free(demangled_name);
184 std::stringstream cstr;
197 {
return (e1==e2) ; }
208 return abs(e1-e2)<std::numeric_limits<tReal>::epsilon();
219 return abs(e1-e2)<std::numeric_limits<tReal>::epsilon();
231 return (e1.compare(e2)==0);
238 template<
typename T> requires isIntegerType<T>
239 inline static T& bitSet(T& a,
const tUCInt& p) {
245 template<
typename T> requires isIntegerType<T>
246 inline static T& bitClear(T& a,
const tUCInt& p) {
251 template<
typename T> requires isIntegerType<T>
252 inline static T& bitFlip(T& a,
const tUCInt& p) {
258 template<
typename T> requires isIntegerType<T>
260 return (!!(a & (1ULL<<p)));
265 template<
typename T> requires isIntegerType<T>
266 inline static T& bitMaskSet(T& x,
const T& mask) {
272 template<
typename T> requires isIntegerType<T>
273 inline static T& bitMaskClear(T& x,
const T& mask) {
279 template<
typename T> requires isIntegerType<T>
280 inline static T& bitMaskFlip(T& x,
const T& mask) {
286 template<
typename T> requires isIntegerType<T>
287 inline static tBoolean bitMaskCheckAll(
const T& x,
const T& mask) {
288 return (!(~(x) & (mask)));
293 template<
typename T> requires isIntegerType<T>
294 inline static tBoolean bitMaskCheckAny(
const T& x,
const T& mask) {
295 return ((x) & (mask));
305 template<
typename T,std::enable_if_t<std::is_
integral_v<T>> * =
nullptr>
308 for (
tUCInt k=ret.length();k<d;k++) {
316 template<
typename T,std::enable_if_t<std::is_arithmetic_v<T>> * =
nullptr>
318 return std::to_string(v);
325 return (v)?
"true":
"false";
333 s=std::regex_replace(s, std::regex(
"^\\s+"), std::string(
""));
341 s=std::regex_replace(s, std::regex(
"\\s+$"), std::string(
""));
360 tIndex pos = str.find(word);
361 tIndex lWord=word.length();
362 tIndex lrWord=rWord.length();
364 while( pos != std::string::npos)
367 str.replace(pos, lWord , rWord);
369 pos =str.find(word, pos + lrWord);
376 std::transform(s.cbegin(), s.cend(), s.begin(),
377 [](
unsigned char c){ return std::tolower(c);});
384 std::transform(s.cbegin(), s.cend(), s.begin(),
385 [](
unsigned char c){ return std::toupper(c);});
396 std::vector<tString> words) {
400 while ( (token = strtok_r(rest,delim.c_str(),&rest))) words.push_back(
tString(token));
414 requires core_functions::isArithmeticType<T>
415 inline const T&
min(
const T& a,
const T&b) {
424 requires core_functions::isArithmeticType<T>
425 inline const T&
max(
const T& a,
const T&b) {
434 requires core_functions::isRealType<T>
436 return std::isnan(s);
445 strtol(s.c_str(), &p, 10);
461 strtod(s.c_str(), &p);
483 requires core_functions::isArithmeticType<T>
484 inline static T getEpsilon() {
485 return std::numeric_limits<T>::epsilon();
491 requires core_functions::isArithmeticType<T>
492 inline static T getInfinity() {
493 return std::numeric_limits<T>::infinity();
499 requires core_functions::isIntegerType<T>
500 inline static T getMax() {
507 requires core_functions::isIntegerType<T>
508 inline static T getMin() {
519 std::stringstream ss;
531 if (ss.compare(
"true")==0) v=
true;
537 template<
typename T,
size_t D>
539 std::stringstream ss;
541 for(
const auto & ai : a) {
544 ss.seekp(-1, std::ios_base::end);
552 std::stringstream ss;
554 for(
const auto & ai : a) {
557 ss.seekp(-1, std::ios_base::end);
564 inline const std::pair<Q,Q>&
complexMultiply(
const std::pair<Q,Q>& alpha,std::pair<Q,Q>& beta) {
565 Q betaImg=beta.second;
566 beta.second=alpha.first*betaImg+alpha.second*beta.first;
567 beta.first=alpha.first*beta.first-alpha.second*betaImg;
574 inline const std::pair<Q,Q>&
complexAdd(
const std::pair<Q,Q>& alpha,std::pair<Q,Q>& beta) {
575 beta.first+=alpha.first;
576 beta.second+=alpha.second;
593 #define ASSERT(a) {assert(a);}
594 #define ASSERT_IN(a) {assert(a);}
595 #define ASSERT_OUT(a) {assert(a);}
596 #define ASSERT_EXCEPTION(T,P,F,C) { if (!(T)) throw CORE_Exception(P,F,C);}
601 #define ASSERT_IN(a) {}
602 #define ASSERT_OUT(a) {}
603 #define ASSERT_EXCEPTION(T,P,F,C)
Definition: functions.h:66
concept isIntegerType
Definition: functions.h:106
concept isSameType
Definition: functions.h:150
concept isOrderedType
Definition: functions.h:90
tBoolean areEquals(const T &e1, const T &e2)
tests if two elements are equals
Definition: functions.h:196
tString pointerToString(const T *ptr)
return the pointer of the class as a string
Definition: functions.h:183
concept isBoundedArray
Definition: functions.h:130
concept isUnsignedIntegerType
Definition: functions.h:116
concept isBaseOf
Definition: functions.h:122
const std::pair< Q, Q > & complexMultiply(const std::pair< Q, Q > &alpha, std::pair< Q, Q > &beta)
Definition: functions.h:564
concept isSignedIntegerType
Definition: functions.h:111
tString booleanToString(const tBoolean &v)
Definition: functions.h:324
requires core_functions::isArithmeticType< T > const T & min(const T &a, const T &b)
min function
Definition: functions.h:415
tString toString(const T &v, const tUCInt &d)
Definition: functions.h:306
tBoolean isInteger(const tString &s)
return true if the argument is an integer number
Definition: functions.h:443
concept isStringType
Definition: functions.h:95
concept isComplexType
Definition: functions.h:79
void replaceAll(const tString &word, const tString &rWord, tString &str)
replace all instnce of word by replace word in string
Definition: functions.h:359
tString & trim(tString &s)
remove all the empty characters at the begining and end of the string
Definition: functions.h:349
requires core_functions::isArithmeticType< T > const T & max(const T &a, const T &b)
max function
Definition: functions.h:425
void tokenize(tString &str, const tString &delim, std::vector< tString > words)
tokenize
Definition: functions.h:394
concept iNotNullPointer
Definition: functions.h:146
void toUpper(tString &s)
turn a string to lower value
Definition: functions.h:382
concept isUnboundedArray
Definition: functions.h:134
concept isArithmeticType
Definition: functions.h:85
const std::pair< Q, Q > & complexAdd(const std::pair< Q, Q > &alpha, std::pair< Q, Q > &beta)
Definition: functions.h:574
requires core_functions::isRealType< T > tBoolean isNAN(const T &s)
return true if the argument is an integer number
Definition: functions.h:435
concept isArray
Definition: functions.h:126
concept isPointer
Definition: functions.h:142
tString & ltrim(tString &s)
remove all the empty characters at the beginning of the string
Definition: functions.h:332
concept isDoubleArray
Definition: functions.h:138
void parse(const tString &s, T &v)
parse the string
Definition: functions.h:518
tBoolean isString(const tString &s)
return true if the argument is a string
Definition: functions.h:475
void toLower(tString &s)
turn a string to lower value
Definition: functions.h:375
tBoolean isNumeric(const tString &s)
return true if the argument is an integer number
Definition: functions.h:459
tString & rtrim(tString &s)
remove all the empty characters at the end of the string
Definition: functions.h:340
concept isRealType
Definition: functions.h:100
Definition: functions.h:73
#define tIndex
Definition: types.h:157
#define tString
Definition: types.h:147
#define tComplex
Definition: types.h:139
#define tUCInt
Definition: types.h:26
#define tBoolean
Definition: types.h:151
#define tReal
Definition: types.h:137