Documentation
¶
Overview ¶
mathutils provides functions and structs to perform mathematical operations.
Index ¶
- func BinaryExponentiation(number uint64, power uint64) uint64
- func ExtendedGCD(numberA int, numberB int) (int, int, int)
- func GCD(numberA int, numberB int) int
- func IsPrime(numberA int) bool
- func Mod(numberA int, modulo int) (int, error)
- func Mod26(numberA int) int
- func ModularInverse(numberA int, modulo int) (int, bool, error)
- type Matrix
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinaryExponentiation ¶
BinaryExponentiation computes number raised to the given power using fast exponentiation.
func ExtendedGCD ¶
ExtendedGCD returns the GCD of numberA and numberB along with the coefficients x and y such that numberA*x + numberB*y = GCD.
func GCD ¶
GCD returns the greatest common divisor of numberA and numberB using the Euclidean algorithm.
func Mod ¶
Mod returns the result of numberA modulo modulo in the range [0, modulo).
Returns an error if modulo is less than or equal to zero.
Types ¶
type Matrix ¶
type Matrix[T any] struct { Data [][]T }
Matrix is a generic 2D matrix with elements of type T.
func MatrixInverseModuloPrime ¶
MatrixInverseModuloPrime computes the modular inverse of a matrix over a prime field.
Returns an error if moduloPrime is not prime, the matrix is not square, or the matrix is not invertible.
func NewMatrixFromData ¶
NewMatrixFromData creates a new matrix from a 2D slice.
Returns an error if data is empty, contains empty rows, or has inconsistent row lengths.
func NewMatrixZero ¶
NewMatrixZero creates a new matrix with all elements initialized to the zero value of T.
Returns an error if rows or columns is less than or equal to zero.