You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/specs/stdlib_math.md
+19-20Lines changed: 19 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -19,8 +19,7 @@ title: math
19
19
20
20
#### Description
21
21
22
-
Limits the input value `x` to the given interval [`xmin`, `xmax`] (interval is `xmin` and `xmax` inclusive). Returns a value which lies in the given interval and is closest to the input value `x`.
23
-
If the input value `x` already lies in the given interval, then the output value will be equal to the input value.
22
+
Returns a value which lies in the given interval [`xmin`, `xmax`] (interval is `xmin` and `xmax` inclusive) and is closest to the input value `x`.
24
23
25
24
#### Syntax
26
25
@@ -36,25 +35,25 @@ Elemental function.
36
35
37
36
#### Argument(s)
38
37
39
-
`x`: scalar of either `integer` or `real`. This argument is `intent(in)`.
40
-
`xmin`: scalar of either `integer` or `real`. This argument is `intent(in)`.
41
-
`xmax`: scalar of either `integer` or `real`, which must be greater than or equal to `xmin`. This argument is `intent(in)`.
38
+
`x`: scalar of either `integer` or `real` type. This argument is `intent(in)`.
39
+
`xmin`: scalar of either `integer` or `real` type. This argument is `intent(in)`.
40
+
`xmax`: scalar of either `integer` or `real` type, which must be greater than or equal to `xmin`. This argument is `intent(in)`.
42
41
43
42
Note: All arguments must have same `type` and same `kind`.
44
43
45
44
#### Output value or Result value
46
45
47
-
Output is a scalar of either `integer` or `real` depending on the arguments. The output value will have`type` and `kind` same as to that of the arguments.
46
+
The output is a scalar of `type` and `kind` same as to that of the arguments.
48
47
49
48
#### Examples
50
49
51
50
##### Example 1:
52
51
53
52
Here inputs are of type `integer` and kind `int32`
54
53
```fortran
55
-
program demo
54
+
program demo_clip_integer
56
55
use stdlib_math
57
-
use iso_fortran_env
56
+
use stdlib_kinds
58
57
implicit none
59
58
integer(int32) :: x
60
59
integer(int32) :: xmin
@@ -70,30 +69,30 @@ program demo
70
69
71
70
clipped_value = clip(x, xmin, xmax)
72
71
! clipped_value <- 5
73
-
end program demo
72
+
end program demo_clip_integer
74
73
```
75
74
76
75
##### Example 2:
77
76
78
-
Here inputs are of type `real` and kind `real32` (or `sp`)
0 commit comments