NANA
matrix.h
浏览该文件的文档.
1#pragma once
2
16#include "core_global.h"
17#include "error.h"
18#include "nadef.hpp"
19
20
21namespace NANA {
22
25
27
32public:
38 };
39
40 Matrix();
41
49 Matrix(int rows, int cols);
50
55 Matrix(const Matrix& M);
56
63 Matrix(int m, int n,NAFLOAT const * val);
64
68 virtual ~Matrix();
69
74 int cols() const;
75
80 int rows() const;
81
82
91 Matrix getMat(int i1, int j1, int i2 = -1, int j2 = -1);
92
99 void setMat(const Matrix& M, int i, int j);
100
105 static void setMatrixEye(Matrix& mat, const int m);
106
107
115 static void LU(const Matrix& A, Matrix& L, Matrix& U);
116
123 static void QR(const Matrix& A, Matrix& Q, Matrix& R);
124
125
126
135 static void SVD( const Matrix & A, Matrix& U, Matrix& W, Matrix& v);
136
144 static void solve(const Matrix& A, const Matrix& b, Matrix& x, int flag = DecompositionMethod::GaussiaJordan);
145
152 static Matrix zeros(int rows, int cols);
153
158 void fill(const NAFLOAT& value);
159
164 NAFLOAT** getValPtr() const;
165
170 const NAFLOAT** getConstValPtr() const;
171
172
177 Matrix T() const;
178
184 Matrix& operator= (const Matrix& M);
185
191 const NAFLOAT* operator[](int row) const;
192
198 Matrix operator+ (const Matrix& B);
199
200
206 Matrix operator- (const Matrix& M);
207
213 Matrix operator* (const Matrix& B);
214
220 Matrix dot(const Matrix& B) const;
221
222
223
229 Matrix dot(NAFLOAT b) const;
230
236 Matrix inv(int flag = GaussiaJordan) const;
237
243 NAFLOAT det() const;
244
250 int rank() const;
251
258 friend NA_API std::istream& operator>>(std::istream& is, Matrix& m);
259
266 friend NA_API std::ostream& operator<< (std::ostream& out, const Matrix& M);
267
268
269
270
276 void create(int rows, int cols);
277
282 void release();
283
284protected:
286 NAFLOAT** m_val;
287 NAFLOAT* m_data;
288
295};
296
298
302public:
303 SparseMatrix();
304
305private:
306
307
308};
309
310
313
317public:
318 CMatrix();
322 virtual ~CMatrix();
323
329 void create(int rows, int cols);
330
331
336 void release();
337private:
338 NAFLOAT* m_redata;
339 NAFLOAT* m_imdata;
340 NAFLOAT** m_reval;
341 NAFLOAT** m_imval;
342 int m_rows;
343 int m_cols;
344 int m_step;
345
346};
347
348
349
350
351
352
354}
355
356
复数矩阵
Definition: matrix.h:316
简单矩阵类
Definition: matrix.h:31
NAFLOAT ** m_val
矩阵的数据
Definition: matrix.h:286
DecompositionMethod
枚举矩阵的各种分解方法
Definition: matrix.h:36
@ GaussiaJordan
高斯-约当消去法
Definition: matrix.h:37
int m_rows
行数
Definition: matrix.h:290
int m_cols
列数
Definition: matrix.h:292
int m_step
步长
Definition: matrix.h:294
稀疏矩阵
Definition: matrix.h:301
全局头文件
#define NA_API
兼容windows系统与linux系统
Definition: core_global.h:24
用于抛出异常,移植自OpenCV
std::istream & operator>>(std::istream &is, Matrix &m)
Definition: matrix.cpp:836
数值分析所依赖的定义