MathGroup Archive 2001

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

Search the Archive

Re: Special Matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28242] Re: Special Matrix
  • From: "Souvik Banerjee" <s-banerjee at nwu.edu>
  • Date: Fri, 6 Apr 2001 01:52:51 -0400 (EDT)
  • Organization: Northwestern University, Evanston, IL, US
  • References: <9ah5nq$ps0@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Not sure if the shortest but it works:

CreateMatrix[n_] :=
  Block[{r,c,m},
    Needs["LinearAlgebra`MatrixManipulation`"];
    r = ZeroMatrix[1, n]; m = Table[1, {n - 2}, {n - 2}];
    c = ZeroMatrix[n - 2, 1];
    BlockMatrix[{{r}, {c, m, c}, {r}}]
    ]

The bottleneck seems to be the Table[] operations. If there is a built in
function to create a matrix with a constant element then it will speed this
up.

-Souvik


Yoram Pollack <syftech at saad.org.il> wrote in message
news:9ah5nq$ps0 at smc.vnet.net...
> Hello
> I am trying to create a "n x n" matrix with "1" in every position exept in
> first and last row, and first and last coulumn, where "0" is needed. In
> other words: sqare matrix full of  "1" sorounded by "0".
> What will be the fastest and shortest way to do it?
>
> Thanks
> Yoram
>
>
>




  • Prev by Date: Re: Automatic expansion of Log[a^n] for a, n explicit positive integers?
  • Next by Date: Manipulating Strings
  • Previous by thread: Re: Special Matrix
  • Next by thread: Re: Special Matrix