6 for (
int i = n - 1;
i >= 0;
i--)
11 float dihot(
int degree,
float edgeNegativ,
float edgePositiv,
float* kf) {
13 float x = 0.5 * (edgeNegativ + edgePositiv);
14 if (std::abs(
x - edgeNegativ) < 1e-3 || std::abs(
x - edgePositiv) < 1e-3)
23 void stepUp(
int level,
float** A,
float** B,
int* currentRootsCount) {
26 for (
int i = 0;
i < level;
i++) {
27 float s =
fabs(A[level][
i]);
28 if (s > major) major = s;
32 currentRootsCount[level] = 0;
34 for (
int i = 0;
i <= currentRootsCount[level - 1];
i++) {
35 int signLeft, signRight;
36 float edgeLeft, edgeRight;
37 float edgeNegativ, edgePositiv;
42 edgeLeft = B[level - 1][
i - 1];
44 float rb =
polinom(level, edgeLeft, A[level]);
47 B[level][currentRootsCount[level]] = edgeLeft;
48 currentRootsCount[level]++;
57 if (
i == currentRootsCount[level - 1])
60 edgeRight = B[level - 1][
i];
62 rb =
polinom(level, edgeRight, A[level]);
65 B[level][currentRootsCount[level]] = edgeRight;
66 currentRootsCount[level]++;
74 if (signLeft == signRight)
continue;
77 edgeNegativ = edgeLeft;
78 edgePositiv = edgeRight;
80 edgeNegativ = edgeRight;
81 edgePositiv = edgeLeft;
84 B[level][currentRootsCount[level]] =
85 dihot(level, edgeNegativ, edgePositiv, A[level]);
86 currentRootsCount[level]++;
93 float* kf =
new float[n + 1];
95 float** A =
new float*[n + 1];
96 float** B =
new float*[n + 1];
98 int* currentRootsCount =
new int[n + 1];
100 for (
int i = 1;
i <= n;
i++) {
105 for (
int i = 0;
i <= n;
i++)
108 for (
int i = 0;
i < n;
i++)
109 A[n][
i] = kf[
i] / kf[n];
111 for (
int i1 = n,
i = n - 1;
i > 0; i1 =
i,
i--) {
112 for (
int j1 =
i, j =
i - 1; j >= 0; j1 = j, j--) {
113 A[
i][j] = A[i1][j1] * j1 / i1;
117 currentRootsCount[1] = 1;
120 for (
int i = 2;
i <= n;
i++)
121 stepUp(
i, A, B, currentRootsCount);
123 rootsCount = currentRootsCount[n];
124 for (
int i = 0;
i < rootsCount;
i++)
125 rootsArray[
i] = B[n][
i];
127 for (
int i = 1;
i <= n;
i++) {
133 delete[] currentRootsCount;