00001
00002
00003
00004
00006 #ifndef __vectorExpression_HPP
00007 #define __vectorExpression_HPP "Created 25.05.2006 21:42:27 by werner"
00008
00009 #include "Iterator.hpp"
00010
00011 namespace Fiber
00012 {
00013 using std::type_info;
00014
00018 template <class Operator>
00019 struct Expression
00020 {
00021 template <class Data>
00022 static void unary(const Iterator<Data>&p)
00023 {
00024 for(index_t i=0; i<p.count(); i++)
00025 {
00026 Data&d = p[i];
00027 Operator::unary( d );
00028 }
00029 }
00030
00031 template <class Data>
00032 static void unary(Operator&Op, const Iterator<Data>&p)
00033 {
00034 for(index_t i=0; i<p.count(); i++)
00035 {
00036 Data&d = p[i];
00037 Op.unary( d );
00038 }
00039 }
00040
00041 template <int C, class Data>
00042 static void unary(const Iterator<FixedArray<Data,C> >&p)
00043 {
00044 for(index_t i=0; i<p.count(); i++)
00045 {
00046 Operator::begin_component(i);
00047 for(int c=0; c<C; c++)
00048 {
00049 Operator::unary( p.getComponent(i,c) );
00050 }
00051 Operator::end_component(i);
00052 }
00053 }
00054
00055 template <class Data, class Data2>
00056 static void binary(const Iterator<Data>&p, const Iterator<Data2>&q)
00057 {
00058 for(index_t i=0; i<p.count(); i++)
00059 {
00060 typename Iterator<Data >::reference_t d = p[i];
00061 typename Iterator<Data2>::reference_t e = q[i];
00062 Operator::binary( d, e );
00063 }
00064 }
00065
00075 template <class Data, class Data1, class Data2>
00076 static void ternary(const Iterator<Data>&p, const Iterator<Data1>&q, const Iterator<Data2>&r)
00077 {
00078 index_t Iend = p.count();
00079 for(index_t i=0; i<Iend; i++)
00080 {
00081 typename Iterator<Data >::reference_t a = p[i];
00082 typename Iterator<Data1>::reference_t b = q[i];
00083 typename Iterator<Data2>::reference_t c = r[i];
00084 Operator::ternary( a, b, c );
00085 }
00086 }
00087
00088
00089 template <int C, class Data, class Data1, class Data2>
00090 static void ternary(const Iterator<FixedArray<Data ,C> >&p,
00091 const Iterator<FixedArray<Data1,C> >&q,
00092 const Iterator<FixedArray<Data2,C> >&r)
00093 {
00094 for(index_t i=0; i<p.count(); i++)
00095 {
00096 for(int c=0; c<C; c++)
00097 {
00098 Operator::ternary( p.getComponent(i,c), q.getComponent(i,c), r.getComponent(i,c) );
00099 }
00100 }
00101 }
00102 };
00103
00104
00105 }
00106
00107 #endif
00108