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

static char * colmodeid = "$Id: col_mode.c,v 1.2 1996/12/30 20:10:54 galway Exp $";

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

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



    Wrapper function to return mode of a given column for a given
    block.  First computes a valcnt data structure with the
    frequencies (excluding block values), then calls find_mode to
    acutally compute the mode.

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

extern struct valcnt *col_freq();
extern void free_valcnt();

int col_mode(ic,d,blk)
int ic;struct datamat *d;struct block *blk;
{
  struct valcnt *cvals;int rval;

  cvals = col_freq(d,ic,blk);  /* Get frequencies for block blk,
				  column ic */
  rval = find_mode(cvals);     /* Find the mode */
  free_valcnt(cvals);          /* Clean up the valcnt data structure */
  return(rval);
}
