Digital Signal Processing LibraryVoice LabProgram name: matrix_reallocate Language: C In file: vector_lib.c Objective: reallocate memory for a list of vectors Usage: void matrix_reallocate(double ***matrix, double **matrix_data_ptr, int vector_width, int number_vectors_max); Parameters:
Mathematical Description: Comments: Routine is used to reallocate memory for a list of vectors Code: void matrix_reallocate(double ***matrix, double **matrix_data_ptr, int vector_width, int *number_vectors_max) { int i; /* increase maximum number of vectors permitted */ (*number_vectors_max) += ADDITIONAL_QUANTITY; /* reallocate space for reading in the additional vectors */ (*matrix_data_ptr) = realloc((*matrix_data_ptr), (*number_vectors_max) * vector_width * sizeof(double)); if((*matrix_data_ptr) == NULL) { fprintf(stderr, "Cannot allocate memory for data\n"); exit(1); } /* reallocate space for pointers to the additional vectors */ *matrix = realloc(*matrix, (*number_vectors_max) * sizeof(double *)); if(*matrix == NULL) { fprintf(stderr, "Cannot allocate memory for data\n"); exit(1); } /* set pointers to point to array of data */ for(i = 0; i < (*number_vectors_max); i++) { (*matrix)[i] = (*matrix_data_ptr) + (i * vector_width); } } |
English Version > Documents and tutorials > D.Sc. projects > Routines for DSP > vector_lib >