Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function X_new = shuffle(X,P,x_max)
- # X - набор точек квазиальтернанса для f(x)-P(x)
- # P - коэффициенты полинома "наименее отклоняющегося" от f(x)
- # x_max - максимум модуля отклонения
- for i = 1 : length(X) - 1
- if (x_max > X(i) && x_max < X(i+1))
- if (sign(func(X(i)) - polyval(P, X(i)))==sign(func(x_max) - polyval(P, x_max)))
- X(i) = x_max;
- elseif (sign(func(X(i+1)) - polyval(P, X(i+1)))==sign(func(x_max) - polyval(P, x_max)))
- X(i+1) = x_max;
- endif
- endif
- endfor
- % Шаг 6 алгоритма
- if (x_max < X(1) && (sign(func(X(1)) - polyval(P, X(1)))==sign(func(x_max) - polyval(P, x_max))))
- X(1) = x_max;
- elseif (x_max < X(1) && !(sign(func(X(1)) - polyval(P, X(1)))==sign(func(x_max) - polyval(P, x_max))))
- X = [x_max X];
- X(end) = [];
- endif
- % Шаг 7 алгоритма
- if (x_max > X(end) && (sign(func(X(end)) - polyval(P, X(end)))==sign(func(x_max) - polyval(P, x_max))))
- X(end) = x_max;
- elseif (x_max > X(end) && !(sign(func(X(end)) - polyval(P, X(end)))==sign(func(x_max) - polyval(P, x_max))))
- X = [X x_max];
- X(1) = [];
- endif
- X_new = X;
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement