【发布时间】:2020-08-12 19:16:12
【问题描述】:
我想创建一个 R 函数来生成循环有限群 F[x]。
基本上,我需要找到一种方法将多项式或至少多项式的系数存储在 R 向量的单个元素中。
例如,如果我有一个集合 F={0,1,x,1+x},我想将这四个多项式保存到一个 R 向量中,例如
F[1] <- 0 + 0x
F[2] <- 1 + 0x
F[3] <- 0 + x
F[4] <- 1 + x
但我不断收到错误消息:“要替换的项目数不是替换长度的倍数”
有没有办法让我至少可以做类似的事情:
F[1] <- (0,0)
F[2] <- (1,0)
F[3] <- (0,1)
F[4] <- (1,1)
如果有人对我正在尝试处理的数学问题感兴趣,作为参考,到目前为止,我的整个 R 函数是
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
}
}
}
list(poly.x=poly.x,poly=poly)
### Now, we need to construct the cyclic group F[x] given the irreducible polynomial "poly"
F <- c(rep(0,q^p)) #initialize the vector F
for(j in 0:(q^p-1)){
#F[j] <- polynomial(coef = c(rep(j,p)))
F[j] <- c(rep(0,3))
}
F
}
【问题讨论】:
标签: r vector abstract polynomials coefficients