MathGroup Archive 2010

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

Search the Archive

Re: It would be nice to have DiagonalMatrix accept a matrix as building


On 10/31/2010 6:47 AM, Patrick Scheibe wrote:
> Hi,
>
> aehmm, what about
>
> SparseArray[Band[{1, 1}] ->  {b,b,b,b,b,b}]
>
> where b={{1, 2}, {3, 4}}?
> Takes me about 5 seconds to type. So why care that DiagonalMatrix
> can't do it?
>
> Cheers
> Patrick
>

Well, if you wanted to repeat the block 200 times, you probably do not 
want to sit and type 'b' 200 times :)

But using ConstantArray, like Zach just mentioned is what I did not know 
about.  His solution:

SparseArray[Band[{1, 1}] -> ConstantArray[block, {nBlocks}]]

is good enough so not to require special option for DiagonalMatrix. So 
this issue is closed for me. I'll use ConstantArray for this.

Thanks for everyone input on this.

--Nasser


  • Prev by Date: Re: EventHandler vs ControllerState
  • Next by Date: Using the fonts available in the Format>Font menu as part of Style[]?
  • Previous by thread: Re: It would be nice to have DiagonalMatrix accept a matrix as building
  • Next by thread: Re: It would be nice to have DiagonalMatrix accept a matrix as building