mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 09:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,48 @@
|
||||
package com.hurlant.math
|
||||
{
|
||||
use namespace bi_internal;
|
||||
|
||||
internal class ClassicReduction implements IReduction
|
||||
{
|
||||
|
||||
private var m:BigInteger;
|
||||
|
||||
public function ClassicReduction(m:BigInteger)
|
||||
{
|
||||
super();
|
||||
this.m = m;
|
||||
}
|
||||
|
||||
public function convert(x:BigInteger) : BigInteger
|
||||
{
|
||||
if(x.s < 0 || x.compareTo(this.m) >= 0)
|
||||
{
|
||||
return x.mod(this.m);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public function revert(x:BigInteger) : BigInteger
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public function reduce(x:BigInteger) : void
|
||||
{
|
||||
x.divRemTo(this.m,null,x);
|
||||
}
|
||||
|
||||
public function mulTo(x:BigInteger, y:BigInteger, r:BigInteger) : void
|
||||
{
|
||||
x.multiplyTo(y,r);
|
||||
this.reduce(r);
|
||||
}
|
||||
|
||||
public function sqrTo(x:BigInteger, r:BigInteger) : void
|
||||
{
|
||||
x.squareTo(r);
|
||||
this.reduce(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user