MathGroup Archive 2003

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

Search the Archive

Can Mathematica recognize the difference between a vector and a matrix?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41273] Can Mathematica recognize the difference between a vector and a matrix?
  • From: Bob.Buchanan at millersville.edu (J Robert Buchanan)
  • Date: Mon, 12 May 2003 00:58:45 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hello,

I would like to define a Mathematica function which does something
different depending on whether one of the arguments to the function is
a matrix or a vector. I know there are some in-elegant ways to achieve
the affect that I want, but I'm searching for an elegant and efficient
way. Here is an example of the function when both arguments are
vectors.

DMetric[x\[Tau]_List, xt_List] := 
    Sqrt[\[CapitalLambda] . \((\((x\[Tau] - xt)\)\^2)\)]

I would like to be able to define the other version where the first
argument is a matrix like this.

DMetric[x\[Tau]_Matrix, xt_List] := 
    Sqrt[Map[\((\[CapitalLambda] . #)\) &,
\((Transpose[Transpose[x\[Tau]] - xt]\^2)\)]]

In both cases CapitalLambda is a constant vector of weights. Does
anyone have a suggestion?

Thanks,
Bob Buchanan



  • Prev by Date: graph from incidence matrix
  • Next by Date: Spirals and arc length
  • Previous by thread: Re: graph from incidence matrix
  • Next by thread: Re: Can Mathematica recognize the difference between a vector and a matrix?