-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSafeArray.cpp
More file actions
28 lines (25 loc) · 1.16 KB
/
SafeArray.cpp
File metadata and controls
28 lines (25 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "SafeArray.h"
#include <cstddef>
template <typename T, unsigned int N>
void ArrayMulTemplate(const SafeArray<T, N> &matrixA,
const SafeArray<T, N> &matrixB, SafeArray<T, N> &result,
size_t dimension) {
for (size_t i = 0; i < dimension; ++i) {
for (size_t j = 0; j < dimension; ++j) {
for (size_t k = 0; k < dimension; ++k) {
result[i * dimension + j] +=
matrixA[i * dimension + k] * matrixB[k * dimension + j];
}
}
}
}
// Explicit template instantiation
template void ArrayMulTemplate<int, 64>(const SafeArray<int, 64> &,
const SafeArray<int, 64> &,
SafeArray<int, 64> &, size_t);
template void ArrayMulTemplate<int, 256>(const SafeArray<int, 256> &,
const SafeArray<int, 256> &,
SafeArray<int, 256> &, size_t);
template void ArrayMulTemplate<int, 1024>(const SafeArray<int, 1024> &,
const SafeArray<int, 1024> &,
SafeArray<int, 1024> &, size_t);