#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
int numeric::compare_same_type(basic const & other) const
{
- ASSERT(is_exactly_of_type(other, numeric));
+ GINAC_ASSERT(is_exactly_of_type(other, numeric));
numeric const & o = static_cast<numeric &>(const_cast<basic &>(other));
if (*value == *o.value) {
bool numeric::is_equal_same_type(basic const & other) const
{
- ASSERT(is_exactly_of_type(other,numeric));
+ GINAC_ASSERT(is_exactly_of_type(other,numeric));
numeric const *o = static_cast<numeric const *>(&other);
return is_equal(*o);
/** 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) */
* if the number is really an integer before calling this method. */
int numeric::to_int(void) const
{
- ASSERT(is_integer());
+ GINAC_ASSERT(is_integer());
return cl_I_to_int(The(cl_I)(*value));
}
* if the number is really not complex before calling this method. */
double numeric::to_double(void) const
{
- ASSERT(is_real());
+ GINAC_ASSERT(is_real());
return cl_double_approx(realpart(*value));
}
/** Numerator. Computes the numerator of rational numbers, rationalized
* numerator of complex if real and imaginary part are both rational numbers
- * (i.e numer(4/3+5/6*I) == 8+5*I), the number itself in all other cases. */
+ * (i.e numer(4/3+5/6*I) == 8+5*I), the number carrying the sign in all other
+ * cases. */
numeric numeric::numer(void) const
{
if (is_integer()) {
/** 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