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
+68-22Lines changed: 68 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -111,16 +111,19 @@ Function.
111
111
112
112
#### Argument(s)
113
113
114
-
`start`: Shall be scalar of any numeric type. This argument is `intent(in)`.
114
+
`start`: Shall be scalar of any numeric type or kind. This argument is `intent(in)`.
115
115
`end`: Shall be the same `type` and `kind` as `start`. This argument is `intent(in)`.
116
116
`n`: Shall be an integer specifying the length of the output. This argument is `optional` and `intent(in)`.
117
117
118
118
#### Output value or Result value
119
119
120
-
The output is a rank 1 array of `type` and `kind`, whose length is either 100 (default value) or `n`.
120
+
The output is a rank 1 array whose length is either 100 (default value) or `n`.
121
121
122
122
If `n` == 1, return a rank 1 array whose only element is `end`.
123
-
If `n` <= 0, return a rank 1 array with length 0
123
+
If `n` <= 0, return a rank 1 array with length 0.
124
+
125
+
If `start`/`end` are real or complex types, the `result` will be the same `type` and `kind` as `start`/`end`.
126
+
If `start`/`end` are integer types, the `result` will default to a double precision real array.
124
127
125
128
#### Examples
126
129
@@ -144,17 +147,17 @@ end program demo_linspace_complex
144
147
145
148
##### Example 2:
146
149
147
-
Here inputs are of type `integer` and kind `int16`
150
+
Here inputs are of type `integer` and kind `int16`, with the result defaulting to double precision real.
148
151
```fortran
149
152
program demo_linspace_int16
150
153
use stdlib_math, only: linspace
151
-
use stdlib_kinds, only: int16
154
+
use stdlib_kinds, only: int16, dp
152
155
implicit none
153
156
154
157
integer(int16) :: start = 10_int16
155
158
integer(int16) :: end = 23_int16
156
159
157
-
integer(int16) :: r(15)
160
+
real(dp) :: r(15)
158
161
159
162
r = linspace(start, end, 15)
160
163
end program demo_linspace_int16
@@ -164,7 +167,7 @@ end program demo_linspace_int16
164
167
165
168
#### Description
166
169
167
-
Returns a logarithmically spaced rank 1 array from [`base`^`start`, `base`^`end`]. The default size of the array is 100. Optionally, you can specify the length of the returned array by passing `n`.
170
+
Returns a logarithmically spaced rank 1 array from [`base`^`start`, `base`^`end`]. The default size of the array is 50. Optionally, you can specify the length of the returned array by passing `n`. You can also specify the `base` used to compute the range (default 10).
168
171
169
172
#### Syntax
170
173
@@ -180,52 +183,95 @@ Function.
180
183
181
184
#### Argument(s)
182
185
183
-
`start`: Shall be a scalar of any numeric type. This argument is `intent(in)`.
186
+
`start`: Shall be a scalar of any numeric type. All kinds are supported for real and complex arguments. For integers, only the default kind is currently implemented. This argument is `intent(in)`.
184
187
`end`: Shall be the same `type` and `kind` as `start`. This argument is `intent(in)`.
185
188
`n`: Shall be an integer specifying the length of the output. This argument is `optional` and `intent(in)`.
186
-
`base` : Shall be a scalar of any numeric type. This argument is `optional` and `intent(in)`
189
+
`base` : Shall be a scalar of any numeric type. All kinds are supported for real and complex arguments. For integers, only the default kind is currently implemented. This argument is `optional` and `intent(in)`.
187
190
188
191
#### Output value or Result value
189
192
190
-
The output is a rank 1 array of `type` and `kind`, whose length is either 50 (default value) or `n`.
193
+
The output is a rank 1 array whose length is either 50 (default value) or `n`.
191
194
192
195
If `n` == 1, return a rank 1 array whose only element is `base`^`end`.
193
196
If `n` <= 0, return a rank 1 array with length 0
194
197
198
+
The `type` and `kind` of the output is dependent on the `type` and `kind` of the passed parameters.
199
+
200
+
For function calls where the `base` is not specified: `logspace(start, end)`/`logspace(start, end, n)`, the `type` and `kind` of
201
+
the output follows the same scheme as above for `linspace`.
202
+
>If `start`/`end` are real or complex types, the `result` will be the same `type` and `kind` as `start`/`end`.
203
+
>If `start`/`end` are integer types, the `result` will default to a double precision real array.
204
+
205
+
For function calls where the `base` is specified, the `type` and `kind` of the result is in accordance with the following table:
0 commit comments