poly.h revision d37634d73670180f99a3e0ea583621373d90ec4f
/**
* \file
* \brief \todo brief description
*
* Authors:
* ? <?@?.?>
*
* Copyright ?-? authors
*
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
*/
#ifndef LIB2GEOM_SEEN_POLY_H
#define LIB2GEOM_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, negative terms are disallowed
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?
*/
#ifdef HAVE_GSL
/*** 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.
*/
#endif
out_file << "0";
else {
if(i == 1) {
out_file << " + ";
} else if(i) {
out_file << " + ";
} else
}
}
return out_file;
}
} // namespace Geom
#endif //LIB2GEOM_SEEN_POLY_H
/*
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:fileencoding=utf-8:textwidth=99 :