source: trunk/lib/statistics/MultiDimensional.cc @ 386

Last change on this file since 386 was 386, checked in by Jari Häkkinen, 17 years ago

Extracted the underlying GSL multifit algo from Polynomial into separate
class (MultiDimensional?).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 850 bytes
Line 
1// $Id: MultiDimensional.cc 386 2005-08-14 23:16:52Z jari $
2
3#include <c++_tools/statistics/MultiDimensional.h>
4#include <c++_tools/gslapi/matrix.h>
5#include <c++_tools/gslapi/vector.h>
6
7namespace theplu {
8namespace statistics {
9namespace regression {
10
11
12  MultiDimensional::~MultiDimensional(void)
13  {
14    if (work_)
15      gsl_multifit_linear_free(work_);
16  }
17
18
19
20  void MultiDimensional::fit(const gslapi::matrix& x, const gslapi::vector& y)
21  {
22    covariance_=gslapi::matrix(x.columns(),x.columns());
23    fit_parameters_=gslapi::vector(x.columns());
24    if (work_)
25      gsl_multifit_linear_free(work_);
26    work_=gsl_multifit_linear_alloc(x.rows(),fit_parameters_.size());
27    gsl_multifit_linear(x.gsl_matrix_pointer(),y.gsl_vector_pointer(),
28                        fit_parameters_.TEMP_gsl_vector_pointer(),
29                        covariance_.gsl_matrix_pointer(),&chisquare_,work_);
30  }
31
32
33}}} // of namespaces regression, statisitcs and thep
Note: See TracBrowser for help on using the repository browser.