permaviss.gauss_mod_p.functions

functions.py

This code implements multiplication mod p and solving a linear equation mod p.

Functions

multiply_mod_p(A, B, p) Multiply matrices mod p.
solve_matrix_mod_p(A, B, p) Same as solve_mod_p(), but with B and X being matrices.
solve_mod_p(A, b, p) Find the vector x such that A * x = b (mod p)
permaviss.gauss_mod_p.functions.multiply_mod_p(A, B, p)[source]

Multiply matrices mod p.

permaviss.gauss_mod_p.functions.solve_matrix_mod_p(A, B, p)[source]

Same as solve_mod_p(), but with B and X being matrices.

That is, given two matrices A and B, we want to find a matrix X such that A * X = B (mod p)

Parameters:
  • A (Numpy Array) – 2D array
  • B (Numpy Array) – 2D array
  • p (int(prime)) –
Returns:

X – 2D array solution.

Return type:

Numpy Array

Raises:

ValueError – There is no solution to the given equation

permaviss.gauss_mod_p.functions.solve_mod_p(A, b, p)[source]

Find the vector x such that A * x = b (mod p)

This method assumes that a solution exists to the equation A * x = b (mod p). If a solution does not exist, it raises a ValueError exception.

Parameters:
  • A (Numpy Array) – 2D array
  • b (Numpy Array) – 1D array
  • p (int(prime)) – Number to mod out by.
Returns:

x – 1D array. Solution to equation.

Return type:

Numpy Array

Raises:

ValueError – If a solution to the equation does not exist.