So Im doing so Matrix calculations/conversions right now and now an assertion error showed up.
I started implementing a Matrix-CRS-Conversion and the program works just fine:
uint32_t size = 0;
for (uint32_t i = 0; i < ROWS; i++)
{
for (uint32_t j = 0; j < COLUMNS; j++)
{
if(Matrix[i][j] != 0)
size++;
}
}
// Allocating memory for CRS
uint32_t *values = (uint32_t*)malloc(size * sizeof(uint32_t));
uint32_t *columnindex = (uint32_t*)malloc(size * sizeof(uint32_t));
uint32_t *rowchange = (uint32_t*)malloc(ROWS+1 * sizeof(uint32_t));
uint32_t position = 0;
uint32_t rowPtr = 0;
rowchange[0] = 0;
rowchange[ROWS] = size;
for (uint32_t i = 0; i < ROWS; i++)
{
for (uint32_t j = 0; j < COLUMNS; j++)
{
if(Matrix[i][j] != 0) {
values[position] = Matrix[i][j];
columnindex[position] = j;
position++;
}
}
rowPtr++;
if(rowPtr != ROWS)
rowchange[rowPtr] = position;
}
When I print out the results everything is correct as intended.
Now I wanted to implement a matrix-vector-multiplication and I started allocating memory for a vector to multiplicate and a result vector:
uint32_t *multvector = (uint32_t*)malloc(ROWS * sizeof(uint32_t));
uint32_t *result = (uint32_t*)malloc(ROWS * sizeof(uint32_t));
I did it in the same way as above but now I get an Assertion error:
Matrix: malloc.c:2385: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
I have no idea why.