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