00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __MMX_ODE_SERIES_HPP
00014 #define __MMX_ODE_SERIES_HPP
00015 #include <algebramix/series_vector.hpp>
00016 #include <algebramix/series_matrix.hpp>
00017 #include <multimix/slp_multivariate.hpp>
00018
00019 namespace mmx {
00020 #define Homotopy_variant(C) typename homotopy_variant_helper<C>::HV
00021 #define TMPL template<typename C>
00022 #define Series series<C>
00023 #define Series_rep series_rep<C>
00024 #define Function_C slp_tangent<C>
00025 #define Function_Series slp_tangent<Series >
00026
00027
00028
00029
00030
00031 template<typename C>
00032 class solve_ode_series_rep: public recursive_series_rep<vector<C> > {
00033 Function_Series fun;
00034 vector<C> c;
00035 public:
00036 solve_ode_series_rep (const Function_Series& fun2, const vector<C>& c2):
00037 recursive_series_rep<vector<C> > (CF(c2)), fun (fun2), c (c2) {}
00038 syntactic expression (const syntactic& z) const {
00039 (void) z;
00040 return apply ("solve_ode", flatten (fun), flatten (c)); }
00041 series<vector<C> > initialize () {
00042 this->initial (0)= c;
00043 vector<series<C> > in = as_vector (this->me ());
00044 vector<series<C> > out= integrate (eval (fun, in));
00045 return from_vector (out); }
00046 };
00047
00048 template<typename C> inline vector<Series >
00049 solve_ode (const Function_Series& fun, const vector<C>& c) {
00050 series_rep<vector<C> >* rep= new solve_ode_series_rep<C> (fun, c);
00051 return as_vector (recursive (series<vector<C> > (rep)));
00052 }
00053
00054 template<typename C> inline vector<Series >
00055 solve_ode_series (const Function_C& fun, const vector<C>& c) {
00056 return solve_ode (as<Function_Series > (fun), c);
00057 }
00058
00059 template<typename C> vector<generic>
00060 solve_ode_series (const vector<multivariate<sparse_polynomial<rational> > >& f,
00061 const vector<multivariate_coordinate<> >& vars,
00062 const vector<C>& c) {
00063 Function_C fun= as_slp_tangent (f, vars, CF (c));
00064 return as<vector<generic> > (solve_ode_series (fun, c));
00065 }
00066
00067
00068
00069
00070
00071 template<typename C> inline matrix<Series >
00072 first_variation (const Function_Series& fun, const vector<Series >& at) {
00073 matrix<Series > jac= jacobian (fun, at);
00074 return solve_lde (jac);
00075 }
00076
00077 template<typename C> inline matrix<Series >
00078 first_variation_series (const Function_C& fun, const vector<Series >& at) {
00079 return first_variation (as<Function_Series > (fun), at);
00080 }
00081
00082 template<typename C> inline matrix<Series >
00083 first_variation_series (const Function_C& fun, const vector<C>& c) {
00084 vector<Series > at= solve_ode_series (fun, c);
00085 return first_variation_series (fun, at);
00086 }
00087
00088 template<typename C> matrix<generic>
00089 first_variation_series (const vector<multivariate<sparse_polynomial<rational> > >& f,
00090 const vector<multivariate_coordinate<> >& vars,
00091 const vector<C>& c) {
00092 Function_C fun= as_slp_tangent (f, vars, CF (c));
00093 return as<matrix<generic> > (first_variation_series (fun, c));
00094 }
00095
00096 }
00097 #undef TMPL
00098 #undef Series
00099 #undef Series_rep
00100 #undef Function_C
00101 #undef Function_Series
00102 #endif // __MMX_ODE_SERIES_HPP