mathkit
1.5
Main Page
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
include
Matrix.hpp
1
#ifndef MATRIX_HPP
2
#define MATRIX_HPP
3
4
#include "mathkit.hpp"
5
6
namespace
mathkit {
10
typedef
pair<int, int>
Dimen
;
11
15
class
Matrix
{
16
private
:
17
Table
_data;
18
Dimen
_dimen;
19
public
:
23
Matrix
();
24
29
Matrix
(
const
Table
& data);
30
36
Matrix
(
Dimen
dimen
,
double
val = 0);
37
44
Matrix
(
const
Vector
& data,
Dimen
dimen,
bool
byrow =
true
);
45
50
void
setData
(
const
Table
& data);
51
57
void
setData
(
Dimen
dimen,
double
val = 0);
58
65
void
setData
(
const
Vector
& data,
Dimen
dimen,
bool
byrow =
true
);
66
71
Table
getData
()
const
;
72
77
Dimen
dimen
()
const
;
78
86
bool
dimen
(
Dimen
dimen);
87
92
int
nrow
()
const
;
93
98
int
ncol
()
const
;
99
105
Matrix
round
(
int
ndec = 4)
const
;
106
111
bool
square
()
const
;
112
117
bool
symmetric
()
const
;
118
124
Vector
getRow
(
int
m)
const
;
125
131
Vector
getCol
(
int
n)
const
;
132
138
void
setRow
(
int
m,
const
Vector
& row);
139
145
void
setCol
(
int
n,
const
Vector
& col);
146
153
void
exchange
(
int
i,
int
j,
bool
row =
true
);
154
159
Matrix
transpose
()
const
;
160
166
int
rank
(
const
Epsilon
& eps =
Epsilon
())
const
;
167
176
Matrix
submat
(
int
frow,
int
lrow,
int
fcol,
int
lcol);
177
184
Matrix
resid
(
int
i,
int
j)
const
;
185
192
double
&
operator()
(
int
m,
int
n);
193
200
double
operator()
(
int
m,
int
n)
const
;
201
207
Matrix
operator+
(
const
Matrix
& mat)
const
;
208
214
Matrix
operator-
(
const
Matrix
& mat)
const
;
215
221
Matrix
operator*
(
const
Matrix
& mat)
const
;
222
228
bool
operator==
(
const
Matrix
& mat)
const
;
229
235
bool
operator!=
(
const
Matrix
& mat)
const
;
236
};
237
241
typedef
vector<Matrix>
Matrices
;
242
249
Matrix
operator*
(
const
Matrix
& mat,
double
scalar);
250
257
Matrix
operator*
(
double
scalar,
const
Matrix
& mat);
258
265
ostream &
operator<<
(ostream & outs,
const
Matrix
& mat);
266
273
istream &
operator>>
(istream & ins,
Matrix
& mat);
274
280
Matrix
t
(
const
Matrix
& mat);
281
287
Matrix
eye
(
int
n);
288
294
Vector
diag
(
const
Matrix
& mat);
295
301
Matrix
diag
(
const
Vector
& vec);
302
309
double
det
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
310
317
Matrix
inv
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
318
325
double
trace
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
326
333
bool
positive
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
334
342
Table
table
(
const
Vector
& data,
Dimen
dimen,
bool
byrow =
true
);
343
349
Matrix
rowmat
(
const
Vector
& data);
350
356
Matrix
colmat
(
const
Vector
& data);
357
364
Matrix
cbind
(
const
Matrix
& mat1,
const
Matrix
& mat2);
365
372
Matrix
rbind
(
const
Matrix
& mat1,
const
Matrix
& mat2);
373
380
Matrices
lu
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
381
388
Matrices
qr
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
389
397
Vector
linsolve
(
const
Matrix
& mat,
const
Vector
& vec,
const
Epsilon
& eps =
Epsilon
());
398
406
Vector
lusolve
(
const
Matrices
& lup,
const
Vector
& vec,
const
Epsilon
& eps =
Epsilon
());
407
415
Vector
qrsolve
(
const
Matrices
& qrmat,
const
Vector
& vec,
const
Epsilon
& eps =
Epsilon
());
416
424
string
to_str
(
const
Matrix
& mat,
bool
byrow =
true
,
string
delim =
"[]"
);
425
}
426
427
#endif
Generated on Wed Jul 10 2013 09:17:09 for mathkit by
1.8.4