On 3/14/13 8:10 PM, pascal wrote:
Does Sage provide support for building the circulant matrix associated
to a given list ?
Here is a simple piece of code to do it directly in Sage:
def hankel(R,c,r):
entries=c+r[1:]
return matrix(R, len(c), len(r), lambda i,j: entries[i+j])
def circulant(R,E):
return hankel(R, E, E[-1:]+E[:-1])
circulant(QQ, [1,2,3])
Or you can directly use scipy to do it:
from scipy.linalg import circulant
matrix(circulant([1,2,3]))
(see
http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.circulant.html#scipy.linalg.circulant)
FYI, you might find our chapter in the Handbook of Linear Algebra to be
a good resource: http://sage.math.washington.edu/home/jason/sage-HLA2.pdf
The code above was in an early draft of the chapter, which may have been
commented out recently to edit the chapter down. We'll put it back in
when we include the chapter in Sage documentation. Even better, as you
implicitly suggest, we should include these and many other matrix
constructors directly into Sage.
Thanks,
Jason
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.