Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_matrix.hpp
1/*
2 * Copyright (C) 2002-2013, Matrix Science Limited, London, UK.
3 * All rights reserved.
4 *
5 * @(#)$Source: parser/inc/ms_matrix.hpp $
6 * @(#)$Revision: 436aa2996c6a3d2d2f0cdb88fab902c2780ae29a | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $
7 * @(#)$Date: 2019-05-16 11:53:33 +0100 $
8 */
9
10#ifndef MS_MATRIX_HPP
11#define MS_MATRIX_HPP
12
13
14#include <vector>
15
16namespace matrix_science
17{
24
35 class MS_MASCOTRESFILE_API ms_matrix
36 {
37 public:
38
39 typedef std::vector<double> column_vector_t;
40 typedef std::vector<column_vector_t> matrix_t;
41
43 static ms_matrix diagonalMatrix(size_t s, double v);
44
46 static ms_matrix identityMatrix(size_t s);
47
49 static ms_matrix rowMatrix(const std::vector<double> & v);
50
52 static ms_matrix columnMatrix(const std::vector<double> & v);
53
55 ms_matrix();
56
58 ms_matrix(const matrix_t & m);
59
61 ms_matrix(size_t si, size_t sj, double v = 0.0);
62
64 size_t sizei() const;
65
67 size_t sizej() const;
68
69#ifndef SWIG
71 column_vector_t & operator[](size_t i);
72
74 const column_vector_t & operator[](size_t i) const;
75#endif
77 double getCR(size_t i, size_t j) const;
79 void setCR(size_t i, size_t j, double value);
80
82 double getRC(size_t i, size_t j) const { return getCR(j, i); }
84 void setRC(size_t i, size_t j, double value) { setCR(j, i, value); }
85
87 const matrix_t & data() const;
88#ifndef SWIG
90 bool operator==(const ms_matrix & m) const;
91
93 bool operator!=(const ms_matrix & m) const;
94
96 ms_matrix operator*(const ms_matrix & m) const;
97#endif
99 bool isZero() const;
100
102 void resize(size_t si, size_t sj, double v = 0.0);
103
105 double multiplyByRow(const std::vector<double> & column, size_t row) const;
106
108 void setColumnDown(size_t row, size_t col, const std::vector<double> & vec);
109
111 void setColumnUp(size_t row, size_t col, const std::vector<double> & vec);
112
114 void transpose();
115
117 void logContents(ms_errs & errs, const char * description) const;
118
119 private:
120 matrix_t matrix_;
121 };
122 // end of tools_group
124} // namespace matrix_science
125
126#endif // MS_MATRIX_HPP
127
128/*------------------------------- End of File -------------------------------*/
All errors are collected in an instance of this class.
Definition: ms_errors.hpp:37
A two-dimensional matrix of numbers.
Definition: ms_matrix.hpp:36
double getRC(size_t i, size_t j) const
Get the value for the specified row and column.
Definition: ms_matrix.hpp:82
void setRC(size_t i, size_t j, double value)
Set the value for the specified row and column.
Definition: ms_matrix.hpp:84