MCPcopy Create free account
hub / github.com/numpy/numpy / make_rational_fast

Function make_rational_fast

numpy/core/src/umath/_rational_tests.c:173–185  ·  view source on GitHub ↗

Assumes d_ > 0 */

Source from the content-addressed store, hash-verified

171
172/* Assumes d_ > 0 */
173static rational
174make_rational_fast(npy_int64 n_, npy_int64 d_) {
175 npy_int64 g = gcd(n_,d_);
176 rational r;
177 n_ /= g;
178 d_ /= g;
179 r.n = (npy_int32)n_;
180 r.dmm = (npy_int32)(d_-1);
181 if (r.n!=n_ || r.dmm+1!=d_) {
182 set_overflow();
183 }
184 return r;
185}
186
187static inline rational
188rational_negative(rational r) {

Callers 4

rational_addFunction · 0.85
rational_subtractFunction · 0.85
rational_multiplyFunction · 0.85
rational_ufunc_test_addFunction · 0.85

Calls 2

gcdFunction · 0.85
set_overflowFunction · 0.85

Tested by

no test coverage detected