poly.h revision 8001ba81cb851b38d86650a2fef5817facffb763
#ifndef SEEN_POLY_H
#define SEEN_POLY_H
#include <assert.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <complex>
// coeff; // sum x^i*coeff[i]
//unsigned size() const { return coeff.size();}
//double operator[](const int i) const { return (*this)[i];}
//double& operator[](const int i) { return (*this)[i];}
//result.reserve(out_size);
for(unsigned i = 0; i < min_size; i++) {
}
return result;
}
for(unsigned i = 0; i < min_size; i++) {
}
return result;
}
for(unsigned i = 0; i < min_size; i++) {
(*this)[i] -= p[i];
}
(*this)[i] = -p[i];
return *this;
}
for(unsigned i = 0; i < out_size; i++) {
}
result[0] -= k;
return result;
}
for(unsigned i = 0; i < size(); i++) {
}
return result;
}
for(unsigned i = 0; i < out_size; i++) {
}
return result;
}
// equivalent to multiply by x^terms, discard negative terms
// This was a no-op and breaks the build on x86_64, as it's trying
// to take maximum of 32-bit and 64-bit integers
//const unsigned out_size = std::max(unsigned(0), size()+terms);
if(terms < 0) {
for(unsigned i = 0; i < out_size; i++) {
}
} else {
for(unsigned i = 0; i < terms; i++) {
}
for(unsigned i = 0; i < size(); i++) {
}
}
return result;
}
T eval(T x) const {
T r = 0;
for(int k = size()-1; k >= 0; k--) {
r = r*x + T((*this)[k]);
}
return r;
}
void normalize();
void monicify();
Poly() {}
void val_and_deriv(T x, U &pd) const {
pd[j] = 0.0;
for(int i = nc -1; i >= 0; i--) {
for(int j = nnd; j >= 1; j--)
}
double cnst = 1;
for(int i = 2; i <= nd; i++) {
cnst *= i;
}
}
Poly p;
p.push_back(b);
return p;
}
};
/*** solve(Poly p)
* find all p.degree() roots of p.
* This function can take a long time with suitably crafted polynomials, but in practice it should be fast. Should we provide special forms for degree() <= 4?
*/
/*** solve_reals(Poly p)
* find all real solutions to Poly p.
* currently we just use solve and pick out the suitably real looking values, there may be a better algorithm.
*/
out_file << "0";
else {
if(i == 1) {
out_file << " + ";
} else if(i) {
out_file << " + ";
} else
}
}
return out_file;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
#endif