FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Expression.hpp
1
2//
3// $Id: Expression.hpp,v 1.8 2007/12/06 15:27:37 werner Exp $
4//
6#ifndef __vectorExpression_HPP
7#define __vectorExpression_HPP "Created 25.05.2006 21:42:27 by werner"
8
9#include "Iterator.hpp"
10
11namespace Fiber
12{
13 using std::type_info;
14
18template <class Operator>
20{
21 template <class Data>
22 static void unary(const Iterator<Data>&p)
23 {
24 for(index_t i=0; i<p.count(); i++)
25 {
26 Data&d = p[i];
27 Operator::unary( d );
28 }
29 }
30
31 template <class Data>
32 static void unary(Operator&Op, const Iterator<Data>&p)
33 {
34 for(index_t i=0; i<p.count(); i++)
35 {
36 Data&d = p[i];
37 Op.unary( d );
38 }
39 }
40
41 template <int C, class Data>
42 static void unary(const Iterator<FixedArray<Data,C> >&p)
43 {
44 for(index_t i=0; i<p.count(); i++)
45 {
46 Operator::begin_component(i);
47 for(int c=0; c<C; c++)
48 {
49 Operator::unary( p.getComponent(i,c) );
50 }
51 Operator::end_component(i);
52 }
53 }
54
55 template <class Data, class Data2>
56 static void binary(const Iterator<Data>&p, const Iterator<Data2>&q)
57 {
58 for(index_t i=0; i<p.count(); i++)
59 {
60 typename Iterator<Data >::reference_t d = p[i];
61 typename Iterator<Data2>::reference_t e = q[i];
62 Operator::binary( d, e );
63 }
64 }
65
75 template <class Data, class Data1, class Data2>
76 static void ternary(const Iterator<Data>&p, const Iterator<Data1>&q, const Iterator<Data2>&r)
77 {
78 index_t Iend = p.count();
79 for(index_t i=0; i<Iend; i++)
80 {
81 typename Iterator<Data >::reference_t a = p[i];
82 typename Iterator<Data1>::reference_t b = q[i];
83 typename Iterator<Data2>::reference_t c = r[i];
84 Operator::ternary( a, b, c );
85 }
86 }
87
88
89 template <int C, class Data, class Data1, class Data2>
90 static void ternary(const Iterator<FixedArray<Data ,C> >&p,
93 {
94 for(index_t i=0; i<p.count(); i++)
95 {
96 for(int c=0; c<C; c++)
97 {
98 Operator::ternary( p.getComponent(i,c), q.getComponent(i,c), r.getComponent(i,c) );
99 }
100 }
101 }
102};
103
104
105} /* namespace Fiber */
106
107#endif /* __VectorExpression_HPP */
108
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
index_t count() const
Return the number of steps which can be traversed through this ElementIterator.
Definition HyperslabParameters.hpp:147
Implementation of an Iterator to a sequence of elements, which might be contiguous or a projection of...
Definition vector/Iterator.hpp:525
Iterator< component_t > getComponent(int n) const
Get an iterator that operates on the nth component.
Definition vector/Iterator.hpp:1307
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
IndexTypeConfig< sizeof(void *)>::index_t index_t
Define the index type as according to the size of a pointer, i.e.
Definition Index.hpp:22
Definition Expression.hpp:20
static void ternary(const Iterator< Data > &p, const Iterator< Data1 > &q, const Iterator< Data2 > &r)
Definition Expression.hpp:76