mathkit
2.0
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
113
bool
eq
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
())
const
;
114
119
bool
square
()
const
;
120
126
bool
symmetric
(
const
Epsilon
& eps =
Epsilon
())
const
;
127
133
bool
uptri
(
const
Epsilon
& eps =
Epsilon
())
const
;
134
140
bool
lowtri
(
const
Epsilon
& eps =
Epsilon
())
const
;
141
147
bool
diag
(
const
Epsilon
& eps =
Epsilon
())
const
;
148
154
Vector
getRow
(
int
m)
const
;
155
161
Vector
getCol
(
int
n)
const
;
162
168
void
setRow
(
int
m,
const
Vector
& row);
169
175
void
setCol
(
int
n,
const
Vector
& col);
176
183
void
exchange
(
int
i,
int
j,
bool
row =
true
);
184
189
Matrix
transpose
()
const
;
190
196
int
rank
(
const
Epsilon
& eps =
Epsilon
())
const
;
197
206
Matrix
submat
(
int
frow,
int
lrow,
int
fcol,
int
lcol);
207
214
Matrix
resid
(
int
i,
int
j)
const
;
215
222
double
&
operator()
(
int
m,
int
n);
223
230
double
operator()
(
int
m,
int
n)
const
;
231
237
Matrix
operator+
(
const
Matrix
& mat)
const
;
238
244
Matrix
operator-
(
const
Matrix
& mat)
const
;
245
251
Matrix
operator*
(
const
Matrix
& mat)
const
;
252
258
bool
operator==
(
const
Matrix
& mat)
const
;
259
265
bool
operator!=
(
const
Matrix
& mat)
const
;
266
};
267
271
struct
Elim
{
275
vector<int>
pivotcol
;
276
280
vector<int>
freecol
;
281
285
Matrix
coef_mat
;
286
};
287
291
struct
Eigen
{
295
Vector
values
;
296
300
Matrix
vectors
;
301
};
302
306
typedef
vector<Matrix>
Matrices
;
307
314
Matrix
operator*
(
const
Matrix
& mat,
double
scalar);
315
322
Matrix
operator*
(
double
scalar,
const
Matrix
& mat);
323
330
ostream &
operator<<
(ostream & outs,
const
Matrix
& mat);
331
338
istream &
operator>>
(istream & ins,
Matrix
& mat);
339
345
Matrix
t
(
const
Matrix
& mat);
346
352
Matrix
eye
(
int
n);
353
359
Vector
diag
(
const
Matrix
& mat);
360
366
Matrix
diag
(
const
Vector
& vec);
367
374
double
det
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
375
382
Matrix
inv
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
383
390
double
trace
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
391
398
bool
positive
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
399
407
Table
table
(
const
Vector
& data,
Dimen
dimen,
bool
byrow =
true
);
408
414
Matrix
rowmat
(
const
Vector
& data);
415
421
Matrix
colmat
(
const
Vector
& data);
422
429
Matrix
cbind
(
const
Matrix
& mat1,
const
Matrix
& mat2);
430
437
Matrix
rbind
(
const
Matrix
& mat1,
const
Matrix
& mat2);
438
445
Vector
eigval
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
446
453
Eigen
eigen
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
454
461
Matrices
svd
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
462
470
Elim
elim
(
const
Matrix
& mat,
bool
augment =
false
,
const
Epsilon
& eps =
Epsilon
());
471
479
Matrix
nullbasis
(
const
Matrix
& mat,
bool
augment =
false
,
const
Epsilon
& eps =
Epsilon
());
480
487
Matrices
lu
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
488
495
Matrices
qr
(
const
Matrix
& mat,
const
Epsilon
& eps =
Epsilon
());
496
504
Vector
linsolve
(
const
Matrix
& mat,
const
Vector
& vec,
const
Epsilon
& eps =
Epsilon
());
505
513
Vector
lusolve
(
const
Matrices
& lup,
const
Vector
& vec,
const
Epsilon
& eps =
Epsilon
());
514
522
Vector
qrsolve
(
const
Matrices
& qrmat,
const
Vector
& vec,
const
Epsilon
& eps =
Epsilon
());
523
531
Vector
upsolve
(
const
Matrix
& upmat,
const
Vector
& vec,
const
Epsilon
& eps =
Epsilon
());
532
540
string
to_str
(
const
Matrix
& mat,
bool
byrow =
true
,
string
delim =
"[]"
);
541
}
542
543
#endif
Generated on Sun Aug 25 2013 16:48:01 for mathkit by
1.8.4