41 #if defined(__GPMP_PYTHON_API__)
42 #define __PYTHON_API__
44 #include <boost/bind/bind.hpp>
45 #include <boost/python.hpp>
46 #include <boost/python/numpy.hpp>
60 #if defined(__GPMP_PYTHON_API__)
63 #include <boost/bind/bind.hpp>
64 #include <boost/python.hpp>
65 #include <boost/python/numpy.hpp>
70 void mtx_add(
const boost::python::numpy::ndarray &
A,
71 const boost::python::numpy::ndarray &
B,
72 boost::python::numpy::ndarray &
C,
77 #elif defined(__GPMP_CPP_API__)
92 void mtx_mult_f90(
int *
A,
106 #if defined(__x86_64__) || defined(i386) || defined(__i386__) || \
107 defined(__i386) || defined(__amd64__) || defined(__amd64)
118 mtx_add(
const int8_t *
A,
const int8_t *
B, int8_t *
C,
int rows,
int cols);
130 mtx_add(
const int16_t *
A,
const int16_t *
B, int16_t *
C,
int rows,
int cols);
140 void mtx_add(
const int *
A,
const int *
B,
int *
C,
int rows,
int cols);
152 mtx_add(
const double *
A,
const double *
B,
double *
C,
int rows,
int cols);
163 void mtx_add(
const float *
A,
const float *
B,
float *
C,
int rows,
int cols);
174 void mtx_add(
const std::vector<std::vector<int>> &
A,
175 const std::vector<std::vector<int>> &
B,
176 std::vector<std::vector<int>> &
C);
187 void mtx_add(
const std::vector<std::vector<double>> &
A,
188 const std::vector<std::vector<double>> &
B,
189 std::vector<std::vector<double>> &
C);
200 void mtx_add(
const std::vector<std::vector<float>> &
A,
201 const std::vector<std::vector<float>> &
B,
202 std::vector<std::vector<float>> &
C);
214 mtx_sub(
const int8_t *
A,
const int8_t *
B, int8_t *
C,
int rows,
int cols);
226 mtx_sub(
const int16_t *
A,
const int16_t *
B, int16_t *
C,
int rows,
int cols);
236 void mtx_sub(
const int *
A,
const int *
B,
int *
C,
int rows,
int cols);
248 mtx_sub(
const double *
A,
const double *
B,
double *
C,
int rows,
int cols);
259 void mtx_sub(
const float *
A,
const float *
B,
float *
C,
int rows,
int cols);
322 void mtx_tpose(
const int *
A,
int *
C,
int rows,
int cols);
333 void mtx_sub(
const std::vector<std::vector<int>> &
A,
334 const std::vector<std::vector<int>> &
B,
335 std::vector<std::vector<int>> &
C);
346 void mtx_sub(
const std::vector<std::vector<double>> &
A,
347 const std::vector<std::vector<double>> &
B,
348 std::vector<std::vector<double>> &
C);
359 void mtx_mult(
const std::vector<std::vector<int>> &
A,
360 const std::vector<std::vector<int>> &
B,
361 std::vector<std::vector<int>> &
C);
372 void mtx_mult(
const std::vector<std::vector<double>> &
A,
373 const std::vector<std::vector<double>> &
B,
374 std::vector<std::vector<double>> &
C);
381 void mtx_tpose(std::vector<std::vector<int>> &matrix);
389 void mtx_tpose(std::vector<std::vector<double>> &matrix);
394 #elif defined(__ARM_ARCH_ISA_A64) || defined(__ARM_NEON) || \
395 defined(__ARM_ARCH) || defined(__aarch64__)
405 void mtx_add(
const std::vector<std::vector<int>> &
A,
406 const std::vector<std::vector<int>> &
B,
407 std::vector<std::vector<int>> &
C);
418 void mtx_add(
const std::vector<std::vector<float>> &
A,
419 const std::vector<std::vector<float>> &
B,
420 std::vector<std::vector<float>> &
C);
431 void mtx_sub(
const std::vector<std::vector<int>> &
A,
432 const std::vector<std::vector<int>> &
B,
433 std::vector<std::vector<int>> &
C);
444 void mtx_sub(
const std::vector<std::vector<float>> &
A,
445 const std::vector<std::vector<float>> &
B,
446 std::vector<std::vector<float>> &
C);
457 void mtx_mult(
const std::vector<std::vector<int>> &
A,
458 const std::vector<std::vector<int>> &
B,
459 std::vector<std::vector<int>> &
C);
470 void mtx_mult(
const std::vector<std::vector<double>> &
A,
471 const std::vector<std::vector<double>> &
B,
472 std::vector<std::vector<double>> &
C);
488 void mtx_tpose(std::vector<std::vector<int>> &matrix);
496 void mtx_tpose(std::vector<std::vector<double>> &matrix);
509 template <
typename T>
512 for (
int i = 0; i <
rows; ++i) {
513 for (
int j = 0; j <
cols; ++j) {
528 template <
typename T>
531 for (
int i = 0; i <
rows; ++i) {
532 for (
int j = 0; j <
cols; ++j) {
539 template <
typename T,
typename U>
546 for (
int i = 0; i < rows_a; ++i) {
547 for (
int j = 0; j < cols_b; ++j) {
549 for (
int k = 0; k < cols_a; ++k) {
550 sum +=
A[i * cols_a + k] *
B[k * cols_b + j];
552 C[i * cols_b + j] = sum;
557 template <
typename T>
559 for (
int i = 0; i <
rows; ++i) {
560 for (
int j = 0; j <
cols; ++j) {
572 template <
typename T>
574 const std::vector<T> &
B,
584 template <
typename T>
586 const std::vector<std::vector<T>> &
B,
587 std::vector<std::vector<T>> &
C);
596 template <
typename T>
598 const std::vector<std::vector<T>> &
B,
599 std::vector<std::vector<T>> &
C);
608 template <
typename T>
610 const std::vector<std::vector<T>> &
B,
611 std::vector<std::vector<T>> &
C);
Mtx class offers matrix arithmetic operations. Some methods are element-wise while others make use of...
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.
void std_mtx_tpose(const T *A, T *At, int rows, int cols)
void mtx_mult(std::vector< double > A, std::vector< double > B, std::vector< double > C)
The source C++ openGPMP namespace.