Re: Adding elements of a matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg40609] Re: Adding elements of a matrix
- From: bobhanlon at aol.com (Bob Hanlon)
- Date: Fri, 11 Apr 2003 02:01:18 -0400 (EDT)
- References: <b738oh$o7l$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
(mat = Array[m, {3,3}]); For the sum of every term m[[i,j]] with i < j Sum[mat[[i,j]], {j, Length[mat]},{i,j-1}] m[1,2]+m[1,3]+m[2,3] For the sum of every term m[[i,j]] with i <= j Sum[mat[[i,j]], {j, Length[mat]},{i,j}] m[1,1]+m[1,2]+m[1,3]+m[2,2]+m[2,3]+m[3,3] Bob Hanlon In article <b738oh$o7l$1 at smc.vnet.net>, Rebeca Choy <rchoy at ula.ve> wrote: << Subject: Adding elements of a matrix From: Rebeca Choy <rchoy at ula.ve> To: mathgroup at smc.vnet.net Date: Thu, 10 Apr 2003 08:07:45 +0000 (UTC) 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 >><BR><BR>