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

static char *rowfreqid = "$Id: row_freq.c,v 1.3 1996/12/30 23:21:13 galway Exp $";

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

    row_freq.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



    Computes for row irow the sum (across the row) of frequencies (in
    their respective columns) of each row entry that is NOT a block
    symbol.

    L. Galway 30-DEC-1996 */
/*****************************************************************/

extern enum logical is_blkind();

int row_freq(d,vcnt,irow)
struct datamat *d; struct valcnt **vcnt;int irow;
{
  int i,j,freqsum,cnt;

  freqsum=0;
  for (i=0;i<d->ncols;i++) {
    if (is_blkind(irow,i,d) == FALSE) /* if not a block symbol in
					 [irow][i]... */
      for (j=0;j<vcnt[i]->nvals;j++)  /* get the frequency from the
					 array of valcnts */
	if (d->data[irow][i]==vcnt[i]->vals[j]) 
	  freqsum=freqsum+vcnt[i]->cnts[j];
  };
  return(freqsum);
}
