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 // 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( int n, const T eps, Array<OneD, T> &x, const int incx, int outseed)
57  {
58  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Out of bounds");
59 
60  FillWhiteNoise(n,eps,&x[0],incx,outseed);
61  }
62 
63  /// \brief Multiply vector z = x*y
64  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)
65  {
66  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
67  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
68  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
69 
70  Vmul(n,&x[0],incx,&y[0],incy,&z[0],incz);
71  }
72 
73  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)
74  {
75  ASSERTL1(n*incx <= x.num_elements(),"Array out of bounds");
76  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
77  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
78 
79  Vmul(n,x.origin(),incx,&y[0],incy,&z[0],incz);
80  }
81 
82  /// \brief Scalar multiply y = alpha*y
83 
84  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)
85  {
86  ASSERTL1(static_cast<unsigned int>(n*incx) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
87  ASSERTL1(static_cast<unsigned int>(n*incy) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
88 
89  Smul(n,alpha, &x[0],incx,&y[0],incy);
90  }
91 
92  /// \brief Multiply vector z = x/y
93  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)
94  {
95  ASSERTL1(static_cast<unsigned int>(n*incx) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
96  ASSERTL1(static_cast<unsigned int>(n*incy) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
97  ASSERTL1(static_cast<unsigned int>(n*incz) <= z.num_elements()+z.GetOffset(),"Array out of bounds");
98 
99  Vdiv(n,&x[0],incx,&y[0],incy,&z[0],incz);
100 
101  }
102 
103  /// \brief Scalar multiply y = alpha/y
104  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)
105  {
106  ASSERTL1(static_cast<unsigned int>(n*incx) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
107  ASSERTL1(static_cast<unsigned int>(n*incy) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
108 
109  Sdiv(n,alpha,&x[0],incx,&y[0],incy);
110  }
111 
112  /// \brief Add vector z = x+y
113  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)
114  {
115 
116  ASSERTL1(static_cast<unsigned int>(n*incx) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
117  ASSERTL1(static_cast<unsigned int>(n*incy) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
118  ASSERTL1(static_cast<unsigned int>(n*incz) <= z.num_elements()+z.GetOffset(),"Array out of bounds");
119 
120  Vadd(n,&x[0],incx,&y[0],incy,&z[0],incz);
121  }
122 
123  /// \brief Add vector y = alpha + x
124  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)
125  {
126 
127  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
128  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
129 
130  Sadd(n,alpha,&x[0],incx,&y[0],incy);
131  }
132 
133  /// \brief Subtract vector z = x-y
134  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)
135  {
136  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
137  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
138  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
139 
140  Vsub(n,&x[0],incx,&y[0],incy,&z[0],incz);
141 
142  }
143 
144  /// \brief Zero vector
145  template<class T> void Zero(int n, Array<OneD,T> &x, const int incx)
146  {
147  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
148 
149  Zero(n,&x[0],incx);
150 
151  }
152 
153  /// \brief Negate x = -x
154  template<class T> void Neg( int n, Array<OneD,T> &x, const int incx)
155  {
156  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
157 
158  Neg(n,&x[0],incx);
159 
160  }
161 
162  template<class T> void Vlog(int n, const Array<OneD,const T> &x, const int incx, Array<OneD,T> &y, const int incy)
163  {
164  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
165  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
166 
167  Vlog(n, &x[0], incx, &y[0], incy);
168  }
169 
170 
171  template<class T> void Vexp(int n, const Array<OneD,const T> &x, const int incx, Array<OneD,T> &y, const int incy)
172  {
173  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
174  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
175 
176  Vexp(n, &x[0], incx, &y[0], incy);
177  }
178 
179  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)
180  {
181  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
182  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
183 
184  Vpow(n, &x[0], incx, f, &y[0], incy);
185  }
186 
187  /// \brief sqrt y = sqrt(x)
188  template<class T> void Vsqrt(int n, const Array<OneD,const T> &x, const int incx, Array<OneD,T> &y, const int incy)
189  {
190  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
191  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
192 
193  Vsqrt(n,&x[0],incx,&y[0],incy);
194  }
195 
196  /// \brief vabs: y = |x|
197  template<class T> void Vabs(int n, const Array<OneD,const T> &x, const int incx, Array<OneD,T> &y, const int incy)
198  {
199  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
200  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
201 
202  Vabs(n,&x[0],incx,&y[0],incy);
203  }
204 
205  /********** Triad routines ***********************/
206 
207  /// \brief vvtvp (vector times vector plus vector): z = w*x + y
208  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)
209  {
210  ASSERTL1(n*incw <= w.num_elements()+w.GetOffset(),"Array out of bounds");
211  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
212  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
213  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
214 
215  Vvtvp(n,&w[0],incw,&x[0],incx,&y[0],incy,&z[0],incz);
216  }
217 
218  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)
219  {
220  ASSERTL1(n*incw <= w.num_elements(),"Array out of bounds");
221  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
222  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
223  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
224 
225  Vvtvp(n,w.origin(),incw,&x[0],incx,&y[0],incy,&z[0],incz);
226  }
227 
228  /// \brief svtvp (scalar times vector plus vector): z = alpha*x + y
229  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)
230  {
231  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
232  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
233  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
234 
235  Svtvp(n,alpha,&x[0],incx,&y[0],incy,&z[0],incz);
236 
237  }
238 
239  /// \brief svtvp (scalar times vector plus vector): z = alpha*x + y
240  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)
241  {
242  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
243  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
244  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
245 
246  Svtvm(n,alpha,&x[0],incx,&y[0],incy,&z[0],incz);
247 
248  }
249 
250  /// \brief vvtvm (vector times vector minus vector): z = w*x - y
251  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)
252  {
253  ASSERTL1(n*incw <= w.num_elements()+w.GetOffset(),"Array out of bounds");
254  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
255  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
256  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
257 
258  Vvtvm(n,&w[0],incw,&x[0],incx,&y[0],incy,&z[0],incz);
259 
260  }
261 
262  /// \brief vvtvvtp (vector times vector plus vector times vector): z = v*w + y*z
263  template<class T> void Vvtvvtp (
264  int n,
265  const Array<OneD,const T> &v, int incv,
266  const Array<OneD,const T> &w, int incw,
267  const Array<OneD,const T> &x, int incx,
268  const Array<OneD,const T> &y, int incy,
269  Array<OneD, T> &z, int incz)
270  {
271  ASSERTL1(n*incv <= v.num_elements()+v.GetOffset(),"Array out of bounds");
272  ASSERTL1(n*incw <= w.num_elements()+w.GetOffset(),"Array out of bounds");
273  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
274  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
275  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
276 
277  Vvtvvtp(n,&v[0],incv,&w[0],incw,&x[0],incx,&y[0],incy,&z[0],incz);
278  }
279 
280  /// \brief svtsvtp (scalar times vector plus scalar times vector): z = alpha*x + beta*y
281  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)
282  {
283  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
284  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
285  ASSERTL1(n*incz <= z.num_elements()+z.GetOffset(),"Array out of bounds");
286 
287  Svtsvtp(n,alpha,&x[0],incx,beta,&y[0],incy,&z[0],incz);
288  }
289 
290 
291 
292 
293  /************ Misc routine from Veclib (and extras) ************/
294 
295  /// \brief Gather vector z[i] = x[y[i]]
296  template<class T> void Gathr(int n, const Array<OneD, const T> &x, const Array<OneD, const int> &y, Array<OneD,T> &z)
297  {
298 
299  ASSERTL1(n <= y.num_elements()+y.GetOffset(),"Array out of bounds");
300  ASSERTL1(n <= z.num_elements()+z.GetOffset(),"Array out of bounds");
301 
302  Gathr(n,&x[0],&y[0],&z[0]);
303 
304  }
305 
306  /// \brief Scatter vector z[y[i]] = x[i]
307  template<class T> void Scatr(int n, const Array<OneD,const T> &x, const Array<OneD,const int> &y, Array<OneD,T> &z)
308  {
309  ASSERTL1(n <= x.num_elements()+x.GetOffset(),"Array out of bounds");
310  ASSERTL1(n <= y.num_elements()+y.GetOffset(),"Array out of bounds");
311 
312  Scatr(n,&x[0],&y[0],&z[0]);
313  }
314 
315 
316  /// \brief Assemble z[y[i]] += x[i]; z should be zero'd first
317  template<class T> void Assmb(int n, const Array<OneD,T> &x, const Array<OneD,int> &y, Array<OneD,T> &z)
318  {
319  ASSERTL1(n <= x.num_elements()+x.GetOffset(),"Array out of bounds");
320  ASSERTL1(n <= y.num_elements()+y.GetOffset(),"Array out of bounds");
321 
322  Assmb(n,&x[0],&y[0],&z[0]);
323  }
324 
325 
326  /************* Reduction routines *****************/
327 
328  /// \brief Subtract return sum(x)
329  template<class T> T Vsum( int n, const Array<OneD, const T> &x, const int incx)
330  {
331  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
332 
333  return Vsum(n,&x[0],incx);
334  }
335 
336 
337  /// \brief Return the index of the maximum element in x
338  template<class T> int Imax( int n, const Array<OneD, const T> &x, const int incx)
339  {
340  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
341 
342  return Imax(n,&x[0],incx);
343  }
344 
345  /// \brief Return the maximum element in x -- called vmax to avoid
346  /// conflict with max
347  template<class T> T Vmax( int n, const Array<OneD, const T> &x, const int incx)
348  {
349  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
350 
351  return Vmax(n,&x[0],incx);
352  }
353 
354  /// \brief Return the index of the maximum absolute element in x
355  template<class T> int Iamax( int n, const Array<OneD, const T> &x, const int incx)
356  {
357  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
358 
359  return Iamax(n,&x[0],incx);
360 
361  }
362 
363  /// \brief Return the maximum absolute element in x
364  /// called vamax to avoid conflict with max
365  template<class T> T Vamax( int n, const Array<OneD, const T> &x, const int incx)
366  {
367  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
368 
369  return Vamax(n,&x[0],incx);
370  }
371 
372 
373  /// \brief Return the index of the minimum element in x
374  template<class T> int Imin( int n, const Array<OneD, const T> &x, const int incx)
375  {
376  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
377 
378  return Imin(n,&x[0],incx);
379  }
380 
381  /// \brief Return the minimum element in x - called vmin to avoid
382  /// conflict with min
383  template<class T> T Vmin( int n, const Array<OneD, const T> &x, const int incx)
384  {
385  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
386 
387  return Vmin(n,&x[0],incx);
388  }
389 
390  /// \brief Return number of NaN elements of x
391  template<class T> int Nnan(int n, const Array<OneD, const T> &x, const int incx)
392  {
393  ASSERTL1(n * incx <= x.num_elements() + x.GetOffset(), "Array out of bounds");
394 
395  return Nnan(n, &x[0], incx);
396  }
397 
398  /// \brief
399  template<class T> T Dot(int n,
400  const Array<OneD, const T> &w,
401  const Array<OneD, const T> &x)
402  {
403  ASSERTL1(n <= w.num_elements()+w.GetOffset(),"Array out of bounds");
404  ASSERTL1(n <= x.num_elements()+x.GetOffset(),"Array out of bounds");
405 
406  return Dot(n,&w[0],&x[0]);
407  }
408 
409  /// \brief
410  template<class T> T Dot(int n,
411  const Array<OneD, const T> &w, const int incw,
412  const Array<OneD, const T> &x, const int incx)
413  {
414  ASSERTL1(n*incw <= w.num_elements()+w.GetOffset(),"Array out of bounds");
415  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
416 
417  return Dot(n,&w[0],incw,&x[0],incx);
418  }
419 
420  /// \brief
421  template<class T> T Dot2(int n,
422  const Array<OneD, const T> &w,
423  const Array<OneD, const T> &x,
424  const Array<OneD, const int> &y)
425  {
426  ASSERTL1(n <= w.num_elements()+w.GetOffset(),"Array out of bounds");
427  ASSERTL1(n <= x.num_elements()+x.GetOffset(),"Array out of bounds");
428  ASSERTL1(n <= y.num_elements()+y.GetOffset(),"Array out of bounds");
429 
430  return Dot2(n,&w[0],&x[0],&y[0]);
431  }
432 
433  /// \brief
434  template<class T> T Ddot(int n,
435  const Array<OneD, const T> &w, const int incw,
436  const Array<OneD, const T> &x, const int incx,
437  const Array<OneD, const int> &y, const int incy)
438  {
439  ASSERTL1(n*incw <= w.num_elements()+w.GetOffset(),"Array out of bounds");
440  ASSERTL1(n*incx <= x.num_elements()+x.GetOffset(),"Array out of bounds");
441  ASSERTL1(n*incy <= y.num_elements()+y.GetOffset(),"Array out of bounds");
442 
443  return Dot2(n,&w[0],incw,&x[0],incx,&y[0],incy);
444  }
445 
446  /********** Memory routines ***********************/
447 
448  template<class T> void Vcopy(int n, const Array<OneD, const T> &x, int incx, Array<OneD,T> &y, int const incy)
449  {
450  ASSERTL1(static_cast<unsigned int>(std::abs(n*incx)) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
451  ASSERTL1(static_cast<unsigned int>(std::abs(n*incy)) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
452 
453  Vcopy(n,&x[0],incx,&y[0],incy);
454  }
455 
456  template<class T> void Reverse(int n, const Array<OneD, const T> &x, int incx, Array<OneD,T> &y, int const incy)
457  {
458  ASSERTL1(static_cast<unsigned int>(std::abs(n*incx)) <= x.num_elements()+x.GetOffset(),"Array out of bounds");
459  ASSERTL1(static_cast<unsigned int>(std::abs(n*incy)) <= y.num_elements()+y.GetOffset(),"Array out of bounds");
460 
461  Reverse(n,&x[0],incx,&y[0],incy);
462  }
463 
464  }
465 #endif //VECTORMATHARRAY_HPP
466 
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:118
void Gathr(int n, const T *x, const int *y, T *z)
Gather vector z[i] = x[y[i]].
Definition: Vmath.cpp:630
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:394
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:756
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:848
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:824
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:471
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:428
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:257
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:227
void Vabs(int n, const T *x, const int incx, T *y, const int incy)
vabs: y = |x|
Definition: Vmath.cpp:410
int Imax(int n, const T *x, const int incx)
Return the index of the maximum element in x.
Definition: Vmath.cpp:732
void Reverse(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1062
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:199
int Nnan(int n, const T *x, const int incx)
Return number of NaN elements of x.
Definition: Vmath.cpp:869
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:504
void Scatr(int n, const T *x, const int *y, T *z)
Scatter vector z[y[i]] = x[i].
Definition: Vmath.cpp:659
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:382
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:686
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:802
int Iamax(int n, const T *x, const int incx)
Return the index of the maximum absolute element in x.
Definition: Vmath.cpp:777
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:301
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:434
T Dot(int n, const T *w, const T *x)
vvtvp (vector times vector times vector): z = w*x*y
Definition: Vmath.cpp:891
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:329
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:523
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:451
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:931
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: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:577
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Definition: Vmath.cpp:714
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:359
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1038
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:285
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:169