|
Last change
on this file since be2997 was a9b2a0a, checked in by Frederik Heber <heber@…>, 16 years ago |
|
Huge refactoring to make const what is const (ticket #38), continued.
- too many changes because of too many cross-references to be able to list them up here.
- NOTE that "make check" runs fine and did catch several error.
- note that we had to use const_iterator several times when the map, ... was declared const.
- at times we changed an allocated LinkedCell LCList(...) into
const LinkedCell *LCList;
LCList = new LinkedCell(...);
- also mutable (see ticket #5) was used, e.g. for molecule::InternalPointer (PointCloud changes are allowed, because they are just accounting).
Signed-off-by: Frederik Heber <heber@…>
|
-
Property mode
set to
100644
|
|
File size:
684 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 * 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])->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.