MatrixTemplate (Generalization)
- To: mathgroup at smc.vnet.net
- Subject: [mg28425] MatrixTemplate (Generalization)
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Wed, 18 Apr 2001 03:23:28 -0400 (EDT)
- References: <9bgf1v$ddq@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
This extends the idea to tensors of arbitrary rank TensorTemplate[x_, dims_]:= Fold[PadRight[{},#2,{#1}]&, x, Reverse[dims]] TensorTemplate[0,{3,4,5}] {{{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}}, {{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}}, {{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}} } Dimensions[%] {3,4,5} -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Allan Hayes" <hay at haystack.demon.co.uk> wrote in message news:9bgf1v$ddq at smc.vnet.net... > > Clear["`*"] > > CreateMatrix[x_, m_, n_] := PadRight[{}, m, {PadRight[{}, {n}, {x}]}] > > Check > > CreateMatrix[0,3,5] > > {{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}} > > > -- > Allan > --------------------- > Allan Hayes > Mathematica Training and Consulting > Leicester UK > www.haystack.demon.co.uk > hay at haystack.demon.co.uk > Voice: +44 (0)116 271 4198 > Fax: +44 (0)870 164 0565 > > > >