Skip to content

Commit 3c7cf65

Browse files
committed
Improve arange func and doc.
1 parent 0c9036c commit 3c7cf65

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

doc/specs/stdlib_math.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ program demo_logspace_rstart_cbase
275275
276276
end program demo_logspace_rstart_cbase
277277
```
278-
## `arange` - Create a vector of the `integer/real` type with evenly spaced values within a given interval.
278+
## `arange`
279279

280280
### Status
281281

@@ -287,14 +287,20 @@ Pure function.
287287

288288
### Description
289289

290-
Create a vector of the `integer/real` type with evenly spaced values within a given interval.
290+
Create a vector of the `integer/real` type with given fixed spaced values within a given interval.
291+
292+
#### Note
293+
294+
Because of the `i` (`huge(integer :: i) = 2147483647`) index inside the `arange` function , the dimensional maximum length of array created by the `arange` function is `2147483647`.
291295

292296
### Syntax
293297

294298
`result = [[stdlib_math(module):arange(interface)]](start [, end, by])`
295299

296300
### Arguments
297301

302+
All arguments should be the same type and kind.
303+
298304
`start`: Shall be an `integer/real` scalar.
299305
This is an `intent(in)` argument.
300306
The default `start` value is `1`.
@@ -313,8 +319,9 @@ If `by < 0`, the `by` argument will be corrected to `abs(by)` by the internal pr
313319

314320
### Return value
315321

316-
Return a vector of evenly spaced values.
322+
Return a vector of fixed spaced spaced values.
317323

324+
For `integer` type arguments, the length of the result vector is `(end - start)/by + 1`.
318325
For `real` type arguments, the length of the result vector is `floor((end - start)/by) + 1`.
319326

320327
### Example
@@ -331,7 +338,7 @@ program demo_math_arange
331338
332339
print *, arange(3.0) !! [1.0,2.0,3.0]
333340
print *, arange(0.0,5.0) !! [0.0,1.0,2.0,3.0,4.0,5.0]
334-
print *, arange(0.0,5.0,2.0) !! [0.0,2.0,4.0]
341+
print *, arange(0.0,6.0,2.5) !! [0.0,2.5,5.0]
335342
336343
print *, (1.0,1.0)*arange(3) !! [(1.0,1.0),(2.0,2.0),[3.0,3.0]]
337344

src/stdlib_math.fypp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,7 @@ module stdlib_math
266266
!>
267267
!> `arange` creates a vector of the `integer/real` type
268268
!> with evenly spaced values within a given interval.
269-
!> ([Specification](../page/specs/stdlib_math.html#
270-
!>arange-create-a-vector-of-the-integerreal-type-
271-
!>with-evenly-spaced-values-within-a-given-interval))
269+
!> ([Specification](../page/specs/stdlib_math.html#arange))
272270
interface arange
273271
#:set RI_KINDS_TYPES = REAL_KINDS_TYPES + INT_KINDS_TYPES
274272
#:for k1, t1 in RI_KINDS_TYPES

src/stdlib_math_arange.fypp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#:include "common.fypp"
22
submodule(stdlib_math) stdlib_math_arange
33

4-
implicit none
5-
64
contains
75

86
#:for k1, t1 in REAL_KINDS_TYPES

0 commit comments

Comments
 (0)