Решение систем нелинейных уравнений https://www.mapleprimes.com/users/one%20man/posts?page=1
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

main.cpp 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //#include <iostream>
  2. #include <fstream>
  3. #include "sysdiffeqn.h"
  4. #include "solver.h"
  5. #include "sysosndan.h"
  6. #ifndef OCTAVE
  7. #include "draghilevinout.h"
  8. int main(int argc, char* argv[])
  9. {
  10. draghilevinout Dinout(argc, argv);
  11. sys_osn_dan DATA(Dinout.mystreamin, Dinout.nocomp.getValue(), Dinout.nocpp.getValue());
  12. sys_diff_equation A(DATA);
  13. //double t0=clock();//START_TIMER;
  14. solver_diff_eqn B(DATA, Dinout.exit.getValue());
  15. Dinout.checkdel();
  16. //STOP_TIMER
  17. //std::cout << (clock()-t0)/CLOCKS_PER_SEC<< '\t' <<N<< std::endl;
  18. Dinout.write_out_text(DATA);
  19. Dinout.write_octave_m(DATA, A);
  20. Dinout.write_mathgl_disp(A, B);
  21. return 0;
  22. }
  23. #endif
  24. #include <iostream>
  25. #ifdef OCTAVE
  26. #include <octave/oct.h>
  27. DEFUN_DLD (draghilev_oct, args, , "Draghilev method")
  28. {
  29. octave_value_list retval;
  30. std::ifstream octfilein ( "example.txt" );
  31. std::stringstream buffer;
  32. buffer << octfilein.rdbuf();
  33. octfilein.close();
  34. bool not_comp=args.length() == 0 || (args.length() != 0 && args(0).int_value() != 1), //компилировать если аргумент равен 1
  35. not_cpp=true;
  36. sys_osn_dan DATA(buffer, not_comp, not_cpp);
  37. double N=DATA.get_par_diff().N;
  38. int N_var=DATA.get_par_diff().nv;
  39. double dt=DATA.get_par_diff().dt;
  40. int N_upr=DATA.get_par_diff().up.size();//число управляющих параметров
  41. if ( args.length() == 2)
  42. {
  43. N=N*dt/args(1).double_value();
  44. dt=args(1).double_value();
  45. DATA.set_par_diff(N,dt);
  46. }
  47. double exit_tol=-1;
  48. if ( args.length() == 3)
  49. exit_tol=args(2).double_value();
  50. solver_diff_eqn B(DATA, exit_tol);
  51. int nrow=DATA.get_resOUT().size()/N_var;
  52. int t=0;
  53. Matrix res_matrix(nrow, N_var);
  54. for (int i=0;i<nrow;i++)
  55. for (int j=0;j<N_var;j++)
  56. res_matrix(i,j)=DATA.get_resOUT()[t++];
  57. retval(0)=res_matrix;
  58. retval(1)=dt;
  59. if (N_upr != 0)
  60. {
  61. int t=0;
  62. Matrix upr_matrix(nrow, N_upr);
  63. for (int i=0;i<nrow;i++)
  64. for (int j=0;j<N_upr;j++)
  65. upr_matrix(i,j)=DATA.get_uprOUT()[t++];
  66. retval(2)=upr_matrix;
  67. }
  68. return retval;
  69. }
  70. #endif