MathGroup Archive 2008

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

Search the Archive

Re: Column Product of a Matrix of zeros and 1's

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88020] Re: Column Product of a Matrix of zeros and 1's
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Tue, 22 Apr 2008 06:26:53 -0400 (EDT)

On 4/21/08 at 3:26 AM, petervansummeren at gmail.com (P_ter) wrote:

>I have a matrix of zero's and ones: myGlobalMatrix; also a set
>called thisSet with the columns of myGlobalMatrix which have to be
>multiplied (e.g. column 1,3,4). I would like to know the positions
>of the 1's. I do this as follows:
>Flatten[Position[Product[myGlobalMatrix[[All,i]],{i, thisSet}],1]]
>But this is to general. It does not use that the matrix consists of
>zeros and ones. Can this be taken into account? with friendly

I am unclear as to what you are trying to accomplish. If
myGloblMatrix consists of just ones and zeros, then probably the
fastest way to locate all of the ones would be

Most@ArrayRules@SparseArray@myGlobalMatricx

It looks like the code you have above locates all rows of
myGlobalMatrix where the first thisSet columns are 1

If this is what you want, then one way would be

Position[Clip[Total/@(myGlobalMatrix[[All,;;thisSet]]),{thisSet,thisSet},{0=
,1}],1]

Here, I assume you are using verision 6.x


  • Prev by Date: Defining output formats
  • Next by Date: Re: Converting Power terms to Times terms
  • Previous by thread: Column Product of a Matrix of zeros and 1's
  • Next by thread: Re: Column Product of a Matrix of zeros and 1's