HackerPapers

arXiv:2102.06959cs.DS

Euclidean Affine Functions and Applications to Calendar Algorithms

Cassio Neri, Lorenz Schneider

HN submission. Found in a submission link or body. Submitters do not count as commenters in the main ranking; a submission is not an endorsement.

Abstract

We study properties of Euclidean affine functions (EAFs), namely those of the form $f(r) = (α\cdot r + β)/δ$, and their closely related expression $\mathring{f}(r) = (α\cdot r + β)\%δ$, where $r$, $α$, $β$ and $δ$ are integers, and where $/$ and $\%$ respectively denote the quotient and remainder of Euclidean division. We derive algebraic relations and numerical approximations that are important for the efficient evaluation of these expressions in modern CPUs. Since simple division and remainder are particular cases of EAFs (when $α= 1$ and $β= 0$), the optimisations proposed in this paper can also be appplied to them. Such expressions appear in some of the most common tasks in any computer system, such as printing numbers, times and dates. We use calendar calculations as the main application example because it is richer with respect to the number of EAFs employed. Specifically, the main application presented in this article relates to Gregorian calendar algorithms. We will show how they can be implemented substantially more efficiently than is currently the case in widely used C, C++, C# and Java open source libraries. Gains in speed of a factor of two or more are common.

arXiv comments
24 pages, 4 figures
Journal reference
Softw Pract Exper. 2023;53(4):937-970
DOI
doi:10.1002/spe.3172
Subjects
cs.DSData Structures and Algorithms cs.DMDiscrete Mathematics

On Hacker News

No comments linking this paper were found in the collected sources. Found in 1 HN submission from Aug 2022 to Aug 2022. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments0 threads

No comments linking this paper were found in the collected sources. Open submission discussions.

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.