00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __MMX_ANALYTIC_SUGAR_HPP
00014 #define __MMX_ANALYTIC_SUGAR_HPP
00015 #include <basix/routine.hpp>
00016 #include <algebramix/series_sugar.hpp>
00017 #include <continewz/analytic_vector.hpp>
00018 namespace mmx {
00019 #define TMPL template<typename C>
00020 #define Vector vector<C>
00021 #define Analytic analytic<C>
00022 #define Scalar typename unvectorize<C>::val
00023
00024
00025
00026
00027
00028 TMPL Analytic
00029 fixed_point_analytic (const routine& fun, const C& c);
00030 TMPL analytic<Vector >
00031 fixed_point_analytic_vector (const routine& fun, const Vector& c);
00032 TMPL vector<Analytic >
00033 fixed_point_vector_analytic (const routine& fun, const Vector& c);
00034 TMPL vector<generic>
00035 gen_fixed_point_vector_analytic (const routine& fun, const Vector& c);
00036
00037
00038
00039
00040
00041 TMPL
00042 class fixed_point_analytic_rep: public recursive_analytic_rep<C> {
00043 routine fun;
00044 C c;
00045 public:
00046 fixed_point_analytic_rep (const routine& fun2, const C& c2):
00047 recursive_analytic_rep<C> (get_format (c2)), fun (fun2), c (c2) {}
00048 syntactic expression (const syntactic& z) const {
00049 (void) z;
00050 return apply ("fixed_point", flatten (fun), flatten (c)); }
00051 series<C> Expand () const {
00052 return fixed_point_series (fun, c); }
00053 C Initial () const {
00054 return c; }
00055 Analytic Equation () const {
00056 return as<Analytic > (fun->apply (as<generic> (this->me ()))); }
00057 Analytic Move (const Scalar& z) const {
00058 return fixed_point_analytic (fun, eval (this->me (), z)); }
00059 Analytic Derive () const {
00060 ERROR ("not yet implemented"); }
00061 };
00062
00063 TMPL inline Analytic
00064 fixed_point_analytic (const routine& fun, const C& c) {
00065 return recursive (new fixed_point_analytic_rep<C> (fun, c));
00066 }
00067
00068 TMPL inline Analytic
00069 integrate_analytic (const routine& fun, const C& c) {
00070 return fixed_point_analytic (integrate (fun), c);
00071 }
00072
00073 TMPL
00074 class fixed_point_vector_analytic_rep:
00075 public recursive_analytic_rep<Vector >
00076 {
00077 routine fun;
00078 Vector c;
00079 public:
00080 fixed_point_vector_analytic_rep
00081 (const routine& fun2, const Vector& c2):
00082 recursive_analytic_rep<Vector > (get_format (c2)),
00083 fun (fun2), c (c2) {}
00084 syntactic expression (const syntactic& z) const {
00085 (void) z;
00086 return apply ("fixed_point", flatten (fun), flatten (c)); }
00087 series<Vector > Expand () const {
00088 return fixed_point_series_vector (fun, c); }
00089 Vector Initial () const {
00090 return c; }
00091 analytic<Vector > Equation () const {
00092 vector<Analytic > in= as_vector (this->me ());
00093 generic genout= fun->apply (as<generic> (as<vector<generic> > (in)));
00094 vector<Analytic > out=
00095 as<vector<Analytic > > (as<vector<generic> > (genout));
00096 return from_vector (out); }
00097 analytic<Vector > Move (const Scalar& z) const {
00098 return fixed_point_analytic_vector (fun, eval (this->me (), z)); }
00099 analytic<Vector > Derive () const {
00100 ERROR ("not yet implemented"); }
00101 };
00102
00103 TMPL inline analytic<Vector >
00104 fixed_point_analytic_vector (const routine& fun, const Vector& c) {
00105 return recursive (new fixed_point_vector_analytic_rep<C> (fun, c));
00106 }
00107
00108 TMPL inline vector<Analytic >
00109 fixed_point_vector_analytic (const routine& fun, const Vector& c) {
00110 return as_vector (fixed_point_analytic_vector (fun, c));
00111 }
00112
00113 TMPL inline vector<generic>
00114 gen_fixed_point_vector_analytic (const routine& fun, const Vector& c) {
00115 return as<vector<generic> > (fixed_point_vector_analytic (fun, c));
00116 }
00117
00118 TMPL inline vector<generic>
00119 gen_integrate_vector_analytic (const routine& fun, const Vector& c) {
00120 return gen_fixed_point_vector_analytic (integrate (fun), c);
00121 }
00122
00123 #undef TMPL
00124 #undef Vector
00125 #undef Analytic
00126 #undef Scalar
00127 }
00128 #endif // __MMX_ANALYTIC_IMPLICIT_HPP