27void stepUp(
int level,
float** A,
float** B,
int* currentRootsCount)
31 for (
int i = 0; i < level; i++) {
32 float s = fabs(A[level][i]);
33 if (s > major) major = s;
37 currentRootsCount[level] = 0;
39 for (
int i = 0; i <= currentRootsCount[level - 1]; i++) {
40 int signLeft, signRight;
41 float edgeLeft, edgeRight;
42 float edgeNegativ, edgePositiv;
44 if (i == 0) edgeLeft = -major;
46 edgeLeft = B[level - 1][i - 1];
48 float rb =
polinom(level, edgeLeft, A[level]);
51 B[level][currentRootsCount[level]] = edgeLeft;
52 currentRootsCount[level]++;
56 if (rb > 0) signLeft = 1;
60 if (i == currentRootsCount[level - 1]) edgeRight = major;
62 edgeRight = B[level - 1][i];
64 rb =
polinom(level, edgeRight, A[level]);
67 B[level][currentRootsCount[level]] = edgeRight;
68 currentRootsCount[level]++;
72 if (rb > 0) signRight = 1;
75 if (signLeft == signRight)
continue;
78 edgeNegativ = edgeLeft;
79 edgePositiv = edgeRight;
82 edgeNegativ = edgeRight;
83 edgePositiv = edgeLeft;
86 B[level][currentRootsCount[level]] =
dihot(level, edgeNegativ, edgePositiv, A[level]);
87 currentRootsCount[level]++;
95 float*
kf =
new float[n + 1];
97 float** A =
new float*[n + 1];
98 float** B =
new float*[n + 1];
100 int* currentRootsCount =
new int[n + 1];
102 for (
int i = 1; i <= n; i++) {
107 for (
int i = 0; i <= n; i++)
110 for (
int i = 0; i < n; i++)
111 A[n][i] =
kf[i] /
kf[n];
113 for (
int i1 = n, i = n - 1; i > 0; i1 = i, i--) {
114 for (
int j1 = i, j = i - 1; j >= 0; j1 = j, j--) {
115 A[i][j] = A[i1][j1] * j1 / i1;
119 currentRootsCount[1] = 1;
122 for (
int i = 2; i <= n; i++)
123 stepUp(i, A, B, currentRootsCount);
125 rootsCount = currentRootsCount[n];
126 for (
int i = 0; i < rootsCount; i++)
127 rootsArray[i] = B[n][i];
129 for (
int i = 1; i <= n; i++) {
135 delete[] currentRootsCount;