Re: Adding elements of a matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg40601] Re: Adding elements of a matrix
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 11 Apr 2003 01:59:25 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <b738oh$o7l$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi, m = Table[a[i, j], {i, 3}, {j, 3}]; summand = Table[b[i, j], {i, 3}, {j, 3}]; and MapIndexed[ If[Greater @@ #2, #1 + Part[summand, Sequence @@ #2], #1] &, m, {2}] will increment only the upper triangular part. Regards Jens Rebeca Choy wrote: > > Hi, > > How can I add in Mathematica every element of a matrix without adding > twice the mixed terms? > > for example i have a matrix m[[i,j]] and i want to add every term where > i<j (this is to avoiding adding twice the same number) > > Can I do it with Sum? > > Rebeca Choy
- Follow-Ups:
- Re: Re: Adding elements of a matrix
- From: Dr Bob <majort@cox-internet.com>
- Re: Re: Adding elements of a matrix