MCKL
Monte Carlo Kernel Library
vmf.hpp
Go to the documentation of this file.
1 //============================================================================
2 // MCKL/include/mckl/math/vmf.hpp
3 //----------------------------------------------------------------------------
4 // MCKL: Monte Carlo Kernel Library
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013-2018, Yan Zhou
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30 //============================================================================
31 
32 #ifndef MCKL_MATH_VMF_HPP
33 #define MCKL_MATH_VMF_HPP
34 
35 #include <mckl/internal/config.h>
36 
37 #include <mckl/internal/assert.hpp>
38 #include <mckl/math/constants.hpp>
39 #include <mckl/math/erf.hpp>
40 
41 #include <algorithm>
42 #include <array>
43 #include <cmath>
44 #include <complex>
45 
46 #if MCKL_USE_MKL_VML
47 
48 #include <mkl_vml.h>
49 
50 #define MCKL_DEFINE_MATH_VMF_VML_1R(func, name) \
51  inline void name(std::size_t n, const float *a, float *y) \
52  { \
53  internal::size_check<MKL_INT>(n, #name); \
54  ::vs##func(static_cast<MKL_INT>(n), a, y); \
55  } \
56  \
57  inline void name(std::size_t n, const double *a, double *y) \
58  { \
59  internal::size_check<MKL_INT>(n, #name); \
60  ::vd##func(static_cast<MKL_INT>(n), a, y); \
61  }
62 
63 #define MCKL_DEFINE_MATH_VMF_VML_1C(func, name) \
64  inline void name( \
65  std::size_t n, const std::complex<float> *a, std::complex<float> *y) \
66  { \
67  internal::size_check<MKL_INT>(n, #name); \
68  ::vc##func(static_cast<MKL_INT>(n), \
69  reinterpret_cast<const ::MKL_Complex8 *>(a), \
70  reinterpret_cast<::MKL_Complex8 *>(y)); \
71  } \
72  \
73  inline void name(std::size_t n, const std::complex<double> *a, \
74  std::complex<double> *y) \
75  { \
76  internal::size_check<MKL_INT>(n, #name); \
77  ::vz##func(static_cast<MKL_INT>(n), \
78  reinterpret_cast<const ::MKL_Complex16 *>(a), \
79  reinterpret_cast<::MKL_Complex16 *>(y)); \
80  }
81 
82 #define MCKL_DEFINE_MATH_VMF_VML_2R(func, name) \
83  inline void name(std::size_t n, const float *a, const float *b, float *y) \
84  { \
85  internal::size_check<MKL_INT>(n, #name); \
86  ::vs##func(static_cast<MKL_INT>(n), a, b, y); \
87  } \
88  \
89  inline void name( \
90  std::size_t n, const double *a, const double *b, double *y) \
91  { \
92  internal::size_check<MKL_INT>(n, #name); \
93  ::vd##func(static_cast<MKL_INT>(n), a, b, y); \
94  }
95 
96 #define MCKL_DEFINE_MATH_VMF_VML_2C(func, name) \
97  inline void name(std::size_t n, const std::complex<float> *a, \
98  const std::complex<float> *b, std::complex<float> *y) \
99  { \
100  internal::size_check<MKL_INT>(n, #name); \
101  ::vc##func(static_cast<MKL_INT>(n), \
102  reinterpret_cast<const ::MKL_Complex8 *>(a), \
103  reinterpret_cast<const ::MKL_Complex8 *>(b), \
104  reinterpret_cast<::MKL_Complex8 *>(y)); \
105  } \
106  \
107  inline void name(std::size_t n, const std::complex<double> *a, \
108  const std::complex<double> *b, std::complex<double> *y) \
109  { \
110  internal::size_check<MKL_INT>(n, #name); \
111  ::vz##func(static_cast<MKL_INT>(n), \
112  reinterpret_cast<const ::MKL_Complex16 *>(a), \
113  reinterpret_cast<const ::MKL_Complex16 *>(b), \
114  reinterpret_cast<::MKL_Complex16 *>(y)); \
115  }
116 
117 namespace mckl {
118 
129 
130 inline void abs(std::size_t n, const std::complex<float> *a, float *y)
131 {
132  internal::size_check<MKL_INT>(n, "abs");
133  ::vcAbs(static_cast<MKL_INT>(n),
134  reinterpret_cast<const ::MKL_Complex8 *>(a), y);
135 }
136 
137 inline void abs(std::size_t n, const std::complex<double> *a, double *y)
138 {
139  internal::size_check<MKL_INT>(n, "abs");
140  ::vzAbs(static_cast<MKL_INT>(n),
141  reinterpret_cast<const ::MKL_Complex16 *>(a), y);
142 }
143 
144 inline void arg(std::size_t n, const std::complex<float> *a, float *y)
145 {
146  internal::size_check<MKL_INT>(n, "arg");
147  ::vcArg(static_cast<MKL_INT>(n),
148  reinterpret_cast<const ::MKL_Complex8 *>(a), y);
149 }
150 
151 inline void arg(std::size_t n, const std::complex<double> *a, double *y)
152 {
153  internal::size_check<MKL_INT>(n, "arg");
154  ::vzArg(static_cast<MKL_INT>(n),
155  reinterpret_cast<const ::MKL_Complex16 *>(a), y);
156 }
157 
158 inline void linear_frac(std::size_t n, const float *a, const float *b,
159  float beta_a, float beta_b, float mu_a, float mu_b, float *y)
160 {
161  internal::size_check<MKL_INT>(n, "linear_frac");
162  ::vsLinearFrac(
163  static_cast<MKL_INT>(n), a, b, beta_a, beta_b, mu_a, mu_b, y);
164 }
165 
166 inline void linear_frac(std::size_t n, const double *a, const double *b,
167  double beta_a, double beta_b, double mu_a, double mu_b, double *y)
168 {
169  internal::size_check<MKL_INT>(n, "linear_frac");
170  ::vdLinearFrac(
171  static_cast<MKL_INT>(n), a, b, beta_a, beta_b, mu_a, mu_b, y);
172 }
173 
186 
187 inline void pow(std::size_t n, const float *a, float b, float *y)
188 {
189  internal::size_check<MKL_INT>(n, "pow");
190  ::vsPowx(static_cast<MKL_INT>(n), a, b, y);
191 }
192 
193 inline void pow(std::size_t n, const double *a, double b, double *y)
194 {
195  internal::size_check<MKL_INT>(n, "pow");
196  ::vdPowx(static_cast<MKL_INT>(n), a, b, y);
197 }
198 
199 inline void pow(std::size_t n, const std::complex<float> *a,
200  std::complex<float> b, std::complex<float> *y)
201 {
202  internal::size_check<MKL_INT>(n, "pow");
203  ::MKL_Complex8 c = {b.real(), b.imag()};
204  ::vcPowx(static_cast<MKL_INT>(n),
205  reinterpret_cast<const ::MKL_Complex8 *>(a), c,
206  reinterpret_cast<::MKL_Complex8 *>(y));
207 }
208 
209 inline void pow(std::size_t n, const std::complex<double> *a,
210  std::complex<double> b, std::complex<double> *y)
211 {
212  internal::size_check<MKL_INT>(n, "pow");
213  ::MKL_Complex16 c = {b.real(), b.imag()};
214  ::vzPowx(static_cast<MKL_INT>(n),
215  reinterpret_cast<const ::MKL_Complex16 *>(a), c,
216  reinterpret_cast<::MKL_Complex16 *>(y));
217 }
218 
220 
233 
240 
241 inline void sincos(std::size_t n, const float *a, float *y, float *z)
242 {
243  internal::size_check<MKL_INT>(n, "sincos");
244  ::vsSinCos(static_cast<MKL_INT>(n), a, y, z);
245 }
246 
247 inline void sincos(std::size_t n, const double *a, double *y, double *z)
248 {
249  internal::size_check<MKL_INT>(n, "sincos");
250  ::vdSinCos(static_cast<MKL_INT>(n), a, y, z);
251 }
252 
253 inline void cis(std::size_t n, const float *a, std::complex<float> *y)
254 {
255  internal::size_check<MKL_INT>(n, "cis");
256  ::vcCIS(static_cast<MKL_INT>(n), a, reinterpret_cast<::MKL_Complex8 *>(y));
257 }
258 
259 inline void cis(std::size_t n, const double *a, std::complex<double> *y)
260 {
261  internal::size_check<MKL_INT>(n, "cis");
262  ::vzCIS(
263  static_cast<MKL_INT>(n), a, reinterpret_cast<::MKL_Complex16 *>(y));
264 }
265 
283 
296 
306 
313 
314 inline void modf(std::size_t n, const float *a, float *y, float *z)
315 {
316  internal::size_check<MKL_INT>(n, "modf");
317  ::vsModf(static_cast<MKL_INT>(n), a, y, z);
318 }
319 
320 inline void modf(std::size_t n, const double *a, double *y, double *z)
321 {
322  internal::size_check<MKL_INT>(n, "modf");
323  ::vdModf(static_cast<MKL_INT>(n), a, y, z);
324 }
325 
326 } // namespace mckl
327 
328 #endif // MCKL_USE_MKL_VML
329 
330 #if MCKL_USE_ASM_LIBRARY && MCKL_USE_ASM_VMF && MCKL_USE_FMA
331 
332 #define MCKL_DEFINE_MATH_VMF_ASM_1S(func) \
333  inline void func(std::size_t n, const float *a, float *y) \
334  { \
335  ::mckl_vs_##func(n, a, y); \
336  }
337 
338 #define MCKL_DEFINE_MATH_VMF_ASM_1D(func) \
339  inline void func(std::size_t n, const double *a, double *y) \
340  { \
341  ::mckl_vd_##func(n, a, y); \
342  }
343 
344 #define MCKL_DEFINE_MATH_VMF_ASM_2S(func) \
345  inline void func(std::size_t n, const float *a, const float *b, float *y) \
346  { \
347  ::mckl_vs_##func(n, a, b, y); \
348  }
349 
350 #define MCKL_DEFINE_MATH_VMF_ASM_2D(func) \
351  inline void func( \
352  std::size_t n, const double *a, const double *b, double *y) \
353  { \
354  ::mckl_vd_##func(n, a, b, y); \
355  }
356 
357 namespace mckl {
358 
359 #if !MCKL_USE_MKL_VML
360 
361 MCKL_DEFINE_MATH_VMF_ASM_1S(sqrt)
362 MCKL_DEFINE_MATH_VMF_ASM_1D(sqrt)
363 
364 MCKL_DEFINE_MATH_VMF_ASM_1S(exp)
365 MCKL_DEFINE_MATH_VMF_ASM_1D(exp)
366 
367 MCKL_DEFINE_MATH_VMF_ASM_1S(expm1)
368 MCKL_DEFINE_MATH_VMF_ASM_1D(expm1)
369 
370 MCKL_DEFINE_MATH_VMF_ASM_1S(log)
371 MCKL_DEFINE_MATH_VMF_ASM_1D(log)
372 
373 MCKL_DEFINE_MATH_VMF_ASM_1S(log10)
374 MCKL_DEFINE_MATH_VMF_ASM_1D(log10)
375 MCKL_DEFINE_MATH_VMF_ASM_1S(log1p)
376 MCKL_DEFINE_MATH_VMF_ASM_1D(log1p)
377 
378 MCKL_DEFINE_MATH_VMF_ASM_1D(cos)
379 MCKL_DEFINE_MATH_VMF_ASM_1D(sin)
380 
381 inline void sincos(std::size_t n, const double *a, double *y, double *z)
382 {
383  ::mckl_vd_sincos(n, a, y, z);
384 }
385 
386 MCKL_DEFINE_MATH_VMF_ASM_1D(tan)
387 
388 MCKL_DEFINE_MATH_VMF_ASM_1S(exp2)
389 MCKL_DEFINE_MATH_VMF_ASM_1D(exp2)
390 
391 MCKL_DEFINE_MATH_VMF_ASM_1S(log2)
392 MCKL_DEFINE_MATH_VMF_ASM_1D(log2)
393 
394 #endif // MCKL_USE_MKL_VML
395 
396 } // namespace mckl
397 
398 #endif // MCKL_USE_ASM_LIBRARY && MCKL_USE_ASM_VMF && MCKL_USE_FMA
399 
400 #if MCKL_USE_ASM_LIBRARY && MCKL_USE_ASM_FMA
401 
402 #define MCKL_DEFINE_MATH_FMA_FMA(op, name) \
403  inline void name(std::size_t n, const float *a, const float *b, \
404  const float *c, float *y) \
405  { \
406  ::mckl_##op##_vvv_ps(n, a, b, c, y); \
407  } \
408  \
409  inline void name( \
410  std::size_t n, const float *a, const float *b, float c, float *y) \
411  { \
412  ::mckl_##op##_vvs_ps(n, a, b, c, y); \
413  } \
414  \
415  inline void name( \
416  std::size_t n, const float *a, float b, const float *c, float *y) \
417  { \
418  ::mckl_##op##_vsv_ps(n, a, b, c, y); \
419  } \
420  \
421  inline void name( \
422  std::size_t n, float a, const float *b, const float *c, float *y) \
423  { \
424  ::mckl_##op##_svv_ps(n, a, b, c, y); \
425  } \
426  \
427  inline void name( \
428  std::size_t n, float a, float b, const float *c, float *y) \
429  { \
430  ::mckl_##op##_ssv_ps(n, a, b, c, y); \
431  } \
432  \
433  inline void name( \
434  std::size_t n, float a, const float *b, float c, float *y) \
435  { \
436  ::mckl_##op##_svs_ps(n, a, b, c, y); \
437  } \
438  \
439  inline void name( \
440  std::size_t n, const float *a, float b, float c, float *y) \
441  { \
442  ::mckl_##op##_vss_ps(n, a, b, c, y); \
443  } \
444  \
445  inline void name(std::size_t n, const double *a, const double *b, \
446  const double *c, double *y) \
447  { \
448  ::mckl_##op##_vvv_pd(n, a, b, c, y); \
449  } \
450  \
451  inline void name( \
452  std::size_t n, const double *a, const double *b, double c, double *y) \
453  { \
454  ::mckl_##op##_vvs_pd(n, a, b, c, y); \
455  } \
456  \
457  inline void name( \
458  std::size_t n, const double *a, double b, const double *c, double *y) \
459  { \
460  ::mckl_##op##_vsv_pd(n, a, b, c, y); \
461  } \
462  \
463  inline void name( \
464  std::size_t n, double a, const double *b, const double *c, double *y) \
465  { \
466  ::mckl_##op##_svv_pd(n, a, b, c, y); \
467  } \
468  \
469  inline void name( \
470  std::size_t n, double a, double b, const double *c, double *y) \
471  { \
472  ::mckl_##op##_ssv_pd(n, a, b, c, y); \
473  } \
474  \
475  inline void name( \
476  std::size_t n, double a, const double *b, double c, double *y) \
477  { \
478  ::mckl_##op##_svs_pd(n, a, b, c, y); \
479  } \
480  \
481  inline void name( \
482  std::size_t n, const double *a, double b, double c, double *y) \
483  { \
484  ::mckl_##op##_vss_pd(n, a, b, c, y); \
485  }
486 
487 namespace mckl {
488 
489 #if MCKL_USE_AVX512
490 
491 MCKL_DEFINE_MATH_FMA_FMA(fmadd512, muladd)
492 MCKL_DEFINE_MATH_FMA_FMA(fmsub512, mulsub)
493 MCKL_DEFINE_MATH_FMA_FMA(fnmadd512, nmuladd)
494 MCKL_DEFINE_MATH_FMA_FMA(fnmsub512, nmulsub)
495 
496 MCKL_DEFINE_MATH_FMA_FMA(fmadd512, fmadd)
497 MCKL_DEFINE_MATH_FMA_FMA(fmsub512, fmsub)
498 MCKL_DEFINE_MATH_FMA_FMA(fnmadd512, fnmadd)
499 MCKL_DEFINE_MATH_FMA_FMA(fnmsub512, fnmsub)
500 
501 #else // MCKL_USE_AVX512
502 
503 MCKL_DEFINE_MATH_FMA_FMA(fmadd, muladd)
504 MCKL_DEFINE_MATH_FMA_FMA(fmsub, mulsub)
505 MCKL_DEFINE_MATH_FMA_FMA(fnmadd, nmuladd)
506 MCKL_DEFINE_MATH_FMA_FMA(fnmsub, nmulsub)
507 
508 MCKL_DEFINE_MATH_FMA_FMA(fmadd, fmadd)
509 MCKL_DEFINE_MATH_FMA_FMA(fmsub, fmsub)
510 MCKL_DEFINE_MATH_FMA_FMA(fnmadd, fnmadd)
511 MCKL_DEFINE_MATH_FMA_FMA(fnmsub, fnmsub)
512 
513 #endif // MCKL_USE_AVX512
514 
515 } // namespace mckl
516 
517 #endif // MCKL_USE_ASM_LIBRARY && MCKL_USE_ASM_FMA
518 
519 #define MCKL_DEFINE_MATH_VMF_1(func, name) \
520  template <typename T> \
521  inline void name(std::size_t n, const T *a, T *y) \
522  { \
523  for (std::size_t i = 0; i != n; ++i) \
524  y[i] = func(a[i]); \
525  }
526 
527 #define MCKL_DEFINE_MATH_VMF_2(func, name) \
528  template <typename T> \
529  inline void name(std::size_t n, const T *a, const T *b, T *y) \
530  { \
531  for (std::size_t i = 0; i != n; ++i) \
532  y[i] = func(a[i], b[i]); \
533  }
534 
535 #define MCKL_DEFINE_MATH_VMF_2VS(func, name) \
536  template <typename T> \
537  inline void name(std::size_t n, const T *a, T b, T *y) \
538  { \
539  for (std::size_t i = 0; i != n; ++i) \
540  y[i] = func(a[i], b); \
541  }
542 
543 #define MCKL_DEFINE_MATH_VMF_2SV(func, name) \
544  template <typename T> \
545  inline void name(std::size_t n, T a, const T *b, T *y) \
546  { \
547  for (std::size_t i = 0; i != n; ++i) \
548  y[i] = func(a, b[i]); \
549  }
550 
551 #define MCKL_DEFINE_MATH_VMF_B(op, name) \
552  template <typename T> \
553  inline void name(std::size_t n, const T *a, const T *b, T *y) \
554  { \
555  for (std::size_t i = 0; i != n; ++i) \
556  y[i] = a[i] op b[i]; \
557  } \
558  \
559  template <typename T> \
560  inline T name(T a, T b) \
561  { \
562  return a op b; \
563  }
564 
565 #define MCKL_DEFINE_MATH_VMF_BVS(op, name) \
566  template <typename T> \
567  inline void name(std::size_t n, const T *a, T b, T *y) \
568  { \
569  for (std::size_t i = 0; i != n; ++i) \
570  y[i] = a[i] op b; \
571  }
572 
573 #define MCKL_DEFINE_MATH_VMF_BSV(op, name) \
574  template <typename T> \
575  inline void name(std::size_t n, T a, const T *b, T *y) \
576  { \
577  for (std::size_t i = 0; i != n; ++i) \
578  y[i] = a op b[i]; \
579  }
580 
581 #define MCKL_DEFINE_MATH_VMF_FMA(op, name, attr) \
582  template <typename T> \
583  attr inline void name( \
584  std::size_t n, const T *a, const T *b, const T *c, T *y) \
585  { \
586  for (std::size_t i = 0; i != n; ++i) \
587  y[i] = op(a[i], b[i], c[i]); \
588  } \
589  \
590  template <typename T> \
591  attr inline void name(std::size_t n, const T *a, const T *b, T c, T *y) \
592  { \
593  for (std::size_t i = 0; i != n; ++i) \
594  y[i] = op(a[i], b[i], c); \
595  } \
596  \
597  template <typename T> \
598  attr inline void name(std::size_t n, const T *a, T b, const T *c, T *y) \
599  { \
600  for (std::size_t i = 0; i != n; ++i) \
601  y[i] = op(a[i], b, c[i]); \
602  } \
603  \
604  template <typename T> \
605  attr inline void name(std::size_t n, T a, const T *b, const T *c, T *y) \
606  { \
607  for (std::size_t i = 0; i != n; ++i) \
608  y[i] = op(a, b[i], c[i]); \
609  } \
610  \
611  template <typename T> \
612  attr inline void name(std::size_t n, T a, T b, const T *c, T *y) \
613  { \
614  for (std::size_t i = 0; i != n; ++i) \
615  y[i] = op(a, b, c[i]); \
616  } \
617  \
618  template <typename T> \
619  attr inline void name(std::size_t n, T a, const T *b, T c, T *y) \
620  { \
621  for (std::size_t i = 0; i != n; ++i) \
622  y[i] = op(a, b[i], c); \
623  } \
624  \
625  template <typename T> \
626  attr inline void name(std::size_t n, const T *a, T b, T c, T *y) \
627  { \
628  for (std::size_t i = 0; i != n; ++i) \
629  y[i] = op(a[i], b, c); \
630  }
631 
632 namespace mckl {
633 
634 template <typename T>
635 inline T mulbyconj(T a, T b)
636 {
637  return a * std::conj(b);
638 }
639 
640 template <typename T>
641 inline T inv(T a)
642 {
643  return const_one<T>() / a;
644 }
645 
646 template <typename T>
647 inline T fmadd(T a, T b, T c)
648 {
649  return std::fma(a, b, c);
650 }
651 
652 template <typename T>
653 inline T fmsub(T a, T b, T c)
654 {
655  return std::fma(a, b, -c);
656 }
657 
658 template <typename T>
659 inline T fnmadd(T a, T b, T c)
660 {
661  return -std::fma(a, b, -c);
662 }
663 
664 template <typename T>
665 inline T fnmsub(T a, T b, T c)
666 {
667  return -std::fma(a, b, c);
668 }
669 
670 #if MCKL_USE_FMA
671 
672 template <typename T>
673 inline T muladd(T a, T b, T c)
674 {
675  return fmadd(a, b, c);
676 }
677 
678 template <typename T>
679 inline T mulsub(T a, T b, T c)
680 {
681  return fmsub(a, b, c);
682 }
683 
684 template <typename T>
685 inline T nmuladd(T a, T b, T c)
686 {
687  return fnmadd(a, b, c);
688 }
689 
690 template <typename T>
691 inline T nmulsub(T a, T b, T c)
692 {
693  return fnmsub(a, b, c);
694 }
695 
696 #else // MCKL_USE_FMA
697 
698 template <typename T>
699 inline T muladd(T a, T b, T c)
700 {
701  return a * b + c;
702 }
703 
704 template <typename T>
705 inline T mulsub(T a, T b, T c)
706 {
707  return a * b - c;
708 }
709 
710 template <typename T>
711 inline T nmuladd(T a, T b, T c)
712 {
713  return -(a * b) + c;
714 }
715 
716 template <typename T>
717 inline T nmulsub(T a, T b, T c)
718 {
719  return -(a * b + c);
720 }
721 
722 #endif // MCKL_USE_FMA
723 
724 template <typename T>
725 inline T invsqrt(T a)
726 {
727  return inv(std::sqrt(a));
728 }
729 
730 template <typename T>
731 inline T invcbrt(T a)
732 {
733  return inv(std::cbrt(a));
734 }
735 
736 template <typename T>
737 inline T pow2o3(T a)
738 {
739  T y = std::cbrt(a);
740 
741  return y * y;
742 }
743 
744 template <typename T>
745 inline T pow3o2(T a)
746 {
747  T y = std::sqrt(a);
748 
749  return y * y * y;
750 }
751 
752 template <typename T>
753 inline T cdfnorm(T a)
754 {
755  T y = const_sqrt_1by2<T>() * a;
756  y = std::erf(y);
757 
758  return y * static_cast<T>(0.5) + static_cast<T>(0.5);
759 }
760 
761 template <typename T>
762 inline T cdfnorminv(T a)
763 {
764  T y = a * static_cast<T>(-2) + static_cast<T>(2);
765  y = erfcinv(y);
766 
767  return y * const_sqrt_2<T>();
768 }
769 
773 
776 
779 
782 
785 
788 
791 
792 template <typename T>
794 inline void sqr(std::size_t n, const T *a, T *y)
795 {
796  for (std::size_t i = 0; i != n; ++i) {
797  y[i] = a[i] * a[i];
798  }
799 }
800 
803 
806 
809 
812 
815 
818 
821 
824 
825 template <typename T>
827 inline void abs(std::size_t n, const std::complex<T> *a, T *y)
828 {
829  for (std::size_t i = 0; i != n; ++i) {
830  y[i] = std::abs(a[i]);
831  }
832 }
833 
835 template <typename T>
836 inline void arg(std::size_t n, const std::complex<T> *a, T *y)
837 {
838  for (std::size_t i = 0; i != n; ++i) {
839  y[i] = std::arg(a[i]);
840  }
841 }
842 
845 template <typename T>
846 inline void linear_frac(std::size_t n, const T *a, const T *b, T beta_a,
847  T beta_b, T mu_a, T mu_b, T *y)
848 {
849  const std::size_t k = 1024;
850  const std::size_t m = n / k;
851  const std::size_t l = n % k;
852  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
853  for (std::size_t j = 0; j != k; ++j) {
854  y[j] = muladd(beta_a, a[j], mu_a);
855  }
856  for (std::size_t j = 0; j != k; ++j) {
857  y[j] /= muladd(beta_b, b[j], mu_b);
858  }
859  }
860  for (std::size_t i = 0; i != l; ++i) {
861  y[i] = muladd(beta_a, a[i], mu_a);
862  }
863  for (std::size_t i = 0; i != l; ++i) {
864  y[i] /= muladd(beta_b, b[i], mu_b);
865  }
866 }
867 
869 MCKL_DEFINE_MATH_VMF_FMA(muladd, fma, [[deprecated("use **muladd** instead")]])
870 
873 
876 
879 
882 
885 
888 
891 
894 
896 
900 
903 
906 
909 
912 
915 
917 template <typename T>
918 inline void invsqrt(std::size_t n, const T *a, T *y)
919 {
920  const std::size_t k = 1024;
921  const std::size_t m = n / k;
922  const std::size_t l = n % k;
923  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
924  inv<T>(k, a, y);
925  sqrt<T>(k, y, y);
926  }
927  inv<T>(l, a, y);
928  sqrt<T>(l, y, y);
929 }
930 
933 
934 template <typename T>
936 inline void invcbrt(std::size_t n, const T *a, T *y)
937 {
938  const std::size_t k = 1024;
939  const std::size_t m = n / k;
940  const std::size_t l = n % k;
941  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
942  cbrt<T>(k, a, y);
943  inv<T>(k, y, y);
944  }
945  cbrt<T>(l, a, y);
946  inv<T>(l, y, y);
947 }
948 
950 template <typename T>
951 inline void pow2o3(std::size_t n, const T *a, T *y)
952 {
953  const std::size_t k = 1024;
954  const std::size_t m = n / k;
955  const std::size_t l = n % k;
956  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
957  cbrt<T>(k, a, y);
958  sqr<T>(k, y, y);
959  }
960  cbrt<T>(l, a, y);
961  sqr<T>(l, y, y);
962 }
963 
965 template <typename T>
966 inline void pow3o2(std::size_t n, const T *a, T *y)
967 {
968  const std::size_t k = 1024;
969  const std::size_t m = n / k;
970  const std::size_t l = n % k;
971  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
972  sqrt<T>(k, a, y);
973  for (std::size_t j = 0; j != k; ++j) {
974  y[j] = y[j] * y[j] * y[j];
975  }
976  }
977  sqrt<T>(l, a, y);
978  for (std::size_t i = 0; i != l; ++i) {
979  y[i] = y[i] * y[i] * y[i];
980  }
981 }
982 
985 
988 
991 
994 
997 
1000 
1001 
1006 
1009 
1012 
1014 template <typename T>
1015 inline void exp10(std::size_t n, const T *a, T *y)
1016 {
1017  pow<T>(n, static_cast<T>(10), a, y);
1018 }
1019 
1022 
1025 
1028 
1031 
1034 
1037 
1038 
1043 
1046 
1049 
1052 template <typename T>
1053 inline void sincos(std::size_t n, const T *a, T *y, T *z)
1054 {
1055  const std::size_t k = 1024;
1056  const std::size_t m = n / k;
1057  const std::size_t l = n % k;
1058 
1059  if (a == y) {
1060  alignas(MCKL_ALIGNMENT) std::array<T, k> s;
1061  for (std::size_t i = 0; i != m; ++i, a += k, y += k, z += k) {
1062  sin<T>(k, a, s.data());
1063  cos<T>(k, a, z);
1064  std::copy_n(s.data(), k, y);
1065  }
1066  sin<T>(l, a, s.data());
1067  cos<T>(l, a, z);
1068  std::copy_n(s.data(), l, y);
1069  } else {
1070  for (std::size_t i = 0; i != m; ++i, a += k, y += k, z += k) {
1071  sin<T>(k, a, y);
1072  cos<T>(k, a, z);
1073  }
1074  sin<T>(l, a, y);
1075  cos<T>(l, a, z);
1076  }
1077 }
1078 
1080 template <typename T>
1081 inline void cis(std::size_t n, const T *a, std::complex<T> *y)
1082 {
1083  const std::size_t k = 1024;
1084  const std::size_t m = n / k;
1085  const std::size_t l = n % k;
1086  alignas(MCKL_ALIGNMENT) T s[k];
1087  alignas(MCKL_ALIGNMENT) T c[k];
1088  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1089  sincos<T>(k, a, s, c);
1090  for (std::size_t j = 0; j != k; ++j) {
1091  y[j].real() = c[j];
1092  y[j].imag() = s[j];
1093  }
1094  }
1095  sincos<T>(l, a, s, c);
1096  for (std::size_t j = 0; j != l; ++j) {
1097  y[j].real() = c[j];
1098  y[j].imag() = s[j];
1099  }
1100 }
1101 
1104 
1105 template <typename T>
1107 inline void cospi(std::size_t n, const T *a, T *y)
1108 {
1109  const std::size_t k = 1024;
1110  const std::size_t m = n / k;
1111  const std::size_t l = n % k;
1112  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1113  mul<T>(k, a, const_pi<T>(), y);
1114  cos<T>(k, y, y);
1115  }
1116  mul<T>(l, a, const_pi<T>(), y);
1117  cos<T>(l, y, y);
1118 }
1119 
1121 template <typename T>
1122 inline void sinpi(std::size_t n, const T *a, T *y)
1123 {
1124  const std::size_t k = 1024;
1125  const std::size_t m = n / k;
1126  const std::size_t l = n % k;
1127  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1128  mul<T>(k, a, const_pi<T>(), y);
1129  sin<T>(k, y, y);
1130  }
1131  mul<T>(l, a, const_pi<T>(), y);
1132  sin<T>(l, y, y);
1133 }
1134 
1136 template <typename T>
1137 inline void tanpi(std::size_t n, const T *a, T *y)
1138 {
1139  const std::size_t k = 1024;
1140  const std::size_t m = n / k;
1141  const std::size_t l = n % k;
1142  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1143  mul<T>(k, a, const_pi<T>(), y);
1144  tan<T>(k, y, y);
1145  }
1146  mul<T>(l, a, const_pi<T>(), y);
1147  tan<T>(l, y, y);
1148 }
1149 
1151 template <typename T>
1152 inline void cosd(std::size_t n, const T *a, T *y)
1153 {
1154  const std::size_t k = 1024;
1155  const std::size_t m = n / k;
1156  const std::size_t l = n % k;
1157  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1158  mul<T>(k, a, const_pi<T>() / 180, y);
1159  cos<T>(k, y, y);
1160  }
1161  mul<T>(l, a, const_pi<T>() / 180, y);
1162  cos<T>(l, y, y);
1163 }
1164 
1166 template <typename T>
1167 inline void sind(std::size_t n, const T *a, T *y)
1168 {
1169  const std::size_t k = 1024;
1170  const std::size_t m = n / k;
1171  const std::size_t l = n % k;
1172  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1173  mul<T>(k, a, const_pi<T>() / 180, y);
1174  sin<T>(k, y, y);
1175  }
1176  mul<T>(l, a, const_pi<T>() / 180, y);
1177  sin<T>(l, y, y);
1178 }
1179 
1181 template <typename T>
1182 inline void tand(std::size_t n, const T *a, T *y)
1183 {
1184  const std::size_t k = 1024;
1185  const std::size_t m = n / k;
1186  const std::size_t l = n % k;
1187  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1188  mul<T>(k, a, const_pi<T>() / 180, y);
1189  tan<T>(k, y, y);
1190  }
1191  mul<T>(l, a, const_pi<T>() / 180, y);
1192  tan<T>(l, y, y);
1193 }
1194 
1197 
1200 
1203 
1207 
1211 
1215 
1216 template <typename T>
1218 inline void acospi(std::size_t n, const T *a, T *y)
1219 {
1220  const std::size_t k = 1024;
1221  const std::size_t m = n / k;
1222  const std::size_t l = n % k;
1223  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1224  acos<T>(k, a, y);
1225  mul<T>(k, y, 1 / const_pi<T>(), y);
1226  }
1227  acos<T>(l, a, y);
1228  mul<T>(l, y, 1 / const_pi<T>(), y);
1229 }
1230 
1232 template <typename T>
1233 inline void asinpi(std::size_t n, const T *a, T *y)
1234 {
1235  const std::size_t k = 1024;
1236  const std::size_t m = n / k;
1237  const std::size_t l = n % k;
1238  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1239  asin<T>(k, a, y);
1240  mul<T>(k, y, 1 / const_pi<T>(), y);
1241  }
1242  asin<T>(l, a, y);
1243  mul<T>(l, y, 1 / const_pi<T>(), y);
1244 }
1245 
1247 template <typename T>
1248 inline void atanpi(std::size_t n, const T *a, T *y)
1249 {
1250  const std::size_t k = 1024;
1251  const std::size_t m = n / k;
1252  const std::size_t l = n % k;
1253  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1254  atan<T>(k, a, y);
1255  mul<T>(k, y, 1 / const_pi<T>(), y);
1256  }
1257  atan<T>(l, a, y);
1258  mul<T>(l, y, 1 / const_pi<T>(), y);
1259 }
1260 
1263 template <typename T>
1264 inline void atan2pi(std::size_t n, const T *a, const T *b, T *y)
1265 {
1266  const std::size_t k = 1024;
1267  const std::size_t m = n / k;
1268  const std::size_t l = n % k;
1269  for (std::size_t i = 0; i != m; ++i, a += k, b += k, y += k) {
1270  atan2<T>(k, a, b, y);
1271  mul<T>(k, y, 1 / const_pi<T>(), y);
1272  }
1273  atan2<T>(l, a, b, y);
1274  mul<T>(l, y, 1 / const_pi<T>(), y);
1275 }
1276 
1279 template <typename T>
1280 inline void atan2pi(std::size_t n, const T *a, T b, T *y)
1281 {
1282  const std::size_t k = 1024;
1283  const std::size_t m = n / k;
1284  const std::size_t l = n % k;
1285  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1286  atan2<T>(k, a, b, y);
1287  mul<T>(k, y, 1 / const_pi<T>(), y);
1288  }
1289  atan2<T>(l, a, b, y);
1290  mul<T>(l, y, 1 / const_pi<T>(), y);
1291 }
1292 
1295 template <typename T>
1296 inline void atan2pi(std::size_t n, T a, const T *b, T *y)
1297 {
1298  const std::size_t k = 1024;
1299  const std::size_t m = n / k;
1300  const std::size_t l = n % k;
1301  for (std::size_t i = 0; i != m; ++i, b += k, y += k) {
1302  atan2<T>(k, a, b, y);
1303  mul<T>(k, y, 1 / const_pi<T>(), y);
1304  }
1305  atan2<T>(l, a, b, y);
1306  mul<T>(l, y, 1 / const_pi<T>(), y);
1307 }
1308 
1310 
1314 
1317 
1320 
1323 
1326 
1329 
1332 
1333 
1338 
1341 
1345 
1348 
1352 
1355 template <typename T>
1356 inline void cdfnorm(std::size_t n, const T *a, T *y)
1357 {
1358  const std::size_t k = 1024;
1359  const std::size_t m = n / k;
1360  const std::size_t l = n % k;
1361  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1362  mul<T>(k, const_sqrt_1by2<T>(), a, y);
1363  erf<T>(k, y, y);
1364  muladd<T>(k, y, static_cast<T>(0.5), static_cast<T>(0.5), y);
1365  }
1366  mul<T>(l, const_sqrt_1by2<T>(), a, y);
1367  erf<T>(l, y, y);
1368  muladd<T>(l, y, static_cast<T>(0.5), static_cast<T>(0.5), y);
1369 }
1370 
1373 template <typename T>
1374 inline void cdfnorminv(std::size_t n, const T *a, T *y)
1375 {
1376  const std::size_t k = 1024;
1377  const std::size_t m = n / k;
1378  const std::size_t l = n % k;
1379  for (std::size_t i = 0; i != m; ++i, a += k, y += k) {
1380  muladd<T>(k, a, static_cast<T>(-2), static_cast<T>(2), y);
1381  erfcinv<T>(k, y, y);
1382  mul<T>(k, const_sqrt_2<T>(), y, y);
1383  }
1384  muladd<T>(l, a, static_cast<T>(-2), static_cast<T>(2), y);
1385  erfcinv<T>(l, y, y);
1386  mul<T>(l, const_sqrt_2<T>(), y, y);
1387 }
1388 
1391 
1394 
1395 
1400 
1403 
1406 
1410 
1414 
1418 
1422 
1424 template <typename T>
1425 inline void modf(std::size_t n, const T *a, T *y, T *z)
1426 {
1427  for (std::size_t i = 0; i != n; ++i, ++a, ++y, ++z) {
1428  *z = std::modf(*a, y);
1429  }
1430 }
1431 
1433 
1437 
1438 #if MCKL_USE_ASM_LIBRARY && MCKL_USE_AVX2
1439 
1440 #define MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(func) \
1441  inline std::size_t func(std::size_t n, const float *a) \
1442  { \
1443  return ::mckl_vs_##func(n, a); \
1444  } \
1445  \
1446  inline std::size_t func(std::size_t n, const double *a) \
1447  { \
1448  return ::mckl_vd_##func(n, a); \
1449  }
1450 
1451 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(find_normal)
1452 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(find_subnormal)
1453 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(find_zero)
1454 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(find_inf)
1455 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(find_nan)
1456 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(find_finite)
1457 
1458 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(count_normal)
1459 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(count_subnormal)
1460 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(count_zero)
1461 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(count_inf)
1462 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(count_nan)
1463 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(count_finite)
1464 
1465 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(find_not_normal)
1466 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(find_not_subnormal)
1467 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(find_not_zero)
1468 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(find_not_inf)
1469 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(find_not_nan)
1470 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(find_not_finite)
1471 
1472 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(count_not_normal)
1473 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(count_not_subnormal)
1474 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(count_not_zero)
1475 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(count_not_inf)
1476 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(count_not_nan)
1477 MCKL_DEFINE_MATH_VMF_ASM_FPCLASSIFY(count_not_finite)
1478 
1479 #endif // MCKL_USE_ASM_LIBRARY && MCKL_USE_AVX2
1480 
1481 #define MCKL_DEFINE_MATH_VMF_FPCLASSIFY_FIND(func, test) \
1482  template <typename T> \
1483  inline std::size_t find_##func(std::size_t n, const T *a) \
1484  { \
1485  for (std::size_t i = 0; i != n; ++i, ++a) \
1486  if (test(*a)) \
1487  return i; \
1488  return n; \
1489  } \
1490  \
1491  template <typename T> \
1492  inline std::size_t find_##func(std::size_t n, const std::complex<T> *a) \
1493  { \
1494  return find_##func(n * 2, reinterpret_cast<const T *>(a)) / 2; \
1495  }
1496 
1497 #define MCKL_DEFINE_MATH_VMF_FPCLASSIFY_COUNT(func, test) \
1498  template <typename T> \
1499  inline std::size_t count_##func(std::size_t n, const T *a) \
1500  { \
1501  std::size_t c = 0; \
1502  for (std::size_t i = 0; i != n; ++i, ++a) \
1503  if (test(*a)) \
1504  ++c; \
1505  return c; \
1506  } \
1507  \
1508  template <typename T> \
1509  inline std::size_t count_##func(std::size_t n, const std::complex<T> *a) \
1510  { \
1511  return count_##func(n * 2, reinterpret_cast<const T *>(a)) / 2; \
1512  }
1513 
1514 namespace internal {
1515 
1516 template <typename T>
1517 inline bool __issubnormal(T a)
1518 {
1519  static_assert(std::is_floating_point<T>::value,
1520  "checking for subnormal used with a type other than floating point");
1521 
1522  T b = std::abs(a);
1523 
1524  return b > 0 && b < std::numeric_limits<T>::min();
1525 }
1526 
1527 template <typename T>
1528 inline bool __iszero(T a)
1529 {
1530  MCKL_PUSH_CLANG_WARNING("-Wfloat-equal")
1531  MCKL_PUSH_INTEL_WARNING(1572) // floating-point comparison
1532  return a == 0;
1535 }
1536 
1537 } // namespace internal
1538 
1541 
1544 
1547 
1548 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_FIND(inf, std::isinf)
1550 
1551 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_FIND(nan, std::isnan)
1553 
1554 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_FIND(finite, std::isfinite)
1556 
1557 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_COUNT(normal, std::isnormal)
1559 
1562 
1565 
1568 
1571 
1572 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_COUNT(finite, std::isfinite)
1574 
1575 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_FIND(not_normal, !std::isnormal)
1577 
1580 
1583 
1584 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_FIND(not_inf, !std::isinf)
1586 
1587 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_FIND(not_nan, !std::isnan)
1589 
1590 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_FIND(not_finite, !std::isfinite)
1592 
1593 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_COUNT(not_normal, !std::isnormal)
1595 
1598 
1601 
1602 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_COUNT(not_inf, !std::isinf)
1604 
1605 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_COUNT(not_nan, !std::isnan)
1607 
1608 MCKL_DEFINE_MATH_VMF_FPCLASSIFY_COUNT(not_finite, !std::isfinite)
1610 
1611 
1613 } // namespace mckl
1614 
1615 #endif // MCKL_MATH_VMF_HPP
void sinpi(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:267
std::size_t count_subnormal(std::size_t n, const T *a)
Return the number of elements that are subnormal.
Definition: vmf.hpp:1561
void atan(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1202
void lgamma(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1390
std::size_t count_not_subnormal(std::size_t n, const T *a)
Return the number of elements that are not subnormal.
Definition: vmf.hpp:1597
void cbrt(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:932
void hypot(std::size_t n, const float *a, const float *b, float *y)
Definition: vmf.hpp:219
void expm1(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:225
std::size_t count_not_zero(std::size_t n, const T *a)
Return the number of elements that are not zero.
Definition: vmf.hpp:1600
std::size_t count_inf(std::size_t n, const T *a)
Return the number of elements that are infinity.
Definition: vmf.hpp:1567
void asinh(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:292
std::size_t find_not_normal(std::size_t n, const T *a)
Return the index of the first element that is not normal.
Definition: vmf.hpp:1576
void pow(std::size_t n, const float *a, const float *b, float *y)
Definition: vmf.hpp:184
void arg(std::size_t n, const std::complex< float > *a, float *y)
Definition: vmf.hpp:144
void mul(std::size_t n, const float *a, const float *b, float *y)
Definition: vmf.hpp:124
void fma(std::size_t n, const T *a, const T *b, const T *c, T *y)
For , compute .
Definition: vmf.hpp:869
T erfcinv(T y)
Inverse complement error function.
Definition: erf.hpp:45
T nmulsub(T a, T b, T c)
Definition: vmf.hpp:691
void invcbrt(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:181
void hypot(std::size_t n, T a, const T *b, T *y)
For , compute .
Definition: vmf.hpp:999
#define MCKL_DEFINE_MATH_VMF_FPCLASSIFY_FIND(func, test)
Definition: vmf.hpp:1481
void cosh(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:284
bool __iszero(T a)
Definition: vmf.hpp:1528
void arg(std::size_t n, const std::complex< T > *a, T *y)
For , compute .
Definition: vmf.hpp:836
void ceil(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:308
void tan(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:238
#define MCKL_DEFINE_MATH_VMF_1(func, name)
Definition: vmf.hpp:519
void logb(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1036
void erf(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:297
#define MCKL_PUSH_CLANG_WARNING(warning)
Definition: compiler.h:63
void round(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:310
void acos(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:272
T fnmsub(T a, T b, T c)
Definition: vmf.hpp:665
void sinh(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:286
std::size_t count_zero(std::size_t n, const T *a)
Return the number of elements that are zero.
Definition: vmf.hpp:1564
void acosh(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1325
void tan(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1103
std::size_t count_not_finite(std::size_t n, const T *a)
Return the number of elements that are not finite.
Definition: vmf.hpp:1609
void lgamma(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:303
void fma(std::size_t n, const T *a, T b, T c, T *y)
Definition: vmf.hpp:869
void pow2o3(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:182
void atan2(std::size_t n, T a, const T *b, T *y)
For , compute with signs to determine the quadrant.
Definition: vmf.hpp:1214
std::size_t find_subnormal(std::size_t n, const T *a)
Return the index of the first element that is subnormal.
Definition: vmf.hpp:1543
std::size_t find_inf(std::size_t n, const T *a)
Return the index of the first element that is infinity.
Definition: vmf.hpp:1549
void mulbyconj(std::size_t n, const std::complex< float > *a, const std::complex< float > *b, std::complex< float > *y)
Definition: vmf.hpp:126
#define MCKL_DEFINE_MATH_VMF_2SV(func, name)
Definition: vmf.hpp:543
void sin(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:236
void tand(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:271
void atanpi(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:280
void inv(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:174
void linear_frac(std::size_t n, const float *a, const float *b, float beta_a, float beta_b, float mu_a, float mu_b, float *y)
Definition: vmf.hpp:158
STL namespace.
std::size_t count_not_inf(std::size_t n, const T *a)
Return the number of elements that are not infinity.
Definition: vmf.hpp:1603
std::size_t find_finite(std::size_t n, const T *a)
Return the index of the first element that is finite.
Definition: vmf.hpp:1555
void log(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:226
void tanpi(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:268
#define MCKL_DEFINE_MATH_VMF_2(func, name)
Definition: vmf.hpp:527
void log1p(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1033
std::size_t count_finite(std::size_t n, const T *a)
Return the number of elements that are finite.
Definition: vmf.hpp:1573
std::size_t find_nan(std::size_t n, const T *a)
Return the index of the first element that is nan.
Definition: vmf.hpp:1552
void cdfnorm(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:299
#define MCKL_DEFINE_MATH_VMF_VML_1R(func, name)
Definition: vmf.hpp:50
void cdfnorminv(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:302
T muladd(T a, T b, T c)
Definition: vmf.hpp:673
void log2(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1027
#define MCKL_DEFINE_MATH_VMF_BSV(op, name)
Definition: vmf.hpp:573
void sqrt(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:914
#define MCKL_DEFINE_MATH_VMF_B(op, name)
Definition: vmf.hpp:551
bool __issubnormal(T a)
Definition: vmf.hpp:1517
void sinh(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1319
void log(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1024
std::size_t find_not_finite(std::size_t n, const T *a)
Return the index of the first element that is not finite.
Definition: vmf.hpp:1591
void sincos(std::size_t n, const float *a, float *y, float *z)
Definition: vmf.hpp:241
#define MCKL_DEFINE_MATH_VMF_FMA(op, name, attr)
Definition: vmf.hpp:581
void abs(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:128
void conj(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:820
void log1p(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:231
void exp2(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:223
void exp10(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:224
void erf(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1340
T fmadd(T a, T b, T c)
Definition: vmf.hpp:647
void cbrt(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:180
void mckl_vd_sincos(size_t, const double *, double *, double *)
void sub(std::size_t n, const float *a, const float *b, float *y)
Definition: vmf.hpp:121
#define MCKL_DEFINE_MATH_VMF_FPCLASSIFY_COUNT(func, test)
Definition: vmf.hpp:1497
void acos(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1196
void atanh(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1331
void tanh(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1322
void acosh(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:290
void cospi(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:266
void floor(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:307
std::size_t find_normal(std::size_t n, const T *a)
Return the index of the first element that is normal.
Definition: vmf.hpp:1540
void acospi(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:278
void cis(std::size_t n, const float *a, std::complex< float > *y)
Definition: vmf.hpp:253
void modf(std::size_t n, const float *a, float *y, float *z)
Definition: vmf.hpp:314
void sqr(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:123
#define MCKL_PUSH_INTEL_WARNING(wid)
Definition: compiler.h:88
std::size_t find_zero(std::size_t n, const T *a)
Return the index of the first element that is zero.
Definition: vmf.hpp:1546
void atan2(std::size_t n, const float *a, const float *b, float *y)
Definition: vmf.hpp:281
std::size_t find_not_subnormal(std::size_t n, const T *a)
Return the index of the first element that is not subnormal.
Definition: vmf.hpp:1579
void modf(std::size_t n, const T *a, T *y, T *z)
For , compute the integeral and fraction parts.
Definition: vmf.hpp:1425
std::size_t find_not_nan(std::size_t n, const T *a)
Return the index of the first element that is not nan.
Definition: vmf.hpp:1588
void logb(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:232
void cosd(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:269
std::size_t count_not_nan(std::size_t n, const T *a)
Return the number of elements that are not nan.
Definition: vmf.hpp:1606
void expint1(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:305
T fnmadd(T a, T b, T c)
Definition: vmf.hpp:659
#define MCKL_DEFINE_MATH_VMF_2VS(func, name)
Definition: vmf.hpp:535
void invsqrt(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:179
void sqrt(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:177
void cos(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:234
std::size_t count_not_normal(std::size_t n, const T *a)
Return the number of elements that are not normal.
Definition: vmf.hpp:1594
void sind(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:270
void tgamma(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1393
void asin(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:274
void atan(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:276
Definition: mcmc.hpp:40
void exp(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:221
void atan2pi(std::size_t n, const float *a, const float *b, float *y)
Definition: vmf.hpp:282
#define MCKL_POP_CLANG_WARNING
Definition: compiler.h:66
void conj(std::size_t n, const std::complex< float > *a, std::complex< float > *y)
Definition: vmf.hpp:127
#define MCKL_ALIGNMENT
The default alignment for scalar type.
Definition: config.h:187
void tanh(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:288
#define MCKL_DEFINE_MATH_VMF_VML_1C(func, name)
Definition: vmf.hpp:63
#define MCKL_DEFINE_MATH_VMF_VML_2C(func, name)
Definition: vmf.hpp:96
T erfinv(T y)
Inverse error function.
Definition: erf.hpp:75
#define MCKL_DEFINE_MATH_VMF_VML_2R(func, name)
Definition: vmf.hpp:82
void log10(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1030
void erfc(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:298
void asinpi(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:279
std::size_t find_not_inf(std::size_t n, const T *a)
Return the index of the first element that is not infinity.
Definition: vmf.hpp:1585
std::size_t count_nan(std::size_t n, const T *a)
Return the number of elements that are nan.
Definition: vmf.hpp:1570
void asinh(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1328
void cosh(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1316
T mulsub(T a, T b, T c)
Definition: vmf.hpp:679
void tgamma(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:304
void pow(std::size_t n, T a, const T *b, T *y)
For , compute .
Definition: vmf.hpp:990
void log2(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:228
T fmsub(T a, T b, T c)
Definition: vmf.hpp:653
void abs(std::size_t n, const std::complex< T > *a, T *y)
For , compute .
Definition: vmf.hpp:827
void nearbyint(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:311
void log10(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:229
T nmuladd(T a, T b, T c)
Definition: vmf.hpp:685
void pow3o2(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:183
void div(std::size_t n, const float *a, const float *b, float *y)
Definition: vmf.hpp:175
void expm1(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1021
std::size_t count_normal(std::size_t n, const T *a)
Return the number of elements that are normal.
Definition: vmf.hpp:1558
void trunc(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:309
#define MCKL_POP_INTEL_WARNING
Definition: compiler.h:89
std::size_t find_not_zero(std::size_t n, const T *a)
Return the index of the first element that is not zero.
Definition: vmf.hpp:1582
void asin(std::size_t n, const T *a, T *y)
For , compute .
Definition: vmf.hpp:1199
void atanh(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:294
void rint(std::size_t n, const float *a, float *y)
Definition: vmf.hpp:312
void add(std::size_t n, const float *a, const float *b, float *y)
Definition: vmf.hpp:119
#define MCKL_DEFINE_MATH_VMF_BVS(op, name)
Definition: vmf.hpp:565