Last change
on this file since 48b5fd 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
|
Rev | Line | |
---|
[da84d6] | 1 | /*
|
---|
| 2 | * leastsquaremin.cpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Aug 18, 2009
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[17b3a5c] | 8 | #include <iostream>
|
---|
| 9 |
|
---|
[da84d6] | 10 | #include "leastsquaremin.hpp"
|
---|
[17b3a5c] | 11 | #include "vector.hpp"
|
---|
[da84d6] | 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 | */
|
---|
[a9b2a0a] | 18 | double LSQ (const gsl_vector * const x, void * params)
|
---|
[da84d6] | 19 | {
|
---|
| 20 | double sum = 0.;
|
---|
| 21 | struct LSQ_params *par = (struct LSQ_params *)params;
|
---|
[a9b2a0a] | 22 | const Vector ** vectors = par->vectors;
|
---|
[da84d6] | 23 | int num = par->num;
|
---|
| 24 |
|
---|
| 25 | for (int i=num;i--;) {
|
---|
| 26 | for(int j=NDIM;j--;)
|
---|
[71910a] | 27 | sum += (gsl_vector_get(x,j) - (vectors[i])->at(j))*(gsl_vector_get(x,j) - (vectors[i])->at(j));
|
---|
[da84d6] | 28 | }
|
---|
| 29 |
|
---|
| 30 | return sum;
|
---|
| 31 | };
|
---|
| 32 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.