MathGroup Archive 2000

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

Search the Archive

Re: Re: vector multiplication

  • To: mathgroup at
  • Subject: [mg26192] Re: [mg26182] Re: vector multiplication
  • From: "Christopher J. Purcell" <purcell at>
  • Date: Thu, 30 Nov 2000 22:02:10 -0500 (EST)
  • References: <8rjjdh$>
  • Sender: owner-wri-mathgroup at

Here is a slightly fancier version that adds another argument (like 
the Version 4.0 Tr function).
I have no idea how to add the third argument.

Tr::usage="Tr[list] finds the trace of the matrix or tensor list. 
Tr[list, f] finds a \
generalized trace, combining terms with f instead of Plus."


>Tr[] is new in version 4. But this will work:
>tr[m_] := Plus @@ Table[m[[i, i]], {i, Min[Dimensions[m]]}]
>-- David
Dr. Christopher J. Purcell
Defence Research Establishment Atlantic
9 Grove St., Dartmouth, NS Canada B2Y 3Z7

Tel: 902-426-3100-x389
Fax: 902-426-9654
E-mail: purcell at

  • Prev by Date: Re: Q compatibility between NT4 and Win2k?
  • Next by Date: Re: Symbolic complex conjugation
  • Previous by thread: Re: vector multiplication
  • Next by thread: Computeralgebra in University physics teaching