#include #include #include typedef std::vector VecType; double f(const VecType &coefficients, const VecType &history) { double result(0); for(unsigned i = 0; i < coefficients.size(); ++i) result += coefficients[i] * history[i]; return result; } void shift(VecType &vec, double current) { for(unsigned int i = vec.size() - 1; i > 0; --i) vec[i] = vec[i-1]; vec[0] = current; } int main(int argc, char **argv) { VecType coefficients; for(int i = 1; i < argc; ++i) { double cur(std::strtod(argv[i],nullptr)); coefficients.push_back(cur); } VecType history = VecType(coefficients.size(),0.0); double current = 1.0; VecType outVec; for(unsigned i = 0; current <= 2.0; i++) { if(current > 1.0) outVec.push_back(current); shift(history,current); current = f(coefficients, history); } std::cout << "KW test Scale" << std::endl; std::cout << outVec.size()+1 << std::endl; for(const auto &curval : outVec) { double scaledVal = ((curval - 1.0) * 1200.00) + 100.0; std::cout << "! " << curval << std::endl; std::cout << scaledVal << std::endl; } std::cout << "! octave" << std::endl << "1200.00" << std::endl; }