ECF 1.5
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
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);
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
56inline int Matrica::GetRow(void) const
57{ return row; }
58
59inline int Matrica::GetCol(void) const
60{ return col; }
61
62inline double* Matrica::operator[](const int redak)
63{ assert(redak >= 0 && redak < row);
64 return data[redak]; }
65
66class 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
82class 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
Definition: matrice.h:83
Definition: matrice.h:67