SSJ  3.3.1
Stochastic Simulation in Java
List of all members
ArithmeticMod Class Reference

This class provides facilities to compute multiplications of scalars, of vectors and of matrices modulo m. More...

Static Public Member Functions

Methods using `double`
static double multModM (double a, double s, double c, double m)
 Computes \((a \times s + c) \bmod m\). More...
 
static void matVecModM (double A[][], double s[], double v[], double m)
 Computes the result of \(\mathtt{A} \times\mathtt{\mathbf{s}} \bmod m\) and puts the result in v. More...
 
static void matMatModM (double A[][], double B[][], double C[][], double m)
 Computes \(\mathtt{A} \times\mathtt{B} \bmod m\) and puts the result in C. More...
 
static void matTwoPowModM (double A[][], double B[][], double m, int e)
 Computes \(\mathtt{A}^{2^{\mathtt{e}}} \bmod m\) and puts the result in B. More...
 
static void matPowModM (double A[][], double B[][], double m, int c)
 Computes \(\mathtt{A}^c \bmod m\) and puts the result in B. More...
 
Methods using `int`
static int multModM (int a, int s, int c, int m)
 Computes \((a \times s + c) \bmod m\). More...
 
static void matVecModM (int A[][], int s[], int v[], int m)
 Exactly like matVecModM(double[][],double[],double[],double) using double, but with int instead of double. More...
 
static void matMatModM (int A[][], int B[][], int C[][], int m)
 Exactly like matMatModM(double[][],double[][],double[][],double) using double, but with int instead of double. More...
 
static void matTwoPowModM (int A[][], int B[][], int m, int e)
 Exactly like matTwoPowModM(double[][],double[][],double,int) using double, but with int instead of double. More...
 
static void matPowModM (int A[][], int B[][], int m, int c)
 Exactly like matPowModM(double[][],double[][],double,int) using double, but with int instead of double. More...
 
Methods using `long`
static long multModM (long a, long s, long c, long m)
 Computes \((a \times s + c) \bmod m\). More...
 
static void matVecModM (long A[][], long s[], long v[], long m)
 Exactly like matVecModM(double[][],double[],double[],double) using double, but with long instead of double. More...
 
static void matMatModM (long A[][], long B[][], long C[][], long m)
 Exactly like matMatModM(double[][],double[][],double[][],double) using double, but with long instead of double. More...
 
static void matTwoPowModM (long A[][], long B[][], long m, int e)
 Exactly like matTwoPowModM(double[][],double[][],double,int) using double, but with long instead of double. More...
 
static void matPowModM (long A[][], long B[][], long m, int c)
 Exactly like matPowModM(double[][],double[][],double,int) using double, but with long instead of double. More...
 

Detailed Description

This class provides facilities to compute multiplications of scalars, of vectors and of matrices modulo m.

All algorithms are present in three different versions. These allow operations on double, int and long. The int and long versions work exactly like the double ones.

Member Function Documentation

◆ matMatModM() [1/3]

static void matMatModM ( double  A[][],
double  B[][],
double  C[][],
double  m 
)
static

Computes \(\mathtt{A} \times\mathtt{B} \bmod m\) and puts the result in C.

Works even if A = C, B = C or A = B = C.

Parameters
Athe first factor of the multiplication
Bthe second factor of the multiplication
Cthe result of the multiplication
mthe modulus

◆ matMatModM() [2/3]

static void matMatModM ( int  A[][],
int  B[][],
int  C[][],
int  m 
)
static

Exactly like matMatModM(double[][],double[][],double[][],double) using double, but with int instead of double.

Parameters
Athe first factor of the multiplication
Bthe second factor of the multiplication
Cthe result of the multiplication
mthe modulus

◆ matMatModM() [3/3]

static void matMatModM ( long  A[][],
long  B[][],
long  C[][],
long  m 
)
static

Exactly like matMatModM(double[][],double[][],double[][],double) using double, but with long instead of double.

Parameters
Athe first factor of the multiplication
Bthe second factor of the multiplication
Cthe result of the multiplication
mthe modulus

◆ matPowModM() [1/3]

static void matPowModM ( double  A[][],
double  B[][],
double  m,
int  c 
)
static

Computes \(\mathtt{A}^c \bmod m\) and puts the result in B.

Works even if A = B.

Parameters
Athe matrix to raise to a power
Bthe result of the exponentiation
mthe modulus
cthe exponent

◆ matPowModM() [2/3]

static void matPowModM ( int  A[][],
int  B[][],
int  m,
int  c 
)
static

Exactly like matPowModM(double[][],double[][],double,int) using double, but with int instead of double.

Parameters
Athe matrix to raise to a power
Bthe result of the exponentiation
mthe modulus
cthe exponent

◆ matPowModM() [3/3]

static void matPowModM ( long  A[][],
long  B[][],
long  m,
int  c 
)
static

Exactly like matPowModM(double[][],double[][],double,int) using double, but with long instead of double.

Parameters
Athe matrix to raise to a power
Bthe result of the exponentiation
mthe modulus
cthe exponent

◆ matTwoPowModM() [1/3]

static void matTwoPowModM ( double  A[][],
double  B[][],
double  m,
int  e 
)
static

Computes \(\mathtt{A}^{2^{\mathtt{e}}} \bmod m\) and puts the result in B.

Works even if A = B.

Parameters
Athe matrix to raise to a power
Bthe result of exponentiation
mthe modulus
ethe \(\log_2\) of the exponent

◆ matTwoPowModM() [2/3]

static void matTwoPowModM ( int  A[][],
int  B[][],
int  m,
int  e 
)
static

Exactly like matTwoPowModM(double[][],double[][],double,int) using double, but with int instead of double.

Parameters
Athe matrix to raise to a power
Bthe result of exponentiation
mthe modulus
ethe \(\log_2\) of the exponent

◆ matTwoPowModM() [3/3]

static void matTwoPowModM ( long  A[][],
long  B[][],
long  m,
int  e 
)
static

Exactly like matTwoPowModM(double[][],double[][],double,int) using double, but with long instead of double.

Parameters
Athe matrix to raise to a power
Bthe result of exponentiation
mthe modulus
ethe \(\log_2\) of the exponent

◆ matVecModM() [1/3]

static void matVecModM ( double  A[][],
double  s[],
double  v[],
double  m 
)
static

Computes the result of \(\mathtt{A} \times\mathtt{\mathbf{s}} \bmod m\) and puts the result in v.

Where s and v are both column vectors. This method works even if s = v.

Parameters
Athe multiplication matrix
sthe multiplied vector
vthe result of the multiplication
mthe modulus

◆ matVecModM() [2/3]

static void matVecModM ( int  A[][],
int  s[],
int  v[],
int  m 
)
static

Exactly like matVecModM(double[][],double[],double[],double) using double, but with int instead of double.

Parameters
Athe multiplication matrix
sthe multiplied vector
vthe result of the multiplication
mthe modulus

◆ matVecModM() [3/3]

static void matVecModM ( long  A[][],
long  s[],
long  v[],
long  m 
)
static

Exactly like matVecModM(double[][],double[],double[],double) using double, but with long instead of double.

Parameters
Athe multiplication matrix
sthe multiplied vector
vthe result of the multiplication
mthe modulus

◆ multModM() [1/3]

static double multModM ( double  a,
double  s,
double  c,
double  m 
)
static

Computes \((a \times s + c) \bmod m\).

Where m must be smaller than \(2^{35}\). Works also if s or c are negative. The result is always positive (and thus always between 0 and m - 1).

Parameters
athe first factor of the multiplication
sthe second factor of the multiplication
cthe second term of the addition
mthe modulus
Returns
the result of the multiplication and the addition modulo m

◆ multModM() [2/3]

static int multModM ( int  a,
int  s,
int  c,
int  m 
)
static

Computes \((a \times s + c) \bmod m\).

Works also if s or c are negative. The result is always positive (and thus always between 0 and m - 1).

Parameters
athe first factor of the multiplication
sthe second factor of the multiplication
cthe second term of the addition
mthe modulus
Returns
the result of the multiplication and the addition modulo m

◆ multModM() [3/3]

static long multModM ( long  a,
long  s,
long  c,
long  m 
)
static

Computes \((a \times s + c) \bmod m\).

Works also if s or c are negative. The result is always positive (and thus always between 0 and m - 1).

Parameters
athe first factor of the multiplication
sthe second factor of the multiplication
cthe second term of the addition
mthe modulus
Returns
the result of the multiplication and the addition modulo m

The documentation for this class was generated from the following file: