File: Math.cpp

package info (click to toggle)
yade 2025.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,308 kB
  • sloc: cpp: 93,298; python: 50,409; sh: 577; makefile: 162
file content (24 lines) | stat: -rw-r--r-- 1,082 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <lib/base/Math.hpp>
#include <boost/math/constants/constants.hpp>

namespace yade { // Cannot have #include directive inside.

template <> int  ZeroInitializer<int>() { return (int)0; }
template <> Real ZeroInitializer<Real>() { return (Real)0; }

#ifdef YADE_MASK_ARBITRARY
bool   operator==(const mask_t& g, int i) { return g == mask_t(i); }
bool   operator==(int i, const mask_t& g) { return g == i; }
bool   operator!=(const mask_t& g, int i) { return !(g == i); }
bool   operator!=(int i, const mask_t& g) { return g != i; }
mask_t operator&(const mask_t& g, int i) { return g & mask_t(i); }
mask_t operator&(int i, const mask_t& g) { return g & i; }
mask_t operator|(const mask_t& g, int i) { return g | mask_t(i); }
mask_t operator|(int i, const mask_t& g) { return g | i; }
bool   operator||(const mask_t& g, bool b) { return (g != 0) || b; }
bool   operator||(bool b, const mask_t& g) { return g || b; }
bool   operator&&(const mask_t& g, bool b) { return (g != 0) && b; }
bool   operator&&(bool b, const mask_t& g) { return g && b; }
#endif

}; // namespace yade