int QccDatasetInitialize(QccDataset *dataset);
int QccDatasetAlloc(QccDataset
*dataset);
void QccDatasetFree(QccDataset *dataset);
int QccDatasetGetBlockSize(const
QccDataset *dataset);
int QccDatasetPrint(const QccDataset *dataset);
int QccDatasetCopy(QccDataset *dataset1, const QccDataset *dataset2);
The main component of a QccDataset structure is an array of vectors. For file input and output, this array of vectors is the current block of vectors being written to or read from the file. That is, access to DAT-format files is block-based, with a block of vectors being written or read at once. Optionally, the block size can be set to be the same as the file size, so that all vectors in the dataset are accessed simultaneously. QccDataset datasets that do not involve file access typically hold all vectors of the dataset in the vector array.
typedef struct
{
QccString filename;
FILE *fileptr;
QccString magic_num;
int major_version;
int minor_version;
int num_vectors;
int vector_dimension;
int access_block_size;
int num_blocks_accessed;
double min_val;
double max_val;
QccMatrix vectors;
} QccDataset;
The fields of QccDataset are as follows:
The DAT file format consists of the following information:
where DAT is the magic number, X.X is the version number, <white space> is white space and/or comment lines, N is the number of vectors the file contains, dim is the number of components each vector contains (vector dimension), min and max give the smallest and largest vector components, respectively, in the file, and vij is the jth component of the ith vector. N and dim are integers. vij, min, and max are doubles. N, dim, min, and max are stored in ASCII, vij as binary (4 bytes, MSB first, see QccFileWriteDouble(3) ). No white space may exist between the vij's.DATX.X
<white space>
N dim
min max
v11 v12 v13...
v21 v22 v23...
.
.
.
filename: NULL string
magic_num: QCCDATASET_MAGICNUM
major_version, minor_version: initialized to output of QccGetQccPackVersion(3)
num_vectors: 0
vector_dimension: 0
access_block_size: QCCDATASET_ACCESSWHOLEFILE
num_blocks_accessed: 0
min_val, max_val: 0
vectors: NULL
QccDatasetAlloc() allocates storage space for the vectors array of dataset. If vectors is not NULL, QccDatasetAlloc() returns immediately without changing the state of any memory allocation. Otherwise, the vectors array is allocated. The fields access_block_size, num_vectors, and vector_dimension must be defined prior to calling QccDatasetAlloc(). If access_block_size equals QCCDATASET_ACCESSWHOLEFILE, then space for num_vectors vectors is allocated; otherwise, space for access_block_size vectors is allocated.
QccDatasetFree() frees the vectors array previously allocated by QccDatasetAlloc() .
QccDatasetGetBlockSize() returns the block size of the vectors array of dataset. If access_block_size is QCCDATASET_ACCESSWHOLEFILE, num_vectors is returned; otherwise, access_block_size is returned.
QccDatasetPrint() prints the contents of dataset to stdout.
QccDatasetCopy() copies dataset2 to dataset1. If dataset1 has not been allocated prior to calling QccDatasetCopy() (as is evidenced by a NULL dataset1->vectors pointer), then QccDatasetAlloc() is called to allocate space for dataset1 with the same block_size and vector_dimension as dataset2. Otherwise (non-NULL dataset1->vectors pointer), it is assumed that sufficient space as already been allocated to dataset1. In either case, QccDatasetCopy() copies the vectors array of dataset2 to the vectors array of dataset1 via QccMatrixCopy(3) .