#include "datamat.h"
#include "valcnt.h"

static char *rowmaxid = "$Id: row_max.c,v 1.3 1996/12/30 23:23:06 galway Exp galway $";

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

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




    Returns the index of the row with the maximum frequency sum.

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

extern int row_freq();

int row_max(d,vcnt)
struct datamat *d; struct valcnt **vcnt;
{
  int i,rmax,maxfreq,tmpfreq;

  rmax=0; maxfreq=row_freq(d,vcnt,0);
    printf("row_max: i=%d rowfreq=%d\n",0,maxfreq);
  /* Go through all rows */
  for (i=1;i<d->nrows;i++) {
    tmpfreq=row_freq(d,vcnt,i);
    printf("row_max: i=%2d (%s) rowfreq=%d\n",i,d->rowlabs[i],tmpfreq);
    if (maxfreq < tmpfreq) {rmax=i;maxfreq=tmpfreq;};
  };
  return(rmax);
}


