| To: | Marco Bianchi <M.Bianchi@nrcl.com> |
|---|---|
| Subject: | Re: Toeplitz matrix |
| From: | Prof Brian Ripley <ripley@stats.ox.ac.uk> |
| Date: | Tue, 29 Jul 2003 19:30:25 +0100 (BST) |
| Cc: | s-news@lists.biostat.wustl.edu |
| In-reply-to: | <A18B69DC41B1D31198940000E85FF41BAE8AB0@mailhost.nrcl.com> |
On Tue, 29 Jul 2003, Marco Bianchi wrote:
> Dear Splus users
>
> given a vector x = {x1, x2, ..., xp}, has anyone already worked out an Splus
> function producing the corresponding pxp Toeplitz matrix without looping?
R has
toeplitz <- function (x)
{
if (!is.vector(x))
stop("x is not a vector")
n <- length(x)
A <- matrix(0, n, n)
matrix(x[abs(col(A) - row(A)) + 1], n, n)
}
and that should work in S-PLUS too.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Toeplitz matrix, Marco Bianchi |
|---|---|
| Next by Date: | Re: Toeplitz matrix, Ravi Varadhan |
| Previous by Thread: | Toeplitz matrix, Marco Bianchi |
| Next by Thread: | Re: Toeplitz matrix, Ravi Varadhan |
| Indexes: | [Date] [Thread] [Top] [All Lists] |