Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VmathArray.hpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File VmathArray.hpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Wrappers around Vmath routines using Array<OneD,T> as arugments
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIB_LIBUTILITIES_BASSICUTILS_VECTORMATHARRAY_HPP
37 #define NEKTAR_LIB_LIBUTILITIES_BASSICUTILS_VECTORMATHARRAY_HPP
38 
41 
42  namespace Vmath
43  {
44  using namespace Nektar;
45 
46  /***************** Math routines ***************/
47  /// \brief Fill a vector with a constant value
48  template<class T> void Fill( int n, const T alpha, Array<OneD, T> &x, const int incx )
49  {
50 
51  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Out of bounds");
52 
53  Fill(n,alpha,&x[0],incx);
54  }
55 
56  template<class T> void FillWhiteNoise(
57  int n, const T eps, Array<OneD, T> &x,
58  const int incx, int outseed = 9999)
59  {
60  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Out of bounds");
61 
62  FillWhiteNoise(n,eps,&x[0],incx,outseed);
63  }
64 
65  /// \brief Multiply vector z = x*y
66  template<class T> void Vmul( int n, const Array<OneD, const T> &x, const int incx, const Array<OneD, const T> &y, const int incy, Array<OneD,T> &z, const int incz)
67  {
68  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
69  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
70  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
71 
72  Vmul(n,&x[0],incx,&y[0],incy,&z[0],incz);
73  }
74 
75  template<class T> void Vmul( int n, const Array<TwoD,NekDouble>::const_reference &x, const int incx, const Array<OneD,const T> &y, const int incy, Array<OneD,T> &z, const int incz)
76  {
77  ASSERTL1(n*incx <= x.num_elements(),"Array out of bounds");
78  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
79  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
80 
81  Vmul(n,x.origin(),incx,&y[0],incy,&z[0],incz);
82  }
83 
84  /// \brief Scalar multiply y = alpha*y
85 
86  template<class T> void Smul( int n, const T alpha, const Array<OneD,const T> &x, const int incx, Array<OneD,T> &y, const int incy)
87  {
88  ASSERTL1(static_cast<unsigned int>(n*incx) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
89  ASSERTL1(static_cast<unsigned int>(n*incy) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
90 
91  Smul(n,alpha, &x[0],incx,&y[0],incy);
92  }
93 
94  /// \brief Multiply vector z = x/y
95  template<class T> void Vdiv( int n, const Array<OneD,const T> &x, const int incx, const Array<OneD,const T> &y, const int incy, Array<OneD,T> &z, const int incz)
96  {
97  ASSERTL1(static_cast<unsigned int>(n*incx) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
98  ASSERTL1(static_cast<unsigned int>(n*incy) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
99  ASSERTL1(static_cast<unsigned int>(n*incz) <= z.num_elements()+z.GetOffset(),"Array out of bounds");
100 
101  Vdiv(n,&x[0],incx,&y[0],incy,&z[0],incz);
102 
103  }
104 
105  /// \brief Scalar multiply y = alpha/y
106  template<class T> void Sdiv( int n, const T alpha, const Array<OneD,const T> &x, const int incx, Array<OneD,T> &y, const int incy)
107  {
108  ASSERTL1(static_cast<unsigned int>(n*incx) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
109  ASSERTL1(static_cast<unsigned int>(n*incy) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
110 
111  Sdiv(n,alpha,&x[0],incx,&y[0],incy);
112  }
113 
114  /// \brief Add vector z = x+y
115  template<class T> void Vadd( int n, const Array<OneD,const T> &x, const int incx, const Array<OneD,const T> &y, const int incy, Array<OneD,T> &z, const int incz)
116  {
117 
118  ASSERTL1(static_cast<unsigned int>(n*incx) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
119  ASSERTL1(static_cast<unsigned int>(n*incy) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
120  ASSERTL1(static_cast<unsigned int>(n*incz) <= z.num_elements()+z.GetOffset(),"Array out of bounds");
121 
122  Vadd(n,&x[0],incx,&y[0],incy,&z[0],incz);
123  }
124 
125  /// \brief Add vector y = alpha + x
126  template<class T> void Sadd( int n, const T alpha, const Array<OneD,const T> &x,const int incx, Array<OneD,T> &y, const int incy)
127  {
128 
129  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
130  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
131 
132  Sadd(n,alpha,&x[0],incx,&y[0],incy);
133  }
134 
135  /// \brief Subtract vector z = x-y
136  template<class T> void Vsub( int n, const Array<OneD,const T> &x, const int incx, const Array<OneD,const T> &y, const int incy, Array<OneD,T> &z, const int incz)
137  {
138  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
139  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
140  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
141 
142  Vsub(n,&x[0],incx,&y[0],incy,&z[0],incz);
143 
144  }
145 
146  /// \brief Zero vector
147  template<class T> void Zero(int n, Array<OneD,T> &x, const int incx)
148  {
149  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
150 
151  Zero(n,&x[0],incx);
152 
153  }
154 
155  /// \brief Negate x = -x
156  template<class T> void Neg( int n, Array<OneD,T> &x, const int incx)
157  {
158  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
159 
160  Neg(n,&x[0],incx);
161 
162  }
163 
164  template<class T> void Vlog(int n, const Array<OneD,const T> &x, const int incx, Array<OneD,T> &y, const int incy)
165  {
166  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
167  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
168 
169  Vlog(n, &x[0], incx, &y[0], incy);
170  }
171 
172 
173  template<class T> void Vexp(int n, const Array<OneD,const T> &x, const int incx, Array<OneD,T> &y, const int incy)
174  {
175  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
176  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
177 
178  Vexp(n, &x[0], incx, &y[0], incy);
179  }
180 
181  template<class T> void Vpow(int n, const Array<OneD,const T> &x, const int incx, const T f, Array<OneD,T> &y, const int incy)
182  {
183  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
184  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
185 
186  Vpow(n, &x[0], incx, f, &y[0], incy);
187  }
188 
189  /// \brief sqrt y = sqrt(x)
190  template<class T> void Vsqrt(int n, const Array<OneD,const T> &x, const int incx, Array<OneD,T> &y, const int incy)
191  {
192  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
193  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
194 
195  Vsqrt(n,&x[0],incx,&y[0],incy);
196  }
197 
198  /// \brief vabs: y = |x|
199  template<class T> void Vabs(int n, const Array<OneD,const T> &x, const int incx, Array<OneD,T> &y, const int incy)
200  {
201  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
202  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
203 
204  Vabs(n,&x[0],incx,&y[0],incy);
205  }
206 
207  /********** Triad routines ***********************/
208 
209  /// \brief vvtvp (vector times vector plus vector): z = w*x + y
210  template<class T> void Vvtvp(int n, const Array<OneD, const T> &w, const int incw, const Array<OneD,const T> &x, const int incx, const Array<OneD, const T> &y, const int incy, Array<OneD,T> &z, const int incz)
211  {
212  ASSERTL1(n*incw <= w.num_elements()+w.GetOffset(),"Array out of bounds");
213  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
214  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
215  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
216 
217  Vvtvp(n,&w[0],incw,&x[0],incx,&y[0],incy,&z[0],incz);
218  }
219 
220  template<class T> void Vvtvp(int n, const Array<TwoD,NekDouble>::const_reference &w, const int incw, const Array<OneD, const T> &x, const int incx, const Array<OneD,const T> &y, const int incy, Array<OneD,T> &z, const int incz)
221  {
222  ASSERTL1(n*incw <= w.num_elements(),"Array out of bounds");
223  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
224  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
225  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
226 
227  Vvtvp(n,w.origin(),incw,&x[0],incx,&y[0],incy,&z[0],incz);
228  }
229 
230  /// \brief svtvp (scalar times vector plus vector): z = alpha*x + y
231  template<class T> void Svtvp(int n, const T alpha, const Array<OneD,const T> &x, const int incx, const Array<OneD, const T> &y, const int incy, Array<OneD,T> &z, const int incz)
232  {
233  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
234  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
235  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
236 
237  Svtvp(n,alpha,&x[0],incx,&y[0],incy,&z[0],incz);
238 
239  }
240 
241  /// \brief svtvp (scalar times vector plus vector): z = alpha*x + y
242  template<class T> void Svtvm(int n, const T alpha, const Array<OneD,const T> &x, const int incx, const Array<OneD, const T> &y, const int incy, Array<OneD,T> &z, const int incz)
243  {
244  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
245  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
246  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
247 
248  Svtvm(n,alpha,&x[0],incx,&y[0],incy,&z[0],incz);
249 
250  }
251 
252  /// \brief vvtvm (vector times vector minus vector): z = w*x - y
253  template<class T> void Vvtvm(int n, const Array<OneD,const T> &w, const int incw, const Array<OneD,const T> &x, const int incx, const Array<OneD,const T> &y, const int incy, Array<OneD,T> &z, const int incz)
254  {
255  ASSERTL1(n*incw <= w.num_elements()+w.GetOffset(),"Array out of bounds");
256  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
257  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
258  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
259 
260  Vvtvm(n,&w[0],incw,&x[0],incx,&y[0],incy,&z[0],incz);
261 
262  }
263 
264  /// \brief vvtvvtp (vector times vector plus vector times vector): z = v*w + y*z
265  template<class T> void Vvtvvtp (
266  int n,
267  const Array<OneD,const T> &v, int incv,
268  const Array<OneD,const T> &w, int incw,
269  const Array<OneD,const T> &x, int incx,
270  const Array<OneD,const T> &y, int incy,
271  Array<OneD, T> &z, int incz)
272  {
273  ASSERTL1(n*incv <= v.num_elements()+v.GetOffset(),"Array out of bounds");
274  ASSERTL1(n*incw <= w.num_elements()+w.GetOffset(),"Array out of bounds");
275  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
276  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
277  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
278 
279  Vvtvvtp(n,&v[0],incv,&w[0],incw,&x[0],incx,&y[0],incy,&z[0],incz);
280  }
281 
282  /// \brief svtsvtp (scalar times vector plus scalar times vector): z = alpha*x + beta*y
283  template<class T> void Svtsvtp(int n, const T alpha, const Array<OneD,const T> &x, const int incx, const T beta, const Array<OneD,const T> &y, const int incy, Array<OneD,T> &z, const int incz)
284  {
285  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
286  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
287  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
288 
289  Svtsvtp(n,alpha,&x[0],incx,beta,&y[0],incy,&z[0],incz);
290  }
291 
292 
293 
294 
295  /************ Misc routine from Veclib (and extras) ************/
296 
297  /// \brief Gather vector z[i] = x[y[i]]
298  template<class T> void Gathr(int n, const Array<OneD, const T> &x, const Array<OneD, const int> &y, Array<OneD,T> &z)
299  {
300 
301  ASSERTL1(n <= y.num_elements()+y.GetOffset(),"Array out of bounds");
302  ASSERTL1(n <= z.num_elements()+z.GetOffset(),"Array out of bounds");
303 
304  Gathr(n,&x[0],&y[0],&z[0]);
305 
306  }
307 
308  /// \brief Scatter vector z[y[i]] = x[i]
309  template<class T> void Scatr(int n, const Array<OneD,const T> &x, const Array<OneD,const int> &y, Array<OneD,T> &z)
310  {
311  ASSERTL1(n <= x.num_elements()+x.GetOffset(),"Array out of bounds");
312  ASSERTL1(n <= y.num_elements()+y.GetOffset(),"Array out of bounds");
313 
314  Scatr(n,&x[0],&y[0],&z[0]);
315  }
316 
317 
318  /// \brief Assemble z[y[i]] += x[i]; z should be zero'd first
319  template<class T> void Assmb(int n, const Array<OneD,T> &x, const Array<OneD,int> &y, Array<OneD,T> &z)
320  {
321  ASSERTL1(n <= x.num_elements()+x.GetOffset(),"Array out of bounds");
322  ASSERTL1(n <= y.num_elements()+y.GetOffset(),"Array out of bounds");
323 
324  Assmb(n,&x[0],&y[0],&z[0]);
325  }
326 
327 
328  /************* Reduction routines *****************/
329 
330  /// \brief Subtract return sum(x)
331  template<class T> T Vsum( int n, const Array<OneD, const T> &x, const int incx)
332  {
333  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
334 
335  return Vsum(n,&x[0],incx);
336  }
337 
338 
339  /// \brief Return the index of the maximum element in x
340  template<class T> int Imax( int n, const Array<OneD, const T> &x, const int incx)
341  {
342  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
343 
344  return Imax(n,&x[0],incx);
345  }
346 
347  /// \brief Return the maximum element in x -- called vmax to avoid
348  /// conflict with max
349  template<class T> T Vmax( int n, const Array<OneD, const T> &x, const int incx)
350  {
351  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
352 
353  return Vmax(n,&x[0],incx);
354  }
355 
356  /// \brief Return the index of the maximum absolute element in x
357  template<class T> int Iamax( int n, const Array<OneD, const T> &x, const int incx)
358  {
359  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
360 
361  return Iamax(n,&x[0],incx);
362 
363  }
364 
365  /// \brief Return the maximum absolute element in x
366  /// called vamax to avoid conflict with max
367  template<class T> T Vamax( int n, const Array<OneD, const T> &x, const int incx)
368  {
369  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
370 
371  return Vamax(n,&x[0],incx);
372  }
373 
374 
375  /// \brief Return the index of the minimum element in x
376  template<class T> int Imin( int n, const Array<OneD, const T> &x, const int incx)
377  {
378  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
379 
380  return Imin(n,&x[0],incx);
381  }
382 
383  /// \brief Return the minimum element in x - called vmin to avoid
384  /// conflict with min
385  template<class T> T Vmin( int n, const Array<OneD, const T> &x, const int incx)
386  {
387  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
388 
389  return Vmin(n,&x[0],incx);
390  }
391 
392  /// \brief Return number of NaN elements of x
393  template<class T> int Nnan(int n, const Array<OneD, const T> &x, const int incx)
394  {
395  ASSERTL1(n * incx <= x.num_elements() + x.GetOffset(), "Array out of bounds");
396 
397  return Nnan(n, &x[0], incx);
398  }
399 
400  /// \brief
401  template<class T> T Dot(int n,
402  const Array<OneD, const T> &w,
403  const Array<OneD, const T> &x)
404  {
405  ASSERTL1(n <= w.num_elements()+w.GetOffset(),"Array out of bounds");
406  ASSERTL1(n <= x.num_elements()+x.GetOffset(),"Array out of bounds");
407 
408  return Dot(n,&w[0],&x[0]);
409  }
410 
411  /// \brief
412  template<class T> T Dot(int n,
413  const Array<OneD, const T> &w, const int incw,
414  const Array<OneD, const T> &x, const int incx)
415  {
416  ASSERTL1(n*incw <= w.num_elements()+w.GetOffset(),"Array out of bounds");
417  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
418 
419  return Dot(n,&w[0],incw,&x[0],incx);
420  }
421 
422  /// \brief
423  template<class T> T Dot2(int n,
424  const Array<OneD, const T> &w,
425  const Array<OneD, const T> &x,
426  const Array<OneD, const int> &y)
427  {
428  ASSERTL1(n <= w.num_elements()+w.GetOffset(),"Array out of bounds");
429  ASSERTL1(n <= x.num_elements()+x.GetOffset(),"Array out of bounds");
430  ASSERTL1(n <= y.num_elements()+y.GetOffset(),"Array out of bounds");
431 
432  return Dot2(n,&w[0],&x[0],&y[0]);
433  }
434 
435  /// \brief
436  template<class T> T Ddot(int n,
437  const Array<OneD, const T> &w, const int incw,
438  const Array<OneD, const T> &x, const int incx,
439  const Array<OneD, const int> &y, const int incy)
440  {
441  ASSERTL1(n*incw <= w.num_elements()+w.GetOffset(),"Array out of bounds");
442  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
443  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
444 
445  return Dot2(n,&w[0],incw,&x[0],incx,&y[0],incy);
446  }
447 
448  /********** Memory routines ***********************/
449 
450  template<class T> void Vcopy(int n, const Array<OneD, const T> &x, int incx, Array<OneD,T> &y, int const incy)
451  {
452  ASSERTL1(static_cast<unsigned int>(std::abs(n*incx)) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
453  ASSERTL1(static_cast<unsigned int>(std::abs(n*incy)) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
454 
455  Vcopy(n,&x[0],incx,&y[0],incy);
456  }
457 
458  template<class T> void Reverse(int n, const Array<OneD, const T> &x, int incx, Array<OneD,T> &y, int const incy)
459  {
460  ASSERTL1(static_cast<unsigned int>(std::abs(n*incx)) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
461  ASSERTL1(static_cast<unsigned int>(std::abs(n*incy)) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
462 
463  Reverse(n,&x[0],incx,&y[0],incy);
464  }
465 
466  }
467 #endif //VECTORMATHARRAY_HPP
468 
Definition: Vmath.cpp:40
void Vpow(int n, const T *x, const int incx, const T f, T *y, const int incy)
Definition: Vmath.hpp:119
void Gathr(int n, const T *x, const int *y, T *z)
Gather vector z[i] = x[y[i]].
Definition: Vmath.cpp:644
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:408
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
Definition: Vmath.cpp:779
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
Definition: Vmath.cpp:871
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:46
int Imin(int n, const T *x, const int incx)
Return the index of the minimum element in x.
Definition: Vmath.cpp:847
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
Definition: Vmath.cpp:485
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:442
void Sdiv(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha/y.
Definition: Vmath.cpp:271
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
Definition: Vmath.cpp:241
void Vabs(int n, const T *x, const int incx, T *y, const int incy)
vabs: y = |x|
Definition: Vmath.cpp:424
int Imax(int n, const T *x, const int incx)
Return the index of the maximum element in x.
Definition: Vmath.cpp:755
void Reverse(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1085
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:213
int Nnan(int n, const T *x, const int incx)
Return number of NaN elements of x.
Definition: Vmath.cpp:892
void Vexp(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:108
void Svtvm(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x - y
Definition: Vmath.cpp:518
void Scatr(int n, const T *x, const int *y, T *z)
Scatter vector z[y[i]] = x[i].
Definition: Vmath.cpp:673
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:396
void Assmb(int n, const T *x, const int *y, T *z)
Assemble z[y[i]] += x[i]; z should be zero'd first.
Definition: Vmath.cpp:709
T Vamax(int n, const T *x, const int incx)
Return the maximum absolute element in x called vamax to avoid conflict with max. ...
Definition: Vmath.cpp:825
int Iamax(int n, const T *x, const int incx)
Return the index of the maximum absolute element in x.
Definition: Vmath.cpp:800
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
Definition: Vmath.cpp:315
T Ddot(int n, const Array< OneD, const T > &w, const int incw, const Array< OneD, const T > &x, const int incx, const Array< OneD, const int > &y, const int incy)
Definition: VmathArray.hpp:436
T Dot(int n, const T *w, const T *x)
vvtvp (vector times vector times vector): z = w*x*y
Definition: Vmath.cpp:914
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.cpp:343
void Vvtvvtp(int n, const T *v, int incv, const T *w, int incw, const T *x, int incx, const T *y, int incy, T *z, int incz)
vvtvvtp (vector times vector plus vector times vector):
Definition: Vmath.cpp:537
void Vvtvm(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvm (vector times vector plus vector): z = w*x - y
Definition: Vmath.cpp:465
T Dot2(int n, const T *w, const T *x, const int *y)
vvtvp (vector times vector times vector): z = w*x*y
Definition: Vmath.cpp:954
void FillWhiteNoise(int n, const T eps, T *x, const int incx, int outseed)
Fills a vector with white noise.
Definition: Vmath.cpp:138
void Vlog(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:96
void Svtsvtp(int n, const T alpha, const T *x, int incx, const T beta, const T *y, int incy, T *z, int incz)
vvtvvtp (scalar times vector plus scalar times vector):
Definition: Vmath.cpp:591
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Definition: Vmath.cpp:737
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:373
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:228
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:299
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:183