00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __MMX_ANALYTIC_VECTOR_HPP
00014 #define __MMX_ANALYTIC_VECTOR_HPP
00015 #include <continewz/analytic.hpp>
00016 #include <algebramix/series_vector.hpp>
00017 namespace mmx {
00018 #define TMPL_DEF template<typename C, typename V>
00019 #define TMPL template<typename C, typename V>
00020 #define Analytic analytic<C,V>
00021 #define Analytic_rep analytic_rep<C,V>
00022 #define Assume assume_bound<typename unvectorize<R >::val>
00023 #define Scalar typename unvectorize<C>::val
00024 #define Radius Abs_type(Scalar)
00025 #define Series series<C>
00026 #define R Abs_type(C)
00027 #define VR Abs_type(vector<C> )
00028
00029
00030
00031
00032
00033 TMPL Analytic access (const analytic<vector<C>,V>& f, nat i);
00034 TMPL vector<Analytic > as_vector (const analytic<vector<C>,V>& f);
00035 TMPL analytic<vector<C>,V> as_analytic (const vector<Analytic >& v);
00036
00037 TMPL analytic<vector<C>,V> trig (const analytic<vector<C>,V>& f);
00038 TMPL vector<Analytic > cos_sin (const Analytic& f);
00039
00040 TMPL analytic<vector<C>,V>
00041 solve_vector_lde_init (const analytic<vector<C>,V>& f, const vector<C>& c);
00042 TMPL vector<Analytic >
00043 solve_lde_init (const vector<Analytic >& f, const vector<C>& c);
00044
00045
00046
00047
00048
00049 #define Analytic_vector analytic<vector<C>,V>
00050 #define Vector_analytic vector<analytic<C,V> >
00051 STYPE_TO_TYPE(TMPL,as_vector_type,Analytic_vector,Vector_analytic);
00052 #undef Vector_analytic
00053 #undef Analytic_vector
00054
00055 template<typename C, typename W>
00056 struct unvectorize<vector<C,W> > {
00057
00058 typedef C val;
00059 static inline vector<val> encode (const vector<C,W>& x) {
00060 return x; }
00061 static inline vector<C,W>
00062 decode (const vector<val>& v, const vector<C,W>& gauge) {
00063 (void) gauge;
00064 return v; }
00065 };
00066
00067 TMPL
00068 class vector_access_analytic_rep: public Analytic_rep {
00069 protected:
00070 const analytic<vector<C>,V> f;
00071 nat i;
00072 public:
00073 vector_access_analytic_rep (const analytic<vector<C>,V>& f2, nat i2):
00074 Analytic_rep (get_format1 (CF(f2))), f (f2), i (i2) {}
00075 void Clear_cache (nat which) const {
00076 Analytic_rep::Clear_cache (which);
00077 clear_cache (f, which); }
00078 Series Expand () const {
00079 return access (expand (f), i); }
00080 Radius Radius_bound (nat order) const {
00081 return radius_bound (f, order); }
00082 R Tail_bound (const Radius& r, nat order, Assume& a) const {
00083 return read (tail_bound (this->f, Radius (r), order, a), i); }
00084 Analytic Move (const Scalar& z) const {
00085 return access (move (f, z), i); }
00086 C Eval (const Scalar& z) const {
00087 return eval (f, z) [i]; }
00088 Analytic Derive () const {
00089 return access (derive (f), i); }
00090 };
00091
00092 TMPL Analytic
00093 access (const analytic<vector<C>,V>& f, nat i) {
00094 return (Analytic_rep*) new vector_access_analytic_rep<C,V> (f, i);
00095 }
00096
00097 TMPL vector<Analytic >
00098 as_vector (const analytic<vector<C>,V>& f) {
00099 nat n= N(f[0]);
00100 vector<Analytic > v (Analytic (0, get_format1 (CF(f))), n);
00101 for (nat i=0; i<n; i++)
00102 v[i]= access (f, i);
00103 return v;
00104 }
00105
00106 TMPL vector<R >
00107 head_extremum (const analytic<vector<C>,V>& f,
00108 const Radius& r, nat order, int type) {
00109 nat i, n= N(f[0]);
00110 vector<R > b (R (0), n);
00111 for (i=0; i<n; i++)
00112 b[i]= head_extremum (access (f, i), r, order, type);
00113 return b;
00114 }
00115
00116 TMPL
00117 class vector_analytic_rep: public analytic_rep<vector<C>,V> {
00118 const vector<Analytic > v;
00119 public:
00120 vector_analytic_rep (const vector<Analytic >& v2):
00121 analytic_rep<vector<C>,V> (format<vector<C> > (get_format1 (CF(v2)))),
00122 v (v2) {}
00123 void Clear_cache (nat which) const {
00124 analytic_rep<vector<C>,V>::Clear_cache (which);
00125 for (nat i=0; i<N(v); i++) clear_cache (v[i], which); }
00126 series<vector<C> > Expand () const {
00127 nat i, n= N(v);
00128 vector<Series > r (Series (promote (0, get_format1 (this->tfm()))), n);
00129 for (i=0; i<n; i++)
00130 r[i]= expand (v[i]);
00131 return as_series (r); }
00132 Radius Radius_bound (nat order) const {
00133 Radius r= Maximal (Radius);
00134 for (nat i=0; i<N(v); i++)
00135 r= min (r, radius_bound (v[i], order));
00136 return r; }
00137 VR Tail_bound (const Radius& r, nat order, Assume& a) const {
00138 nat i, n= N(v);
00139 VR b (R (0), n);
00140 for (i=0; i<n; i++)
00141 b[i]= tail_bound (v[i], r, order, a);
00142 return b; }
00143 analytic<vector<C>,V> Move (const Scalar& z) const {
00144 nat i, n= N(v);
00145 vector<Analytic > r (Analytic (0, get_format1 (this->tfm())), n);
00146 for (i=0; i<n; i++)
00147 r[i]= move (v[i], z);
00148 return as_analytic (r); }
00149 vector<C> Eval (const Scalar& z) const {
00150 nat i, n= N(v);
00151 vector<C> r (C (0), n);
00152 for (i=0; i<n; i++)
00153 r[i]= eval (v[i], z);
00154 return r; }
00155 analytic<vector<C>,V> Derive () const {
00156 return as_analytic (derive (v)); }
00157 };
00158
00159 TMPL analytic<vector<C>,V>
00160 as_analytic (const vector<Analytic >& v) {
00161 return (analytic_rep<vector<C>,V>*) new vector_analytic_rep<C,V> (v);
00162 }
00163
00164 TMPL analytic<vector<C>,V>
00165 from_vector (const vector<Analytic >& v) {
00166 return (analytic_rep<vector<C>,V>*) new vector_analytic_rep<C,V> (v);
00167 }
00168
00169
00170
00171
00172
00173 TMPL analytic<vector<C>,V>
00174 trig (const analytic<vector<C>,V>& f) {
00175 return unary_recursive_analytic<trig_op> (f);
00176 }
00177
00178 template<typename C,typename V> vector<Analytic >
00179 cos_sin (const Analytic& f) {
00180 return as_vector (trig (as_analytic (vec (f))));
00181 }
00182
00183 template<typename C,typename V> Analytic
00184 cos (const Analytic& f) {
00185 return unary_recursive_analytic<cos_op> (f);
00186 }
00187
00188 template<typename C,typename V> Analytic
00189 sin (const Analytic& f) {
00190 return unary_recursive_analytic<sin_op> (f);
00191 }
00192
00193 template<typename C,typename V> Analytic
00194 tan (const Analytic& f) {
00195 return unary_recursive_analytic<tan_op> (f);
00196 }
00197
00198 TMPL analytic<vector<C>,V>
00199 solve_vector_lde_init (const analytic<vector<C>,V>& f, const vector<C>& c) {
00200 return unary_recursive_analytic<solve_vector_lde_op> (f, c);
00201 }
00202
00203 TMPL vector<Analytic >
00204 solve_lde_init (const vector<Analytic >& f, const vector<C>& c) {
00205 return as_vector (solve_vector_lde_init (as_analytic (f), c));
00206 }
00207
00208 #undef TMPL_DEF
00209 #undef TMPL
00210 #undef Analytic
00211 #undef Analytic_rep
00212 #undef Assume
00213 #undef Scalar
00214 #undef Radius
00215 #undef Series
00216 #undef R
00217 #undef VR
00218 }
00219 #endif // __MMX_ANALYTIC_VECTOR_HPP