8000 Auto-generated commit · stdlib-js/array-linspace@1a44e34 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1a44e34

Browse files
committed
Auto-generated commit
1 parent 9ed8d99 commit 1a44e34

File tree

5 files changed

+1102
-42
lines changed

5 files changed

+1102
-42
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ var arr = linspace( 0.0, -100.0, 6 );
9090

9191
The function accepts the following `options`:
9292

93-
- **dtype**: output array data type. Must be a [floating-point data type][@stdlib/array/typed-float-dtypes] or `'generic'`. If either `start` or `stop` is a complex number, the default output array data type is `'complex128'`; otherwise, the default output array data type is `'float64'`.
93+
- **dtype**: output array data type. Must be a [floating-point data type][@stdlib/array/typed-float-dtypes] or `'generic'`. If both `start` and `stop` are the same type (either `'float64'`, `'complex64'`, or `'complex128'`), the default output array data type is the same type as the input values (either `'float64'`, `'complex64'`, or `'complex128'`, respectively). Otherwise, the default output array data type is `'complex128'`.
9494
- **endpoint**: `boolean` indicating whether to include the `stop` value in the output array. If `false`, the function generates `length + 1` linearly spaced values over the interval `[start, stop]` and only writes `length` values to the output array, thus excluding `stop` from the output array. Accordingly, for a fixed `length`, the spacing between adjacent values in the output array changes depending on the value of `endpoint`. Default: `true`.
9595

9696
By default, the function generates a linearly spaced array over the closed interval `[start, stop]`. To generate linearly spaced values over the half-open interval `[start, stop)`, set the `endpoint` option to `false`.
@@ -236,7 +236,7 @@ var arr = linspace.assign( 0.0, 100.0, out, opts );
236236
237237
where `M` is the number of values to generate. Accordingly, values may not be evenly spaced due to floating-point rounding errors.
238238
239-
- When the output array length is greater than `1` and `endpoint` is `true`, the output array is guaranteed to include the `start` and `stop` values. Beware, however, that values between the `start` and `stop` are subject to floating-point rounding errors. Hence,
239+
- When the output array length is greater than `1` and `endpoint` is `true`, the output array is guaranteed to include the `start` and `stop` values. Beware, however, that values between `start` and `stop` are subject to floating-point rounding errors. Hence,
240240
241241
```javascript
242242
var arr = linspace( 0.0, 1.0, 3 );

docs/repl.txt

Lines changed: 110 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,129 @@
11

2-
{{alias}}( start, stop[, length] )
3-
Generates a linearly spaced numeric array.
2+
{{alias}}( start, stop, length[, options] )
3+
Generates a linearly spaced array over a specified interval.
44

5-
If a `length` is not provided, the default output array length is `100`.
5+
If the specified length is zero, the function returns an empty array.
66

7-
The output array is guaranteed to include the `start` and `stop` values.
7+
If the specified length is one, the function returns an array containing
8+
`stop`, but not `start`, when `endpoint` is true; otherwise, the function
9+
returns an array containing `start`, but not `stop`.
10+
11+
For real-valued `start` and `stop`, if `start` is less than `stop`, the
12+
output array will contain ascending values, and, if `start` is greater than
13+
`stop`, the output array will contain descending values.
14+
15+
When the output array length is greater than one and `endpoint` is true, the
16+
output array is guaranteed to include the `start` and `stop` values. Beware,
17+
however, that values between `start` and `stop` are subject to floating-
18+
point rounding errors.
19+
20+
If both `start` and `stop` are real-valued, the output array data type may
21+
be any floating-point data type or 'generic'. However, if either `start` or
22+
`stop` are complex numbers, the output array type must be a complex
23+
floating-point data type or 'generic'.
24+
25+
When writing to a complex floating-point output array, real-valued `start`
26+
and `stop` values are treated as complex numbers having a real component
27+
equaling the provided value and having an imaginary component equaling zero.
28+
29+
When generating linearly spaced complex floating-point numbers, the real and
30+
imaginary components are generated separately.
831

932
Parameters
1033
----------
11-
start: number
12-
First array value.
34+
start: number|ComplexLike
35+
Start of interval.
36+
37+
stop: number|ComplexLike
38+
End of interval.
39+
40+
length: integer
41+
Length of output array.
1342

14-
stop: number
15-
Last array value.
43+
options: Object (optional)
44+
Options.
1645

17-
length: integer (optional)
18-
Length of output array. Default: `100`.
46+
options.dtype: string (optional)
47+
Output array data type. Must be a floating-point data type or 'generic'.
48+
If both `start` and `stop` are the same type (either 'float64',
49+
'complex64', or 'complex128'), the default output array data type is
50+
the same type as the input values (either 'float64', 'complex64', or
51+
'complex128', respectively). Otherwise, the default output array data
52+
type is 'complex128'.
53+
54+
options.endpoint: boolean (optional)
55+
Boolean indicating whether to include the `stop` value in the output
56+
array. If false, the function generates `length + 1` linearly spaced
57+
values over the interval `[start, stop]` and only writes `length` values
58+
to the output array, thus excluding `stop` from the output array.
59+
Accordingly, for a fixed `length`, the spacing between adjacent values
60+
in the output array changes depending on the value of `endpoint`.
61+
Default: true.
1962

2063
Returns
2164
-------
2265
arr: Array
23-
Linearly spaced numeric array.
66+
Linearly spaced array.
67+
68+
Examples
69+
--------
70+
> var arr = {{alias}}( 0.0, 100.0, 6 )
71+
<Float64Array>[ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]
72+
> arr = {{alias}}( 0.0, 100.0, 5, { 'endpoint': false } )
73+
<Float64Array>[ 0.0, 20.0, 40.0, 60.0, 80.0 ]
74+
> arr = {{alias}}( 0.0, 100.0, 6, { 'dtype': 'generic' } )
75+
[ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]
76+
77+
78+
{{alias}}.assign( start, stop, out[, options] )
79+
Generates a linearly spaced sequence over a specified interval and assigns
80+
the results to a provided output array.
81+
82+
If the provided output array is empty, the function returns the provided
83+
output array unchanged.
84+
85+
If the provided output array contains a single element, the function writes
86+
the `stop` value, but not `start`, when `endpoint` is true; otherwise, the
87+
function writes the `start` value, but not `stop`.
88+
89+
Parameters
90+
----------
91+
start: number|ComplexLike
92+
Start of interval.
93+
94+
stop: number|ComplexLike
95+
End of interval.
96+
97+
out: ArrayLikeObject
98+
Output array.
99+
100+
options: Object (optional)
101+
Options.
102+
103+
options.endpoint: boolean (optional)
104+
Boolean indicating whether to include the `stop` value in the output
105+
array. If false, the function generates `N+1` linearly spaced values
106+
(where `N` is the length of the provided output array) over the interval
107+
`[start, stop]` and only writes `N` values to the output array, thus
108+
excluding `stop` from the output array. Accordingly, for a fixed `N`,
109+
the spacing between adjacent values in the output array changes
110+
depending on the value of `endpoint`. Default: true.
111+
112+
Returns
113+
-------
114+
out: ArrayLikeObject
115+
Output array.
24116

25117
Examples
26118
--------
27-
> var arr = {{alias}}( 0, 100, 6 )
119+
> var arr = [ 0, 0, 0, 0, 0, 0 ];
120+
> var out = {{alias}}.assign( 0, 100, arr )
28121
[ 0, 20, 40, 60, 80, 100 ]
122+
> var bool = ( arr === out )
123+
true
124+
> arr = [ 0, 0, 0, 0, 0 ];
125+
> out = {{alias}}.assign( 0, 100, arr, { 'endpoint': false } )
126+
[ 0, 20, 40, 60, 80 ]
29127

30128
See Also
31129
--------

0 commit comments

Comments
 (0)
0