#include <stdio.h>

#include "block.h"

static char *allocblockid = "$Id: alloc_block.c,v 1.5 1996/12/30 19:30:00 galway Exp $";

/* ***************************************************************** */
/* 

    alloc_block.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


   Allocates space for a block structure (given the number of rows and
   columns in the data matrix) and initializes the values.

   L. Galway  16-AUG-1996 */
/* ***************************************************************** */


struct block *alloc_block(nr,nc)
int nr,nc;
{
  struct block *retval;int i;

  retval= (struct block *)malloc(sizeof(struct block));
  retval->nr=retval->nc=0;  /* Set row and column counts to zero */
  retval->NR=nr;retval->NC=nc; /* Set matrix dimensions */

  /* Row indicators */
  retval->irow=(int *)malloc(nr*sizeof(int));
  for (i=0;i<nr;i++) retval->irow[i]=0;

  /* Column indicators and block value array */
  retval->icol=(int *)malloc(nc*sizeof(int));
  retval->blkcd=(int *)malloc(nc*sizeof(int));
  for (i=0;i<nc;i++) {retval->icol[i]=0;retval->blkcd[i]=0;};

  retval->blkcnt=0;retval->bcode=-1;
  
  return(retval);
}
