#include "logical.h";
#include "datamat.h";
#include "block.h";

/* ***************************************************************** */
/* 

    block_count.c

    Copyright (C) 2004  Lionel A. Galway

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    For a copy of the GNU General Public License write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



   Routine to compute block count for a given block on a particular
   data structure.

   L. Galway  16-AUG-1996 */
/* ***************************************************************** */

int block_count(blk,data)
struct block *blk;struct datamat *data;
{
	int i,j,bcount;

	bcount=0;
	/* Count up the number of times data is block element */
	for (i=0;i<data->nrows;i++) {
		for (j=0;j<data->ncols;j++) {
			if (blk->irow[i]==1 && blk->icol[j]==1 && 
			    is_blkind(i,j,data) == TRUE) bcount++;
		}
	};
	/* Subtract number of columns in the block */
	return(bcount - blk->nc);
}
