Ask Your Question

G-circulant matrices

asked 2022-01-12 17:49:54 +0100

tungnt gravatar image

updated 2022-01-12 17:51:54 +0100

Dear the community,

I wonder whether there is a built-in library/function for $G$-circulant matrices in SAGE? Here $G$ is a group and a matrix $A$ is called $G$-circulant if $A$ has the form $A=(a_{ \tau^{-1} \sigma})_{\tau, \sigma \in G}$. Please see [1] for further details.

When $G=\mathbb{Z}/n$, SAGE has a built-in library/function. Namely, given a vector $v$ of length $n$, we can generate a circulant matrix with the first row equal to $v$ using the following code


Thank you for your help!

[1] Kanemitsu, Shigeru, and Michel Waldschmidt. "Matrices of finite abelian groups, finite Fourier transform and codes, Proc. 6th China-Japan Sem. Number Theory, World Sci. London-Singapore-New Jersey (2013): 90-106.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-01-12 18:33:19 +0100

rburing gravatar image

updated 2022-01-12 19:58:33 +0100

They don't seem to be built-in, but such a matrix can be constructed with one line of code:

def group_matrix(G, v):
    Return the G-circulant matrix associated with the vector v.


    - ``G`` -- a list (i.e. an ordered list) of elements which form a finite group
    - ``v`` -- a vector with exactly ``len(G)`` entries
    return matrix(v.base_ring(), len(G), lambda i,j: v[G.index(G[i].inverse()*G[j])])

Example 1:

sage: S = SymmetricGroup(3)
sage: G = S.subgroup([S("(2,3,1)")])
sage: X = vector(PolynomialRing(QQ, 3, names='x').gens())
sage: group_matrix(list(G), X)
[x0 x1 x2]
[x2 x0 x1]
[x1 x2 x0]

Example 2:

sage: Y = vector(PolynomialRing(QQ, 6, names='y').gens())
sage: group_matrix(list(S), Y)
[y0 y1 y2 y3 y4 y5]
[y2 y0 y1 y4 y5 y3]
[y1 y2 y0 y5 y3 y4]
[y3 y4 y5 y0 y1 y2]
[y4 y5 y3 y2 y0 y1]
[y5 y3 y4 y1 y2 y0]

Example 3:

sage: v = vector(ZZ, [0,1,2])
sage: group_matrix(list(G), v)
[0 1 2]
[2 0 1]
[1 2 0]
edit flag offensive delete link more


Thank you so much for your help. This is really awesome.

I have a follow-up question: for the problems that I am working on, I need to specify the values of the $x_i$ variables. When I tried

$X=[0,1,-1]$ (meaning that x0=0, x1=1, x2=-1), there is the following error

AttributeError: 'list' object has no attribute 'base_ring'

I guess I don't quite understand the meaning of the code "v.base_ring()". For me, the base_ring=Z is good enough (I can use the syntax to change the base ring to $\mathbb{F}_p$ later).

Thank you!

tungnt gravatar imagetungnt ( 2022-01-12 19:06:18 +0100 )edit

You're welcome! The function assumes that the input v is a vector, so that its base ring can be used as the base ring of the matrix. To clarify, I've added an example with concrete values instead of variables.

rburing gravatar imagerburing ( 2022-01-12 19:57:47 +0100 )edit

Everything makes sense (and works now!) Thank you very much!

tungnt gravatar imagetungnt ( 2022-01-12 20:40:05 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2022-01-12 17:49:54 +0100

Seen: 416 times

Last updated: Jan 12 '22