@@ -67,10 +67,16 @@ impl<S, A> ArrayBase<S, Ix1>
67
67
Self :: from_vec ( iterable. into_iter ( ) . collect ( ) )
68
68
}
69
69
70
- /// Create a one-dimensional array from the inclusive interval
71
- /// `[ start, end]` with `n` elements . `A` must be a floating point type.
70
+ /// Create a one-dimensional array with `n` evenly spaced elements from
71
+ /// `start` to `end` (inclusive) . `A` must be a floating point type.
72
72
///
73
- /// **Panics** if `n` is greater than `isize::MAX`.
73
+ /// Note that if `start > end`, the first element will still be `start`,
74
+ /// and the following elements will be decreasing. This is different from
75
+ /// the behavior of `std::ops::RangeInclusive`, which interprets `start >
76
+ /// end` to mean that the range is empty.
77
+ ///
78
+ /// **Panics** if `n` is greater than `isize::MAX` or if converting `n - 1`
79
+ /// to type `A` fails.
74
80
///
75
81
/// ```rust
76
82
/// use ndarray::{Array, arr1};
@@ -84,9 +90,8 @@ impl<S, A> ArrayBase<S, Ix1>
84
90
Self :: from_vec ( to_vec ( linspace:: linspace ( start, end, n) ) )
85
91
}
86
92
87
- /// Create a one-dimensional array from the half-open interval
88
- /// `[start, end)` with elements spaced by `step`. `A` must be a floating
89
- /// point type.
93
+ /// Create a one-dimensional array with elements from `start` to `end`
94
+ /// (exclusive), incrementing by `step`. `A` must be a floating point type.
90
95
///
91
96
/// **Panics** if the length is greater than `isize::MAX`.
92
97
///
@@ -102,13 +107,14 @@ impl<S, A> ArrayBase<S, Ix1>
102
107
Self :: from_vec ( to_vec ( linspace:: range ( start, end, step) ) )
103
108
}
104
109
105
- /// Create a one-dimensional array with `n` elements logarithmically spaced,
106
- /// with the starting value being `base.powf(start)` and the final one being
107
- /// `base.powf(end)`. `A` must be a floating point type.
110
+ /// Create a one-dimensional array with `n` logarithmically spaced
111
+ /// elements, with the starting value being `base.powf(start)` and the
112
+ /// final one being `base.powf(end)`. `A` must be a floating point type.
108
113
///
109
114
/// If `base` is negative, all values will be negative.
110
115
///
111
- /// **Panics** if the length is greater than `isize::MAX`.
116
+ /// **Panics** if `n` is greater than `isize::MAX` or if converting `n - 1`
117
+ /// to type `A` fails.
112
118
///
113
119
/// ```rust
114
120
/// use approx::assert_abs_diff_eq;
@@ -129,15 +135,15 @@ impl<S, A> ArrayBase<S, Ix1>
129
135
Self :: from_vec ( to_vec ( logspace:: logspace ( base, start, end, n) ) )
130
136
}
131
137
132
- /// Create a one-dimensional array from the inclusive interval `[start,
133
- /// end]` with `n` elements geometrically spaced. `A` must be a floating
134
- /// point type.
138
+ /// Create a one-dimensional array with `n` geometrically spaced elements
139
+ /// from `start` to `end` (inclusive). `A` must be a floating point type.
135
140
///
136
141
/// Returns `None` if `start` and `end` have different signs or if either
137
142
/// one is zero. Conceptually, this means that in order to obtain a `Some`
138
143
/// result, `end / start` must be positive.
139
144
///
140
- /// **Panics** if `n` is greater than `isize::MAX`.
145
+ /// **Panics** if `n` is greater than `isize::MAX` or if converting `n - 1`
146
+ /// to type `A` fails.
141
147
///
142
148
/// ```rust
143
149
/// use approx::assert_abs_diff_eq;
0 commit comments