/*
 *  DistMatrix.h
 *
 *    routines for handling of distributed dynamic arrays in C
 *    Distribution: column-block
 */


#define TYPE  int

typedef struct
{ 
  TYPE     *data;
  int       nx;      /* no. of columns (globally) */
  int       ny;      /* no. of rows (globally)    */
  int       lx;      /* no. of columns (locally) */
  int       ly;      /* no. of rows (locally)  */
  int       dx;      /* index of first column in global array */
  
} DistMatrix;

#define INDEX(a,i,j)  ( ((a).data)[(a).lx * (i) + (j)] )

void newDistMatrix(DistMatrix *ar, int n, int m);
  /* creates local part of global n x m array */

void deleteDistMatrix(DistMatrix ar);

void blockDistribute(int n, int nt, int id, int *count, int *offset);