Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60720230
matrix.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
Thu, May 2, 04:37
Size
582 B
Mime Type
text/x-c++
Expires
Sat, May 4, 04:37 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17402226
Attached To
R12662 PHPC-graded_hw_1
matrix.hh
View Options
#include <string>
#include <vector>
#ifndef __MATRIX_H_
#define __MATRIX_H_
class Matrix {
public:
Matrix(int m = 0, int n = 0) : m_m(m), m_n(n), m_a(m * n) {}
void resize(int m, int n) {
m_m = m;
m_n = n;
m_a.resize(m * n);
}
inline double & operator()(int i, int j) { return m_a[i * m_n + j]; }
inline int m() const { return m_m; }
inline int n() const { return m_n; }
inline double * data() { return m_a.data(); }
void read(const std::string & filename);
private:
int m_m{0};
int m_n{0};
std::vector<double> m_a;
};
#endif // __MATRIX_H_
Event Timeline
Log In to Comment