|
Last change
on this file since a2db10 was 17b3a5c, checked in by Frederik Heber <heber@…>, 16 years ago |
|
forward declarations used to untangle interdependet classes.
- basically, everywhere in header files we removed '#include' lines were only pointer to the respective classes were used and the include line was moved to the implementation file.
- as a sidenote, lots of funny errors happened because headers were included via a nesting over three other includes. Now, all should be declared directly as needed, as only very little include lines remain in header files.
|
-
Property mode
set to
100644
|
|
File size:
671 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 | */
|
|---|
| 18 | double LSQ (const gsl_vector * x, void * params)
|
|---|
| 19 | {
|
|---|
| 20 | double sum = 0.;
|
|---|
| 21 | struct LSQ_params *par = (struct LSQ_params *)params;
|
|---|
| 22 | 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])->x[j])*(gsl_vector_get(x,j) - (vectors[i])->x[j]);
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | return sum;
|
|---|
| 31 | };
|
|---|
| 32 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.