-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmmse.cpp
70 lines (61 loc) · 1.54 KB
/
mmse.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Universidade Federal do Rio de Janeiro
* Author: Luiz Giserman
* Class: Numeric Linear Algebra
*/
#include "utilities.h"
#include "mmse.h"
MMSE::MMSE() : eq(true)
{
string str;
cout << "How many variables will your approximation have?" << endl;
getline (cin, str);
if (!VerifyInput(str, false))
{
cout << "Number of variables has to be of type unsigned int\n";
exit(ERROR_BAD_INPUT);
}
stringstream(str) >> this-> numVar;
cout << "How many points would you like to enter? " << endl;
getline (cin, str);
if (!VerifyInput(str, false))
{
cout << "Number of variables has to be of type unsigned int\n";
exit(ERROR_BAD_INPUT);
}
stringstream(str) >> this->X.m;
this->X.n = 1;
cout << "Regarding the X values, please enter: " << endl;
this->X.SetMatrix();
if(X.m != 0)
{
this->Y.m = this->X.m;
this->Y.n = 1;
cout << "Regarding the Y values, please enter: "<< endl;
this->Y.SetMatrix();
}
else
{
cout << "You have to enter at least 1 coordinate for the SSME methods" << endl;
exit (ERROR_BAD_INPUT);
}
}
void MMSE::Solve()
{
cout << "in solve" << endl;
int i = 0;
this->P.m = this->X.m;
this->P.n = this->numVar;
P.Allocate();
for (i = 0; i < int(P.m); i++)
{
this->P.matrix[i][0] = 1;
this->P.matrix[(unsigned int) i][1] = this->X.matrix[(unsigned int) i][0];
}
this->P.Transpose(this->Pt);
this->eq.numberVariables = this-> numVar;
this->Pt.Cross(this->eq.matrixA, this->P);
this->Pt.Cross(eq.matrixB, this->Y);
eq.Check();
eq.Solve();
}