-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTpoly.cpp
More file actions
59 lines (54 loc) · 1009 Bytes
/
Copy pathTpoly.cpp
File metadata and controls
59 lines (54 loc) · 1009 Bytes
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
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <vector>
using namespace std;
int main()
{
int n;
cout << "Insert maximum degree + 1: ";
cin >> n;
int Tpoly[n][n + 1];
for (int i = 0; i < n; i++){
for (int j = 0; j < n + 1; j++){
Tpoly[i][j] = 0;
}
}
Tpoly[0][0] = 1;
Tpoly[1][1] = 1;
for (int i = 2; i < n; i++){
for (int j = 0; j < n + 1; j++){
if (j == 0){
if ((i % 2) == 0){
if (i % 4 == 0){
Tpoly[i][j] = 1;
}
if (i % 4 == 2){
Tpoly[i][j] = -1;
}
}
}
else{
Tpoly[i][j] = 2 * Tpoly[i - 1][j - 1] - Tpoly[i - 2][j];
}
}
}
int Sum[n];
for (int i = 0; i < n; i++){
Sum[i] = 0;
}
for (int i = 0; i < n; i++){
for (int j = i; j >= 0; j--){
/*if (Tpoly[i][j] >= 0 ){
Sum[i] = Sum[i] + Tpoly[i][j];
}
else{
Sum[i] = Sum[i] - Tpoly[i][j];
}
*/cout << Tpoly[i][j] << " ";
}
//cout << ";" << " The Sum of absolute values is: " << Sum[i];
cout << endl;
}
}