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

Function RATIONAL_BINOP

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

Source from the content-addressed store, hash-verified

572 }
573#define RATIONAL_BINOP(name) RATIONAL_BINOP_2(name,rational_##name(x,y))
574RATIONAL_BINOP(add)
575RATIONAL_BINOP(subtract)
576RATIONAL_BINOP(multiply)
577RATIONAL_BINOP(divide)
578RATIONAL_BINOP(remainder)
579RATIONAL_BINOP_2(floor_divide,
580 make_rational_int(rational_floor(rational_divide(x,y))))
581
582#define RATIONAL_UNOP(name,type,exp,convert) \
583 static PyObject* \
584 pyrational_##name(PyObject* self) { \
585 rational x = ((PyRational*)self)->r; \
586 type y = exp; \
587 if (PyErr_Occurred()) { \
588 return 0; \
589 } \
590 return convert(y); \
591 }
592RATIONAL_UNOP(negative,rational,rational_negative(x),PyRational_FromRational)
593RATIONAL_UNOP(absolute,rational,rational_abs(x),PyRational_FromRational)
594RATIONAL_UNOP(int,long,rational_int(x),PyLong_FromLong)

Callers

nothing calls this directly

Calls 4

make_rational_intFunction · 0.85
rational_floorFunction · 0.85
rational_divideFunction · 0.85
convertFunction · 0.50

Tested by

no test coverage detected