### [xtensor] added member function in class xPoint

``` added member function in class xtensor::xPoint :
double & operator [] (int i);
double operator [] (int i) const;
xPoint operator / (double other) const;
xPoint& operator /= (double other)
xPoint& operator -= (const xPoint &other)
bool operator == (const xPoint & other) const

xTensor/src/xPoint.h   clang-formated```
parent d26022a1
 ... ... @@ -2,73 +2,129 @@ #define _XPOINT_H_ #include #include namespace xtensor{ class xPoint { double pos; public: inline xPoint(double x = 0.0, double y =0.0, double z = 0.0) { pos = x; pos = y; pos = z; } template inline xPoint(T other) { pos=other(0); pos=other(1); pos=other(2); } inline bool lexicographicLessThan (const xPoint &other, double EPS) const { if(posother(0)+EPS)return 0; if(posother(1)+EPS)return 0; if(posother(2)+EPS)return 0; return 0; } friend std::ostream& operator<< (std::ostream& out, const xPoint& obj) { out <<"("<< obj(0)<<","<< obj(1)<<","<< obj(2)<<")" ; return out; } void print() { std::cout<<" xPoint="<=3)throw -1; return pos[i]; } inline double operator () (int i) const { if(i>=3)throw -1; return pos[i]; } inline xPoint operator * (double other) const { return xPoint(pos*other, pos*other, pos*other); } inline xPoint operator + (const xPoint &other) const { return xPoint(pos+other.pos, pos+other.pos, pos+other.pos);} inline xPoint& operator += (const xPoint &other) { pos+=other.pos; pos+=other.pos; pos+=other.pos; return *this; } inline xPoint& operator *= (double other) { pos*=other; pos*=other; pos*=other; return *this; } inline xPoint operator - (const xPoint &other) const { return xPoint(pos-other.pos, pos-other.pos, pos-other.pos); } inline bool operator< (const xPoint &other) const { return lexicographicLessThan(other,1.e-6); } inline bool closeTo (const xPoint &other, double EPS) const { return ( ( pow( pos-other(0) ,2)+ pow(pos-other(1),2)+ pow( pos } namespace xtensor { class xPoint { double pos; public: inline xPoint(double x = 0.0, double y = 0.0, double z = 0.0) { pos = x; pos = y; pos = z; } template inline xPoint(T other) { pos = other(0); pos = other(1); pos = other(2); } inline bool lexicographicLessThan(const xPoint& other, double EPS) const { if (pos < other(0) - EPS) return 1; if (pos > other(0) + EPS) return 0; if (pos < other(1) - EPS) return 1; if (pos > other(1) + EPS) return 0; if (pos < other(2) - EPS) return 1; if (pos > other(2) + EPS) return 0; return 0; } friend std::ostream& operator<<(std::ostream& out, const xPoint& obj) { out << "(" << obj(0) << "," << obj(1) << "," << obj(2) << ")"; return out; } void print() { std::cout << " xPoint=" << pos << "," << pos << "," << pos << std::endl; } inline double& operator()(int i) { if (i >= 3) throw -1; return pos[i]; } inline double operator()(int i) const { if (i >= 3) throw -1; return pos[i]; } inline double& operator[](int i) { if (i >= 3) throw -1; return pos[i]; } inline double operator[](int i) const { if (i >= 3) throw -1; return pos[i]; } inline xPoint operator*(double other) const { return xPoint(pos * other, pos * other, pos * other); } inline xPoint operator/(double other) const { return xPoint(pos / other, pos / other, pos / other); } inline xPoint& operator+=(const xPoint& other) { pos += other.pos; pos += other.pos; pos += other.pos; return *this; } inline xPoint operator+(const xPoint& other) const { return xPoint(pos + other.pos, pos + other.pos, pos + other.pos); } inline xPoint& operator*=(double other) { pos *= other; pos *= other; pos *= other; return *this; } inline xPoint& operator/=(double other) { pos /= other; pos /= other; pos /= other; return *this; } inline xPoint& operator-=(const xPoint& other) { pos -= other.pos; pos -= other.pos; pos -= other.pos; return *this; } inline xPoint operator-(const xPoint& other) const { return xPoint(pos - other.pos, pos - other.pos, pos - other.pos); } inline bool operator<(const xPoint& other) const { return lexicographicLessThan(other, 1.e-6); } inline bool closeTo(const xPoint& other, double EPS) const { return ((pow(pos - other(0), 2) + pow(pos - other(1), 2) + pow(pos < other(2), 2)) < pow(EPS, 2)); } inline bool operator==(const xPoint& other) const { return (pos == other.pos && pos == other.pos && pos == other.pos); } }; // end of xPoint } // namespace xtensor #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!