#define	MATRIX_CONSTRUCTOR(STORAGE,ROUTINE,BASE_TYPE) \
STORAGE BASE_TYPE \
**ROUTINE(int col_base,int num_cols,int row_base,int num_rows) \
{ \
	int r; \
	BASE_TYPE **idx; \
	printf("data size %u\n",num_cols * num_rows * sizeof(BASE_TYPE)); \
	printf("idx size %u\n",num_rows * sizeof(BASE_TYPE*)); \
	printf("cksize %u\n",num_cols * num_rows * sizeof(BASE_TYPE) + \
		num_rows * sizeof(BASE_TYPE*)); \
	idx = (BASE_TYPE **)memAlloc(num_cols * num_rows * sizeof(BASE_TYPE) + \
		num_rows * sizeof(BASE_TYPE*)); \
	printf("block %u\n",idx); \
	idx[0] = (BASE_TYPE*)(idx + num_rows) - col_base; \
	printf("idx[0] %u\n",idx[0]); \
	for(r = 1;r < num_rows;r++) \
		idx[r] = idx[r-1] + num_cols; \
	return idx - row_base; \
}

#define	MATRIX_DESTRUCTOR(STORAGE,ROUTINE,BASE_TYPE) \
STORAGE	void \
ROUTINE(BASE_TYPE **fake_idx,int row_base) \
{ \
	memFree(fake_idx + row_base); \
}

MATRIX_CONSTRUCTOR(V_LOCAL,new_mat,u8_t)
MATRIX_DESTRUCTOR(V_LOCAL,del_mat,u8_t)

