How can I construct a matrix given a generator for this cyclic group?

倾然丶 夕夏残阳落幕 提交于 2020-06-16 04:12:46

问题


Let F[q^p] be a finite cyclic set of polynomials, where q is a prime number and p is an integer greater than 0. Each element in F[q^p] will be a polynomial up to degree (p-1) under (mod q).

Ex: F[2^2]={0,1,x,1+x}

Ex: F[3^4]={0,1,2,0+x,1+x,2+x,0+x^2,1+x^2,2+x^2,x+x^2,1+x+x^2,2+x+x^2,2x+x^2,1+2x+x^2,2+2x+x^2,0+2x^2,1+2x^2,2+2x^2,x+2x^2,1+x+2x^2,2+x+2x^2,2x+2x^2,1+2x+2x^2,2+2x+2x^2,...,2+2x+2x^2+2x^3}

Thus, there will be q^p elements in F[q,p].

Assume that we have a generator theta, where theta^k, where k=0,1,2,...,q^p-1, will generate the entire finite cyclic set F[q^p].

Let's examine the more complicated example above of F[3^4]. How can I construct an algorithm that can generate a pattern, such as this one for F[3^4], for any F[q^p]?

(0)                (1)                (2)                (x)                (1+x)              ... (2+2x+2x^2+2x^3)
(0)+theta^(0+i)    (1)+theta^(0+i)    (2)+theta^(0+i)    (x)+theta^(0+i)    (1+x)+theta^(0+i)  ... (2+2x+2x^2+2x^3)+theta^(0+i)
(0)+theta^(1+i)    (1)+theta^(1+i)    (2)+theta^(1+i)    (x)+theta^(1+i)    (1+x)+theta^(1+i)  ... (2+2x+2x^2+2x^3)+theta^(1+i)
(0)+theta^(2+i)    (1)+theta^(2+i)    (2)+theta^(2+i)    (x)+theta^(2+i)    (1+x)+theta^(2+i)  ... (2+2x+2x^2+2x^3)+theta^(2+i)
...
(0)+theta^(q-2+i)  (1)+theta^(q-2+i)  (2)+theta^(q-2+i)  (x)+theta^(q-2+i)  (1+x)+theta^(q-2+i)  ... (2+2x+2x^2+2x^3)+theta^(q-2+i)

We note that i=1,...,q-1, but for the sake of getting this to work, let's set i=1.

The difficult part of this problem is that the above elements must remain in (mod q) while still remaining less than degree p.

Ex: (From fifth column, second row above) Suppose theta is 0+x. 1+theta^4 = 1+x^4, but x^4 is not in the set F[q^p] since it is higher than degree (p-1)=3. So, we use polynomial long division to show that if we divide the irreducible polynomial x^4+x^3+x^2+2x+2 by x^4 to get x^3+x^2+2x+2. (Irreducible polynomial can be computed with the first function in my code below.)

Here's what I've been working with so far, but I have not made great progress.

library("polynom")

gf <- function(q,p){

  ### First we need to create an irreducible polynomial of degree p
  poly <- polynomial(coef=c(floor(runif(p,min=0,max=q)),1)) #This generates the first polynomial of degree p with coefficients ranging between the integer values of 0,1,...,q
  for(i in 1:(q^5*p)){ #we generate/check our polynomial a sufficient amount of times to ensure that we get an irreducible polynomial
    poly.x <- as.function(poly) #we coerce the generated polynomial into a function
    for(j in 0:q){ #we check if the generated polynomial is irreducible
      if(poly.x(j) %% q == 0){ #if we find that a polynomial is reducible, then we generate a new polynomial
        poly <- polynomial(coef=c(floor(runif(p,min=0,max=q)),1)) #...and go through the loop again
      }
    }
  }


  ### Now, we need to construct the cyclic group F[x] given the irreducible polynomial "poly"
  F <- matrix(ncol=p,nrow=q^p) #initialize the vector F

  ### Constructs an F[x], where each row contains the coefficients of the polynomial
  F <- as.matrix(expand.grid(lapply(1:p, function(i) 1:q-1L)))

  ### We need to solve for x^p using the irreducible polynomial above 
  ### https://rosettacode.org/wiki/Polynomial_long_division#R
  polylongdiv <- function(n,d) {
    gd <- length(d)
    pv <- vector("numeric", length(n))
    pv[1:gd] <- d
    if ( length(n) >= gd ) {
      q <- c()
      while ( length(n) >= gd ) {
        q <- c(q, n[1]/pv[1])
        n <- n - pv * (n[1]/pv[1])
        n <- n[2:length(n)]
        pv <- pv[1:(length(pv)-1)]
      }
      list(q=q, r=n)
    } else {
      list(q=c(0), r=n)
    }
  }


  ### Now we need to check for a generator
  for(i in (q+1):(q^p/2)){ #we can skip the first 1:q, since those are constants, and we don't need to calculate the second half of the set
    posgen <- F[i,] 
  }

  ### Now we construct the orthogonal mate Latin Square, which must be a List, since it's a 3-dimensional matrix
  gen <- c(0,1)
  LS <- list()
  i <- 1 #this will change later

  for(i in 1:(q^p)){ #this is working well
    LS[[i]] <- F[i,]%%q
  }

  for(k in (q^p+1):q^(2*p)){ #this gives the correct dimensions
    for(i in 1:q^p){ #this is where things are getting weird
      for(j in 0:(q-2)){
        LS[[k]] <- (F[i,] + gen^(j+sub))%%q
      }
    }
  }

  list(poly.x=poly.x,poly=poly,F=F,posgen=posgen,LS=LS)
}

来源:https://stackoverflow.com/questions/61552804/how-can-i-construct-a-matrix-given-a-generator-for-this-cyclic-group

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!