Re: vector multiplication
- To: mathgroup at smc.vnet.net
- Subject: [mg26182] Re: vector multiplication
- From: dkeith at sarif.com
- Date: Thu, 30 Nov 2000 01:04:21 -0500 (EST)
- References: <8rjjdh$ofq@smc.vnet.net> <wTQD5.96470$Zh6.258511@ralph.vnet.net> <%QWU5.9321$b16.215543@ralph.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Tr[] is new in version 4. But this will work:
tr[m_] := Plus @@ Table[m[[i, i]], {i, Min[Dimensions[m]]}]
-- David
In article <%QWU5.9321$b16.215543 at ralph.vnet.net>,
Heiko_Petermann at t-online.de (Heiko) wrote:
> Hello,
> i'm using mathematica 3.0 and tried to follow the example but it
> didn't work for me. Is the Funktion Tr[...]new in version 4 or
> selfdefined.
> Thanks for reply.
> Heiko
> On Sun, 08 Oct 2000 02:22:20 GMT, "Hans Staugaard"
> <hans.staugaard at get2net.dk> wrote:
>
> >Hello
> >
> >First I make a sample matrix:
> >
> >In[1]:=
> >v = Array[Plus, {5, 3}]
> >
> >Out[1]=
> >{{2, 3, 4}, {3, 4, 5}, {4, 5, 6}, {5, 6, 7}, {6, 7, 8}}
> >
> >Then pick out the diagonal elements:
> >
> >In[2]:=
> >Tr[Transpose[v].v, List]
> >
> >Out[2]=
> >{90, 135, 190}
> >
> >
> >Hans
> >
> ><Yannis.Paraskevopoulos at ubsw.com> wrote in message
> >news:8rjjdh$ofq at smc.vnet.net...
> >> Hi there,
> >>
> >> Could you please help me with the following:
> >>
> >> Assume the v is a vector (1xk). I would like to calculate the v'v
and
> >> then take all the diagonal elements.
> >>
> >> Thanks a lot in advance for your effort.
> >>
> >> yannis
> >>
> >>
> >> Visit our website at http://www.ubswarburg.com
> >>
> >> This message contains confidential information and is intended only
> >> for the individual named. If you are not the named addressee you
> >> should not disseminate, distribute or copy this e-mail. Please
> >> notify the sender immediately by e-mail if you have received this
> >> e-mail by mistake and delete this e-mail from your system.
> >>
> >> E-mail transmission cannot be guaranteed to be secure or error-free
> >> as information could be intercepted, corrupted, lost, destroyed,
> >> arrive late or incomplete, or contain viruses. The sender
therefore
> >> does not accept liability for any errors or omissions in the
contents
> >> of this message which arise as a result of e-mail transmission. If
> >> verification is required please request a hard-copy version. This
> >> message is provided for informational purposes and should not be
> >> construed as a solicitation or offer to buy or sell any securities
or
> >> related financial instruments.
> >>
> >>
> >
> >
> >
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.