1 #include "../../include/common/monolish_dense.hpp"
2 #include "../../include/common/monolish_logger.hpp"
3 #include "../../include/common/monolish_matrix.hpp"
4 #include "../../include/common/monolish_vector.hpp"
5 #include "../internal/monolish_internal.hpp"
34 std::copy(value, value + nnz, val.begin());
43 Dense<T>::Dense(
const size_t M,
const size_t N,
const std::vector<T> &value) {
51 std::copy(value.begin(), value.end(), val.begin());
55 const std::vector<double> &value);
57 const std::vector<float> &value);
60 Dense<T>::Dense(
const size_t M,
const size_t N,
const vector<T> &value) {
68 std::copy(value.data(), value.data() + nnz, val.begin());
70 if (value.get_device_mem_stat() ==
true) {
73 const T *data = value.data();
75 #pragma omp target teams distribute parallel for
76 for (
size_t i = 0; i < get_nnz(); i++) {
80 throw std::runtime_error(
81 "error USE_GPU is false, but get_device_mem_stat() == true");
88 const vector<double> &value);
90 const vector<float> &value);
94 const std::initializer_list<T> &list) {
102 std::copy(list.begin(), list.end(), val.begin());
106 const std::initializer_list<double> &list);
108 const std::initializer_list<float> &list);
110 template <
typename T>
120 std::random_device random;
121 std::mt19937 mt(random());
122 std::uniform_real_distribution<> rand(
min,
max);
124 #pragma omp parallel for
125 for (
size_t i = 0; i < val.size(); i++) {
135 template <
typename T>
145 #pragma omp parallel for
146 for (
size_t i = 0; i < val.size(); i++) {
160 val.resize(mat.get_nnz());
162 rowN = mat.get_row();
163 colN = mat.get_col();
167 if (mat.get_device_mem_stat()) {
169 internal::vcopy(get_nnz(), mat.val.data(), val.data(),
true);
172 internal::vcopy(get_nnz(), mat.val.data(), val.data(),
false);