40 void poly(
const vec &r, vec &p)
44 p.set_size(n + 1,
false);
48 for (
int i = 0; i < n; i++)
49 p.set_subvector(1, p(1, i + 1) - r(i)*p(0, i));
52 void poly(
const cvec &r, cvec &p)
56 p.set_size(n + 1,
false);
60 for (
int i = 0; i < n; i++)
61 p.set_subvector(1, p(1, i + 1) - r(i)*p(0, i));
66 void roots(
const vec &p, cvec &r)
68 int n = p.size(), m, l;
69 ivec f =
find(p != 0.0);
75 v = v(f(0), f(m - 1));
81 A.set_row(0, -v(1, l - 1) / v(0));
91 r.set_size(n - f(m - 1) - 1,
false);
99 void roots(
const cvec &p, cvec &r)
101 int n = p.size(), m, l;
105 for (
int i = 0; i < n; i++)
114 if (m > 0 && n > 1) {
115 v = v(f(0), f(m - 1));
120 A.set_row(0, -v(1, l - 1) / v(0));
126 r.set_size(n - f(m - 1) - 1,
false);
131 r.set_size(0,
false);
137 it_error_if(p.size() == 0,
"polyval: size of polynomial is zero");
138 it_error_if(x.size() == 0,
"polyval: size of input value vector is zero");
144 for (
int i = 1; i < p.size(); i++)
152 it_error_if(p.size() == 0,
"polyval: size of polynomial is zero");
153 it_error_if(x.size() == 0,
"polyval: size of input value vector is zero");
159 for (
int i = 1; i < p.size(); i++)
160 out = std::complex<double>(p(i)) +
elem_mult(x, out);
167 it_error_if(p.size() == 0,
"polyval: size of polynomial is zero");
168 it_error_if(x.size() == 0,
"polyval: size of input value vector is zero");
174 for (
int i = 1; i < p.size(); i++)
182 it_error_if(p.size() == 0,
"polyval: size of polynomial is zero");
183 it_error_if(x.size() == 0,
"polyval: size of input value vector is zero");
189 for (
int i = 1; i < p.size(); i++)
197 it_assert((n >= 0),
"cheb(): need a non-negative order n!");
199 if (x < 1.0 && x > -1.0) {
214 for (
int i = 0; i < x.size(); ++i) {
215 out(i) =
cheb(n, x(i));
222 it_assert_debug((x.rows() > 0) && (x.cols() > 0),
"cheb(): empty matrix");
224 mat out(x.rows(), x.cols());
225 for (
int i = 0; i < x.rows(); ++i) {
226 for (
int j = 0; j < x.cols(); ++j) {
227 out(i, j) =
cheb(n, x(i, j));