Skip to content

Commit fc41d10

Browse files
Jean A HurchallaJean A Hurchalla
authored andcommitted
improve comments in montgomery_form_aliases.h
1 parent c087315 commit fc41d10

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

montgomery_arithmetic/include/hurchalla/montgomery_arithmetic/montgomery_form_aliases.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ namespace hurchalla {
4444
// 0 < modulus < (1 << 64)/4. It is undefined behavior to use a modulus that is
4545
// not within the allowed range. The modulus you use must be odd, which is
4646
// always required for montgomery arithmetic.
47-
// In contrast, the default class MontgomeryForm<T> has no restriction on the
48-
// its modulus size, aside from requiring that its modulus must be a positive
47+
// In contrast, the default class MontgomeryForm<T> has no restriction on its
48+
// modulus size, though it still requires that its modulus must be a positive
4949
// odd number.
5050
// You can expect that MontgomeryQuarter<T> will perform better (very often) or
5151
// at worst the same as MontgomeryForm<T>, if both are given the same modulus.
@@ -64,8 +64,8 @@ namespace hurchalla {
6464
// to use a modulus that is not within the allowed range. The modulus you use
6565
// must be odd, which is always required for montgomery arithmetic.
6666
// In contrast, the default class MontgomeryForm<T> has no restriction on its
67-
// modulus size, aside from requiring that its modulus must be a positive odd
68-
// number.
67+
// modulus size, though it still requires that its modulus must be a positive
68+
// odd number.
6969
// For a type T that is the same size as the CPU integer registers (e.g.
7070
// uin64_t on a 64 bit computer) or a type T that is smaller than the register
7171
// size, you can expect that MontgomeryHalf<T> will perform better (very often)
@@ -92,8 +92,10 @@ namespace hurchalla {
9292
// Note that this file also has an alias called MontgomeryStandardMathWrapper.
9393
// This alias maps to a class that uses the MontgomeryForm interface but that
9494
// internally performs all calculations with standard modular arithmetic rather
95-
// than any montgomery arithmetic. This can be useful as an aid for comparing
96-
// performance between montgomery and non-montgomery modular arithmetic.
95+
// than any montgomery arithmetic. This can be useful as a convenient aid to
96+
// compare performance between montgomery and non-montgomery modular arithmetic,
97+
// since the fact that these aliases both provide the exact same API allows you
98+
// to use them interchangably via a function/struct/class template parameter.
9799
// Since MontgomeryStandardMathWrapper does not use montgomery arithmetic, its
98100
// modulus is allowed to be either even or odd. Its modulus must be positive.
99101
//
@@ -140,8 +142,8 @@ using MontgomeryFull = MontgomeryForm<T,
140142
// standard modular arithmetic whenever a large amount of modular multiplication
141143
// is needed, and so this is probably unlikely to be an alias you would expect
142144
// to use. However, CPU architectures vary and evolve, and what is true today
143-
// may not be true tomorrow - the only way to know what is fastest on a given
144-
// system is to measure and compare performance.
145+
// may not be true tomorrow - you will need to measure and compare performance
146+
// on your system to know for certain.
145147
template <typename T>
146148
using MontgomeryStandardMathWrapper = MontgomeryForm<T,
147149
detail::MontyWrappedStandardMath<typename extensible_make_unsigned<T>::type>>;

0 commit comments

Comments
 (0)