Line data Source code
1 : #include <cmath> 2 : #include <exception> 3 : #include <filesystem> 4 : #include <fstream> 5 : #include <iostream> 6 : #include <string> 7 : #include <vector> 8 : 9 : #include "data.hpp" 10 : #include "exceptions.hpp" 11 : #include "io.hpp" 12 : #include "sixterm.hpp" 13 : #include "threeterm.hpp" 14 : #include "topline.hpp" 15 : 16 0 : bool convergence(double err) 17 : { 18 0 : if (err > TOL) 19 : { 20 0 : std::cout.precision(16); 21 0 : std::cout << std::scientific; 22 0 : std::cout << "err = " << err << "\n"; 23 : } 24 : 25 0 : return err < TOL; 26 : } 27 : 28 0 : int roc(const std::vector<double> &coeffs, const double &scale, double &rc, 29 : double &order) 30 : { 31 : double err; 32 : 33 : // Check for sufficient data to perform analysis 34 0 : int k = (int)coeffs.size(); 35 0 : if (k < MINTERMS) 36 : { 37 : std::string message = 38 0 : "The number of coefficients [" + std::to_string((int)coeffs.size()) + 39 0 : "] must be greater than [" + std::to_string(MINTERMS) + "].\n"; 40 0 : throw sayMessage(message); 41 : } 42 : 43 : // Output format 44 0 : std::cout.precision(16); 45 0 : std::cout << std::scientific; 46 : 47 : // Analyse coefficients with all three analysis 48 : try 49 : { 50 0 : err = threeterm(coeffs, scale, rc, order); 51 0 : std::cout << "3TA rc[" << rc << "] order [" << order << "] err [" << err 52 0 : << "]\n"; 53 : } 54 0 : catch (const std::exception &e) 55 : { 56 0 : std::cout << e.what() << '\n'; 57 : } 58 : try 59 : { 60 0 : err = sixterm(coeffs, scale, rc, order); 61 0 : std::cout << "6TA rc[" << rc << "] order [" << order << "] err [" << err 62 0 : << "]\n"; 63 : } 64 0 : catch (const std::exception &e) 65 : { 66 0 : std::cout << e.what() << '\n'; 67 : } 68 : try 69 : { 70 0 : err = topline(coeffs, scale, rc, order); 71 0 : std::cout << "TLA rc[" << rc << "] order [" << order << "] err [" << err 72 0 : << "]\n"; 73 : } 74 0 : catch (const std::exception &e) 75 : { 76 0 : std::cout << e.what() << '\n'; 77 : } 78 : 79 0 : return 0; 80 : }