Решение систем нелинейных уравнений https://www.mapleprimes.com/users/one%20man/posts?page=1
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.

sysosndan.cpp 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include "sysosndan.h"
  2. #include <algorithm>
  3. #include <regex>
  4. unsigned sys_osn_dan::dim_line=2;
  5. sys_osn_dan::sys_osn_dan(std::stringstream &mystreamin_, const bool nocomp_, const bool nocpp_): nocomp(nocomp_), nocpp(nocpp_)
  6. {
  7. isxod_dan(mystreamin_);
  8. }
  9. void sys_osn_dan::isxod_dan(std::stringstream &mystreamin_)
  10. {
  11. std::string str;
  12. std::stringstream _isstemp, mystreamin;
  13. for (std::string str; std::getline(mystreamin_, str);)
  14. if (!str.empty())
  15. mystreamin << str << '\n';
  16. mystreamin>>str_sm>>dt>>N>>dimension;
  17. dim_line=dimension[0]-'0';
  18. std::getline(mystreamin, str);
  19. std::stringstream _iss(str);
  20. for (std::string sub; _iss>>sub;)
  21. uprav_par_naz.push_back(sub);
  22. std::getline(mystreamin, str);
  23. _isstemp.str(str);
  24. for (double temp; _isstemp>>temp;)
  25. x.push_back(temp);
  26. for (std::string str; std::getline(mystreamin, str, '\n');)
  27. {
  28. if (str.find("+sv:") != std::string::npos)
  29. {
  30. for (std::string str; std::getline(mystreamin, str, '\n');)
  31. equations_svob.push_back(razdto_(str));
  32. break;
  33. }
  34. equations.push_back(razdto_(str));
  35. }
  36. N_var=x.size(); //число переменных
  37. int N_ex=equations.size(); //число уравнений
  38. n_svob=1; //число свободных переменных
  39. if (N_var-N_ex > 1 && equations_svob.size() != 0)
  40. n_svob=equations_svob.size();
  41. }
  42. soldif &sys_osn_dan::get_par_diff()
  43. {
  44. A.N=N;
  45. A.dt=dt;
  46. A.x0=x;
  47. A.nsv=n_svob;
  48. A.nv=N_var;
  49. A.eqn=equations;
  50. A.eqn_svob=equations_svob;
  51. A.dln=dim_line;
  52. A.str_sm=str_sm;
  53. A.npp=nocpp;
  54. A.noc=nocomp;
  55. A.up=uprav_par_naz;
  56. return A;
  57. }
  58. std::string &sys_osn_dan::razdto_(std::string &s)
  59. {
  60. std::string razd="[]";
  61. for (size_t i=0;i<razd.length();i++)
  62. std::replace( s.begin(), s.end(), razd[i], '_');
  63. return s;
  64. }