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: [mg41277] Re: Can Mathematica recognize the difference between a vector and a matrix?
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Mon, 12 May 2003 04:36:02 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <b9n9oe$8u3$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

the MatrixQ[] and VectorQ[] functions may help you, i.e.
DMetric[xtau_?MatrixQ,xt_List]:=
DMetric[xtau_?VectorQ,xt_List]:=

Regards
  Jens

J Robert Buchanan wrote:
> 
> 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: (la)tex export as batch process?
  • Next by Date: Re: Can Mathematica recognize the difference between a vector and a matrix?
  • Previous by thread: Can Mathematica recognize the difference between a vector and a matrix?
  • Next by thread: Re: Can Mathematica recognize the difference between a vector and a matrix?