1 #include "../../../include/monolish_blas.hpp"
2 #include "../../internal/monolish_internal.hpp"
8 template <
typename T>
void COO<T>::diag(vector<T> &vec)
const {
12 size_t s = get_row() > get_col() ? get_col() : get_row();
13 assert(s == vec.size());
15 for (
size_t i = 0; i < vec.size(); i++) {
19 for (
size_t nz = 0; nz < get_nnz(); ++nz) {
20 if (get_row_ptr()[nz] == get_col_ind()[nz]) {
21 vec[get_row_ptr()[nz]] = get_val_ptr()[nz];
30 template <
typename T>
void COO<T>::diag(view1D<vector<T>, T> &vec)
const {
34 size_t s = get_row() > get_col() ? get_col() : get_row();
35 assert(s == vec.size());
37 for (
size_t i = 0; i < vec.size(); i++) {
41 for (
size_t nz = 0; nz < get_nnz(); ++nz) {
42 if (get_row_ptr()[nz] == get_col_ind()[nz]) {
43 vec[get_row_ptr()[nz]] = get_val_ptr()[nz];
54 void COO<T>::diag(view1D<matrix::Dense<T>, T> &vec)
const {
58 size_t s = get_row() > get_col() ? get_col() : get_row();
59 assert(s == vec.size());
61 for (
size_t i = 0; i < vec.size(); i++) {
65 for (
size_t nz = 0; nz < get_nnz(); ++nz) {
66 if (get_row_ptr()[nz] == get_col_ind()[nz]) {
67 vec[get_row_ptr()[nz]] = get_val_ptr()[nz];
74 view1D<matrix::Dense<double>,
double> &vec)
const;
76 view1D<matrix::Dense<float>,
float> &vec)
const;
79 template <
typename T>
void COO<T>::row(
const size_t r, vector<T> &vec)
const {
83 assert(get_col() == vec.size());
85 for (
size_t i = 0; i < vec.size(); i++) {
89 for (
size_t nz = 0; nz < get_nnz(); ++nz) {
90 if (get_row_ptr()[nz] ==
static_cast<int>(r)) {
91 vec[get_col_ind()[nz]] = get_val_ptr()[nz];
97 vector<double> &vec)
const;
99 vector<float> &vec)
const;
101 template <
typename T>
102 void COO<T>::row(
const size_t r, view1D<vector<T>, T> &vec)
const {
106 assert(get_col() == vec.size());
108 for (
size_t i = 0; i < vec.size(); i++) {
112 for (
size_t nz = 0; nz < get_nnz(); ++nz) {
113 if (get_row_ptr()[nz] ==
static_cast<int>(r)) {
114 vec[get_col_ind()[nz]] = get_val_ptr()[nz];
121 view1D<vector<double>,
double> &vec)
const;
124 view1D<vector<float>,
float> &vec)
const;
126 template <
typename T>
127 void COO<T>::row(
const size_t r, view1D<matrix::Dense<T>, T> &vec)
const {
131 assert(get_col() == vec.size());
133 for (
size_t i = 0; i < vec.size(); i++) {
137 for (
size_t nz = 0; nz < get_nnz(); ++nz) {
138 if (get_row_ptr()[nz] ==
static_cast<int>(r)) {
139 vec[get_col_ind()[nz]] = get_val_ptr()[nz];
145 const size_t r, view1D<matrix::Dense<double>,
double> &vec)
const;
147 const size_t r, view1D<matrix::Dense<float>,
float> &vec)
const;
150 template <
typename T>
void COO<T>::col(
const size_t c, vector<T> &vec)
const {
154 assert(get_row() == vec.size());
156 for (
size_t i = 0; i < vec.size(); i++) {
160 for (
size_t nz = 0; nz < get_nnz(); ++nz) {
161 if (get_col_ind()[nz] ==
static_cast<int>(c)) {
162 vec[get_row_ptr()[nz]] = get_val_ptr()[nz];
168 vector<double> &vec)
const;
170 vector<float> &vec)
const;
172 template <
typename T>
173 void COO<T>::col(
const size_t c, view1D<vector<T>, T> &vec)
const {
177 assert(get_row() == vec.size());
179 for (
size_t i = 0; i < vec.size(); i++) {
183 for (
size_t nz = 0; nz < get_nnz(); ++nz) {
184 if (get_col_ind()[nz] ==
static_cast<int>(c)) {
185 vec[get_row_ptr()[nz]] = get_val_ptr()[nz];
192 view1D<vector<double>,
double> &vec)
const;
195 view1D<vector<float>,
float> &vec)
const;
197 template <
typename T>
198 void COO<T>::col(
const size_t c, view1D<matrix::Dense<T>, T> &vec)
const {
202 assert(get_row() == vec.size());
204 for (
size_t i = 0; i < vec.size(); i++) {
208 for (
size_t nz = 0; nz < get_nnz(); ++nz) {
209 if (get_col_ind()[nz] ==
static_cast<int>(c)) {
210 vec[get_row_ptr()[nz]] = get_val_ptr()[nz];
216 const size_t c, view1D<matrix::Dense<double>,
double> &vec)
const;
218 const size_t c, view1D<matrix::Dense<float>,
float> &vec)
const;