linearAlgebraSolverLib
Loading...
Searching...
No Matches
sparseMatrixCSR.hpp
1#pragma once
2
3// preprocessor statements
4#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
5 #if defined(COMPILEDLL)
6 #define LINEARALGEBRALIB_EXPORT __declspec(dllexport)
7 #elif defined(COMPILELIB)
8 #define LINEARALGEBRALIB_EXPORT
9 #else
10 #define LINEARALGEBRALIB_EXPORT __declspec(dllimport)
11 #endif
12#else
13 #define LINEARALGEBRALIB_EXPORT
14#endif
15
16// c++ include headers
17#include <iostream>
18#include <algorithm>
19#include <vector>
20#include <cassert>
21
22// third-party include headers
23
24// linear algebra solver library include headers
25#include "linearAlgebraLib/src/vector.hpp"
26
27// helper classes
28
29namespace linearAlgebraLib {
30
46
48
51public:
52 LINEARALGEBRALIB_EXPORT SparseMatrixCSR(unsigned rows, unsigned _columns);
54
57
59
62public:
63 LINEARALGEBRALIB_EXPORT void set(unsigned row, unsigned column, double value);
64 LINEARALGEBRALIB_EXPORT double get(unsigned row, unsigned column) const;
65
66 LINEARALGEBRALIB_EXPORT unsigned getNumberOfRows() const;
67 LINEARALGEBRALIB_EXPORT unsigned getNumberOfColumns() const;
69
72public:
73 LINEARALGEBRALIB_EXPORT Vector operator*(const Vector& rhs);
74 LINEARALGEBRALIB_EXPORT friend SparseMatrixCSR operator*(const double &scaleFactor, const SparseMatrixCSR &matrix);
75 LINEARALGEBRALIB_EXPORT friend std::ostream &operator<<(std::ostream &os, const SparseMatrixCSR &rhs);
77
80
82
85private:
86 std::vector<double> _values;
87 std::vector<unsigned> _columns;
88 std::vector<unsigned> _rows;
89 unsigned _numberOfRows;
90 unsigned _numberOfColumns;
92};
93
94} // namespace linearAlgebraLib
A matrix class with overloaded operators to facilitate arithmetic matrix operations.
Definition sparseMatrixCSR.hpp:43
A vector class with overloaded operators to facilitate arithmetic vector operations.
Definition vector.hpp:41