예제 #1
0
/* EXPORT->CreateDVector:  Allocate space for double vector v[1..size] */
DVector CreateDVector(MemHeap *x, int size)
{
   DVector v;
   int *i;
   
   v = (DVector)New(x,DVectorElemSize(size));
   i = (int *) v; *i = size;
   return v;
}
예제 #2
0
파일: HMem.c 프로젝트: nlphacker/OpenSpeech
/* EXPORT->CreateDTriMat:  Allocate space for double matrix m[1..size][1..i] */
DTriMat CreateDTriMat(MemHeap *x,int size)
{
   int *i,j;
   DVector *m;   
   char *p;
      
   p = (char *) New(x,DTriMatElemSize(size)); 
   i = (int *)p; *i = size;
   m = (DVector *)p;
   p += (size+1)*sizeof(DVector);
   for (j=1;j<=size; j++) {
      i = (int *) p; *i = j;
      m[j] = (DVector) p; p += DVectorElemSize(j);
   }
   return m;
}
예제 #3
0
/* EXPORT->CreateDMatrix:  Allocate space for double matrix m[1..nrows][1..ncols] */
DMatrix CreateDMatrix(MemHeap *x, int nrows,int ncols)
{
   size_t vsize;
   int *i,j;
   DVector *m;   
   char *p;
   
   p = (char *) New(x,DMatrixElemSize(nrows,ncols));
   i = (int *) p; *i = nrows;
   vsize = DVectorElemSize(ncols);
   m = (DVector *) p;
   p += MRound((nrows+1)*sizeof(DVector));
   for (j=1; j<=nrows; j++, p += vsize) {
      i = (int *) p; *i = ncols;
      m[j] = (DVector) p;
   }
   return m;
}
예제 #4
0
size_t DMatrixElemSize(int nrows,int ncols)
{
   return MRound(DVectorElemSize(ncols) * nrows + (nrows+1)*sizeof(DVector));
}
예제 #5
0
파일: HMem.c 프로젝트: nlphacker/OpenSpeech
size_t DTriMatElemSize(int size)
{
   return size*(DVectorElemSize(0)*2 + (size+1)*sizeof(double))/2
      + (size+1)*sizeof(DVector);
}