MathGroup Archive 1999

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

Search the Archive

Re: Matrices-in-functions question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20462] Re: Matrices-in-functions question
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 27 Oct 1999 02:04:37 -0400
  • Organization: Universitaet Leipzig
  • References: <7v3c1t$5uh@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

you must prevent that Part[mat,__] is evaluatet for symbols.
Define:

z[mat_?MatrixQ] := mat[[1, 1]] a + mat[[1, 2]]


and 

z[mat] /. mat -> {{1, 2}, {3, 4}}

will do what you want.

Regards
  Jens

Aram Schiffman wrote:
> 
> 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?
> 
> Thanks,
> Aram Schiffman


  • Prev by Date: Re: service pack for Mathematica?
  • Next by Date: Re: A simple question? Please help
  • Previous by thread: Re: Matrices-in-functions question
  • Next by thread: Re: Matrices-in-functions question