Reputation: 165
Given the first row vector R0 = [a0,a1,...,a(n-1)]
and a specific vector V
, I would like to create a "vector circulant matrix" in SAGE, which will be constructed as follows.
The rows of the matrix will be
R0=R0; R1=p(R0); R2=p(R1), ..., R(n-1)=p(R(n-2))
where p
is a map which takes, for example row Ri = [r0,r1,...,r(n-1)]
and
makes it [0, r0, r1,...,r(n-2)]+r(n-1)*V
Note that I tried to write everything in the language of Sage. And this is not like the classical circulant, Toeplitz or Hankel matrix constructions.
(n, R0, and the vector V will be defined by the user at the beginning)
How to write a simple program that will give me the matrix defined above?
Upvotes: 1
Views: 454
Reputation: 3453
Here is a function:
def f(r,v):
def p(x):
return vector([0]+list(x[:-1r])) + x[-1r]*v
m = [r]
for _ in xrange(len(r)-1r):
m.append(p(m[-1r]))
return matrix(m)
Example:
sage: r = vector(ZZ,(0, 1, 2, 3,))
sage: v = vector(ZZ,(3, 5, 7, 9,))
sage: f(r,v)
[ 0 1 2 3]
[ 9 15 22 29]
[ 87 154 218 283]
[ 849 1502 2135 2765]
Upvotes: 1