[Date Index]
[Thread Index]
[Author Index]
Re: Multiple sum with iterators that cannot equal
*To*: mathgroup at smc.vnet.net
*Subject*: [mg19407] Re: [mg19365] Multiple sum with iterators that cannot equal
*From*: "David Park" <djmp at earthlink.net>
*Date*: Mon, 23 Aug 1999 13:57:18 -0400
*Sender*: owner-wri-mathgroup at wolfram.com
Eric,
Try this...
Sum[If[i != j, f[i, j], 0], {i, 1, 5}, {j, 1, 5}]
f[1, 2] + f[1, 3] + f[1, 4] + f[1, 5] + f[2, 1] + f[2, 3] + f[2, 4] +
f[2, 5] + f[3, 1] + f[3, 2] + f[3, 4] + f[3, 5] + f[4, 1] + f[4, 2] +
f[4, 3] + f[4, 5] + f[5, 1] + f[5, 2] + f[5, 3] + f[5, 4]
A second approach which is much faster if f[i,j] had defined numeric values is
mat = Array[f, {5, 5}];
Plus @@ Flatten[mat] - Tr[mat]
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
>Using multiple summmation signs with condition 'i "not
>equal" j', evaluation stops immediately as 'i' starts as
>1 as does 'j'. My formula requires that the 'i's' and
>'j's' together:
>
> Sum[Sum[f,{j,1,n}],{i,1,n}] ignore cases where i = j.
>
> Or as copied from my notebook:
>
>\!\(\(\(\[Sum]\+\(i = 1\)\%n\[Sum]\+\(j = 1\)\%n\)\+\(i
>!= j\)\) \(w\_i\)
> w\_j\)
>
>How do I solve this without some cumbersome loops.
>
>Many Thanks
>
>Eric Spahr
>Cottage Technology rspahr at worldnet.att.net
>
>
Prev by Date:
**Re: Characteristic Polynomials and Eigenvalues**
Next by Date:
**Re: Multiple sum with iterators that cannot equal**
Previous by thread:
**Re: Multiple sum with iterators that cannot equal**
Next by thread:
**Re: Multiple sum with iterators that cannot equal**
| |