sbasis.h revision 981b809bc6ed10a21e89444d9447e5475801874f
/*
* sbasis.h - S-power basis function class
*
* Authors:
* Nathan Hurst <njh@mail.csse.monash.edu.au>
* Michael Sloan <mgsloan@gmail.com>
*
* Copyright (C) 2006-2007 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 SEEN_SBASIS_H
#define SEEN_SBASIS_H
#include <vector>
#include <cassert>
#include <iostream>
#include "linear.h"
#include "interval.h"
/*** An empty SBasis is identically 0. */
SBasis() {}
}
{}
}
//IMPL: FragmentConcept
typedef double output_type;
inline bool isZero() const {
if(empty()) return true;
for(unsigned i = 0; i < size(); i++) {
}
return true;
}
bool isFinite() const;
inline double at0() const {
}
inline double at1() const{
}
double valueAt(double t) const {
double s = t*(1-t);
double sk = 1;
//TODO: rewrite as horner
for(unsigned k = 0; k < size(); k++) {
sk *= s;
}
}
double operator()(double t) const {
return valueAt(t);
}
// compute f(g)
}
//MUTATOR PRISON
//remove extra zeros
void normalize() {
pop_back();
}
};
//TODO: figure out how to stick this in linear, while not adding an sbasis dep
//implemented in sbasis-roots.cpp
for(unsigned k = 0; k < a.size(); k++)
return result;
}
//IMPL: ScalableConcept
for(unsigned i = 0; i < p.size(); i++) {
}
return result;
}
//IMPL: AddableConcept
//TODO: remove?
if(b.isZero()) return a;
if(a.isZero()) return b;
result[0] += b;
return result;
}
if(b.isZero()) return a;
result[0] -= b;
return result;
}
if(a.isZero())
a.push_back(b);
else
a[0] += b;
return a;
}
if(a.isZero())
a.push_back(-b);
else
a[0] -= b;
return a;
}
//IMPL: OffsetableConcept
result[0] += b;
return result;
}
result[0] -= b;
return result;
}
if(a.isZero())
else
a[0] += b;
return a;
}
if(a.isZero())
else
a[0] -= b;
return a;
}
SBasis c;
return c;
}
// return a kth order approx to 1/a)
return multiply(a, b);
}
a = multiply(a, b);
return a;
}
//valuation: degree of the first non zero coefficient.
inline unsigned
unsigned val=0;
val++;
return val;
}
// a(b(t))
//compose_inverse(f,g)=compose(f,inverse(g)), but is numerically more stable in some good cases...
//TODO: requires g(0)=0 & g(1)=1 atm. generalization should be obvious.
inline SBasis portion(const SBasis &t, double from, double to) { return compose(t, Linear(from, to)); }
// compute f(g)
inline SBasis
}
return out_file;
}
for(unsigned i = 0; i < p.size(); i++) {
}
return out_file;
}
double htol=1e-7,
double vtol=1e-7,
double a=0,
double b=1);
}
/*
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