MathGroup Archive 2006

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

Search the Archive

Re: Summing elements within a List or Array

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69567] Re: [mg69524] Summing elements within a List or Array
  • From: gardyloo <gardyloo at mail.wsu.edu>
  • Date: Fri, 15 Sep 2006 06:46:57 -0400 (EDT)

Plus @@ (# // Flatten) & /@ alist



  (flatten each row/column of the list, then apply Plus to each of the
results)
   I think that'll do what you want.

           Cheers,
                 C.O.

John Adeosun wrote:
> Hello Everyone,
>
> I generated an intended list of real numbers using Mathematica 5.2, say 
> "alist", that looks like:
>
> alist = {{0}, {{1.2},0}, {{2.3},{1.2},0},{{3.4},{2.3},{1.2},0}, 
> ................{{99.0},{98.9},{97.8},.......,0}}
> (In Matrix form, this "alist" can be shown as a LowerDiagonal Matrix)
>
> Meanwhile, my present goal is to then program using Mathematica to obtain a 
> list, say "aalist", having each element equal to the sum of the elements in 
> each(corresponding) sublist of the original list "alist." That is,
>
> aalist  = {0, 1.2, 3.5, 6.9,...........}
>
> In essence, it is like reducing, say, 100 by 100 matrix to 100 by 1 matrix 
> via summing operation.
>
>  I programmed using some summing operations/functions in Mathematica to no 
> avail. I don't know what I 'm doing wrong.
>
> Can anyone help with this problem?
>
> Thanks,
>
> John. 
>
>
>
>   

-- 
==========================================================
Curtis Osterhoudt          
gardyloo at mail.remove_this.wsu.and_this.edu
PGP Key ID: 0x088E6D7A
Please avoid sending me Word or PowerPoint attachments
See http://www.gnu.org/philosophy/no-word-attachments.html
==========================================================


  • Prev by Date: Re: Summing elements within a List or Array
  • Next by Date: Re: How to tell Mathematica to stop conditional testing in an If
  • Previous by thread: Re: Summing elements within a List or Array
  • Next by thread: Re: Summing elements within a List or Array