/** * \file Parabolic \brief * * Copyright 2007-8 IMP Inventors. All rights reserved. * */ #include "IMP/algebra/ParabolicFit.h" IMPALGEBRA_BEGIN_NAMESPACE ParabolicFit::ParabolicFit(const algebra::Vector2Ds& data) : data_(data) { // check that there are at least 3 points IMP_USAGE_CHECK(data_.size() > 2, "At least 3 points are required for ParabolicFit " << data_.size() << " given"); find_regression(); evaluate_error(); } void ParabolicFit::find_regression() { // http://mathforum.org/library/drmath/view/72047.html double S00(0.0), S10(0.0), S20(0.0), S30(0.0), S40(0.0); double S01(0.0), S11(0.0), S21(0.0); S00 = (double)data_.size(); for(unsigned int i=0; i