Re: Matrices-in-functions question

*To*: mathgroup at smc.vnet.net*Subject*: [mg20486] Re: Matrices-in-functions question*From*: "Stephen P Luttrell" <luttrell at signal.dra.hmg.gb>*Date*: Wed, 27 Oct 1999 02:04:51 -0400*Organization*: Defence Evaluation and Research Agency*References*: <7v3c1t$5uh@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

> Here is a simple one, but I can't work it out. > > I would like to be able to define a function this way: > > z=mat[[1]][[1]] a + mat[[1]][[2]] > > without specifying what "mat" is explicitly. I would evaluate it later this > way: > > z/.mat->somePredefinedMatrix > > Of course, Mathematica complains about the definition (Part specification mat[[1]] is > longer than depth of object) ... is there a way to make this fly? I think this solves your problem: z[mat_, a_] := mat[[1]][[1]] a + mat[[1]][[2]] Use := rather than = to maintain the right hand side in unevaluated form until the left hand side is actually used. -- Stephen P Luttrell Signal Processing and Imagery Department DERA Malvern, St.Andrew's Road Malvern, United Kingdom, WR14 3PS +44 (0)1684 894046 (tel) +44 (0)1684 894384 (fax) luttrell at signal.dera.gov.uk (email)