Example #1
0
/* EXPORT->CreateIntVec:  Allocate space for int array v[1..size] */
IntVec CreateIntVec(MemHeap *x,int size)
{
   int *v;
   
   v = (int *)New(x,IntVecElemSize(size));
   *v = size;
   return (IntVec)v;
}
Example #2
0
/* EXPORT->CreateIMatrix:  Allocate space for integer matrix m[1..nrows][1..ncols] */
IMatrix CreateIMatrix(MemHeap *x, int nrows, int ncols)
{
   size_t vsize;
   int *i,j;
   IntVec *m;   
   char *p;
   
   p =(char *)  New(x,IMatrixElemSize(nrows,ncols)); 
   i = (int *)p; *i = nrows;
   vsize = IntVecElemSize(ncols);
   m = (IntVec *)p;
   p += (nrows+1)*sizeof(IntVec);
   for (j=1;j<=nrows; j++, p += vsize) {
      i = (int *) p; *i = ncols;
      m[j] = (IntVec) p;
   }
   return m;
}
Example #3
0
size_t IMatrixElemSize(int nrows,int ncols)
{
   return IntVecElemSize(ncols) * nrows + (nrows+1)*sizeof(IntVec);
}