Number floor(const Number& num1) { switch (num1.type()) { case Number::INTEGER: return num1; case Number::FLOATING: { floating_type f = b_mp::floor(num1.get_f()); return Number(f); } case Number::RATIONAL: return Number(r_to_i(num1.get_r())); #ifndef PMP_DISABLE_VECTOR case Number::VECTOR: { vector_type v = num1.get_v(); for (size_t i = 0; i < v.size(); ++i) { v[i] = floor(v[i]); } return Number(v); } #endif default: assert(0); return 0; } }
Number fabs(const Number& num1) { switch (num1.type()) { case Number::INTEGER: { integer_type i = b_mp::abs(num1.get_i()); return Number(i); } case Number::FLOATING: { floating_type f = b_mp::fabs(num1.to_f()); return Number(f); } case Number::RATIONAL: { rational_type r = b_mp::abs(num1.get_r()); return Number(r); } #ifndef PMP_DISABLE_VECTOR case Number::VECTOR: { vector_type v = num1.get_v(); for (size_t i = 0; i < v.size(); ++i) { v[i] = abs(v[i]); } return Number(v); } #endif default: assert(0); return 0; } }