MathGroup Archive 1999

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

Search the Archive

Re: Matrices-in-functions question


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

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


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

will do what you want.


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