Skip to content

Commit 4284b60

Browse files
committed
Add linspace specs
1 parent 7fe8ebf commit 4284b60

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

doc/specs/stdlib_math.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,69 @@ program demo_clip_real
9090
! clipped_value <- 3.02500010
9191
end program demo_clip_real
9292
```
93+
94+
### `linspace` function
95+
96+
#### Description
97+
98+
Returns a linearly spaced rank 1 array from [`start`, `end`]. Optionally, you can specify the length of the returned array by passing `n`.
99+
100+
#### Syntax
101+
102+
`res = [[stdlib_math(module):linspace(interface)]] (start, end [, n])`
103+
104+
#### Status
105+
106+
Experimental
107+
108+
#### Class
109+
110+
function.
111+
112+
#### Argument(s)
113+
114+
`start`: scalar of any numeric type. This argument is `intent(in)`.
115+
`end`: same `type` and `kind` as `start`. This argument is `intent(in)`.
116+
`n`: Integer parameter specifying the length of the output. This argument is `intent(in)`.
117+
118+
#### Output value or Result value
119+
120+
The output is a rank 1 array of `type` and `kind`, whose length is either 100 (default value) or `n`.
121+
122+
#### Examples
123+
124+
##### Example 1:
125+
126+
Here inputs are of type `complex` and kind `dp`
127+
```fortran
128+
program demo_linspace_complex
129+
use stdlib_math, only: linspace
130+
use stdlib_kinds, only: dp
131+
implicit none
132+
133+
complex(dp) :: start = complex(10.0_dp, 5.0_dp)
134+
complex(dp) :: end = complex(-10.0_dp, 15.0_dp)
135+
136+
complex(dp) :: z(11)
137+
138+
z = linspace(start, end, 11)
139+
end program demo_linspace_complex
140+
```
141+
142+
##### Example 2:
143+
144+
Here inputs are of type `integer` and kind `int16`
145+
```fortran
146+
program demo_linspace_int16
147+
use stdlib_math, only: linspace
148+
use stdlib_kinds, only: int16
149+
implicit none
150+
151+
integer(int16) :: start = 10_int16
152+
integer(int16) :: end = 23_int16
153+
154+
integer(int16) :: r(15)
155+
156+
r = linspace(start, end, 15)
157+
end program demo_linspace_int16
158+
```

0 commit comments

Comments
 (0)