Skip to content

Rows vs Cols indexing #1

Description

@zahirtezcan-bugs

Two dimensional array access should be similar to:
array[(rowIndex * columnCount) + columnIndex]

But for example:

for(int i = 0; i < cols; i++)
{
for(int j = 0; j < rows; j++)
{
array[(i * cols) + j]++;
}
}

which is
array[(columnIndex * columnCount) + rowIndex]

The results seem to be aligned with your course outline because one of them is using the outer loop index while other uses the inner loop. But that will need a fix when you have different column and row counts. It is useful to have different counts, if you want to keep the array size same and increase column size to see the effect of different levels of cache.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions