1 #include "../../include/common/monolish_dense.hpp"
2 #include "../../include/common/monolish_logger.hpp"
3 #include "../../include/common/monolish_matrix.hpp"
4 #include "../internal/monolish_internal.hpp"
14 COO<T>::COO(
const size_t M,
const size_t N,
const size_t NNZ,
const int *row,
15 const int *col,
const T *value) {
22 row_index.resize(nnz);
23 col_index.resize(nnz);
26 std::copy(row, row + nnz, row_index.begin());
27 std::copy(col, col + nnz, col_index.begin());
28 std::copy(value, value + nnz, val.begin());
32 const int *row,
const int *col,
const double *value);
33 template COO<float>::COO(
const size_t M,
const size_t N,
const size_t NNZ,
34 const int *row,
const int *col,
const float *value);
37 COO<T>::COO(
const size_t M,
const size_t N,
const size_t NNZ,
const int *row,
38 const int *col,
const T *value,
const size_t origin) {
45 row_index.resize(nnz);
46 col_index.resize(nnz);
49 std::copy(row, row + nnz, row_index.begin());
50 std::copy(col, col + nnz, col_index.begin());
51 std::copy(value, value + nnz, val.begin());
53 #pragma omp parallel for
54 for (
size_t i = 0; i < nnz; i++) {
55 row_index[i] -= origin;
56 col_index[i] -= origin;
61 const int *row,
const int *col,
const double *value,
63 template COO<float>::COO(
const size_t M,
const size_t N,
const size_t NNZ,
64 const int *row,
const int *col,
const float *value,
67 template <
typename T>
COO<T>::COO(
const matrix::COO<T> &coo) {
74 row_index.resize(nnz);
75 col_index.resize(nnz);
77 std::copy(coo.row_index.data(), coo.row_index.data() + nnz,
79 std::copy(coo.col_index.data(), coo.col_index.data() + nnz,
81 std::copy(coo.val.data(), coo.val.data() + nnz, val.begin());