#include <cln.h>
#endif
+#ifndef NO_GINAC_NAMESPACE
namespace GiNaC {
+#endif // ndef NO_GINAC_NAMESPACE
// linker has no problems finding text symbols for numerator or denominator
//#define SANE_LINKER
/** True if object is a non-complex integer. */
bool numeric::is_integer(void) const
{
- return (bool)instanceof(*value, cl_I_ring); // -> CLN
+ return instanceof(*value, cl_I_ring); // -> CLN
}
/** True if object is an exact integer greater than zero. */
* (denominator may be unity). */
bool numeric::is_rational(void) const
{
- if (instanceof(*value, cl_RA_ring)) {
- return true;
- } else if (!is_real()) { // complex case, handle Q(i):
- if ( instanceof(realpart(*value), cl_RA_ring) &&
- instanceof(imagpart(*value), cl_RA_ring) )
- return true;
- }
- return false;
+ return instanceof(*value, cl_RA_ring);
}
/** True if object is a real integer, rational or float (but not complex). */
bool numeric::is_real(void) const
{
- return (bool)instanceof(*value, cl_R_ring); // -> CLN
+ return instanceof(*value, cl_R_ring); // -> CLN
}
bool numeric::operator==(numeric const & other) const
return (*value != *other.value); // -> CLN
}
+/** True if object is element of the domain of integers extended by I, i.e. is
+ * of the form a+b*I, where a and b are integers. */
+bool numeric::is_cinteger(void) const
+{
+ if (instanceof(*value, cl_I_ring))
+ return true;
+ else if (!is_real()) { // complex case, handle n+m*I
+ if (instanceof(realpart(*value), cl_I_ring) &&
+ instanceof(imagpart(*value), cl_I_ring))
+ return true;
+ }
+ return false;
+}
+
+/** True if object is an exact rational number, may even be complex
+ * (denominator may be unity). */
+bool numeric::is_crational(void) const
+{
+ if (instanceof(*value, cl_RA_ring))
+ return true;
+ else if (!is_real()) { // complex case, handle Q(i):
+ if (instanceof(realpart(*value), cl_RA_ring) &&
+ instanceof(imagpart(*value), cl_RA_ring))
+ return true;
+ }
+ return false;
+}
+
/** Numerical comparison: less.
*
* @exception invalid_argument (complex inequality) */
/** The psi function (aka polygamma function).
* This is only a stub! */
+numeric psi(numeric const & x)
+{
+ clog << "psi(): Does anybody know good way to calculate this numerically?" << endl;
+ return numeric(0);
+}
+
+/** The psi functions (aka polygamma functions).
+ * This is only a stub! */
numeric psi(numeric const & n, numeric const & x)
{
clog << "psi(): Does anybody know good way to calculate this numerically?" << endl;
* assignment from C++ unsigned ints and evaluated like any built-in type. */
_numeric_digits Digits;
+#ifndef NO_GINAC_NAMESPACE
} // namespace GiNaC
+#endif // ndef NO_GINAC_NAMESPACE