1#![allow(clippy::excessive_precision)]
2#![allow(clippy::redundant_closure)]
3#![allow(clippy::legacy_numeric_constants)]
4#![allow(clippy::needless_borrows_for_generic_args)]
5#![allow(clippy::needless_range_loop)]
6#![allow(clippy::manual_slice_size_calculation)]
7#![allow(clippy::useless_format)]
8#![allow(clippy::manual_div_ceil)]
9#![allow(clippy::redundant_pattern_matching)]
10#![allow(clippy::needless_return)]
11#![allow(clippy::let_and_return)]
12#![allow(clippy::derivable_impls)]
13#![allow(clippy::cast_abs_to_unsigned)]
14pub mod error;
106pub mod error_context;
107pub mod error_wrappers;
108pub use error::{SpecialError, SpecialResult};
109
110pub mod advanced_performance_enhancement;
112mod airy;
113mod anger_weber;
114#[cfg(feature = "high-precision")]
115pub mod arbitrary_precision;
116#[cfg(feature = "gpu")]
117pub mod array_ops;
118pub mod bessel;
119mod bessel_zeros;
120mod boxcox;
121mod carlson;
122mod combinatorial;
123mod constants;
124pub mod convenience;
125mod coulomb;
126pub mod cross_validation;
127pub mod distributions;
128pub mod edge_case_tests;
129mod ellipsoidal;
130mod elliptic;
131pub mod elliptic_ext;
132pub mod erf;
133#[cfg(test)]
134mod extended_property_tests;
135pub mod extended_scipy_validation;
136mod fresnel;
137pub mod gamma;
138#[cfg(feature = "gpu")]
139pub mod gpu_context_manager;
140#[cfg(feature = "gpu")]
141pub mod gpu_ops;
142mod hypergeometric;
143mod hypergeometric_enhanced;
144pub mod incomplete_gamma;
145pub mod information_theory;
146mod kelvin;
147mod lambert;
148pub mod legendre_elliptic;
149mod logint;
150mod mathieu;
151pub mod memory_efficient;
152pub mod optimizations;
153mod orthogonal;
154mod parabolic;
155pub mod performance_benchmarks;
156pub mod physics_engineering;
157pub mod polylogarithm;
158pub mod precision;
159mod property_tests;
160pub mod hill;
162pub mod mathieu_hill;
163pub mod mixed_precision;
164pub mod python_interop;
165#[cfg(test)]
166mod quickcheck_tests;
167pub mod simd_ops;
168mod spherical_harmonics;
169mod spheroidal;
170pub mod stability_analysis;
171mod statistical;
172mod struve;
173pub mod utility;
174pub mod validated;
175mod validation;
176#[cfg(feature = "plotting")]
177pub mod visualization;
178mod voigt;
179mod wright;
180mod wright_bessel;
181mod wright_simplified;
182mod zeta;
183mod zeta_ext;
184
185mod clausen;
187mod debye;
188mod scipy_compat;
189mod spherical_bessel_extended;
190
191pub mod theta_functions;
193
194pub mod chromatic;
196pub mod clebsch_gordan;
198pub mod clebsch_gordan_lie;
200pub mod gpu_dispatch;
202pub mod gpu_kernels;
204pub mod hall_polynomials;
206pub mod dedekind_zeta;
208pub mod differentiation;
210pub mod elliptic_modular;
212pub mod connection_formulas;
214pub mod elliptic_l;
216pub mod hecke_l;
218pub mod l_functions;
220pub mod lame;
222pub mod nield_kuznetsov;
224pub mod painleve;
226pub mod schur;
228pub mod selberg_zeta;
230pub mod symbolic;
232pub mod tutte;
234
235pub use advanced_performance_enhancement::{
239 benchmark_function, erf_advancedfast, gamma_advancedfast, gamma_array_advancedfast,
240 j0_advancedfast, PerformanceConfig, PerformanceMetrics,
241};
242pub use airy::{ai, ai_zeros, aie, aip, airye, bi, bi_zeros, bie, bip, itairy};
243pub use anger_weber::{anger_j, anger_weber, lommel_s1, lommel_s2, weber_e};
244pub use airy::complex::{ai_complex, aip_complex, bi_complex, bip_complex};
246pub use bessel::{
247 h1vp,
248 h2vp,
249 hankel1,
251 hankel1e,
252 hankel2,
253 hankel2e,
254 i0,
256 i0_prime,
258 i0e,
259 i1,
260 i1_prime,
261 i1e,
262 iv,
263 iv_prime,
264 ive,
265 ivp,
266 j0,
267 j0_prime,
269 j0e,
270 j1,
271 j1_prime,
272 j1e,
273 jn,
274 jn_prime,
275 jne,
276 jv,
277 jv_prime,
278 jve,
279 jvp,
281 k0,
282 k0_prime,
283 k0e,
284 k1,
285 k1_prime,
286 k1e,
287 kv,
288 kv_prime,
289 kve,
290 kvp,
291 spherical_jn,
293 spherical_yn,
294 y0,
295 y0_prime,
296 y0e,
297 y1,
298 y1_prime,
299 y1e,
300 yn,
301 yn_prime,
302 yne,
303 yvp,
304};
305pub use bessel_zeros::{
306 besselpoly,
307 itj0y0,
309 j0_zeros,
311 j1_zeros,
312 jn_zeros,
313 jnjnp_zeros,
314 jnp_zeros,
315 jnyn_zeros,
316 y0_zeros,
317 y1_zeros,
318 yn_zeros,
319};
320pub use boxcox::{
321 boxcox, boxcox1p, boxcox1p_array, boxcox_array, inv_boxcox, inv_boxcox1p, inv_boxcox1p_array,
322 inv_boxcox_array,
323};
324pub use carlson::{elliprc, elliprd, elliprf, elliprf_array, elliprg, elliprj};
325pub use combinatorial::{
326 bell_number, bernoulli_number, binomial, comb, double_factorial, euler_number, factorial,
327 factorial2, factorialk, perm, permutations, stirling2, stirling_first, stirling_second,
328};
329pub use coulomb::{coulomb_f, coulomb_g, coulomb_h_plus, coulomb_hminus, coulomb_phase_shift};
330pub use distributions::{
331 bdtr,
333 bdtr_array,
334 bdtrc,
335 bdtri,
336 bdtrik,
337 bdtrin,
338 btdtria,
340 btdtrib,
341 chdtr,
343 chdtrc,
344 chdtri,
345 fdtr,
347 fdtrc,
348 fdtridfd,
349 gdtr,
351 gdtrc,
352 gdtria,
353 gdtrib,
354 gdtrix,
355 kolmogi,
356 kolmogorov,
358 log_ndtr,
359 nbdtr,
361 nbdtrc,
362 nbdtri,
363 ndtr,
365 ndtr_array,
366 ndtri,
367 ndtri_exp,
368 pdtr,
370 pdtrc,
371 pdtri,
372 pdtrik,
373 stdtr,
375};
376pub use ellipsoidal::{
377 ellip_harm, ellip_harm_2, ellip_harm_array, ellip_harm_coefficients, ellip_harm_complex,
378 ellip_normal,
379};
380pub use elliptic::{
381 complete_elliptic_pi, ellipe, ellipeinc, ellipj, ellipk, ellipkinc, ellipkm1, elliptic_e,
382 elliptic_e_inc, elliptic_f, elliptic_k, elliptic_nome, elliptic_pi, jacobi_cn, jacobi_dn,
383 jacobi_sn, weierstrass_p, weierstrass_p_prime, weierstrass_sigma, weierstrass_zeta,
384};
385pub use fresnel::{
386 fresnel, fresnel_complex, fresnelc, fresnels, mod_fresnel_plus, mod_fresnelminus,
387};
388pub use gamma::{
389 beta,
390 beta_safe,
392 betainc,
393 betainc_regularized,
394 betaincinv,
395 betaln,
396 digamma,
397 digamma_safe,
398 gamma,
399 gamma_safe,
400 gammaln,
401 loggamma,
402 polygamma,
403};
404pub use incomplete_gamma::{
405 gammainc, gammainc_lower, gammainc_upper, gammaincc, gammainccinv, gammaincinv, gammasgn,
406 gammastar,
407};
408pub use gamma::complex::{beta_complex, digamma_complex, gamma_complex, loggamma_complex};
410pub use bessel::complex::{i0_complex, j0_complex, j1_complex, jn_complex, jv_complex, k0_complex};
412pub use erf::complex::{erf_complex, erfc_complex, erfcx_complex, faddeeva_complex};
414pub use hypergeometric::{hyp0f1, hyp1f1, hyp2f1, hyperu, ln_pochhammer, pochhammer};
415pub use hypergeometric_enhanced::{
416 hyp0f1_enhanced, hyp1f1_enhanced, hyp1f1_regularized, hyp2f1_enhanced, hyp2f1_regularized,
417 whittaker_m, whittaker_w,
418};
419pub use information_theory::{
420 binary_entropy, cross_entropy, entr, entr_array, entropy, huber, huber_loss, kl_div,
421 kl_divergence, pseudo_huber, rel_entr,
422};
423pub use kelvin::{bei, beip, ber, berp, kei, keip, kelvin, ker, kerp};
424pub use lambert::{lambert_w, lambert_w_real};
425pub use logint::{chi, ci, e1, expint, li, li_complex, polylog, shi, shichi, si, sici, spence};
426pub use mathieu::{
427 mathieu_a, mathieu_b, mathieu_cem, mathieu_even_coef, mathieu_odd_coef, mathieu_sem,
428};
429pub use orthogonal::{
430 chebyshev, gegenbauer, hermite, hermite_prob, jacobi, laguerre, laguerre_generalized, legendre,
431 legendre_assoc,
432};
433pub use parabolic::{pbdv, pbdv_seq, pbvv, pbvv_seq, pbwa};
434pub use spherical_harmonics::{
435 solid_harmonic_irregular, solid_harmonic_regular, sph_harm, sph_harm_complex,
436 sph_harm_cos_angle, sph_harm_normalization,
437};
438pub use spheroidal::{
439 obl_ang1, obl_cv, obl_cv_seq, obl_rad1, obl_rad2, pro_ang1, pro_cv, pro_cv_seq, pro_rad1,
440 pro_rad2,
441};
442pub use spheroidal::{
444 angular_spheroidal, associated_legendre, radial_spheroidal_1, spherical_bessel_j,
445 spheroidal_eigenvalue_wf, SpheroidType, SpheroidalConfig,
446};
447pub use spheroidal::{
449 spheroidal_eigenvalue_mn, spheroidal_ps, spheroidal_wronskian, SpheroidalEigenvalue,
450 SpheroidalKind,
451};
452pub use spheroidal::cf_helpers::{
456 angular_function, cf_modified_lentz, d_coefficients, d_coefficients_with_len,
457 flammer_eigenvalue, radial_function, scaled_recurrence_step, tail_ratio_lentz, LentzResult,
458 SphericalBesselKind, SpheroidalParity, DEFAULT_D_LEN,
459};
460pub use hill::{hill_floquet, mathieu_hill, CurveType, HillEquation, HillResult, StabilityCurve};
462pub use mathieu_hill::{
464 hill_characteristic_exponent, hill_periodic_solution, hill_stability_check,
465 hill_stability_exponent, HillCoefficients,
466};
467pub use mixed_precision::{
469 auto_dispatch_bessel_j0, auto_dispatch_erf, auto_dispatch_gamma, batch_eval_mixed,
470 MixedPrecisionConfig,
471};
472pub use statistical::{
473 expm1_array, log1p_array, log_abs_gamma, log_softmax, logistic, logistic_derivative, logsumexp,
474 sinc, sinc_array, softmax,
475};
476pub use struve::{it2_struve0, it_mod_struve0, it_struve0, mod_struve, struve};
477
478pub use clausen::clausen;
480pub use debye::{debye1, debye2, debye3, debye4, debye5};
481pub use scipy_compat::{
482 acosdg, asindg, atandg, bernoulli_poly, euler_poly, exp1, expn, loggamma_sign, multinomial,
483};
484pub use spherical_bessel_extended::{
485 riccati_jn, riccati_yn, spherical_in, spherical_in_derivative, spherical_kn,
486 spherical_kn_derivative,
487};
488pub use utility::{
489 agm,
490 cbrt,
492 cbrt_array,
494 cosdg,
495 cosm1,
497 cotdg,
498 diric,
500 exp10,
501 exp10_array,
502 exp2,
503 expit,
505 expit_array,
506 expm1_array_utility,
507 exprel,
508 gradient,
509 log1p_array_utility,
510 log_expit,
511 logit,
512 logit_array,
513 owens_t,
514 powm1,
515 radian,
517 round,
518 round_array,
519 sindg,
520 softplus,
521 spherical_distance,
522 tandg,
523 xlog1py,
524 xlog1py_scalar,
526 xlogy,
527};
528pub use voigt::{
529 pseudo_voigt, voigt_profile, voigt_profile_array, voigt_profile_fwhm, voigt_profile_fwhm_array,
530 voigt_profile_normalized,
531};
532pub use wright::{wright_omega_optimized, wright_omega_real_optimized};
533pub use wright_bessel::{
534 log_wright_bessel, wright_bessel, wright_bessel_complex, wright_bessel_zeros,
535};
536pub use wright_simplified::{wright_omega, wright_omega_real};
537pub use zeta::{hurwitz_zeta, zeta, zetac};
538pub use zeta_ext::{dirichlet_eta, lerch_phi, riemann_zeta, riemann_zeta_complex};
539
540#[cfg(feature = "simd")]
542pub use simd_ops::{
543 benchmark_simd_performance, erf_f32_simd, exp_f32_simd, gamma_f32_simd, gamma_f64_simd,
544 j0_f32_simd, vectorized_special_ops,
545};
546
547#[cfg(feature = "simd")]
549pub use simd_ops::{
550 batch_bessel_j0_f32, batch_bessel_j0_f64, batch_bessel_j1_f32, batch_bessel_j1_f64,
551 batch_bessel_y0_f32, batch_bessel_y0_f64, batch_bessel_y1_f32, batch_bessel_y1_f64,
552 batch_beta_f32, batch_beta_f64, batch_digamma_f32, batch_digamma_f64, batch_erf_f32,
553 batch_erf_f64, batch_erfc_f32, batch_erfc_f64, batch_gamma_f32, batch_gamma_f64,
554 batch_lgamma_f32, batch_lgamma_f64,
555};
556
557#[cfg(feature = "parallel")]
559pub use simd_ops::{
560 adaptive_gamma_processing, benchmark_parallel_performance, gamma_f64_parallel, j0_f64_parallel,
561};
562
563#[cfg(all(feature = "simd", feature = "parallel"))]
565pub use simd_ops::gamma_f32_simd_parallel;
566
567pub use erf::{dawsn, erf, erfc, erfcinv, erfcx, erfi, erfinv, wofz};
569
570#[cfg(feature = "high-precision")]
572pub use arbitrary_precision::{
573 bessel::{bessel_j_ap, bessel_j_mp, bessel_y_ap, bessel_y_mp},
574 cleanup_cache,
575 error_function::{erf_ap, erf_mp, erfc_ap, erfc_mp},
576 gamma::{gamma_ap, gamma_mp, log_gamma_ap, log_gamma_mp},
577 to_complex64, to_f64, PrecisionContext,
578};
579
580#[cfg(feature = "high-precision")]
582pub use arbitrary_precision::{
583 bessel_j0_mpfr, bessel_k0_mpfr, digamma_mpfr, erf_mpfr, erfc_mpfr, gamma_mpfr, lgamma_mpfr,
584};
585
586#[cfg(test)]
587mod tests {
588 use super::*;
589 use approx::assert_relative_eq;
590 use scirs2_core::numeric::Complex64;
591
592 #[test]
593 fn test_gamma_function() {
594 assert_relative_eq!(gamma(1.0), 1.0, epsilon = 1e-10);
596 assert_relative_eq!(gamma(2.0), 1.0, epsilon = 1e-10);
597 assert_relative_eq!(gamma(3.0), 2.0, epsilon = 1e-10);
598 assert_relative_eq!(gamma(4.0), 6.0, epsilon = 1e-10);
599 assert_relative_eq!(gamma(5.0), 24.0, epsilon = 1e-10);
600 }
601
602 #[test]
603 fn test_lambert_w() {
604 let w = lambert_w(Complex64::new(1.0, 0.0), 0, 1e-8).expect("Operation failed");
606 let expected = Complex64::new(0.567_143_290_409_783_8, 0.0);
607 assert!((w - expected).norm() < 1e-10);
608
609 let z = Complex64::new(1.0, 0.0);
611 let w_exp_w = w * w.exp();
612 assert!((w_exp_w - z).norm() < 1e-10);
613
614 let w_b1 = lambert_w(Complex64::new(1.0, 0.0), 1, 1e-8).expect("Operation failed");
616 assert!(w_b1.im > 0.0);
617
618 let w_bm1 = lambert_w(Complex64::new(1.0, 0.0), -1, 1e-8).expect("Operation failed");
620 assert!(w_bm1.im < 0.0);
621
622 let w_real = lambert_w_real(1.0, 1e-8).expect("Operation failed");
624 assert!((w_real - 0.567_143_290_409_783_8).abs() < 1e-10);
625 }
626}