CYCLUS
Loading...
Searching...
No Matches
l_matrix.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// This is the header file for the LMatrix class. Specific class details can
3// be found in the "l_matrix.cc" file. This is the same as the Matrix class
4// except its elements are long doubles.
5//-----------------------------------------------------------------------------
6
7#ifndef CYCLUS_SRC_L_MATRIX_H_
8#define CYCLUS_SRC_L_MATRIX_H_
9
10#include <vector>
11
12namespace cyclus {
13
14class LMatrix {
15 // friend arithmetic operators involving a scalar k and matrix A
16 friend LMatrix operator*(const long double k, const LMatrix& A); // k * A
17 friend LMatrix operator*(const LMatrix& A, const long double k); // A * k
18 friend LMatrix operator^(const LMatrix& A, const int k); // A^k
19
20 public:
21 // constructors
22 LMatrix(); // constructs a 1x1 matrix of zeroes
23 LMatrix(int n, int m); // constructs an nxm matrix of zeroes
24
25 // member access functions
26 int NumRows() const; // returns number of rows
27 int NumCols() const; // returns number of columns
28 const long double& operator()(int i, int j) const; // returns the element aij
29
30 // population functions
31 void SetElement(int i, int j, long double aij); // sets value of element aij
32 long double& operator()(int i, int j); // sets value of element A(i,j)
33 void AddRow(std::vector<long double>
34 row); // adds a row at the end of the Matrix
35
36 // other member functions
37 void Print() const; // prints the matrix
38
39 // assignment operators for matrix objects
40 const LMatrix& operator=(const LMatrix& rhs);
41 const LMatrix& operator+=(const LMatrix& rhs);
42 const LMatrix& operator-=(const LMatrix& rhs);
43 const LMatrix& operator*=(const LMatrix& rhs);
44
45 private:
46 std::vector< std::vector<long double> >
47 M_; // 2D vector containing matrix elements
48 int rows_; // number of rows
49 int cols_; // number of columns
50};
51
52// arithmetic operators for matrix objects A and B
53LMatrix operator+(const LMatrix& lhs, const LMatrix& rhs); // A + B
54LMatrix operator-(const LMatrix& lhs, const LMatrix& rhs); // A - B
55LMatrix operator*(const LMatrix& lhs, const LMatrix& rhs); // A * B
56
57// non-member functions
58LMatrix identity(int n); // creates an nxn identity matrix
59
60} // namespace cyclus
61
62#endif // CYCLUS_SRC_L_MATRIX_H_
const LMatrix & operator*=(const LMatrix &rhs)
Definition l_matrix.cc:176
const LMatrix & operator=(const LMatrix &rhs)
Definition l_matrix.cc:118
void SetElement(int i, int j, long double aij)
Definition l_matrix.cc:74
void AddRow(std::vector< long double > row)
Definition l_matrix.cc:85
int NumCols() const
Definition l_matrix.cc:63
void Print() const
Definition l_matrix.cc:94
const LMatrix & operator-=(const LMatrix &rhs)
Definition l_matrix.cc:157
friend LMatrix operator^(const LMatrix &A, const int k)
Definition l_matrix.cc:269
friend LMatrix operator*(const long double k, const LMatrix &A)
Definition l_matrix.cc:234
const long double & operator()(int i, int j) const
Definition l_matrix.cc:69
int NumRows() const
Definition l_matrix.cc:58
const LMatrix & operator+=(const LMatrix &rhs)
Definition l_matrix.cc:142
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
LMatrix operator-(const LMatrix &lhs, const LMatrix &rhs)
Definition l_matrix.cc:218
LMatrix operator+(const LMatrix &lhs, const LMatrix &rhs)
Definition l_matrix.cc:210
LMatrix identity(int n)
Definition l_matrix.cc:284
LMatrix operator*(const LMatrix &lhs, const LMatrix &rhs)
Definition l_matrix.cc:226
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters