aboutsummaryrefslogtreecommitdiff
path: root/src/types.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-11-02 23:56:19 +0000
committergingerBill <bill@gingerbill.org>2021-11-02 23:56:19 +0000
commitc20230509f61755698e4c0761bc721e0ee016b83 (patch)
tree34c2ec61beeaba7941d67cdb23e1f891bdfa9b91 /src/types.cpp
parentf03e0bee73f2ef6aa28ab4e2b242af5521e45d4d (diff)
Correct index to offset calculation for matrix compound literalsdev-2021-11
Diffstat (limited to 'src/types.cpp')
-rw-r--r--src/types.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/types.cpp b/src/types.cpp
index bfedb5381..52bb2e324 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -1408,12 +1408,13 @@ i64 matrix_indices_to_offset(Type *t, i64 row_index, i64 column_index) {
i64 stride_elems = matrix_type_stride_in_elems(t);
return stride_elems*column_index + row_index;
}
-i64 matrix_index_to_offset(Type *t, i64 index) {
+
+i64 matrix_row_major_index_to_offset(Type *t, i64 index) {
t = base_type(t);
GB_ASSERT(t->kind == Type_Matrix);
- i64 row_index = index%t->Matrix.row_count;
- i64 column_index = index/t->Matrix.row_count;
+ i64 column_index = index%t->Matrix.column_count;
+ i64 row_index = index/t->Matrix.column_count;
return matrix_indices_to_offset(t, row_index, column_index);
}