Author: spouliot
Date: 2007-07-05 10:36:50 -0400 (Thu, 05 Jul 2007)
New Revision: 81394
Modified:
trunk/mcs/class/Mono.Security/Mono.Math/BigInteger.cs
trunk/mcs/class/Mono.Security/Mono.Math/ChangeLog
Log:
2007-07-05 Sebastien Pouliot <[EMAIL PROTECTED]>
* BigInteger.cs: Reduce modulo steps in Multiply. Add #if/#else around
older, and commented, [Odd|Even]Pow methods.
Modified: trunk/mcs/class/Mono.Security/Mono.Math/BigInteger.cs
===================================================================
--- trunk/mcs/class/Mono.Security/Mono.Math/BigInteger.cs 2007-07-05
14:35:24 UTC (rev 81393)
+++ trunk/mcs/class/Mono.Security/Mono.Math/BigInteger.cs 2007-07-05
14:36:50 UTC (rev 81394)
@@ -1042,18 +1042,12 @@
{
if (a == 0 || b == 0) return 0;
- if (a.length >= mod.length << 1)
+ if (a > mod)
a %= mod;
- if (b.length >= mod.length << 1)
+ if (b > mod)
b %= mod;
- if (a.length >= mod.length)
- BarrettReduction (a);
-
- if (b.length >= mod.length)
- BarrettReduction (b);
-
BigInteger ret = new BigInteger (a * b);
BarrettReduction (ret);
@@ -1086,7 +1080,7 @@
diff = mod - diff;
return diff;
}
-
+#if true
public BigInteger Pow (BigInteger a, BigInteger k)
{
BigInteger b = new BigInteger (1);
@@ -1104,7 +1098,7 @@
}
return b;
}
-#if false
+#else
public BigInteger Pow (BigInteger b, BigInteger exp)
{
if ((mod.data [0] & 1) == 1) return OddPow (b,
exp);
@@ -1183,11 +1177,12 @@
#if !INSIDE_CORLIB
[CLSCompliant (false)]
#endif
+#if true
public BigInteger Pow (uint b, BigInteger exp)
{
return Pow (new BigInteger (b), exp);
}
-#if false
+#else
public BigInteger Pow (uint b, BigInteger exp)
{
// if (b != 2) {
@@ -1195,7 +1190,7 @@
return OddPow (b, exp);
else
return EvenPow (b, exp);
-/* buggy in some cases (like the well tested primes)
+/* buggy in some cases (like the well tested primes)
} else {
if ((mod.data [0] & 1) == 1)
return OddModTwoPow (exp);
@@ -1415,8 +1410,9 @@
return resultNum;
}
-
-/* known to be buggy in some cases
+#endif
+/* known to be buggy in some cases */
+#if false
private unsafe BigInteger EvenModTwoPow (BigInteger exp)
{
exp.Normalize ();
@@ -1549,7 +1545,6 @@
resultNum = Montgomery.Reduce (resultNum, mod,
mPrime);
return resultNum;
}
-*/
#endif
#endregion
}
Modified: trunk/mcs/class/Mono.Security/Mono.Math/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Security/Mono.Math/ChangeLog 2007-07-05 14:35:24 UTC
(rev 81393)
+++ trunk/mcs/class/Mono.Security/Mono.Math/ChangeLog 2007-07-05 14:36:50 UTC
(rev 81394)
@@ -1,3 +1,8 @@
+2007-07-05 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * BigInteger.cs: Reduce modulo steps in Multiply. Add #if/#else around
+ older, and commented, [Odd|Even]Pow methods.
+
2007-07-04 Sebastien Pouliot <[EMAIL PROTECTED]>
* BigInteger.cs: In some condition the optimized (4 variants) OddPow
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches