# G-circulant matrices

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  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

matrix.circulant(v)

 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 close merge delete

Sort by » oldest newest most voted 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.

INPUT:

- 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]

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!

1

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.

1

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