@@ -20,15 +20,15 @@ namespace utils
2020 [[nodiscard]] rational get_rational () const noexcept { return rat; }
2121 [[nodiscard]] rational get_infinitesimal () const noexcept { return inf; }
2222
23- [[nodiscard]] inline friend bool is_integer (const inf_rational &rhs) noexcept { return is_integer (rhs. rat ) && is_zero (rhs. inf ); }
24- [[nodiscard]] inline friend bool is_zero (const inf_rational &rhs) noexcept { return is_zero (rhs. rat ) && is_zero (rhs. inf ); }
25- [[nodiscard]] inline friend bool is_positive (const inf_rational &rhs) noexcept { return is_positive (rhs. rat ) || ( is_zero (rhs. rat ) && is_positive (rhs. inf )); }
26- [[nodiscard]] inline friend bool is_positive_or_zero (const inf_rational &rhs) noexcept { return is_positive (rhs. rat ) || ( is_zero (rhs. rat ) && is_positive_or_zero (rhs. inf )); }
27- [[nodiscard]] inline friend bool is_negative (const inf_rational &rhs) noexcept { return is_negative (rhs. rat ) || ( is_zero (rhs. rat ) && is_negative (rhs. inf )); }
28- [[nodiscard]] inline friend bool is_negative_or_zero (const inf_rational &rhs) noexcept { return is_negative (rhs. rat ) || ( is_zero (rhs. rat ) && is_negative_or_zero (rhs. inf )); }
29- [[nodiscard]] inline friend bool is_infinite (const inf_rational &rhs) noexcept { return is_infinite (rhs. rat ); }
30- [[nodiscard]] inline friend bool is_positive_infinite (const inf_rational &rhs) noexcept { return is_positive (rhs) && is_infinite (rhs); }
31- [[nodiscard]] inline friend bool is_negative_infinite (const inf_rational &rhs) noexcept { return is_negative (rhs) && is_infinite (rhs); }
23+ [[nodiscard]] inline friend bool is_integer (const inf_rational &rhs) noexcept ;
24+ [[nodiscard]] inline friend bool is_zero (const inf_rational &rhs) noexcept ;
25+ [[nodiscard]] inline friend bool is_positive (const inf_rational &rhs) noexcept ;
26+ [[nodiscard]] inline friend bool is_positive_or_zero (const inf_rational &rhs) noexcept ;
27+ [[nodiscard]] inline friend bool is_negative (const inf_rational &rhs) noexcept ;
28+ [[nodiscard]] inline friend bool is_negative_or_zero (const inf_rational &rhs) noexcept ;
29+ [[nodiscard]] inline friend bool is_infinite (const inf_rational &rhs) noexcept ;
30+ [[nodiscard]] inline friend bool is_positive_infinite (const inf_rational &rhs) noexcept ;
31+ [[nodiscard]] inline friend bool is_negative_infinite (const inf_rational &rhs) noexcept ;
3232
3333 [[nodiscard]] inline bool operator !=(const inf_rational &rhs) const noexcept { return rat != rhs.rat || inf != rhs.inf ; };
3434 [[nodiscard]] inline bool operator <(const inf_rational &rhs) const noexcept { return rat < rhs.rat || (rat == rhs.rat && inf < rhs.inf ); };
@@ -125,15 +125,15 @@ namespace utils
125125
126126 [[nodiscard]] inline inf_rational operator -() const noexcept { return inf_rational (-rat, -inf); }
127127
128- [[nodiscard]] inline friend inf_rational operator +(const rational &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs + rhs. rat , rhs. inf ); }
129- [[nodiscard]] inline friend inf_rational operator -(const rational &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs - rhs. rat , rhs. inf ); }
130- [[nodiscard]] inline friend inf_rational operator *(const rational &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs * rhs. rat , lhs * rhs. inf ); }
131- [[nodiscard]] inline friend inf_rational operator /(const rational &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs / rhs. rat , lhs / rhs. inf ); }
128+ [[nodiscard]] inline friend inf_rational operator +(const rational &lhs, const inf_rational &rhs) noexcept ;
129+ [[nodiscard]] inline friend inf_rational operator -(const rational &lhs, const inf_rational &rhs) noexcept ;
130+ [[nodiscard]] inline friend inf_rational operator *(const rational &lhs, const inf_rational &rhs) noexcept ;
131+ [[nodiscard]] inline friend inf_rational operator /(const rational &lhs, const inf_rational &rhs) noexcept ;
132132
133- [[nodiscard]] inline friend inf_rational operator +(const INT_TYPE &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs + rhs. rat , rhs. inf ); }
134- [[nodiscard]] inline friend inf_rational operator -(const INT_TYPE &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs - rhs. rat , rhs. inf ); }
135- [[nodiscard]] inline friend inf_rational operator *(const INT_TYPE &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs * rhs. rat , lhs * rhs. inf ); }
136- [[nodiscard]] inline friend inf_rational operator /(const INT_TYPE &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs / rhs. rat , lhs / rhs. inf ); }
133+ [[nodiscard]] inline friend inf_rational operator +(const INT_TYPE &lhs, const inf_rational &rhs) noexcept ;
134+ [[nodiscard]] inline friend inf_rational operator -(const INT_TYPE &lhs, const inf_rational &rhs) noexcept ;
135+ [[nodiscard]] inline friend inf_rational operator *(const INT_TYPE &lhs, const inf_rational &rhs) noexcept ;
136+ [[nodiscard]] inline friend inf_rational operator /(const INT_TYPE &lhs, const inf_rational &rhs) noexcept ;
137137
138138 friend std::string to_string (const inf_rational &rhs) noexcept ;
139139
@@ -142,5 +142,25 @@ namespace utils
142142 rational inf; // the infinitesimal part..
143143 };
144144
145+ [[nodiscard]] inline bool is_integer (const inf_rational &rhs) noexcept { return is_integer (rhs.rat ) && is_zero (rhs.inf ); }
146+ [[nodiscard]] inline bool is_zero (const inf_rational &rhs) noexcept { return is_zero (rhs.rat ) && is_zero (rhs.inf ); }
147+ [[nodiscard]] inline bool is_positive (const inf_rational &rhs) noexcept { return is_positive (rhs.rat ) || (is_zero (rhs.rat ) && is_positive (rhs.inf )); }
148+ [[nodiscard]] inline bool is_positive_or_zero (const inf_rational &rhs) noexcept { return is_positive (rhs.rat ) || (is_zero (rhs.rat ) && is_positive_or_zero (rhs.inf )); }
149+ [[nodiscard]] inline bool is_negative (const inf_rational &rhs) noexcept { return is_negative (rhs.rat ) || (is_zero (rhs.rat ) && is_negative (rhs.inf )); }
150+ [[nodiscard]] inline bool is_negative_or_zero (const inf_rational &rhs) noexcept { return is_negative (rhs.rat ) || (is_zero (rhs.rat ) && is_negative_or_zero (rhs.inf )); }
151+ [[nodiscard]] inline bool is_infinite (const inf_rational &rhs) noexcept { return is_infinite (rhs.rat ); }
152+ [[nodiscard]] inline bool is_positive_infinite (const inf_rational &rhs) noexcept { return is_positive (rhs) && is_infinite (rhs); }
153+ [[nodiscard]] inline bool is_negative_infinite (const inf_rational &rhs) noexcept { return is_negative (rhs) && is_infinite (rhs); }
154+
155+ [[nodiscard]] inline inf_rational operator +(const rational &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs + rhs.rat , rhs.inf ); }
156+ [[nodiscard]] inline inf_rational operator -(const rational &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs - rhs.rat , rhs.inf ); }
157+ [[nodiscard]] inline inf_rational operator *(const rational &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs * rhs.rat , lhs * rhs.inf ); }
158+ [[nodiscard]] inline inf_rational operator /(const rational &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs / rhs.rat , lhs / rhs.inf ); }
159+
160+ [[nodiscard]] inline inf_rational operator +(const INT_TYPE &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs + rhs.rat , rhs.inf ); }
161+ [[nodiscard]] inline inf_rational operator -(const INT_TYPE &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs - rhs.rat , rhs.inf ); }
162+ [[nodiscard]] inline inf_rational operator *(const INT_TYPE &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs * rhs.rat , lhs * rhs.inf ); }
163+ [[nodiscard]] inline inf_rational operator /(const INT_TYPE &lhs, const inf_rational &rhs) noexcept { return inf_rational (lhs / rhs.rat , lhs / rhs.inf ); }
164+
145165 [[nodiscard]] std::string to_string (const inf_rational &rhs) noexcept ;
146166} // namespace utils
0 commit comments