Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86455793
cg.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Oct 6, 14:42
Size
992 B
Mime Type
text/x-c++
Expires
Tue, Oct 8, 14:42 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
21426419
Attached To
R12662 PHPC-graded_hw_1
cg.hh
View Options
#include "matrix.hh"
#include "matrix_coo.hh"
#include <cblas.h>
#include <string>
#include <vector>
#ifndef __CG_HH__
#define __CG_HH__
class Solver {
public:
virtual void read_matrix(const std::string & filename) = 0;
void init_source_term(double h);
virtual void solve(std::vector<double> & x) = 0;
inline int m() const { return m_m; }
inline int n() const { return m_n; }
void tolerance(double tolerance) { m_tolerance = tolerance; }
protected:
int m_m{0};
int m_n{0};
std::vector<double> m_b; // Resides on ROOT process
std::vector<double> m_b_loc;
double m_tolerance{1e-10};
/* MPI parameters */
std::vector<int> m_workloads;
int m_prank, m_psize, m_pstart, m_pend, m_chunk_size;
std::vector<int> m_displs;
};
class CGSolver : public Solver {
public:
CGSolver() = default;
virtual void read_matrix(const std::string & filename);
virtual void solve(std::vector<double> & x);
private:
Matrix m_A;
Matrix m_A_loc;
};
#endif /* __CG_HH__ */
Event Timeline
Log In to Comment