Hauptinhalt

gfpretty

R2026b

Polynomial in traditional format

Description

gfpretty(a) displays a polynomial in a traditional format, using X as the variable and a as the coefficients in the order of ascending powers. Terms having a zero coefficient are not displayed.

example

gfpretty(a,str) displays GF using str as the variable and a as the coefficients.

gfpretty(a,str,n)uses screen width n instead of the default value of 79.

Examples

collapse all

Display statements about randomly selected elements of GF(81).

Use the gfprimfd function to find the primitive polynomials for GF(81).

p = 3; 
m = 4;
primpolys = gfprimfd(m,'all',p);
[rows, cols] = size(primpolys);

Randomly select a primitive polynomial by selecting a row jj from primpolys, and then display the jjth primitive polynomial in the traditional format by using the gfpretty function.

jj = randi([1,rows]);
gfpretty(primpolys(jj,:))
 
                                     2      3    4
                            2 + X + X  + 2 X  + X 

For the root A of the primitive polynomial primpoly(jj,:), a randomly selected element A^ii from GF(81) can be displayed in traditional format by using the gfpretty function.

ii = randi([1,p^m-2]);
gfpretty([zeros(1,ii),1],'A')
 
                                       72
                                      A  

The element A^ii can be expressed as shown here by using the gfpretty and gftuple functions.

gfpretty(gftuple(ii,m,p),'A')
 
                                      2      3
                                 1 + A  + 2 A 

Input Arguments

collapse all

Coefficients of the polynomial, specified as a row vector.

Data Types: double

Custom name of variable instead of X, specified as a string.

Data Types: string

Width of each line in the display, specified as a scalar integer.

Data Types: double

Tips

  • For all syntaxes: If you do not use a fixed-width font, the spacing in the display might not look correct.

Version History

Introduced before R2006a

See Also

|