MathGroup Archive 2003

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41274] Re: [mg41273] Can Mathematica recognize the difference between a vector and a matrix?
  • From: Bobby Treat <drmajorbob at mailblocks.com>
  • Date: Mon, 12 May 2003 04:35:47 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

That's illegible, and it doesn't copy properly into a notebook.

Either avoid superscripts and special characters so that copying into 
e-mail works, or convert the cell to InputForm (Ctrl-shift-I) before 
copying it.

The patterns you need are _?VectorQ and _?MatrixQ

Bobby

-----Original Message-----
From: J Robert Buchanan <Bob.Buchanan at millersville.edu>
To: mathgroup at smc.vnet.net
Subject: [mg41274] [mg41273] Can Mathematica recognize the difference between a 
vector and a matrix?

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: Re: Can Mathematica recognize the difference between a vector and a matrix?
  • Next by Date: Re: Spirals and arc length
  • Previous by thread: Re: Can Mathematica recognize the difference between a vector and a matrix?
  • Next by thread: Spirals and arc length