├── .gitignore ├── Bessel ├── ft_j0.c ├── ft_j0f.c ├── ft_j1.c ├── ft_j1f.c ├── ft_jn.c ├── ft_jnf.c ├── ft_y0.c ├── ft_y0f.c ├── ft_y1.c ├── ft_y1f.c ├── ft_yn.c └── ft_ynf.c ├── Exponential_Logarithmic ├── ft_exp.c ├── ft_exp10.c ├── ft_exp10f.c ├── ft_exp2.c ├── ft_exp2f.c ├── ft_expf.c ├── ft_expm1.c ├── ft_expm1f.c ├── ft_frexp.c ├── ft_frexpf.c ├── ft_ilogb.c ├── ft_ilogbf.c ├── ft_ldexp.c ├── ft_ldexpf.c ├── ft_log.c ├── ft_log10.c ├── ft_log10f.c ├── ft_log1p.c ├── ft_log1pf.c ├── ft_log2.c ├── ft_log2f.c ├── ft_logb.c ├── ft_logbf.c ├── ft_logf.c ├── ft_scalbln.c ├── ft_scalblnf.c ├── ft_scalbn.c └── ft_scalbnf.c ├── Floating-point_Classification ├── ft_fpclassify.c ├── ft_fpclassifyf.c ├── ft_isfinite.c ├── ft_isinf.c ├── ft_isnan.c ├── ft_isnormal.c ├── ft_signbit.c ├── ft_significand.c └── ft_significandf.c ├── Hyperbolic ├── ft_acosh.c ├── ft_acoshf.c ├── ft_asinh.c ├── ft_asinhf.c ├── ft_atanh.c ├── ft_atanhf.c ├── ft_cosh.c ├── ft_coshf.c ├── ft_sinh.c ├── ft_sinhf.c ├── ft_tanh.c └── ft_tanhf.c ├── LICENSE ├── MAKE.bat ├── Makefile ├── Neural_Network ├── ft_elu.c ├── ft_eluf.c ├── ft_leakyrelu.c ├── ft_leakyreluf.c ├── ft_mish.c ├── ft_mishf.c ├── ft_prelu.c ├── ft_preluf.c ├── ft_relu.c ├── ft_reluf.c ├── ft_sigmoid.c ├── ft_sigmoidf.c ├── ft_softmax.c ├── ft_softmaxf.c ├── ft_softmedian.c ├── ft_softmedianf.c ├── ft_softmin.c ├── ft_softminf.c ├── ft_swish.c └── ft_swishf.c ├── Other ├── ft_erf.c ├── ft_erfc.c ├── ft_erfcf.c ├── ft_erff.c ├── ft_fabs.c ├── ft_fabsf.c ├── ft_fibonacci.c ├── ft_fma.c ├── ft_fmaf.c ├── ft_fmax.c ├── ft_fmaxf.c ├── ft_fmin.c ├── ft_fminf.c ├── ft_lerp.c ├── ft_lerpf.c ├── ft_lgamma.c ├── ft_lgammaf.c ├── ft_modf.c ├── ft_modff.c ├── ft_tgamma.c └── ft_tgammaf.c ├── Power ├── ft_cbrt.c ├── ft_cbrtf.c ├── ft_hypot.c ├── ft_hypotf.c ├── ft_invsqrt.c ├── ft_invsqrtf.c ├── ft_pow.c ├── ft_pow10.c ├── ft_pow10f.c ├── ft_powf.c ├── ft_sqrt.c └── ft_sqrtf.c ├── README.md ├── Rounding_Remainder ├── ft_ceil.c ├── ft_ceilf.c ├── ft_copysign.c ├── ft_copysignf.c ├── ft_fdim.c ├── ft_fdimf.c ├── ft_floor.c ├── ft_floorf.c ├── ft_fmod.c ├── ft_fmodf.c ├── ft_lrint.c ├── ft_lrintf.c ├── ft_lround.c ├── ft_lroundf.c ├── ft_nan.c ├── ft_nanf.c ├── ft_nearbyint.c ├── ft_nearbyintf.c ├── ft_nextafter.c ├── ft_nextafterf.c ├── ft_nexttoward.c ├── ft_nexttowardf.c ├── ft_remainder.c ├── ft_remainderf.c ├── ft_remquo.c ├── ft_remquof.c ├── ft_rint.c ├── ft_rintf.c ├── ft_round.c ├── ft_roundf.c ├── ft_trunc.c └── ft_truncf.c ├── Trigonometric ├── ft_acos.c ├── ft_acosf.c ├── ft_asin.c ├── ft_asinf.c ├── ft_atan.c ├── ft_atan2.c ├── ft_atan2f.c ├── ft_atanf.c ├── ft_cos.c ├── ft_cosf.c ├── ft_cospi.c ├── ft_cospif.c ├── ft_cot.c ├── ft_cotf.c ├── ft_csc.c ├── ft_cscf.c ├── ft_sec.c ├── ft_secf.c ├── ft_sin.c ├── ft_sincos.c ├── ft_sincosf.c ├── ft_sinf.c ├── ft_sinpi.c ├── ft_sinpif.c ├── ft_tan.c ├── ft_tanf.c ├── ft_tanpi.c └── ft_tanpif.c └── ft_math.h /.gitignore: -------------------------------------------------------------------------------- 1 | # **************************************************************************** # 2 | # # 3 | # ::: :::::::: # 4 | # .gitignore :+: :+: :+: # 5 | # +:+ +:+ +:+ # 6 | # By: hdeniz +#+ +:+ +#+ # 7 | # +#+#+#+#+#+ +#+ # 8 | # Created: 2022/10/12 23:15:03 by hdeniz #+# #+# # 9 | # Updated: 2024/05/19 02:03:?? by hdeniz ### ########.fr # 10 | # # 11 | # **************************************************************************** # 12 | 13 | # Prerequisites 14 | *.d 15 | 16 | # Object files 17 | *.o 18 | *.ko 19 | *.obj 20 | *.elf 21 | 22 | # Linker output 23 | *.ilk 24 | *.map 25 | *.exp 26 | 27 | # Precompiled Headers 28 | *.gch 29 | *.pch 30 | 31 | # Libraries 32 | *.lib 33 | *.a 34 | *.la 35 | *.lo 36 | 37 | # Shared objects (inc. Windows DLLs) 38 | *.dll 39 | *.so 40 | *.so.* 41 | *.dylib 42 | 43 | # Executables 44 | *.exe 45 | *.out 46 | *.app 47 | *.i*86 48 | *.x86_64 49 | *.hex 50 | 51 | # Debug files 52 | *.dSYM/ 53 | *.su 54 | *.idb 55 | *.pdb 56 | 57 | # Kernel Module Compile Results 58 | *.mod* 59 | *.cmd 60 | .tmp_versions/ 61 | modules.order 62 | Module.symvers 63 | Mkfile.old 64 | dkms.conf 65 | 66 | # MACOS Folder Settings 67 | .DS_Store 68 | -------------------------------------------------------------------------------- /Bessel/ft_j0f.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_j0f.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/09 19:20:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_jnf(int, float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_j0f(register float x) 21 | { 22 | return (ft_jnf(0, x)); 23 | } 24 | -------------------------------------------------------------------------------- /Bessel/ft_j1.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_j1.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/09 22:30:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_jn(int, double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_j1(register double x) 21 | { 22 | return (ft_jn(1, x)); 23 | } 24 | -------------------------------------------------------------------------------- /Bessel/ft_j1f.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_j1f.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/09 22:30:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_jnf(int, float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_j1f(register float x) 21 | { 22 | return (ft_jnf(1, x)); 23 | } 24 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_exp10.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_exp10.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 17:09:38 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_pow(double, double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_exp10(register double x) 23 | { 24 | float result; 25 | 26 | if (ft_isnan(x) || ft_isinf(x) == 1) 27 | { 28 | result = x; 29 | return (result); 30 | } 31 | if (ft_isinf(x)) 32 | return (0.0); 33 | if (x == 0.0) 34 | return (1.0); 35 | result = ft_pow(10.0, x); 36 | return (result); 37 | } 38 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_exp10f.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_exp10f.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 17:09:38 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_powf(float, float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_exp10f(register float x) 23 | { 24 | float result; 25 | 26 | if (ft_isnan(x) || ft_isinf(x) == 1) 27 | { 28 | result = x; 29 | return (result); 30 | } 31 | if (ft_isinf(x)) 32 | return (0.0F); 33 | if (x == 0.0F) 34 | return (1.0F); 35 | result = ft_powf(10.0F, x); 36 | return (result); 37 | } 38 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_exp2.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_exp2.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 16:18:27 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # double ft_exp(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | #define LOG2_F 0.69314718055994528623 22 | 23 | double 24 | ft_exp2(register double x) 25 | { 26 | double result; 27 | 28 | if (ft_isinf(x) || ft_isnan(x) == 1) 29 | { 30 | result = x; 31 | return (result); 32 | } 33 | if (ft_isinf(x)) 34 | return (0.0); 35 | result = ft_exp(x * LOG2_F); 36 | return (result); 37 | } 38 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_exp2f.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_exp2f.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 16:18:27 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # float ft_expf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | #define LOG2_F 0.69314718055994528623F 22 | 23 | float 24 | ft_exp2f(register float x) 25 | { 26 | float result; 27 | 28 | if (ft_isinf(x) || ft_isnan(x) == 1) 29 | { 30 | result = x; 31 | return (result); 32 | } 33 | if (ft_isinf(x)) 34 | return (0.0F); 35 | result = ft_expf(x * LOG2_F); 36 | return (result); 37 | } 38 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_expm1.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_expm1.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 17:24:06 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_fabs(double); 18 | # double ft_exp(double); 19 | # */ 20 | /* **************************** [^] INCLUDES [^] **************************** */ 21 | 22 | double 23 | ft_expm1(register double x) 24 | { 25 | double result; 26 | register double x_x; 27 | 28 | if (ft_isnan(x) || ft_isinf(x) || x == 0.0) 29 | { 30 | result = x; 31 | return (result); 32 | } 33 | if (ft_isinf(x)) 34 | return (-1.0); 35 | if (ft_fabs(x) > 1E-5) 36 | return (ft_exp(x) - 1.0); 37 | x_x = x * x; 38 | result = x + x_x * 0.5 + \ 39 | x_x * x * 0.16666666666666666 + x_x * x_x * 0.041666666666666664; 40 | return (result); 41 | } 42 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_expm1f.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_expm1f.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 17:24:06 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_fabsf(float); 18 | # float ft_expf(float); 19 | # */ 20 | /* **************************** [^] INCLUDES [^] **************************** */ 21 | 22 | float 23 | ft_expm1f(register float x) 24 | { 25 | float result; 26 | register float x_x; 27 | 28 | if (ft_isnan(x) || ft_isinf(x) || x == 0.0F) 29 | { 30 | result = x; 31 | return (result); 32 | } 33 | if (ft_isinf(x)) 34 | return (-1.0F); 35 | if (ft_fabsf(x) > 1E-5) 36 | return (ft_expf(x) - 1.0F); 37 | x_x = x * x; 38 | result = x + x_x * 0.5F + \ 39 | x_x * x * 0.16666666666666666F + x_x * x_x * 0.041666666666666664F; 40 | return (result); 41 | } 42 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_frexp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_frexp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 20:39:47 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_fabs(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_frexp(double x, long *exponent) 23 | { 24 | register long sign; 25 | register int epsilon; 26 | 27 | if (ft_isnan(x) || ft_isinf(x)) 28 | return (x); 29 | sign = 1U; 30 | epsilon = -1; 31 | if (x < 0.0) 32 | sign = -1U; 33 | if (x == 0.0) 34 | { 35 | *exponent = 0; 36 | return (0.0); 37 | } 38 | x = ft_fabs(x); 39 | while (++epsilon, x >= 1.0) 40 | x /= 2.0; 41 | epsilon++; 42 | while (--epsilon, x < 0.5) 43 | x *= 2.0; 44 | *exponent = sign * epsilon; 45 | x *= (double)sign; 46 | return (x); 47 | } 48 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_frexpf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_frexpf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 20:39:47 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_fabsf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_frexpf(float x, int *exponent) 23 | { 24 | register int sign; 25 | register int epsilon; 26 | 27 | if (ft_isnan(x) || ft_isinf(x)) 28 | return (x); 29 | sign = 1; 30 | epsilon = -1; 31 | if (x < 0.0F) 32 | sign = -1; 33 | if (x == 0.0F) 34 | { 35 | *exponent = 0; 36 | return (0.0F); 37 | } 38 | x = ft_fabsf(x); 39 | while (++epsilon, x >= 1.0F) 40 | x /= 2.0F; 41 | epsilon++; 42 | while (--epsilon, x < 0.5F) 43 | x *= 2.0F; 44 | *exponent = sign * epsilon; 45 | x *= (float)sign; 46 | return (x); 47 | } 48 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_ilogb.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ilogb.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 20:17:46 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_floor(double); 18 | # double ft_log2(double); 19 | # double ft_fabs(double); 20 | # */ 21 | /* **************************** [^] INCLUDES [^] **************************** */ 22 | 23 | int 24 | ft_ilogb(register double x) 25 | { 26 | if (ft_isnan(x) || x == 0.0) 27 | return (0X80000000); 28 | if (ft_isinf(x)) 29 | return (0X7FFFFFFF); 30 | return ((int)ft_floor(ft_log2(ft_fabs(x)))); 31 | } 32 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_ilogbf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ilogbf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 20:17:46 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_floorf(float); 18 | # float ft_log2f(float); 19 | # float ft_fabsf(float); 20 | # */ 21 | /* **************************** [^] INCLUDES [^] **************************** */ 22 | 23 | int 24 | ft_ilogbf(register float x) 25 | { 26 | if (ft_isnan(x) || x == 0.0F) 27 | return (0X80000000); 28 | if (ft_isinf(x)) 29 | return (0X7FFFFFFF); 30 | return ((int)ft_floorf(ft_log2f(ft_fabsf(x)))); 31 | } 32 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_ldexp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ldexp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 13:29:41 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # double ft_pow(double, double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_ldexp(double x, register long exponent) 23 | { 24 | if (ft_isinf(x) || ft_isnan(x) || x == 0.0 || exponent == 0L) 25 | return (x); 26 | if (exponent == (signed)0X8000000000000000L || \ 27 | exponent == 0X7FFFFFFFFFFFFFFFL) 28 | return (0.0); 29 | if (exponent + ((x / 2L) + 1L) >= 1025L) 30 | return (1.0); 31 | return (x * ft_pow(2.0, exponent)); 32 | } 33 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_ldexpf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ldexpf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 13:29:41 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # float ft_powf(float, float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_ldexpf(float x, register int exponent) 23 | { 24 | if (ft_isinf(x) || ft_isnan(x) || x == 0.0F || exponent == 0) 25 | return (x); 26 | if (exponent == (signed)0X80000000 || exponent == 0X7FFFFFFF) 27 | return (0.0F); 28 | if (exponent + ((x / 2) + 1) >= 1025) 29 | return (1.0F); 30 | return (x * ft_powf(2.0F, exponent)); 31 | } 32 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_log10.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_log10.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/23 15:56:29 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_log(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | #define LOG10 2.3025850929940459 // log(10.0) 20 | 21 | double 22 | ft_log10(register double x) 23 | { 24 | return (ft_log(x) / LOG10); 25 | } 26 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_log10f.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_log10f.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/23 15:56:29 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_logf(float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | #define LOG10_F 2.3025850929940459F // log(10.0) 20 | 21 | float 22 | ft_log10f(register float x) 23 | { 24 | return (ft_logf(x) / LOG10_F); 25 | } 26 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_log1p.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_log1p.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/25 14:26:58 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_log(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_log1p(register double x) 23 | { 24 | double result; 25 | register double y; 26 | 27 | if (ft_isnan(x) || ft_isinf(x)) 28 | { 29 | result = x; 30 | return (result); 31 | } 32 | if (x == -1.0) 33 | return (-1.0 / 0.0); 34 | if (x < -1.0) 35 | return (-0.0 / 0.0); 36 | if (x < 1E-15) 37 | { 38 | result = x - 0.5 * x * x; 39 | return (result); 40 | } 41 | y = 1.0 + x; 42 | result = ft_log(y) - ((y - 1.0) - x) / y; 43 | return (result); 44 | } 45 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_log1pf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_log1pf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/25 14:26:58 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_logf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_log1pf(register float x) 23 | { 24 | float result; 25 | register float y; 26 | 27 | if (ft_isnan(x) || ft_isinf(x)) 28 | { 29 | result = x; 30 | return (result); 31 | } 32 | if (x == -1.0F) 33 | return (-1.0F / 0.0F); 34 | if (x < -1.0F) 35 | return (-0.0F / 0.0F); 36 | if (x < 1E-15) 37 | { 38 | result = x - 0.5F * x * x; 39 | return (result); 40 | } 41 | y = 1.0F + x; 42 | result = ft_logf(y) - ((y - 1.0F) - x) / y; 43 | return (result); 44 | } 45 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_log2.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_log2.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 18:08:32 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_LN2 16 | # int ft_isnan(double); 17 | # int ft_isinf(double); 18 | # double ft_log(double); 19 | # */ 20 | /* **************************** [^] INCLUDES [^] **************************** */ 21 | 22 | double 23 | ft_log2(register double x) 24 | { 25 | if (ft_isnan(x) || ft_isinf(x)) 26 | return (x); 27 | if (x == 0.0) 28 | return ((-1.0 / 0.0)); 29 | if (x < 0.0) 30 | return ((0.0 / 0.0)); 31 | return (ft_log(x) / M_LN2); 32 | } 33 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_log2f.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_log2f.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 18:08:32 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_LN2_F 16 | # int ft_isnan(double); 17 | # int ft_isinf(double); 18 | # float ft_logf(float); 19 | # */ 20 | /* **************************** [^] INCLUDES [^] **************************** */ 21 | 22 | float 23 | ft_log2f(register float x) 24 | { 25 | if (ft_isnan(x) || ft_isinf(x)) 26 | return (x); 27 | if (x == 0.0F) 28 | return ((-1.0F / 0.0F)); 29 | if (x < 0.0F) 30 | return ((0.0F / 0.0F)); 31 | return (ft_logf(x) / M_LN2_F); 32 | } 33 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_logb.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_logb.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 20:45:44 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_frexp(double, long *); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_logb(register double x) 23 | { 24 | long exponent; 25 | 26 | if (x == 0.0) 27 | return ((-1.0 / 0.0)); 28 | if (ft_isnan(x)) 29 | return (x); 30 | if (ft_isinf(x)) 31 | return ((1.0 / 0.0)); 32 | ft_frexp(x, &exponent); 33 | return ((double)exponent - 1.0); 34 | } 35 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_logbf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_logbf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 20:45:44 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_frexpf(float, int *); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_logbf(register float x) 23 | { 24 | int exponent; 25 | 26 | if (x == 0.0F) 27 | return ((-1.0F / 0.0F)); 28 | if (ft_isnan(x)) 29 | return (x); 30 | if (ft_isinf(x)) 31 | return ((1.0F / 0.0F)); 32 | ft_frexpf(x, &exponent); 33 | return ((float)exponent - 1.0F); 34 | } 35 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_scalbln.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_scalbln.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:32:51 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_ldexp(double, long); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_scalbln(register double x, register long exponent) 21 | { 22 | return (ft_ldexp(x, exponent)); 23 | } 24 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_scalblnf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_scalblnf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:32:51 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_ldexpf(float, int); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_scalblnf(register float x, register int exponent) 21 | { 22 | return (ft_ldexpf(x, exponent)); 23 | } 24 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_scalbn.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_scalbn.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 13:30:51 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_ldexp(double, long); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_scalbn(register double x, register long exponent) 21 | { 22 | return (ft_ldexp(x, exponent)); 23 | } 24 | -------------------------------------------------------------------------------- /Exponential_Logarithmic/ft_scalbnf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_scalbnf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 13:30:51 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_ldexpf(float, int); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_scalbnf(register float x, register int exponent) 21 | { 22 | return (ft_ldexpf(x, exponent)); 23 | } 24 | -------------------------------------------------------------------------------- /Floating-point_Classification/ft_fpclassify.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fpclassify.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/06 08:51:42 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define FP_NAN 16 | # define FP_INFINITE 17 | # define FP_ZERO 18 | # define DBL_MIN 19 | # define FP_SUBNORMAL 20 | # define FP_NORMAL 21 | # int ft_isnan(double); 22 | # int ft_isinf(double); 23 | # double ft_fabs(double); 24 | # */ 25 | /* **************************** [^] INCLUDES [^] **************************** */ 26 | 27 | int 28 | ft_fpclassify(register double x) 29 | { 30 | if (ft_isnan(x)) 31 | return (FP_NAN); 32 | if (ft_isinf(x)) 33 | return (FP_INFINITE); 34 | if (x == 0.0) 35 | return (FP_ZERO); 36 | if (ft_fabs(x) < (DBL_MIN)) 37 | return (FP_SUBNORMAL); 38 | return (FP_NORMAL); 39 | } 40 | 41 | /* * * * * * * * * * 42 | * FP_NAN 0 * 43 | * FP_INFINITE 1 * 44 | * FP_ZERO 2 * 45 | * FP_SUBNORMAL 3 * 46 | * FP_NORMAL 4 * 47 | * * * * * * * * * */ 48 | -------------------------------------------------------------------------------- /Floating-point_Classification/ft_fpclassifyf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fpclassifyf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/06 08:51:42 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define FP_NAN 16 | # define FP_INFINITE 17 | # define FP_ZERO 18 | # define FLT_MIN 19 | # define FP_SUBNORMAL 20 | # define FP_NORMAL 21 | # int ft_isnan(double); 22 | # int ft_isinf(double); 23 | # float ft_fabsf(float); 24 | # */ 25 | /* **************************** [^] INCLUDES [^] **************************** */ 26 | 27 | int 28 | ft_fpclassifyf(register float x) 29 | { 30 | if (ft_isnan(x)) 31 | return (FP_NAN); 32 | if (ft_isinf(x)) 33 | return (FP_INFINITE); 34 | if (x == 0.0F) 35 | return (FP_ZERO); 36 | if (ft_fabsf(x) < (FLT_MIN)) 37 | return (FP_SUBNORMAL); 38 | return (FP_NORMAL); 39 | } 40 | 41 | /* * * * * * * * * * 42 | * FP_NAN 0 * 43 | * FP_INFINITE 1 * 44 | * FP_ZERO 2 * 45 | * FP_SUBNORMAL 3 * 46 | * FP_NORMAL 4 * 47 | * * * * * * * * * */ 48 | -------------------------------------------------------------------------------- /Floating-point_Classification/ft_isfinite.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isfinite.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/28 20:10:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | int 21 | ft_isfinite(register double x) 22 | { 23 | return (!ft_isnan(x) && !ft_isinf(x)); 24 | } 25 | -------------------------------------------------------------------------------- /Floating-point_Classification/ft_isinf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isinf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/24 16:06:14 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | int 20 | ft_isinf(register double x) 21 | { 22 | if (x == (-1.0 / 0.0)) 23 | return ((!ft_isnan(x) && ft_isnan(x - x)) * -1); 24 | return (!ft_isnan(x) && ft_isnan(x - x)); 25 | } 26 | -------------------------------------------------------------------------------- /Floating-point_Classification/ft_isnan.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isnan.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/24 16:06:06 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int 14 | ft_isnan(register double x) 15 | { 16 | return (x != x); 17 | } 18 | -------------------------------------------------------------------------------- /Floating-point_Classification/ft_isnormal.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_isnormal.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/28 20:23:31 by hdeniz #+# #+# */ 9 | /* Updated: 2025/01/27 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define DBL_MIN 16 | # int ft_isfinite(double); 17 | # double ft_fabs(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | int 22 | ft_isnormal(register double x) 23 | { 24 | int result; 25 | 26 | result = (ft_isfinite(x) && x != 0.0 && ft_fabs(x) >= DBL_MIN); 27 | return (result); 28 | } 29 | -------------------------------------------------------------------------------- /Floating-point_Classification/ft_signbit.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_signbit.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/28 17:31:04 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int 14 | ft_signbit(double x) 15 | { 16 | return (((sizeof(double) - 1)[((unsigned char *) &x)] & 0X80) != 0); 17 | } 18 | -------------------------------------------------------------------------------- /Floating-point_Classification/ft_significand.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_significand.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/08/13 21:48:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # union u_double_bits; 16 | # int ft_isinf(double); 17 | # int ft_isnan(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_significand(register double x) 23 | { 24 | union u_double_bits bits; 25 | 26 | bits.value = x; 27 | if (ft_isnan(x) || ft_isinf(x) || x == 0.0) 28 | return (bits.value); 29 | bits.parts.exponent = 1023; 30 | bits.parts.sign = 0; 31 | return (bits.value); 32 | } 33 | -------------------------------------------------------------------------------- /Floating-point_Classification/ft_significandf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_significandf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/08/13 21:48:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # union u_float_bits; 16 | # int ft_isinf(double); 17 | # int ft_isnan(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_significandf(register float x) 23 | { 24 | union u_float_bits bits; 25 | 26 | bits.value = x; 27 | if (ft_isnan(x) || ft_isinf(x) || x == 0.0F) 28 | return (bits.value); 29 | bits.parts.exponent = 127; 30 | bits.parts.sign = 0; 31 | return (bits.value); 32 | } 33 | -------------------------------------------------------------------------------- /Hyperbolic/ft_acosh.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_acosh.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 16:01:28 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_log(double); 18 | # double ft_sqrt(double); 19 | # */ 20 | /* **************************** [^] INCLUDES [^] **************************** */ 21 | 22 | double 23 | ft_acosh(register double x) 24 | { 25 | double result; 26 | 27 | if (ft_isnan(x) || ft_isinf(x)) 28 | { 29 | result = x; 30 | return (result); 31 | } 32 | if (x < 1.0) 33 | return (0.0 / 0.0); 34 | result = ft_log(x + ft_sqrt(x * x - 1.0)); 35 | return (result); 36 | } 37 | -------------------------------------------------------------------------------- /Hyperbolic/ft_acoshf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_acoshf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 16:01:28 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_logf(float); 18 | # float ft_sqrtf(float); 19 | # */ 20 | /* **************************** [^] INCLUDES [^] **************************** */ 21 | 22 | float 23 | ft_acoshf(register float x) 24 | { 25 | float result; 26 | 27 | if (ft_isnan(x) || ft_isinf(x)) 28 | { 29 | result = x; 30 | return (result); 31 | } 32 | if (x < 1.0F) 33 | return (0.0F / 0.0F); 34 | result = ft_logf(x + ft_sqrtf(x * x - 1.0F)); 35 | return (result); 36 | } 37 | -------------------------------------------------------------------------------- /Hyperbolic/ft_asinh.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_asinh.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 15:56:37 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # double ft_log(double); 18 | # double ft_sqrt(double); 19 | # */ 20 | /* **************************** [^] INCLUDES [^] **************************** */ 21 | 22 | double 23 | ft_asinh(register double x) 24 | { 25 | double result; 26 | 27 | if (ft_isinf(x) || ft_isnan(x)) 28 | { 29 | result = x; 30 | return (result); 31 | } 32 | result = ft_log(x + ft_sqrt(x * x + 1.0)); 33 | return (result); 34 | } 35 | -------------------------------------------------------------------------------- /Hyperbolic/ft_asinhf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_asinhf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 15:56:37 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # float ft_logf(float); 18 | # float ft_sqrtf(float); 19 | # */ 20 | /* **************************** [^] INCLUDES [^] **************************** */ 21 | 22 | float 23 | ft_asinhf(register float x) 24 | { 25 | float result; 26 | 27 | if (ft_isinf(x) || ft_isnan(x)) 28 | { 29 | result = x; 30 | return (result); 31 | } 32 | result = ft_logf(x + ft_sqrtf(x * x + 1.0F)); 33 | return (result); 34 | } 35 | -------------------------------------------------------------------------------- /Hyperbolic/ft_atanh.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_atanh.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 16:07:37 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_fabs(double); 16 | # double ft_log(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_atanh(register double x) 22 | { 23 | if (!(ft_fabs(x) >= 1.0)) 24 | return (0.5 * ft_log((1.0 + x) / (1.0 - x))); 25 | if (x == 1.0) 26 | return (1.0 / 0.0); 27 | if (x == -1.0) 28 | return (-1.0 / 0.0); 29 | return (0.0 / 0.0); 30 | } 31 | -------------------------------------------------------------------------------- /Hyperbolic/ft_atanhf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_atanhf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 16:07:37 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_fabsf(float); 16 | # float ft_logf(float); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_atanhf(register float x) 22 | { 23 | if (!(ft_fabsf(x) >= 1.0F)) 24 | return (0.5F * ft_logf((1.0F + x) / (1.0F - x))); 25 | if (x == 1.0F) 26 | return (1.0F / 0.0F); 27 | if (x == -1.0F) 28 | return (-1.0F / 0.0F); 29 | return (0.0F / 0.0F); 30 | } 31 | -------------------------------------------------------------------------------- /Hyperbolic/ft_cosh.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_cosh.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/27 13:26:15 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_exp(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_cosh(register double x) 21 | { 22 | return ((ft_exp(x) + ft_exp(-x)) / 2.0); 23 | } 24 | -------------------------------------------------------------------------------- /Hyperbolic/ft_coshf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_coshf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/27 13:26:15 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_expf(float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_coshf(register float x) 21 | { 22 | return ((ft_expf(x) + ft_expf(-x)) / 2.0F); 23 | } 24 | -------------------------------------------------------------------------------- /Hyperbolic/ft_sinh.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sinh.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/26 17:35:15 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_exp(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_sinh(register double x) 21 | { 22 | return ((ft_exp(x) - ft_exp(-x)) / 2.0); 23 | } 24 | -------------------------------------------------------------------------------- /Hyperbolic/ft_sinhf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sinhf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/26 17:35:15 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_expf(float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_sinhf(register float x) 21 | { 22 | return ((ft_expf(x) - ft_expf(-x)) / 2.0F); 23 | } 24 | -------------------------------------------------------------------------------- /Hyperbolic/ft_tanh.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_tanh.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 12:26:29 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_exp(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_tanh(register double x) 23 | { 24 | double result; 25 | 26 | if (ft_isnan(x)) 27 | { 28 | result = x; 29 | return (result); 30 | } 31 | if (ft_isinf(x)) 32 | { 33 | result = 1.0 * ft_isinf(x); 34 | return (result); 35 | } 36 | result = (ft_exp(x) - ft_exp(-x)) / (ft_exp(x) + ft_exp(-x)); 37 | return (result); 38 | } 39 | -------------------------------------------------------------------------------- /Hyperbolic/ft_tanhf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_tanhf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/01 12:26:29 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_expf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_tanhf(register float x) 23 | { 24 | float result; 25 | 26 | if (ft_isnan(x)) 27 | { 28 | result = x; 29 | return (result); 30 | } 31 | if (ft_isinf(x)) 32 | { 33 | result = 1.0F * ft_isinf(x); 34 | return (result); 35 | } 36 | result = (ft_expf(x) - ft_expf(-x)) / (ft_expf(x) + ft_expf(-x)); 37 | return (result); 38 | } 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Huseyin Teoman Deniz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Neural_Network/ft_elu.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_elu.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 14:55:12 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_exp(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_elu(register double x, double alpha) 21 | { 22 | if (x > 0.0) 23 | { 24 | alpha = x; 25 | return (alpha); 26 | } 27 | alpha *= (ft_exp(x) - 1.0); 28 | return (alpha); 29 | } 30 | -------------------------------------------------------------------------------- /Neural_Network/ft_eluf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_eluf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 00:55:12 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_expf(float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_eluf(register float x, float alpha) 21 | { 22 | if (x > 0.0F) 23 | { 24 | alpha = x; 25 | return (alpha); 26 | } 27 | alpha *= (ft_expf(x) - 1.0F); 28 | return (alpha); 29 | } 30 | -------------------------------------------------------------------------------- /Neural_Network/ft_leakyrelu.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_leakyrelu.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 14:47:39 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | double 14 | ft_leakyrelu(register double x, register double alpha) 15 | { 16 | if (x > 0.0) 17 | return (x); 18 | return (alpha * x); 19 | } 20 | -------------------------------------------------------------------------------- /Neural_Network/ft_leakyreluf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_leakyreluf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 14:47:39 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | float 14 | ft_leakyreluf(register float x, register float alpha) 15 | { 16 | if (x > 0.0F) 17 | return (x); 18 | return (alpha * x); 19 | } 20 | -------------------------------------------------------------------------------- /Neural_Network/ft_mish.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_mish.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 15:22:43 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_tanh(double); 16 | # double ft_log(double); 17 | # double ft_exp(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_mish(double x) 23 | { 24 | return (x * ft_tanh(ft_log(1.0 + ft_exp(x)))); 25 | } 26 | -------------------------------------------------------------------------------- /Neural_Network/ft_mishf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_mishf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 15:22:43 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_tanhf(float); 16 | # float ft_logf(float); 17 | # float ft_expf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_mishf(float x) 23 | { 24 | return (x * ft_tanhf(ft_logf(1.0F + ft_expf(x)))); 25 | } 26 | -------------------------------------------------------------------------------- /Neural_Network/ft_prelu.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_prelu.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 15:11:53 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | double 14 | ft_prelu(register double x, register double alpha) 15 | { 16 | if (x > 0.0) 17 | return (x); 18 | return (alpha * x); 19 | } 20 | -------------------------------------------------------------------------------- /Neural_Network/ft_preluf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_preluf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 15:11:53 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | float 14 | ft_preluf(register float x, register float alpha) 15 | { 16 | if (x > 0.0F) 17 | return (x); 18 | return (alpha * x); 19 | } 20 | -------------------------------------------------------------------------------- /Neural_Network/ft_relu.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_relu.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 14:36:47 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_fmax(double, double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_relu(register double x) 21 | { 22 | return (ft_fmax(0.0, x)); 23 | } 24 | -------------------------------------------------------------------------------- /Neural_Network/ft_reluf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_reluf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 14:36:47 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_fmaxf(float, float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_reluf(register float x) 21 | { 22 | return (ft_fmaxf(0.0F, x)); 23 | } 24 | -------------------------------------------------------------------------------- /Neural_Network/ft_sigmoidf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sigmoidf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/09 21:17:45 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_E_F 16 | # int ft_isnan(double); 17 | # int ft_isinf(double); 18 | # float ft_powf(float, float); 19 | # */ 20 | /* **************************** [^] INCLUDES [^] **************************** */ 21 | 22 | /* *************************** [v] PROTOTYPES [v] *************************** */ 23 | extern __inline__ float check_your_six(float x); 24 | /* *************************** [^] PROTOTYPES [^] *************************** */ 25 | 26 | float 27 | ft_sigmoidf(register float x) 28 | { 29 | if (ft_isnan(x) || ft_isinf(x)) 30 | return (check_your_six(x)); 31 | return (1.0F / (1.0F + ft_powf(M_E_F, -x))); 32 | } 33 | 34 | extern __inline__ float 35 | check_your_six(float x) 36 | { 37 | if (ft_isnan(x)) 38 | return (x); 39 | if (ft_isinf(x) == -1) 40 | return (0.0F); 41 | return (1.0F); 42 | } 43 | -------------------------------------------------------------------------------- /Neural_Network/ft_softmax.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_softmax.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 15:02:38 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_exp(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | void 20 | ft_softmax(double *x, register int size) 21 | { 22 | register double sum; 23 | register int epsilon; 24 | 25 | sum = 0.0; 26 | epsilon = -1; 27 | while (++epsilon, epsilon < size) 28 | sum += ft_exp(x[epsilon]); 29 | epsilon = -1; 30 | while (++epsilon, epsilon < size) 31 | x[epsilon] = ft_exp(x[epsilon]) / sum; 32 | } 33 | -------------------------------------------------------------------------------- /Neural_Network/ft_softmaxf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_softmaxf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 15:02:38 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_expf(float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | void 20 | ft_softmaxf(float *x, register int size) 21 | { 22 | register float sum; 23 | register int epsilon; 24 | 25 | sum = 0.0F; 26 | epsilon = -1; 27 | while (++epsilon, epsilon < size) 28 | sum += ft_expf(x[epsilon]); 29 | epsilon = -1; 30 | while (++epsilon, epsilon < size) 31 | x[epsilon] = ft_expf(x[epsilon]) / sum; 32 | } 33 | -------------------------------------------------------------------------------- /Neural_Network/ft_softmedian.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_softmedian.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 15:41:41 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_exp(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_softmedian(double *x, register int size, register double alpha) 21 | { 22 | register int epsilon; 23 | register double result; 24 | register double sum; 25 | 26 | epsilon = -1; 27 | result = 0.0; 28 | sum = 0.0; 29 | while (++epsilon, epsilon < size) 30 | sum += ft_exp(-alpha * x[epsilon]); 31 | epsilon = -1; 32 | while (++epsilon, epsilon < size) 33 | result += x[epsilon] * ft_exp(-alpha * x[epsilon]) / sum; 34 | return (result); 35 | } 36 | -------------------------------------------------------------------------------- /Neural_Network/ft_softmedianf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_softmedianf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 15:41:41 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_expf(float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_softmedianf(float *x, register int size, register float alpha) 21 | { 22 | register int epsilon; 23 | register float result; 24 | register float sum; 25 | 26 | epsilon = -1; 27 | result = 0.0F; 28 | sum = 0.0F; 29 | while (++epsilon, epsilon < size) 30 | sum += ft_expf(-alpha * x[epsilon]); 31 | epsilon = -1; 32 | while (++epsilon, epsilon < size) 33 | result += x[epsilon] * ft_expf(-alpha * x[epsilon]) / sum; 34 | return (result); 35 | } 36 | -------------------------------------------------------------------------------- /Neural_Network/ft_softmin.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_softmin.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 15:02:38 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_exp(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_softmin(double *x, register int size, register double alpha) 21 | { 22 | register int epsilon; 23 | register double result; 24 | register double sum; 25 | 26 | epsilon = -1; 27 | sum = 0.0; 28 | result = 0.0; 29 | while (++epsilon, epsilon < size) 30 | sum += ft_exp(-alpha * x[epsilon]); 31 | epsilon = -1; 32 | while (++epsilon, epsilon < size) 33 | result += x[epsilon] * ft_exp(-alpha * x[epsilon]) / sum; 34 | return (result); 35 | } 36 | -------------------------------------------------------------------------------- /Neural_Network/ft_softminf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_softminf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/13 15:02:38 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_expf(float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_softminf(float *x, register int size, register float alpha) 21 | { 22 | register int epsilon; 23 | register float result; 24 | register float sum; 25 | 26 | epsilon = -1; 27 | sum = 0.0F; 28 | result = 0.0F; 29 | while (++epsilon, epsilon < size) 30 | sum += ft_expf(-alpha * x[epsilon]); 31 | epsilon = -1; 32 | while (++epsilon, epsilon < size) 33 | result += x[epsilon] * ft_expf(-alpha * x[epsilon]) / sum; 34 | return (result); 35 | } 36 | -------------------------------------------------------------------------------- /Neural_Network/ft_swish.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_swish.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 21:34:17 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # double ft_sigmoid(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | /* *************************** [v] PROTOTYPES [v] *************************** */ 22 | extern __inline__ double check_your_six(double x); 23 | /* *************************** [^] PROTOTYPES [^] *************************** */ 24 | 25 | double 26 | ft_swish(register double x) 27 | { 28 | double result; 29 | 30 | if (ft_isinf(x) || ft_isnan(x) || x == 0.0) 31 | return (check_your_six(x)); 32 | result = x * ft_sigmoid(x); 33 | return (result); 34 | } 35 | 36 | extern __inline__ double 37 | check_your_six(double x) 38 | { 39 | if (ft_isnan(x) || ft_isinf(x) == 1 || x == 0.0) 40 | return (x); 41 | return (-(0.0 / 0.0)); 42 | } 43 | -------------------------------------------------------------------------------- /Neural_Network/ft_swishf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_swishf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 21:34:17 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # float ft_sigmoidf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | /* *************************** [v] PROTOTYPES [v] *************************** */ 22 | extern __inline__ float check_your_six(float x); 23 | /* *************************** [^] PROTOTYPES [^] *************************** */ 24 | 25 | float 26 | ft_swishf(register float x) 27 | { 28 | float result; 29 | 30 | if (ft_isinf(x) || ft_isnan(x) || x == 0.0F) 31 | return (check_your_six(x)); 32 | result = x * ft_sigmoidf(x); 33 | return (result); 34 | } 35 | 36 | extern __inline__ float 37 | check_your_six(float x) 38 | { 39 | if (ft_isnan(x) || ft_isinf(x) == 1 || x == 0.0F) 40 | return (x); 41 | return (-(0.0F / 0.0F)); 42 | } 43 | -------------------------------------------------------------------------------- /Other/ft_erf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_erf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/06 09:50:19 by hdeniz #+# #+# */ 9 | /* Updated: 2024/06/02 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_exp(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_erf(double x) 23 | { 24 | register double t; 25 | register double sign; 26 | 27 | if (x == 0.0 || ft_isnan(x)) 28 | return (x); 29 | if (ft_isinf(x) == 1) 30 | return (1.0); 31 | if (ft_isinf(x) == -1) 32 | return (-1.0); 33 | sign = 1.0; 34 | if (x < 0.0) 35 | { 36 | x = -x; 37 | sign = -1.0; 38 | } 39 | t = 1.0 / (1.0 + 0.3275911 * x); 40 | x = sign * (1.0 - (((((1.061405429 * t + -1.453152027) * t) + 1.421413741 \ 41 | ) * t + -0.284496736) * t + 0.254829592) * t * ft_exp(-x * x)); 42 | return (x); 43 | } 44 | -------------------------------------------------------------------------------- /Other/ft_erff.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_erff.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/06 09:50:19 by hdeniz #+# #+# */ 9 | /* Updated: 2024/06/02 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # float ft_expf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_erff(float x) 23 | { 24 | register float t; 25 | register float sign; 26 | 27 | if (x == 0.0F || ft_isnan(x)) 28 | return (x); 29 | if (ft_isinf(x) == 1) 30 | return (1.0F); 31 | if (ft_isinf(x) == -1) 32 | return (-1.0F); 33 | sign = 1.0F; 34 | if (x < 0.0F) 35 | { 36 | x = -x; 37 | sign = -1.0F; 38 | } 39 | t = 1.0F / (1.0F + 0.3275911F * x); 40 | x = sign * (1.0F - (((((1.061405429F * t + -1.453152027F) * t) + \ 41 | 1.421413741F) * t + -0.284496736F) * t + 0.254829592F) * t * \ 42 | ft_expf(-x * x)); 43 | return (x); 44 | } 45 | -------------------------------------------------------------------------------- /Other/ft_fabs.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fabs.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/23 20:31:50 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_fabs(double x) 21 | { 22 | if (ft_isnan(x)) 23 | return (-(0.0 / 0.0)); 24 | if (x < 0.0) 25 | return (x * -1.0); 26 | return (x); 27 | } 28 | -------------------------------------------------------------------------------- /Other/ft_fabsf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fabsf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/23 20:31:50 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_fabsf(float x) 21 | { 22 | if (ft_isnan(x)) 23 | return (-(0.0F / 0.0F)); 24 | if (x < 0.0F) 25 | return (x * -1.0F); 26 | return (x); 27 | } 28 | -------------------------------------------------------------------------------- /Other/ft_fibonacci.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fibonacci.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/08/21 14:01:18 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | unsigned long long 14 | ft_fibonacci(unsigned long long number) 15 | { 16 | if (number <= 1ULL) 17 | return (number); 18 | return (ft_fibonacci(number - 1ULL) + ft_fibonacci(number - 2ULL)); 19 | } 20 | -------------------------------------------------------------------------------- /Other/ft_fma.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fma.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/06 09:20:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | double 14 | ft_fma(register double x, register double y, register double z) 15 | { 16 | return ((x * y) + z); 17 | } 18 | -------------------------------------------------------------------------------- /Other/ft_fmaf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fmaf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/06 09:20:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | float 14 | ft_fmaf(register float x, register float y, register float z) 15 | { 16 | return ((x * y) + z); 17 | } 18 | -------------------------------------------------------------------------------- /Other/ft_fmax.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fmax.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 21:24:18 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | double 14 | ft_fmax(register double x, register double y) 15 | { 16 | if (x > y) 17 | return (x); 18 | return (y); 19 | } 20 | -------------------------------------------------------------------------------- /Other/ft_fmaxf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fmaxf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 21:24:18 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | float 14 | ft_fmaxf(register float x, register float y) 15 | { 16 | if (x > y) 17 | return (x); 18 | return (y); 19 | } 20 | -------------------------------------------------------------------------------- /Other/ft_fmin.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fmin.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 21:24:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | double 14 | ft_fmin(register double x, register double y) 15 | { 16 | if (x < y) 17 | return (x); 18 | return (y); 19 | } 20 | -------------------------------------------------------------------------------- /Other/ft_fminf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fminf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 21:24:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | float 14 | ft_fminf(register float x, register float y) 15 | { 16 | if (x < y) 17 | return (x); 18 | return (y); 19 | } 20 | -------------------------------------------------------------------------------- /Other/ft_lerp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lerp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/08/14 17:40:32 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | double 14 | ft_lerp(register double x, register double y, register double f) 15 | { 16 | return (x + f * (y - x)); 17 | } 18 | -------------------------------------------------------------------------------- /Other/ft_lerpf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lerpf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/08/14 17:41:13 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | float 14 | ft_lerpf(register float x, register float y, register float f) 15 | { 16 | return (x + f * (y - x)); 17 | } 18 | -------------------------------------------------------------------------------- /Other/ft_lgamma.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lgamma.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/07 23:59:08 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_log(double); 18 | # double ft_fabs(double); 19 | # double ft_tgamma(double); 20 | # */ 21 | /* **************************** [^] INCLUDES [^] **************************** */ 22 | 23 | double 24 | ft_lgamma(double x) 25 | { 26 | if (ft_isnan(x)) 27 | return (x); 28 | if (ft_isinf(x) || x == 0.0 || \ 29 | (x < 0.0 && ((double)((double)x - (long)x) == 0.0))) 30 | return (1.0 / 0.0); 31 | if (x == 1.0 || x == 2.0) 32 | return (0.0); 33 | if (x >= 3.0 && ((double)((double)x - (long)x) == 0.0)) 34 | x += 0.00000000001; 35 | return (ft_log(ft_fabs(ft_tgamma(x)))); 36 | } 37 | -------------------------------------------------------------------------------- /Other/ft_lgammaf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lgammaf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/07 23:59:08 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_logf(float); 18 | # float ft_fabsf(float); 19 | # float ft_tgammaf(float); 20 | # */ 21 | /* **************************** [^] INCLUDES [^] **************************** */ 22 | 23 | float 24 | ft_lgammaf(float x) 25 | { 26 | if (ft_isnan(x)) 27 | return (x); 28 | if (ft_isinf(x) || x == 0.0F || \ 29 | (x < 0.0F && ((float)((float)x - (int)x) == 0.0F))) 30 | return (1.0F / 0.0F); 31 | if (x == 1.0F || x == 2.0F) 32 | return (0.0F); 33 | if (x >= 3.0F && ((float)((float)x - (int)x) == 0.0F)) 34 | x += 0.00000000001F; 35 | return (ft_logf(ft_fabsf(ft_tgammaf(x)))); 36 | } 37 | -------------------------------------------------------------------------------- /Other/ft_modf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_modf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/24 19:12:33 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_modf(double x, double *integer) 22 | { 23 | if (ft_isnan(x) || ft_isinf(x)) 24 | { 25 | *integer = x; 26 | if (ft_isnan(x)) 27 | return (x); 28 | return (0.0 * ft_isinf(x)); 29 | } 30 | *integer = x - (double)(x - (long)x); 31 | return ((double)(x - (long)x)); 32 | } 33 | -------------------------------------------------------------------------------- /Other/ft_modff.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_modff.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/24 19:12:33 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_modff(float x, float *integer) 22 | { 23 | if (ft_isnan(x) || ft_isinf(x)) 24 | { 25 | *integer = x; 26 | if (ft_isnan(x)) 27 | return (x); 28 | return (0.0F * ft_isinf(x)); 29 | } 30 | *integer = x - (float)(x - (long)x); 31 | return ((float)(x - (long)x)); 32 | } 33 | -------------------------------------------------------------------------------- /Power/ft_cbrt.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_cbrt.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 12:28:15 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # double ft_fabs(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_cbrt(register double x) 23 | { 24 | register double prev_result; 25 | double result; 26 | 27 | if (x == 0.0 || x == -0.0 || ft_isinf(x) || ft_isnan(x)) 28 | { 29 | result = x; 30 | return (result); 31 | } 32 | result = 1.0; 33 | prev_result = 0.0; 34 | while (ft_fabs(result - prev_result) > 1E-15) 35 | { 36 | prev_result = result; 37 | result = (2.0 * result + x / (result * result)) / 3.0; 38 | } 39 | return (result); 40 | } 41 | -------------------------------------------------------------------------------- /Power/ft_cbrtf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_cbrtf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 12:28:15 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # float ft_fabsf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_cbrtf(register float x) 23 | { 24 | register float prev_result; 25 | float result; 26 | 27 | if (x == 0.0F || x == -0.0F || ft_isinf(x) || ft_isnan(x)) 28 | { 29 | result = x; 30 | return (result); 31 | } 32 | result = 1.0F; 33 | prev_result = 0.0F; 34 | while (ft_fabsf(result - prev_result) > 1E-15) 35 | { 36 | prev_result = result; 37 | result = (2.0F * result + x / (result * result)) / 3.0F; 38 | } 39 | return (result); 40 | } 41 | -------------------------------------------------------------------------------- /Power/ft_hypot.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_hypot.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 12:38:27 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # double ft_sqrt(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_hypot(double p, double b) 23 | { 24 | if (ft_isinf(p) || ft_isinf(b)) 25 | return (1.0 / 0.0); 26 | if (ft_isnan(p)) 27 | return (p); 28 | if (ft_isnan(b)) 29 | return (b); 30 | if (p == 0.0 && b == 0.0) 31 | return (0.0); 32 | return (ft_sqrt((p * p) + (b * b))); 33 | } 34 | -------------------------------------------------------------------------------- /Power/ft_hypotf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_hypotf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 12:38:27 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # float ft_sqrtf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_hypotf(float p, float b) 23 | { 24 | if (ft_isinf(p) || ft_isinf(b)) 25 | return (1.0F / 0.0F); 26 | if (ft_isnan(p)) 27 | return (p); 28 | if (ft_isnan(b)) 29 | return (b); 30 | if (p == 0.0F && b == 0.0F) 31 | return (0.0F); 32 | return (ft_sqrtf((p * p) + (b * b))); 33 | } 34 | -------------------------------------------------------------------------------- /Power/ft_pow10.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_pow10.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/28 20:49:40 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_pow(double, double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_pow10(register double x) 23 | { 24 | if (ft_isnan(x) || ft_isinf(x) == 1) 25 | return (x); 26 | if (ft_isinf(x)) 27 | return (0.0); 28 | if (x == 0.0) 29 | return (1.0); 30 | return (ft_pow(10.0, x)); 31 | } 32 | -------------------------------------------------------------------------------- /Power/ft_pow10f.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_pow10f.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/28 20:49:40 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_powf(float, float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_pow10f(register float x) 23 | { 24 | if (ft_isnan(x) || ft_isinf(x) == 1) 25 | return (x); 26 | if (ft_isinf(x)) 27 | return (0.0F); 28 | if (x == 0.0F) 29 | return (1.0F); 30 | return (ft_powf(10.0F, x)); 31 | } 32 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_ceil.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ceil.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 14:28:47 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_trunc(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_ceil(double x) 23 | { 24 | if (ft_isnan(x) || ft_isinf(x) || x == ft_trunc(x)) 25 | return (x); 26 | if (x > 0.0) 27 | return (ft_trunc(x) + 1.0); 28 | return (ft_trunc(x)); 29 | } 30 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_ceilf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_ceilf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 14:28:47 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_truncf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_ceilf(float x) 23 | { 24 | if (ft_isnan(x) || ft_isinf(x) || x == ft_truncf(x)) 25 | return (x); 26 | if (x > 0.0F) 27 | return (ft_truncf(x) + 1.0F); 28 | return (ft_truncf(x)); 29 | } 30 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_copysign.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_copysign.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 16:49:33 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_signbit(double); 16 | # double ft_fabs(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_copysign(register double x, register double y) 22 | { 23 | if (y >= 0.0 || !ft_signbit(y)) 24 | return (ft_fabs(x)); 25 | return (ft_fabs(x) * -1.0); 26 | } 27 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_copysignf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_copysignf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 16:49:33 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_signbit(double); 16 | # float ft_fabsf(float); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_copysignf(register float x, register float y) 22 | { 23 | if (y >= 0.0F || !ft_signbit(y)) 24 | return (ft_fabsf(x)); 25 | return (ft_fabsf(x) * -1.0F); 26 | } 27 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_fdim.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fdim.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/20 00:51:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_fdim(double x, double y) 22 | { 23 | if (ft_isinf(x) == 1 || ft_isnan(x)) 24 | return (x); 25 | if (ft_isnan(y)) 26 | return (y); 27 | if (x > y) 28 | return (x - y); 29 | return (0.0); 30 | } 31 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_fdimf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fdimf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/20 00:52:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # int ft_isnan(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_fdimf(float x, float y) 22 | { 23 | if (ft_isinf(x) == 1 || ft_isnan(x)) 24 | return (x); 25 | if (ft_isnan(y)) 26 | return (y); 27 | if (x > y) 28 | return (x - y); 29 | return (0.0F); 30 | } 31 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_floor.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_floor.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/27 16:04:12 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_floor(double x) 22 | { 23 | if (ft_isnan(x) || ft_isinf(x)) 24 | return (x); 25 | if (x < 0.0) 26 | return ((long)x - 1.0); 27 | return ((long)x); 28 | } 29 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_floorf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_floorf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/27 16:04:12 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_floorf(float x) 22 | { 23 | if (ft_isnan(x) || ft_isinf(x)) 24 | return (x); 25 | if (x < 0.0F) 26 | return ((long)x - 1.0F); 27 | return ((long)x); 28 | } 29 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_fmod.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fmod.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/23 15:48:05 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # double ft_floor(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_fmod(double x, register double y) 22 | { 23 | if (ft_isinf(x)) 24 | return (-0.0 / 0.0); 25 | if (ft_isinf(y)) 26 | return (x); 27 | x = (x) - (ft_floor(x / y)) * (y); 28 | return (x); 29 | } 30 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_fmodf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_fmodf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/23 15:48:05 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isinf(double); 16 | # float ft_floorf(float); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_fmodf(float x, register float y) 22 | { 23 | if (ft_isinf(x)) 24 | return (-0.0F / 0.0F); 25 | if (ft_isinf(y)) 26 | return (x); 27 | x = (x) - (ft_floorf(x / y)) * (y); 28 | return (x); 29 | } 30 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_lrint.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lrint.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/20 00:38:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | long 14 | ft_lrint(double x) 15 | { 16 | if (x > 0.0) 17 | return ((long)(x + 0.5)); 18 | if (x < 0.0) 19 | return ((long)(x - 0.5)); 20 | return (x); 21 | } 22 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_lrintf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lrintf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/20 00:38:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int 14 | ft_lrintf(float x) 15 | { 16 | if (x > 0.0F) 17 | return ((int)(x + 0.5F)); 18 | if (x < 0.0F) 19 | return ((int)(x - 0.5F)); 20 | return (x); 21 | } 22 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_lround.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lround.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 14:37:55 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_round(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | long 20 | ft_lround(register double x) 21 | { 22 | return ((long)ft_round(x)); 23 | } 24 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_lroundf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_lroundf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 14:37:55 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_roundf(float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | long 20 | ft_lroundf(register float x) 21 | { 22 | return ((long)ft_roundf(x)); 23 | } 24 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_nan.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_nan.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 16:56:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* 14 | union 15 | { 16 | double value; 17 | unsigned char bytes[8]; // Should "[sizeof(double)]" instead of "[8]", !VLA! 18 | } u_number; 19 | 20 | double 21 | ft_nan(const char *tag_pointer) 22 | { 23 | register union u_number; 24 | register int counter; 25 | 26 | u_number.value = (0.0 / 0.0); 27 | if (tag_pointer != ((void *)0)) 28 | { 29 | counter = -1; 30 | while (++counter, (tag_pointer[counter] != '\0') \ 31 | && (counter < (sizeof(u_number.bytes) - 1))) 32 | u_number.bytes[counter] = tag_pointer[counter]; 33 | u_number.bytes[counter] = '\0'; 34 | } 35 | return (u_number.value); 36 | } 37 | */ 38 | 39 | // My sincerest apologies, but i am fucking sick of this thing 40 | 41 | double 42 | ft_nan(const char *tag_pointer) 43 | { 44 | (void)tag_pointer; 45 | return (0.0 / 0.0); 46 | } 47 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_nanf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_nanf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 16:56:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | float 14 | ft_nanf(const char *tag_pointer) 15 | { 16 | (void)tag_pointer; 17 | return (0.0F / 0.0F); 18 | } 19 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_nearbyint.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_nearbyint.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/20 00:35:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_floor(double); 16 | # double ft_ceil(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_nearbyint(register double x) 22 | { 23 | double floor_x; 24 | double ceil_x; 25 | 26 | floor_x = ft_floor(x); 27 | ceil_x = ft_ceil(x); 28 | if ((x - floor_x) < (ceil_x - x)) 29 | return (floor_x); 30 | return (ceil_x); 31 | } 32 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_nearbyintf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_nearbyintf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/20 00:35:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_floorf(float); 16 | # float ft_ceilf(float); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_nearbyintf(register float x) 22 | { 23 | float floorf_x; 24 | float ceilf_x; 25 | 26 | floorf_x = ft_floorf(x); 27 | ceilf_x = ft_ceilf(x); 28 | if ((x - floorf_x) < (ceilf_x - x)) 29 | return (floorf_x); 30 | return (ceilf_x); 31 | } 32 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_nextafter.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_nextafter.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 18:58:04 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define DBL_MAX 16 | # define DBL_MIN 17 | # int ft_isnan(double); 18 | # int ft_isinf(double); 19 | # double ft_copysign(double, double); 20 | # */ 21 | /* **************************** [^] INCLUDES [^] **************************** */ 22 | 23 | double 24 | ft_nextafter(double x, double y) 25 | { 26 | if (ft_isnan(x) || ft_isnan(y)) 27 | return (x + y); 28 | if (ft_isinf(y) || y <= 0.0) 29 | return (x); 30 | if (x == y) 31 | return (y); 32 | if (ft_isinf(x)) 33 | return (ft_copysign(DBL_MAX, x)); 34 | if (x == 0.0) 35 | return (ft_copysign(DBL_MIN, y)); 36 | if ((y - x) > 0.0) 37 | return (x); 38 | return (-x); 39 | } 40 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_nextafterf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_nextafterf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 18:58:04 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define FLT_MAX 16 | # define FLT_MIN 17 | # int ft_isnan(double); 18 | # int ft_isinf(double); 19 | # float ft_copysignf(float, float); 20 | # */ 21 | /* **************************** [^] INCLUDES [^] **************************** */ 22 | 23 | float 24 | ft_nextafterf(float x, float y) 25 | { 26 | if (ft_isnan(x) || ft_isnan(y)) 27 | return (x + y); 28 | if (ft_isinf(y) || y <= 0.0F) 29 | return (x); 30 | if (x == y) 31 | return (y); 32 | if (ft_isinf(x)) 33 | return (ft_copysignf(FLT_MAX, x)); 34 | if (x == 0.0F) 35 | return (ft_copysignf(FLT_MIN, y)); 36 | if ((y - x) > 0.0F) 37 | return (x); 38 | return (-x); 39 | } 40 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_nexttoward.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_nexttoward.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 18:59:28 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_nextafter(double, double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_nexttoward(register double x, register long double y) 21 | { 22 | return (ft_nextafter(x, y)); 23 | } 24 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_nexttowardf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_nexttowardf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 18:59:28 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_nextafterf(float, float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_nexttowardf(register float x, register long double y) 21 | { 22 | return (ft_nextafterf(x, y)); 23 | } 24 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_remainder.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_remainder.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 15:29:31 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_round(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_remainder(double x, double y) 23 | { 24 | register double quotient; 25 | register double rounded_quotient; 26 | 27 | if (ft_isnan(x) || ft_isinf(y)) 28 | return (x); 29 | if (ft_isnan(y)) 30 | return (y); 31 | if (ft_isinf(x) || y == 0.0) 32 | return (0.0 / 0.0); 33 | quotient = (x / y); 34 | rounded_quotient = ft_round(quotient); 35 | return (x - rounded_quotient * y); 36 | } 37 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_remainderf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_remainderf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 15:29:31 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_roundf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_remainderf(float x, float y) 23 | { 24 | register float quotient; 25 | register float rounded_quotient; 26 | 27 | if (ft_isnan(x) || ft_isinf(y)) 28 | return (x); 29 | if (ft_isnan(y)) 30 | return (y); 31 | if (ft_isinf(x) || y == 0.0F) 32 | return (0.0F / 0.0F); 33 | quotient = (x / y); 34 | rounded_quotient = ft_roundf(quotient); 35 | return (x - rounded_quotient * y); 36 | } 37 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_remquo.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_remquo.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 15:53:17 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_fmod(double, double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_remquo(register double x, register double y, int *quotient) 23 | { 24 | double result; 25 | 26 | if (ft_isnan(y)) 27 | { 28 | result = y; 29 | return (result); 30 | } 31 | if (ft_isnan(x)) 32 | { 33 | result = x; 34 | return (result); 35 | } 36 | if (y == 0.0 || ft_isinf(x)) 37 | return (0.0 / 0.0); 38 | result = ft_fmod(x, y); 39 | *quotient = (int)(x / y); 40 | return (result); 41 | } 42 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_remquof.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_remquof.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 15:53:17 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_fmodf(float, float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_remquof(register float x, register float y, int *quotient) 23 | { 24 | float result; 25 | 26 | if (ft_isnan(y)) 27 | { 28 | result = y; 29 | return (result); 30 | } 31 | if (ft_isnan(x)) 32 | { 33 | result = x; 34 | return (result); 35 | } 36 | if (y == 0.0F || ft_isinf(x)) 37 | return (0.0F / 0.0F); 38 | result = ft_fmodf(x, y); 39 | *quotient = (int)(x / y); 40 | return (result); 41 | } 42 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_rint.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_rint.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/20 00:19:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_floor(double); 16 | # double ft_ceil(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_rint(register double x) 22 | { 23 | if (x > 0.0) 24 | return (ft_floor(x + 0.5)); 25 | if (x < 0.0) 26 | return (ft_ceil(x - 0.5)); 27 | return (0.0); 28 | } 29 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_rintf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_rintf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/20 00:26:30 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_floorf(float); 16 | # float ft_ceilf(float); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_rintf(register float x) 22 | { 23 | if (x > 0.0F) 24 | return (ft_floorf(x + 0.5F)); 25 | if (x < 0.0F) 26 | return (ft_ceilf(x - 0.5F)); 27 | return (0.0F); 28 | } 29 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_round.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_round.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 14:37:55 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_modf(double, double *); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_round(register double x) 23 | { 24 | double intpart; 25 | register double fracpart; 26 | 27 | if (ft_isnan(x) || ft_isinf(x) || x == 0.0) 28 | { 29 | intpart = x; 30 | return (intpart); 31 | } 32 | fracpart = ft_modf(x, &intpart); 33 | if (x > 0.0) 34 | { 35 | if (fracpart >= 0.5) 36 | return (intpart + 1.0); 37 | return (intpart); 38 | } 39 | if (fracpart <= -0.5) 40 | return (intpart - 1.0); 41 | return (0.0); 42 | } 43 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_roundf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_roundf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 14:37:55 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_modff(float, float *); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_roundf(register float x) 23 | { 24 | float intpart; 25 | register float fracpart; 26 | 27 | if (ft_isnan(x) || ft_isinf(x) || x == 0.0F) 28 | return (x); 29 | fracpart = ft_modff(x, &intpart); 30 | if (x > 0.0F) 31 | { 32 | if (fracpart >= 0.5F) 33 | return (intpart + 1.0F); 34 | return (intpart); 35 | } 36 | if (fracpart <= -0.5F) 37 | return (intpart - 1.0F); 38 | return (0.0F); 39 | } 40 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_trunc.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_trunc.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 14:13:40 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # double ft_modf(double, double *); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_trunc(register double x) 23 | { 24 | double integer; 25 | 26 | if (ft_isnan(x) || ft_isinf(x) || x == 0.0) 27 | { 28 | integer = x; 29 | return (integer); 30 | } 31 | ft_modf(x, &integer); 32 | return (integer); 33 | } 34 | -------------------------------------------------------------------------------- /Rounding_Remainder/ft_truncf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_truncf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/02 14:13:40 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # int ft_isinf(double); 17 | # float ft_modf(float, float *); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_truncf(register float x) 23 | { 24 | float integer; 25 | 26 | if (ft_isnan(x) || ft_isinf(x) || x == 0.0F) 27 | { 28 | integer = x; 29 | return (integer); 30 | } 31 | ft_modff(x, &integer); 32 | return (integer); 33 | } 34 | -------------------------------------------------------------------------------- /Trigonometric/ft_acos.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_acos.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/26 18:18:03 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_fabs(double); 16 | # double ft_atan2(double, double); 17 | # double ft_sqrt(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | double 22 | ft_acos(register double x) 23 | { 24 | if (x > 1.0 || x < -1.0) 25 | return (0.0 / 0.0); 26 | if (x == 1.0) 27 | return (0.0); 28 | return (ft_fabs(ft_atan2(ft_sqrt(1.0F - (x * x)), x))); 29 | } 30 | -------------------------------------------------------------------------------- /Trigonometric/ft_acosf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_acosf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/26 18:18:03 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_fabsf(float); 16 | # float ft_atan2f(float, float); 17 | # float ft_sqrtf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_acosf(register float x) 23 | { 24 | if (x > 1.0F || x < -1.0F) 25 | return (0.0F / 0.0F); 26 | if (x == 1.0F) 27 | return (0.0F); 28 | return (ft_fabsf(ft_atan2f(ft_sqrtf(1.0F - (x * x)), x))); 29 | } 30 | -------------------------------------------------------------------------------- /Trigonometric/ft_asin.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_asin.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/26 17:35:15 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # double ft_atan2(double, double); 17 | # double ft_sqrt(double); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | /* 22 | * Thanks to "https://github.com/sleepy-monax" for noticing me about 23 | * functon names are not same with in order. 24 | */ 25 | 26 | double 27 | ft_asin(double x) 28 | { 29 | if (ft_isnan(x)) 30 | return (x); 31 | if (ft_isnan(ft_atan2(x, ft_sqrt(1.0 - (x * x))))) 32 | return (-(0.0 / 0.0)); 33 | return (ft_atan2(x, ft_sqrt(1.0 - (x * x)))); 34 | } 35 | -------------------------------------------------------------------------------- /Trigonometric/ft_asinf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_asinf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/26 17:35:15 by hdeniz #+# #+# */ 9 | /* Updated: 2025/01/27 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # int ft_isnan(double); 16 | # float ft_atan2f(float, float); 17 | # float ft_sqrtf(float); 18 | # */ 19 | /* **************************** [^] INCLUDES [^] **************************** */ 20 | 21 | float 22 | ft_asinf(float x) 23 | { 24 | if (ft_isnan(x)) 25 | return (x); 26 | if (ft_isnan(ft_atan2f(x, ft_sqrtf(1.0F - (x * x))))) 27 | return (-(0.0F / 0.0F)); 28 | return (ft_atan2f(x, ft_sqrtf(1.0F - (x * x)))); 29 | } 30 | -------------------------------------------------------------------------------- /Trigonometric/ft_atan.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_atan.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/23 15:59:43 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_PI 16 | # int ft_isnan(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_atan(register double x) 22 | { 23 | register double y; 24 | 25 | if (ft_isnan(x)) 26 | return (x); 27 | if (x == 0.0) 28 | return (0.0); 29 | if (x > 0.0) 30 | { 31 | if (x > 1.0) 32 | return (M_PI / 2 - ft_atan(1.0 / x)); 33 | y = (x * x); 34 | return (x * (1.0 - \ 35 | y * (0.33333333333333333 - y * (0.20000000000000000 - \ 36 | y * (0.14285714285714285 - y * (0.11111111111111111 - \ 37 | y * (0.09090909090909091 - y * (0.07692307692307693) \ 38 | ))))))); 39 | } 40 | return (-ft_atan(-x)); 41 | } 42 | -------------------------------------------------------------------------------- /Trigonometric/ft_atan2.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_atan2.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/23 16:04:12 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_PI_2 16 | # define M_PI_4 17 | # int ft_isnan(double); 18 | # int ft_isinf(double); 19 | # double ft_atan(double); 20 | # */ 21 | /* **************************** [^] INCLUDES [^] **************************** */ 22 | 23 | double 24 | ft_atan2(register double y, register double x) 25 | { 26 | if (ft_isnan(x) || ft_isnan(y)) 27 | return (0.0 / 0.0); 28 | if (x == 0.0) 29 | { 30 | if (y > 0.0) 31 | return (M_PI_2); 32 | if (y < 0.0) 33 | return (-M_PI_2); 34 | return (0.0); 35 | } 36 | if (!(ft_isinf(y) && ft_isinf(x))) 37 | return (ft_atan(y / x)); 38 | if (x > 0.0) 39 | { 40 | if (y > 0.0) 41 | return (M_PI_4); 42 | return (-M_PI_4); 43 | } 44 | if (y > 0.0) 45 | return (3.0 * M_PI_4); 46 | return (-3.0 * M_PI_4); 47 | } 48 | -------------------------------------------------------------------------------- /Trigonometric/ft_atan2f.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_atan2f.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/23 16:04:12 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_PI_2_F 16 | # define M_PI_4_F 17 | # int ft_isnan(double); 18 | # int ft_isinf(double); 19 | # float ft_atanf(float); 20 | # */ 21 | /* **************************** [^] INCLUDES [^] **************************** */ 22 | 23 | float 24 | ft_atan2f(register float y, register float x) 25 | { 26 | if (ft_isnan(x) || ft_isnan(y)) 27 | return (0.0F / 0.0F); 28 | if (x == 0.0F) 29 | { 30 | if (y > 0.0F) 31 | return (M_PI_2_F); 32 | if (y < 0.0F) 33 | return (-M_PI_2_F); 34 | return (0.0F); 35 | } 36 | if (!(ft_isinf(y) && ft_isinf(x))) 37 | return (ft_atanf(y / x)); 38 | if (x > 0.0F) 39 | { 40 | if (y > 0.0F) 41 | return (M_PI_4_F); 42 | return (-M_PI_4); 43 | } 44 | if (y > 0.0F) 45 | return (3.0F * M_PI_4_F); 46 | return (-3.0F * M_PI_4_F); 47 | } 48 | -------------------------------------------------------------------------------- /Trigonometric/ft_atanf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_atanf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/23 15:59:43 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_PI_F 16 | # int ft_isnan(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_atanf(register float x) 22 | { 23 | register float y; 24 | 25 | if (ft_isnan(x)) 26 | return (x); 27 | if (x == 0.0F) 28 | return (0.0F); 29 | if (x > 0.0F) 30 | { 31 | if (x > 1.0F) 32 | return (M_PI_F / 2.0F - ft_atanf(1.0F / x)); 33 | y = (x * x); 34 | return (x * (1.0F - \ 35 | y * (0.33333333333333333F - y * (0.20000000000000000F - \ 36 | y * (0.14285714285714285F - y * (0.11111111111111111F - \ 37 | y * (0.09090909090909091F - y * (0.07692307692307693F) \ 38 | ))))))); 39 | } 40 | return (-ft_atanf(-x)); 41 | } 42 | -------------------------------------------------------------------------------- /Trigonometric/ft_cospi.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_cospi.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:52:47 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_PI 16 | # double ft_cos(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_cospi(register double x) 22 | { 23 | return (ft_cos(x * M_PI)); 24 | } 25 | -------------------------------------------------------------------------------- /Trigonometric/ft_cospif.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_cospif.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:52:47 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_PI_F 16 | # float ft_cosf(float); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_cospif(register float x) 22 | { 23 | return (ft_cosf(x * M_PI_F)); 24 | } 25 | -------------------------------------------------------------------------------- /Trigonometric/ft_cot.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_cot.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:49:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_tan(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_cot(register double x) 21 | { 22 | return (1.0 / ft_tan(x)); 23 | } 24 | -------------------------------------------------------------------------------- /Trigonometric/ft_cotf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_cotf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:49:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_tanf(float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_cotf(register float x) 21 | { 22 | return (1.0F / ft_tanf(x)); 23 | } 24 | -------------------------------------------------------------------------------- /Trigonometric/ft_csc.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_csc.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:49:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_sin(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_csc(register double x) 21 | { 22 | return (1.0 / ft_sin(x)); 23 | } 24 | -------------------------------------------------------------------------------- /Trigonometric/ft_cscf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_cscf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:49:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_sinf(float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_cscf(register float x) 21 | { 22 | return (1.0F / ft_sinf(x)); 23 | } 24 | -------------------------------------------------------------------------------- /Trigonometric/ft_sec.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sec.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:49:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_cos(double); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | double 20 | ft_sec(register double x) 21 | { 22 | return (1.0 / ft_cos(x)); 23 | } 24 | -------------------------------------------------------------------------------- /Trigonometric/ft_secf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_secf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:49:11 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_cosf(float); 16 | # */ 17 | /* **************************** [^] INCLUDES [^] **************************** */ 18 | 19 | float 20 | ft_secf(register float x) 21 | { 22 | return (1.0F / ft_cosf(x)); 23 | } 24 | -------------------------------------------------------------------------------- /Trigonometric/ft_sincos.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sincos.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 00:24:21 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_sin(double); 16 | # double ft_cos(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | void 21 | ft_sincos(register double x, double *sine, double *cosine) 22 | { 23 | *sine = ft_sin(x); 24 | *cosine = ft_cos(x); 25 | } 26 | -------------------------------------------------------------------------------- /Trigonometric/ft_sincosf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sincosf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 00:24:21 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_sinf(float); 16 | # float ft_cosf(float); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | void 21 | ft_sincosf(register float x, float *sine, float *cosine) 22 | { 23 | *sine = ft_sinf(x); 24 | *cosine = ft_cosf(x); 25 | } 26 | -------------------------------------------------------------------------------- /Trigonometric/ft_sinpi.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sinpi.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:52:47 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_PI 16 | # double ft_sin(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_sinpi(register double x) 22 | { 23 | return (ft_sin(x * M_PI)); 24 | } 25 | -------------------------------------------------------------------------------- /Trigonometric/ft_sinpif.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_sinpif.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:52:47 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_PI_F 16 | # float ft_sinf(float); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_sinpif(register float x) 22 | { 23 | return (ft_sinf(x * M_PI_F)); 24 | } 25 | -------------------------------------------------------------------------------- /Trigonometric/ft_tan.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_tan.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/23 15:58:09 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # double ft_sin(double); 16 | # double ft_cos(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_tan(register double x) 22 | { 23 | return (ft_sin(x) / ft_cos(x)); 24 | } 25 | -------------------------------------------------------------------------------- /Trigonometric/ft_tanf.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_tanf.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/02/23 15:58:09 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # float ft_sinf(float); 16 | # float ft_cosf(float); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_tanf(register float x) 22 | { 23 | return (ft_sinf(x) / ft_cosf(x)); 24 | } 25 | -------------------------------------------------------------------------------- /Trigonometric/ft_tanpi.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_tanpi.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:52:47 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_PI 16 | # double ft_tan(double); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | double 21 | ft_tanpi(register double x) 22 | { 23 | return (ft_tan(x * M_PI)); 24 | } 25 | -------------------------------------------------------------------------------- /Trigonometric/ft_tanpif.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_tanpif.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: hdeniz +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/03/12 18:52:47 by hdeniz #+# #+# */ 9 | /* Updated: 2024/05/18 ??:??:?? by hdeniz ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | /* **************************** [v] INCLUDES [v] **************************** */ 14 | #include "../ft_math.h" /* 15 | # define M_PI_F 16 | # float ft_tanf(float); 17 | # */ 18 | /* **************************** [^] INCLUDES [^] **************************** */ 19 | 20 | float 21 | ft_tanpif(register float x) 22 | { 23 | return (ft_tanf(x * M_PI_F)); 24 | } 25 | --------------------------------------------------------------------------------