source: molecuilder/src/leastsquaremin.cpp@ 390a2b

Last change on this file since 390a2b was da84d6, checked in by Frederik Heber <heber@…>, 16 years ago

Incorporation of Unit test on class Vector.

  • new file leastsquaremin.[ch]pp has least square minimisation which is otherwise unclean between classes molecules and Vector

Unit test (later tests rely on good results of earlier ones)

changes to class Vector:

  • Vector::IsNull() -> IsZero()
  • new function Vector::IsOne() similar to IsZero()
  • BUGFIX: Vector::IsNULL() (thx to unit test :)
  • Tesselation::getAngle() changed due to above rename
  • Property mode set to 100644
File size: 628 bytes
Line 
1/*
2 * leastsquaremin.cpp
3 *
4 * Created on: Aug 18, 2009
5 * Author: heber
6 */
7
8#include "leastsquaremin.hpp"
9
10/** Determines sum of squared distances of \a X to all \a **vectors.
11 * \param *x reference vector
12 * \param *params
13 * \return sum of square distances
14 */
15double LSQ (const gsl_vector * x, void * params)
16{
17 double sum = 0.;
18 struct LSQ_params *par = (struct LSQ_params *)params;
19 Vector **vectors = par->vectors;
20 int num = par->num;
21
22 for (int i=num;i--;) {
23 for(int j=NDIM;j--;)
24 sum += (gsl_vector_get(x,j) - (vectors[i])->x[j])*(gsl_vector_get(x,j) - (vectors[i])->x[j]);
25 }
26
27 return sum;
28};
29
Note: See TracBrowser for help on using the repository browser.