ECF
1.5
D:
Projekt
ECF_trunk
examples
iprojekt
matrice.h
1
2
// Deklaracija razreda Matrica, SLAJ, LUdek, Vektor3D
4
5
#ifndef matrica_h
6
#define matrica_h
7
8
#include <stdlib.h>
9
#include <stdio.h>
10
#include <assert.h>
11
#include <math.h>
12
#include <memory.h>
13
14
class
Matrica
15
{
16
protected
:
17
int
row,col;
18
//double **data;
19
void
Take(
void
);
20
void
Free(
void
);
21
public
:
22
double
**data;
// zbog ocajnickog ubrzavanja
23
Matrica
Transpose(
int
);
24
Matrica
();
25
Matrica
(
int
,
int
);
26
Matrica
(
Matrica
&);
27
~Matrica
();
28
double
Get(
int
,
int
)
const
;
29
double
Get(
int
)
const
;
30
double
Set(
int
,
int
,
double
);
31
double
Set(
int
,
double
);
32
double
Norm(
void
);
33
int
GetRow(
void
)
const
;
34
int
GetCol(
void
)
const
;
35
int
CopyColumn(
int
,
Matrica
&);
36
int
SetColumn(
int
,
Matrica
&);
37
Matrica
& operator= (
Matrica
&);
38
Matrica
operator+ (
Matrica
&);
39
Matrica
operator+ (
double
);
40
void
operator+= (
Matrica
&);
41
Matrica
operator- (
const
Matrica
&);
42
void
operator-= (
Matrica
&);
43
Matrica
operator* (
const
Matrica
&);
44
Matrica
operator* (
const
double
&);
45
Matrica
operator/ (
const
double
&);
46
Matrica
operator~ ();
// transponiranje
47
double
* operator[](
const
int
redak);
48
void
Reset(
int
,
int
=1);
49
void
Init(
int
,
int
=1);
50
int
Load(
const
char
*);
51
void
Save(
const
char
*);
52
void
SaveLong(
const
char
* fname);
53
void
Show(
void
);
54
};
55
56
inline
int
Matrica::GetRow(
void
)
const
57
{
return
row; }
58
59
inline
int
Matrica::GetCol(
void
)
const
60
{
return
col; }
61
62
inline
double
* Matrica::operator[](
const
int
redak)
63
{ assert(redak >= 0 && redak < row);
64
return
data[redak]; }
65
66
class
SLAJ
// sustav lin. alg. jednadzbi
67
{
68
protected
:
69
Matrica
A;
70
Matrica
b;
71
public
:
72
void
Load_A(
char
*);
73
void
Load_b(
char
*);
74
void
Save_A(
char
*);
75
void
Save_b(
char
*);
76
void
Set_A(
Matrica
&);
77
void
Set_b(
Matrica
&);
78
void
GetSolution(
Matrica
&);
79
};
80
81
// LU i LUP dekompozicija
82
class
LUdek
:
public
SLAJ
83
{
84
protected
:
85
int
*P;
86
int
n;
87
public
:
88
LUdek
(
void
);
89
int
Solve(
Matrica
&,
Matrica
&,
Matrica
&);
90
int
Decompose(
void
);
91
int
ForwardSubst(
void
);
92
int
BackwardSubst(
void
);
93
Matrica
Invert(
Matrica
&);
94
int
pivot;
// 0 - bez pivotiranja
95
// 1 - sa pivotiranjem
96
};
97
98
#endif
// matrica_h
LUdek
Definition:
matrice.h:83
Matrica
Definition:
matrice.h:15
SLAJ
Definition:
matrice.h:67
Generated on Wed Aug 3 2022 17:50:42 for ECF by
1.9.4