54 const std::vector<T> &
B,
60 for (
int i = 0; i <
rows; ++i) {
61 for (
int j = 0; j <
cols; ++j) {
71 const std::vector<int> &
B,
75 const std::vector<double> &
B,
76 std::vector<double> &
C);
79 const std::vector<float> &
B,
80 std::vector<float> &
C);
90 const std::vector<std::vector<T>> &
B,
91 std::vector<std::vector<T>> &
C) {
92 const int size =
A.size();
94 for (
int i = 0; i < size; ++i) {
95 for (
int j = 0; j < size; ++j) {
97 C[i][j] =
A[i][j] +
B[i][j];
105 const std::vector<std::vector<int>> &
B,
106 std::vector<std::vector<int>> &
C);
110 const std::vector<std::vector<double>> &
B,
111 std::vector<std::vector<double>> &
C);
115 const std::vector<std::vector<float>> &
B,
116 std::vector<std::vector<float>> &
C);
119 template <
typename T>
121 const std::vector<std::vector<T>> &
B,
122 std::vector<std::vector<T>> &
C) {
123 const int size =
A.size();
125 for (
int i = 0; i < size; ++i) {
126 for (
int j = 0; j < size; ++j) {
128 C[i][j] =
A[i][j] -
B[i][j];
136 const std::vector<std::vector<int>> &
B,
137 std::vector<std::vector<int>> &
C);
141 const std::vector<std::vector<double>> &
B,
142 std::vector<std::vector<double>> &
C);
146 const std::vector<std::vector<float>> &
B,
147 std::vector<std::vector<float>> &
C);
150 template <
typename T>
152 const std::vector<std::vector<T>> &
B,
153 std::vector<std::vector<T>> &
C) {
154 assert(
A.size() ==
B.size());
155 assert(
A[0].size() ==
B[0].size());
157 int64_t nrows =
A.size();
158 int64_t ncols =
A[0].size();
160 for (int64_t i = 0; i < nrows; ++i) {
161 for (int64_t j = 0; j < ncols; ++j) {
163 for (int64_t k = 0; k < ncols; ++k) {
164 C[i][j] +=
A[i][k] *
B[k][j];
173 const std::vector<std::vector<int>> &
B,
174 std::vector<std::vector<int>> &
C);
178 const std::vector<std::vector<double>> &
B,
179 std::vector<std::vector<double>> &
C);
183 const std::vector<std::vector<float>> &
B,
184 std::vector<std::vector<float>> &
C);
void std_mtx_mult(const T *A, const T *B, U *C, int rows_a, int cols_a, int cols_b)
void std_mtx_add(const T *A, const T *B, T *C, int rows, int cols)
Perform matrix addition on two matrices as flat arrays.
void std_mtx_sub(const T *A, const T *B, T *C, int rows, int cols)
Perform matrix subtraction on two matrices as flat arrays.