Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Add terms surrounded by zero together in matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59123] Add terms surrounded by zero together in matrix
  • From: "mchangun at gmail.com" <mchangun at gmail.com>
  • Date: Fri, 29 Jul 2005 00:42:08 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi All,

I think this is a rather tough problem to solve.  I'm stumped and would
really appreciated it if someone can come up with a solution.

What i want to do is this.  Suppose i have the following matrix:

0       0       0       1       0
0       0       1       2       0
0       0       0       2       1
1       3       0       0       0
0       0       0       0       0
0       0       0       0       0
0       0       1       1       0
5       0       3       0       0
0       0       0       0       0
0       0       0       3       1

I'd like to go through it and sum the elements which are surrounded by
zeros.  So for the above case, an output:

[7 4 5 5 4]

is required.  The order in which the groups surrounded by zero is
summed does not matter.

The elements are always integers greater than 0. 

Thanks for any help!


  • Prev by Date: Re: Operating with binary numbers
  • Next by Date: Re: Re: How to simplify an expression in version 5
  • Previous by thread: Mathematica 5.2 and mathssh
  • Next by thread: Re: Add terms surrounded by zero together in matrix