diff options
| author | gingerBill <bill@gingerbill.org> | 2021-11-08 12:15:57 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-11-08 12:15:57 +0000 |
| commit | a674e842d099e9676bcd9ef54d325876d51f09a1 (patch) | |
| tree | 3c89a6ed35ea3e4ec0d685b8fff0aa51e1613510 /src/types.cpp | |
| parent | 23f0fbc376bc4065d0d9391415e10ea6d9b43d96 (diff) | |
Improve matrix indices to offset logic
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/types.cpp b/src/types.cpp index 652d383ee..e609815c6 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1406,15 +1406,16 @@ i64 matrix_indices_to_offset(Type *t, i64 row_index, i64 column_index) { GB_ASSERT(0 <= row_index && row_index < t->Matrix.row_count); GB_ASSERT(0 <= column_index && column_index < t->Matrix.column_count); i64 stride_elems = matrix_type_stride_in_elems(t); - return stride_elems*column_index + row_index; + // NOTE(bill): Column-major layout internally + return row_index + stride_elems*column_index; } i64 matrix_row_major_index_to_offset(Type *t, i64 index) { t = base_type(t); GB_ASSERT(t->kind == Type_Matrix); - i64 column_index = index%t->Matrix.column_count; i64 row_index = index/t->Matrix.column_count; + i64 column_index = index%t->Matrix.column_count; return matrix_indices_to_offset(t, row_index, column_index); } i64 matrix_column_major_index_to_offset(Type *t, i64 index) { |