source: molecuilder/src/leastsquaremin.cpp@ 25e17e9

Last change on this file since 25e17e9 was 71910a, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Made data internal data-structure of vector class private

  • Replaced occurences of access to internals with operator
  • moved Vector-class into LinAlg-Module
  • Reworked Vector to allow clean modularization
  • Added Plane class to describe arbitrary planes in 3d space
  • Property mode set to 100644
File size: 686 bytes
Line 
1/*
2 * leastsquaremin.cpp
3 *
4 * Created on: Aug 18, 2009
5 * Author: heber
6 */
7
8#include <iostream>
9
10#include "leastsquaremin.hpp"
11#include "vector.hpp"
12
13/** Determines sum of squared distances of \a X to all \a **vectors.
14 * \param *x reference vector
15 * \param *params
16 * \return sum of square distances
17 */
18double LSQ (const gsl_vector * const x, void * params)
19{
20 double sum = 0.;
21 struct LSQ_params *par = (struct LSQ_params *)params;
22 const Vector ** vectors = par->vectors;
23 int num = par->num;
24
25 for (int i=num;i--;) {
26 for(int j=NDIM;j--;)
27 sum += (gsl_vector_get(x,j) - (vectors[i])->at(j))*(gsl_vector_get(x,j) - (vectors[i])->at(j));
28 }
29
30 return sum;
31};
32
Note: See TracBrowser for help on using the repository browser.