Main Content

gflineq

Find particular solution of Ax = b over prime Galois field

Description

x = gflineq(A,b) outputs a particular solution of the linear equation where A multiplied by x is equal to b in GF(2). The elements in a, b and x are either 0 or 1. If the equation has no solution, then x is empty.

example

x = gflineq(A,b,p) returns a particular solution of the linear equation where A multiplied by x is equal to b over GF(p),

[x,vld] = gflineq(...) returns a flag vld that indicates the existence of a solution.

Note

This function performs computations in GF(p), where p is prime. To work in GF(2m), apply the \ or / operator to Galois arrays. For details, see Solving Linear Equations.

Examples

collapse all

Consider a Galios Field (GF) with three elements.

A = [2 0 1;
     1 1 0;
     1 1 2];

Use gflineq to find a solution.

[x,vld] = gflineq(A,[1;0;0],3)
x = 3×1

     2
     1
     0

vld = 
1

This means the solution is valid over GF(3).

Input Arguments

collapse all

Coefficients of a system of linear equations, specified as a k-by-n matrix.

Data Types: double

Right hand side vector of equations, specified as a n-element vector.

Data Types: double

Prime number, specified as a scalar prime number.

Data Types: double

Output Arguments

collapse all

Solution for linear equation Ax = b, returned as a row vector. If A is a k-by-n matrix and b is a vector of length k, x is a vector of length n. If no solution exists, x is empty.

Flag to indicate the existence of solution, returned as a 0 or 1. If vld = 1, the solution x exists and is valid; if vld = 0, no solution exists.

Algorithms

gflineq uses Gaussian elimination.

Version History

Introduced before R2006a

See Also

| | | | |