You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

28 lines
5.4 KiB

#include <iostream>
#include "turningPoint.h"
int main(){
double x[220] = {8,8.1,8.2,8.3,8.4,8.5,8.6,8.7,8.8,8.9,9,9.1,9.2,9.3,9.4,9.5,9.6,9.7,9.8,9.9,10,10.1,10.21,10.31,10.41,10.51,10.61,10.71,10.81,10.91,11.01,11.11,11.21,11.31,11.41,11.51,11.61,11.71,11.81,11.91,12.01,12.11,12.21,12.31,12.42,12.52,12.62,12.72,12.82,12.92,13.02,13.12,13.22,13.32,13.42,13.52,13.62,13.72,13.82,13.92,14.02,14.12,14.22,14.32,14.42,14.52,14.63,14.73,14.83,14.93,15.03,15.13,15.23,15.33,15.43,15.53,15.63,15.73,15.83,15.93,16.03,16.13,16.23,16.33,16.43,16.53,16.63,16.73,16.84,16.94,17.04,17.14,17.24,17.34,17.44,17.54,17.64,17.74,17.84,17.94,18.04,18.14,18.24,18.34,18.44,18.54,18.64,18.74,18.84,18.94,19.05,19.15,19.25,19.35,19.45,19.55,19.65,19.75,19.85,19.95,20.05,20.15,20.25,20.35,20.45,20.55,20.65,20.75,20.85,20.95,21.05,21.15,21.26,21.36,21.46,21.56,21.66,21.76,21.86,21.96,22.06,22.16,22.26,22.36,22.46,22.56,22.66,22.76,22.86,22.96,23.06,23.16,22.5,22.4,22.3,22.2,22.1,22,21.9,21.8,21.7,21.6,21.5,21.4,21.3,21.2,21.1,21,20.9,20.8,20.7,20.6,20.5,20.39,20.3,20.2,20.1,20,19.89,19.8,19.7,19.6,19.5,19.39,19.3,19.2,19.1,19,18.89,18.8,18.7,18.6,18.5,18.39,18.3,18.2,18.1,18,18,17.89,17.8,17.7,17.6,17.6,17.6,17.6,17.6,17.6,17.6};
// {7.0, 7.2, 7.4, 7.6, 7.8, 8.0, 8.19, 8.4, 8.6, 8.8, 9.0, 9.19, 9.4, 9.6, 9.8, 10.0, 10.19, 10.4, 10.6, 10.8, 11.0, 11.2, 11.4, 11.6, 11.8, 12.0, 12.2, 12.4, 12.6, 12.8, 13.0, 13.2, 13.4, 13.6, 13.8, 14.0, 14.2, 14.4, 14.6, 14.8, 15.0, 15.2, 15.4, 15.6, 15.8, 16.0, 16.2, 16.39, 16.6, 16.8, 17.0, 17.2, 17.39, 17.6, 17.8, 18.0, 18.2, 18.39, 18.6, 18.8, 19.0, 19.2, 19.39, 19.6, 19.8, 20.0, 20.2, 20.39, 20.6, 20.8, 21.0, 21.2, 21.4, 21.6, 21.8, 22.0, 22.2, 22.4, 22.6, 22.8, 23.0, 23.2, 23.4, 23.6, 23.8, 24.0, 24.2, 24.4, 24.6, 24.8, 25.0, 25.2, 25.4, 25.6, 25.8, 26.0, 26.2, 26.4, 26.6, 26.8, 27.0, 27.2, 27.4, 27.6, 27.8, 28.0, 28.2, 28.4, 28.6, 28.8, 29.0, 29.2, 29.4, 29.6, 29.8, 30.0, 30.0, 30.2, 30.4, 30.6, 30.8, 31.0, 31.2, 31.4, 31.6, 31.8, 32.0, 32.2, 32.4, 32.6, 32.79, 33.0, 33.2, 33.4, 33.6, 33.79, 34.0, 34.2, 34.4, 34.6, 34.79};
double y[220] = {35.6181,36.3403,36.5208,36.8819,36.4931,36.6319,36.375,36.2917,36.2014,36.6042,36.4167,36.8056,36.6319,36.7153,37.1181,37.1667,37.1042,37.5347,37.0556,37.4514,38.0833,38.7708,39.6597,41.8681,43.7569,47.1181,49.8194,51.6458,55.0903,58.1319,61.1458,63.8125,66.7222,69.7361,72.2431,76.6111,78.6667,80.8194,83.5556,86.5625,89.375,91.9861,95.2917,97.5069,100.931,104.368,106.556,109.382,112.451,114.896,118.361,120.278,122.944,125.778,128.778,130.681,133.056,135.743,137.861,140.236,142.25,144.5,146.257,148.229,150.708,151.924,154.069,154.826,157.222,159.569,161.09,163.986,164.389,165.771,167.417,168.924,169.903,172.757,174.729,175.688,176.861,178.965,180.257,181.139,181.854,183.604,184.542,185.91,187.014,187.639,189.833,191.229,192.5,193.111,194.66,194.646,196.833,198.132,199.021,200.215,202.299,202.882,205.028,205.938,207.41,208.708,210.188,211.972,212.646,213.278,214.972,215.729,216.951,218.535,219.354,220.181,221.361,221.889,223.153,223.778,224.639,224.694,224.771,225.028,225.722,225.632,226.375,226.639,227.09,227.646,227.618,227.118,228.111,228.424,228.063,228.681,228.688,228.889,228.861,228.806,229.243,229.472,229.104,229.66,229.833,230.083,229.972,229.986,230.215,230.361,230.549,230.833,229.701,229.521,229.236,229.09,229.174,228.556,229.042,228.569,227.972,228.618,228.236,227.715,227.854,227.813,227.667,227.639,227.333,226.819,226.618,226.167,225.785,224.854,225.118,224.375,224.972,224.389,223.368,222.917,222.271,221.958,220.319,218.785,217.951,216.118,215.944,214.083,212.313,212.764,211.41,209.042,208.785,207.861,205.951,204.722,204.014,201.861,201.611,200.313,199.042,198.514,198.194,197.361,211.405,211.41,202.88,203.222,203.667};
// {33.2679, 33.2321, 33.8393, 33.9107, 34.0536, 33.5357, 33.75, 33.8036, 33.8393, 34.0357, 33.4464, 33.7857, 33.4286, 33.8929, 33.7143, 34.0179, 34.1786, 34.0179, 34.3036, 37.25, 40.0357, 42.1429, 43.1786, 44.4643, 44.6786, 45.6786, 45.75, 45.5714, 46.5, 46.2321, 47.6429, 47.5, 48.5893, 48.6786, 48.5714, 49.0179, 49.4821, 49.2679, 49.4286, 49.875, 50.0714, 50.5893, 50.7143, 50.3036, 50.4643, 50.8214, 51.2679, 51.5714, 52.3929, 53.4464, 55.9643, 59.0893, 61.5536, 65.3571, 69.7857, 73.2679, 76.8929, 79.9821, 84.2679, 87.6429, 91.3929, 94.6786, 99.0357, 102.804, 106.286, 110.786, 113.839, 117.411, 121.661, 125.393, 129.0, 132.75, 136.268, 139.982, 143.696, 148.179, 151.089, 155.0, 158.0, 161.286, 164.696, 166.429, 169.857, 172.196, 174.625, 177.107, 179.214, 181.679, 183.393, 186.714, 188.661, 190.554, 192.839, 194.125, 195.464, 198.161, 199.518, 201.214, 202.732, 204.5, 206.821, 207.536, 210.661, 211.464, 213.429, 215.339, 218.143, 219.411, 220.429, 222.321, 222.911, 224.857, 226.018, 227.857, 229.143, 229.018, 229.429, 229.304, 229.911, 229.804, 230.321, 231.089, 231.821, 231.714, 231.804, 232.0, 232.393, 232.393, 232.821, 233.196, 233.357, 233.304, 233.875, 233.679, 233.446, 233.732, 233.446, 233.607, 234.089, 233.839, 233.661};
mysort(x,y,140);
/*for(int i = 0; i<9;i++){
std::cout<<"i = "<<i<<", x["<<i<<"]= "<<x[i]<<", y["<<i<<"] = "<<y[i]<<std::endl;
}
*/
double k ;
double b ;
linear(x,y,20,&k,&b);
std::cout<<"k = "<<k<<", b = "<<b<<std::endl;
std::cout<<"loss = "<<loss(x,y,140)<<std::endl;
double* li = lossline(x,y,140);
for(int i = 0; i<120;i++){
std::cout<<"li["<<i<<"]"<<li[i]<<std::endl;
}
int index = 0;
pointat(x,y,120, &index);
std::cout<<"index = "<<index<<", x["<<index<<"] = "<<x[index]<<std::endl;
}