00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __MMX_RIEMANN_POINT_HPP
00014 #define __MMX_RIEMANN_POINT_HPP
00015 #include <continewz/riemann_square.hpp>
00016
00017 namespace mmx {
00018 #define TMPL_DEF template<typename R,typename V= std_riemann>
00019 #define TMPL template<typename R,typename V>
00020 #define C complex<R>
00021 #define Square riemann_square<R,V>
00022 #define Point riemann_point<R,V>
00023
00024
00025
00026
00027
00028 TMPL_DEF
00029 class riemann_point {
00030 MMX_ALLOCATORS;
00031 public:
00032 Square s;
00033 C z;
00034 inline riemann_point () {}
00035 inline riemann_point (const format<R>& fm): s (fm), z (promote (0, fm)) {}
00036 inline riemann_point (const Square& s2, const C& z2): s (s2), z (z2) {}
00037 };
00038 DEFINE_UNARY_FORMAT_2 (riemann_point)
00039
00040 TMPL inline Square owner (const Point& p) { return p.s; }
00041 TMPL inline C project (const Point& p) { return p.z; }
00042 TMPL inline format<R> CF (const Point& p) { return CF (owner (p)); }
00043
00044
00045
00046
00047
00048 template<typename Op, typename R, typename V> nat
00049 unary_hash (const Point& p) {
00050 nat h= Op::op (p.s);
00051 return (h<<1) ^ (h<<3) ^ (h<<9) ^ (h>>29) ^ Op::op (p.z);
00052 }
00053
00054 template<typename Op, typename R, typename V> bool
00055 binary_test (const Point& p1, const Point& p2) {
00056 return Op::op (p1.s, p2.s) && Op::op (p1.z, p2.z);
00057 }
00058
00059 TRUE_IDENTITY_OP_SUGAR(TMPL,Point)
00060 EXACT_IDENTITY_OP_SUGAR(TMPL,Point)
00061 HARD_IDENTITY_OP_SUGAR(TMPL,Point)
00062
00063 TMPL inline syntactic
00064 flatten (const Point& p) {
00065 return apply ("point", flatten (p.z), flatten (p.s));
00066 }
00067
00068 TMPL
00069 struct binary_helper<Point >: public void_binary_helper<Point > {
00070 static inline string short_type_name () {
00071 return "Rpnt" * Short_type_name (R); }
00072 static inline generic full_type_name () {
00073 return gen ("Riemann_point", Full_type_name (R)); }
00074 static inline generic disassemble (const Point& p) {
00075 return gen_vec (as<generic> (owner (p)),
00076 as<generic> (project (p))); }
00077 static inline Point assemble (const generic& v) {
00078 return Point (as<Square > (vector_access (v, 0)),
00079 as<C > (vector_access (v, 1))); }
00080 static inline void write (const port& out, const Point& p) {
00081 binary_write<Square > (out, owner (p));
00082 binary_write<C > (out, project (p)); }
00083 static inline Point read (const port& in) {
00084 Square o= binary_read<Square > (in);
00085 C p= binary_read<C > (in);
00086 return Point (o, p); }
00087 };
00088
00089 #undef TMPL_DEF
00090 #undef TMPL
00091 #undef C
00092 #undef Square
00093 #undef Point
00094 }
00095 #endif // __MMX_RIEMANN_POINT_HPP