MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: simpler way to get a particular banded matrix?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98145] Re: simpler way to get a particular banded matrix?
  • From: rip pelletier <bitbucket at comcast.net>
  • Date: Tue, 31 Mar 2009 04:19:35 -0500 (EST)
  • References: <gqn910$2o$1@smc.vnet.net> <gqq3qa$7m3$1@smc.vnet.net>

In article <gqq3qa$7m3$1 at smc.vnet.net>, Raffy <raffy at mac.com> wrote:

> On Mar 29, 12:46 am, rip pelletier <bitbuc... at comcast.net> wrote:
> > Hi,
> >
> > The following command constructs a matrix (typically denoted M0, it
> > arises in filter banks in general, in Burrus, Gopinath, & Guo "intro to
> > wavelets and wavelet transforms: a primer" in particular).
> >
> > I'm sure there's a way to do this without typing out all 5 bands. Here's
> > what i did:
> >
> > SparseArray[Band[{1,1}]->H,{6,6}]+
> > SparseArray[Band[{2,3}]->H,{6,6}]+
> > SparseArray[Band[{3,5}]->H,{6,6}]+
> > SparseArray[Band[{-2,-3},{1,1},{-1,-1}]->rH,{6,6}]+
> > SparseArray[Band[{-3,-5},{1,1},{-1,-1}]->rH,{6,6}]
> >
> > where
> >
> > H={h0,h1,h2,h3,h4,h5};
> > rH=Reverse[H];
> >
> > I get what I want:
> >
> > h0  0  0  0  0  0
> > h2 h1 h0 0  0  0
> > h4 h3 h2 h1 h0 0
> > 0  h5 h4 h3 h2 h1
> > 0  0  0  h5 h4 h3
> > 0  0  0  0  0  h5
> >
> > Any easier ways to get this?
> >
> > TIA and vale,
> >    rip
> >
> > --
> > NB eddress is r i p 1 AT c o m c a s t DOT n e t
> 
> To error on the side of readability, I'd probably go with:
> 
> mat[n_Integer] := With[
>    {vRow = Join[
>       ConstantArray[0, n - 1],
>       Table[ToExpression["h" <> ToString[i]], {i, n - 1, 0, -1}],
>       ConstantArray[0, n - 1]]
>     },
>    Table[Take[vRow, {2 n + 1, 3 n} - 2 i], {i, n}]
>    ];

Thanks. I'm not sure it's the kind of simplification i'm looking for, 
but I'll play with it.

Vale,
   Rip

-- 
NB eddress is r i p 1 AT c o m c a s t DOT n e t


  • Prev by Date: Interpolation -> segfault?
  • Previous by thread: Re: simpler way to get a particular banded matrix?
  • Next by thread: Stylesheets and export to HTML