-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoo.cpp
More file actions
54 lines (46 loc) · 1.07 KB
/
Copy pathcoo.cpp
File metadata and controls
54 lines (46 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// source code of COO format
#include "coo.hpp"
#include "vec.hpp"
namespace coo {
// create a csr matrix
COOMatrix *create(const int n, const int nnz) {
COOMatrix *ptr = nullptr;
// FINISH ME
// allocate ptr
// FINISH ME
return ptr;
}
// destroy a csr matrix
void destroy(COOMatrix *mat) {
if (!mat) return;
// FINISH ME
// deallocate ptr
// FINISH ME
}
// assign a triplet (i,j,v)
bool assign_ijv(COOMatrix &mat, const int i, const int j, const double v,
const int nnz_index) {
bool fail = false;
// FINISH ME
// constructo entry (i,j,v) in slot nnz_index
// FINISH ME
return fail;
}
// extract the diagonal values
bool extract_diag(const COOMatrix &A, vec::DenseVec &diag) {
if (A.n != diag.n) return true;
bool fail = false;
// FINISH ME
// extracting diagonal entries
// FINISH ME
return fail;
}
// matrix vector multiplication
bool mv(const COOMatrix &A, const vec::DenseVec &x, vec::DenseVec &y) {
bool fail = false;
// FINISH ME
// matrix vector multiplication
// FINISH ME
return fail;
}
} // namespace coo