@@ -15,7 +15,7 @@ module stdlib_math
1515#:endif
1616 public :: DEFAULT_LINSPACE_LENGTH, DEFAULT_LOGSPACE_BASE, DEFAULT_LOGSPACE_LENGTH
1717 public :: stdlib_meshgrid_ij, stdlib_meshgrid_xy
18- public :: arange, arg, argd, argpi, is_close, all_close, diff, meshgrid
18+ public :: arange, arg, argd, argpi, deg2rad, rad2deg, is_close, all_close, diff, meshgrid
1919
2020 integer, parameter :: DEFAULT_LINSPACE_LENGTH = 100
2121 integer, parameter :: DEFAULT_LOGSPACE_LENGTH = 50
@@ -332,6 +332,26 @@ module stdlib_math
332332 procedure :: argpi_${k1}$
333333 #:endfor
334334 end interface argpi
335+
336+ !> Version: experimental
337+ !>
338+ !> `deg2rad` converts phase angles from degrees to radians.
339+ !> ([Specification](../page/specs/stdlib_math.html#deg2rad-function))
340+ interface deg2rad
341+ #:for k1 in REAL_KINDS
342+ procedure :: deg2rad_${k1}$
343+ #:endfor
344+ end interface deg2rad
345+
346+ !> Version: experimental
347+ !>
348+ !> `rad2deg` converts phase angles from radians to degrees.
349+ !> ([Specification](../page/specs/stdlib_math.html#rad2deg-function))
350+ interface rad2deg
351+ #:for k1 in REAL_KINDS
352+ procedure :: rad2deg_${k1}$
353+ #:endfor
354+ end interface rad2deg
335355
336356 !> Returns a boolean scalar/array where two scalar/arrays are element-wise equal within a tolerance.
337357 !> ([Specification](../page/specs/stdlib_math.html#is_close-function))
@@ -453,6 +473,22 @@ contains
453473 end function argpi_${k1}$
454474 #:endfor
455475
476+ #:for k1, t1 in REAL_KINDS_TYPES
477+ elemental function deg2rad_${k1}$(theta) result(result)
478+ ${t1}$, intent(in) :: theta
479+ ${t1}$ :: result
480+ result = theta * PI_${k1}$ / 180.0_${k1}$
481+
482+ end function deg2rad_${k1}$
483+
484+ elemental function rad2deg_${k1}$(theta) result(result)
485+ ${t1}$, intent(in) :: theta
486+ ${t1}$ :: result
487+ result = theta * 180.0_${k1}$ / PI_${k1}$
488+
489+ end function rad2deg_${k1}$
490+ #:endfor
491+
456492 #:for k1, t1 in INT_KINDS_TYPES
457493 !> Returns the greatest common divisor of two integers of kind ${k1}$
458494 !> using the Euclidean algorithm.
0 commit comments