Opened 10 years ago

Last modified 9 years ago

#13256 closed enhancement

abs floor ceil for quadratic number field — at Initial Version

Reported by: vdelecroix Owned by: vdelecroix
Priority: major Milestone: sage-5.11
Component: number fields Keywords: absolute value, floor, ceiling, number field, quadratic
Cc: mhansen, berocal Merged in:
Authors: Vincent Delecroix Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #7160, #13213 Stopgaps:

Status badges

Description

Implementation of absolute value (abs), floor (floor) and ceiling (ceil) function for elements in quadratic number field. This depends (not very much) on comparisons in quadratic number fields implemented in tickects #7160 and #13213.

Strangely enough, floor and ceil functions are much faster than abs function! The reason is because the comparison in #13213 which is called in abs is actually very slow.

sage: sage: K.<sqrt2> = QuadraticField(2, name='sqrt2')
sage: %timeit abs(sqrt2)
125 loops, best of 3: 2.22 ms per loop
sage: %timeit floor(sqrt2)
625 loops, best of 3: 3.37 µs per loop

Change History (0)

Note: See TracTickets for help on using tickets.