1
0

initial commit

This commit is contained in:
Tibeuleu
2023-12-31 15:42:33 +01:00
commit 9882d0c0d1
484 changed files with 28426 additions and 0 deletions

65
costfunctions.cpp Executable file
View File

@@ -0,0 +1,65 @@
#include<math.h>
#include<vector>
#include "costfunctions.h"
/*
* Lest squared cost
*/
Khi2::Khi2(){
std::vector<std::vector<double>> T1;
std::vector<std::vector<double>> T2;
k_exp = T1;
k_mod = T2;
}
Khi2::Khi2(const Khi2& other):k_exp(other.k_exp),k_mod(other.k_mod){}
Khi2::Khi2(std::vector<std::vector<double>> T1,std::vector<std::vector<double>> T2): k_exp(T1), k_mod(T2){}
void Khi2::setData(std::vector<std::vector<double>> T1, std::vector<std::vector<double>> T2){
k_exp = T1;
k_mod = T2;
}
double Khi2::get() const {
double S=0,temp=0;
for(int i=0;i<k_exp.size();i++){
temp = S;
S = temp + pow(k_exp[i][1]-k_mod[i][1],2);
}
return S;
}
/*
* Total distance
*/
Distance::Distance(){
std::vector<std::vector<double>> T1;
std::vector<int> T2;
d_pos = T1;
d_ord = T2;
}
Distance::Distance(const Distance& other):d_pos(other.d_pos),d_ord(other.d_ord){}
Distance::Distance(std::vector<std::vector<double>> T1, std::vector<int> T2): d_pos(T1), d_ord(T2){}
void Distance::setData(std::vector<std::vector<double>> T1, std::vector<int> T2){
d_pos = T1;
d_ord = T2;
}
double Distance::get() const {
double S=0,temp=0,x1=0,y1=0,x2=0,y2=0;
for(int i=0;i<d_pos.size()-1;i++){
x1 = d_pos[d_ord[i]][0];
y1 = d_pos[d_ord[i]][1];
x2 = d_pos[d_ord[i+1]][0];
y2 = d_pos[d_ord[i+1]][1];
temp = S;
S = temp + sqrt(pow(x2-x1,2)+pow(y2-y1,2));
}
return S;
}