Parabolic Cylinder Functions C++ faster version

版本 1.2.2 (61.7 KB) 作者: shuang zhou
11 times faster than the original Matlab code
37.0 次下载
更新时间 2022/7/19

Parabolic Cylinder Functions C++ Version

View Parabolic Cylinder Functions C++ faster version on File Exchange

This project is a faster version of MATLAB code original from E. Cojocaru. Parabolic Cylinder Functions (https://www.mathworks.com/matlabcentral/fileexchange/22620-parabolic-cylinder-functions)

Features:

  • The API is similar to original functions, such as val = pwlx(a,x); -> val = pcf_mex(a,x,'pwlx');
  • The MATLAB toolbox only support scalar inputs, pcf_mex now support 1D array of size (1,n) or (n,1), return value will have size(n,1).
  • Intel compiler, OPENMP, AVX2 or AVX512 are utilized to speed up the calculation.
  • Add two useful functions for bortfeld function
  • Apple Silicon supported (Rosseta2(R2022a) and Native(R2022a beta) Matlab)

What's inside the box

  • pcf_mex(a,x,'pu') Compute parabolic cylinder function U(a,x), s.t. abs(a)<5 and abs(x)<5
  • pcf_mex(a,x,'dpu') Compute derivative of parabolic cylinder function U(a,x), s.t. abs(a)<5 and abs(x)<5
  • pcf_mex(a,x,'pulx') Compute parabolic cylinder function U(a,x) for large argument x (|x| >> |a| and |a| moderate)
  • pcf_mex(a,x,'dpulx') Compute parabolic derivative of cylinder function U(a,x) for large argument x (|x| >> |a| and |a| moderate)
  • pcf_mex(a,x,'pd') Compute parabolic cylinder function D(a,x) = U(-a-0.5,x), s.t. |a|<5 and |x|<5 (used in bortfeld function)
  • pcf_mex(a,x,'dpd') Compute parabolic derivative of cylinder function D(a,x) = U(-a-0.5,x), s.t. |a|<5 and |x|<5 (used in bortfeld function)
  • pcf_mex(a,x,'pv') Compute parabolic cylinder function V(a,x), s.t. abs(a)<5 and abs(x)<5
  • pcf_mex(a,x,'dpv') Compute derivative of parabolic cylinder function V(a,x), s.t. abs(a)<5 and abs(x)<5
  • pcf_mex(a,x,'pvlx') Compute parabolic cylinder function V(a,x) for large argument x (|x| >> |a| and |a| moderate)
  • pcf_mex(a,x,'dpvlx') Compute parabolic derivative of cylinder function V(a,x) for large argument x (|x| >> |a| and |a| moderate)
  • pcf_mex(a,x,'pw') Compute parabolic cylinder function W(a,x), s.t. abs(a)<5 and abs(x)<5
  • pcf_mex(a,x,'dpw') Compute derivative of parabolic cylinder function W(a,x), s.t. abs(a)<5 and abs(x)<5
  • pcf_mex(a,x,'pwlx') Compute parabolic cylinder function W(a,x) for large argument x (|x| >> |a| and |a| moderate)
  • pcf_mex(a,x,'dpwlx') Compute parabolic derivative of cylinder function W(a,x) for large argument x (|x| >> |a| and |a| moderate)

Speed benchmark

I tested it with simple benchmark : pcf_mex(-1,linspace(4,5,1e6),'pwlx'), unit is seconds % 0.7554 Apple M1 pro(8core) + openmp (Matlab2022a beta Native)

% 1.8453 Apple M1 pro(8core) + openmp (Matlab2022a Rosseta2)

% 0.3994 intel compiler 2021 + openmp + avx2

% 1.0733 vs + openmp + avx2

% 1.0858 vs + openmp

% 9.7933 vs

% 4.476539 original + parfor

% 32.521651 original

The first one is compiled with Visual Studio + Intel OneAPI, intel compiler 2021 is much more faster.

"omp.h" not found at M1 Mac

refer to my answer: https://www.mathworks.com/matlabcentral/answers/1761950-m1-mac-compile-mex-file-with-openmp

引用格式

shuang zhou (2024). Parabolic Cylinder Functions C++ faster version (https://github.com/civerjia/Parabolic-Cylinder-Functions-C-/releases/tag/v1.2.2), GitHub. 检索时间: .

MATLAB 版本兼容性
创建方式 R2022a
兼容任何版本
平台兼容性
Windows macOS Linux
标签 添加标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.2.2

See release notes for this release on GitHub: https://github.com/civerjia/Parabolic-Cylinder-Functions-C-/releases/tag/v1.2.2

1.2.1

See release notes for this release on GitHub: https://github.com/civerjia/Parabolic-Cylinder-Functions-C-/releases/tag/v1.2.1

1.1.0

See release notes for this release on GitHub: https://github.com/civerjia/Parabolic-Cylinder-Functions-C-/releases/tag/v1.1.0

1.0.0

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库