NeoPZ
tinyveccpy.h
Go to the documentation of this file.
1 // Emacs will be in -*- Mode: c++ -*-
2 //
3 // ***************** DO NOT REMOVE THIS BANNER *****************
4 //
5 // SUMMARY: Templatized Oriented Object Finte Element Method
6 // TOOFEM
7 // RELEASE: 0.1
8 // USAGE : You may copy freely these files and use it for
9 // teaching or research. These or part of these may
10 // not be sold or used for a commercial purpose with-
11 // out our consent : fax (33)1 44 27 72 00
12 //
13 // AUTHOR : Nicolas Di cesare
14 // ORG :
15 // E-MAIL : Nicolas.Dicesare@ann.jussieu.fr
16 //
17 // ORIG-DATE: September 98
18 // LAST-MOD : 15/09/98
19 // ************************************************************
20 #ifndef _tinyveccpy_h
21 #define _tinyveccpy_h
22 
23 
24 // Recursive definition
25 template < int N> struct TinyCopy {
26  template <int Num, class T> static inline void eval( TinyVector< T, Num >& y, const TinyVector< T, Num >& x)
27  {
28  y[N] = x[N];
30  }
31  template <int Num, class T> static inline void eval( TinyVector< T, Num >& y, const T & val)
32  {
33  y[N] = val;
34  TinyCopy<N-1>::eval(y,val);
35  }
36 };
37 
38 // Specialization
39 template <> struct TinyCopy<3> {
40  template <int Num, class T> static inline void eval( TinyVector< T, Num >& y, const TinyVector< T, Num >& x)
41  {
42  y[0] = x[0]; y[1] = x[1]; y[2] = x[2]; y[3] = x[3];
43  }
44  template <int Num, class T> static inline void eval( TinyVector< T, Num >& y, const T & val)
45  {
46  y[0] = y[1] = y[2] = y[3] = val;
47  }
48 };
49 
50 template <> struct TinyCopy<2> {
51  template <int Num, class T> static inline void eval( TinyVector< T, Num >& y, const TinyVector< T, Num >& x)
52  {
53  y[0] = x[0]; y[1] = x[1]; y[2] = x[2];
54  }
55  template <int Num, class T> static inline void eval( TinyVector< T, Num >& y, const T & val)
56  {
57  y[0] = y[1] = y[2] = val;
58  }
59 };
60 
61 template <> struct TinyCopy<1> {
62  template <int Num, class T> static inline void eval( TinyVector< T, Num >& y, const TinyVector< T, Num >& x)
63  {
64  y[0] = x[0]; y[1] = x[1];
65  }
66  template <int Num, class T> static inline void eval( TinyVector< T, Num >& y, const T & val)
67  {
68  y[0] = y[1] = val;
69  }
70 };
71 
72 template <> struct TinyCopy<0> {
73  template <int Num, class T> static inline void eval( TinyVector< T, Num >& y, const TinyVector< T, Num >& x)
74  {
75  y[0] = x[0];
76  }
77  template <int Num, class T> static inline void eval( TinyVector< T, Num >& y, const T & val)
78  {
79  y[0] = val;
80  }
81 };
82 
83 
84 
85 // Recursive definition
86 template < int Num, class T> inline
88 {
89  for (int i=0; i<Num; ++i)
90  y[i] = x[i];
91  // TinyCopy<Num-1>::eval(y,x);
92 }
93 
94 template < int Num, class T> inline
95 void Copy( TinyVector< T, Num >& y, const T & val)
96 {
97  for (int i=0; i<Num; ++i)
98  y[i] = val;
99  // TinyCopy<Num-1>::eval(y,val);
100 }
101 
102 
103 //Specializaions
104 template < class T> inline
106 {
107  y[0] = x[0]; y[1] = x[1]; y[2] = x[2];
108  y[3] = x[3]; y[4] = x[4]; y[5] = x[5];
109 }
110 
111 template < class T> inline
112 void Copy( TinyVector< T, 6>& y, const T & val)
113 {
114  y[0] = y[1] = y[2] = y[3] = y[4] = y[5] = val;
115 }
116 
117 
118 template < class T> inline
120 {
121  y[0] = x[0]; y[1] = x[1]; y[2] = x[2]; y[3] = x[3]; y[4] = x[4];
122 }
123 
124 template < class T> inline
125 void Copy( TinyVector< T, 5>& y, const T & val)
126 {
127  y[0] = y[1] = y[2] = y[3] = y[4] = val;
128 }
129 
130 
131 template < class T> inline
133 {
134  y[0] = x[0]; y[1] = x[1]; y[2] = x[2]; y[3] = x[3];
135 }
136 
137 template < class T> inline
138 void Copy( TinyVector< T, 4>& y, const T & val)
139 {
140  y[0] = y[1] = y[2] = y[3] = val;
141 }
142 
143 
144 template < class T> inline
146 {
147  y[0] = x[0]; y[1] = x[1]; y[2] = x[2];
148 }
149 
150 template < class T> inline
151 void Copy( TinyVector< T, 3>& y, const T & val)
152 {
153  y[0] = y[1] = y[2] = val;
154 }
155 
156 
157 template < class T> inline
159 {
160  y[0] = x[0]; y[1] = x[1];
161 }
162 
163 template < class T> inline
164 void Copy( TinyVector< T, 2>& y, const T & val)
165 {
166  y[0] = y[1] = val;
167 }
168 
169 
170 template < class T> inline
172 {
173  y[0] = x[0];
174 }
175 
176 template < class T> inline
177 void Copy( TinyVector< T, 1>& y, const T & val)
178 {
179  y[0] = val;
180 }
181 
182 
183 #endif
static void eval(TinyVector< T, Num > &y, const TinyVector< T, Num > &x)
Definition: tinyveccpy.h:26
static void eval(TinyVector< T, Num > &y, const T &val)
Definition: tinyveccpy.h:44
static void eval(TinyVector< T, Num > &y, const TinyVector< T, Num > &x)
Definition: tinyveccpy.h:40
REAL val(STATE &number)
Returns value of the variable.
Definition: pzartdiff.h:23
static void eval(TinyVector< T, Num > &y, const T &val)
Definition: tinyveccpy.h:66
static void eval(TinyVector< T, Num > &y, const TinyVector< T, Num > &x)
Definition: tinyveccpy.h:62
static void eval(TinyVector< T, Num > &y, const T &val)
Definition: tinyveccpy.h:77
void Copy(TinyVector< T, Num > &y, const TinyVector< T, Num > &x)
Definition: tinyveccpy.h:87
static void eval(TinyVector< T, Num > &y, const TinyVector< T, Num > &x)
Definition: tinyveccpy.h:73
static void eval(TinyVector< T, Num > &y, const TinyVector< T, Num > &x)
Definition: tinyveccpy.h:51
static void eval(TinyVector< T, Num > &y, const T &val)
Definition: tinyveccpy.h:55
static void eval(TinyVector< T, Num > &y, const T &val)
Definition: tinyveccpy.h:31