Skip to content

Commit ad3bd84

Browse files
committed
fix: apply suggestions from code review
1 parent bc5d841 commit ad3bd84

5 files changed

Lines changed: 109 additions & 65 deletions

File tree

lib/node_modules/@stdlib/ndarray/diagonal/README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ limitations under the License.
2222

2323
> Return a **read-only** view of the diagonal of a matrix (or stack of matrices).
2424
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro section element. -->
26+
2527
<section class="intro">
2628

2729
For an `M`-by-`N` matrix `A`, the `k`-th diagonal is defined as
@@ -39,12 +41,29 @@ D_k = \{\, A_{i,j} : j - i = k \,\}
3941

4042
<!-- </equation> -->
4143

42-
where `k = 0` corresponds to the main diagonal, `k > 0` corresponds to the super-diagonals (above the main diagonal), and `k < 0` corresponds to the sub-diagonals (below the main diagonal).
44+
where `k = 0` corresponds to the main diagonal, `k > 0` corresponds to the super-diagonals (above the main diagonal), and `k < 0` corresponds to the sub-diagonals (below the main diagonal). For example, given the matrix
45+
46+
<!-- <equation class="equation" label="eq:diagonal_example" align="center" raw="A = \begin{bmatrix} a_{0,0} & a_{0,1} & a_{0,2} \\ a_{1,0} & a_{1,1} & a_{1,2} \\ a_{2,0} & a_{2,1} & a_{2,2} \end{bmatrix}" alt="Example matrix."> -->
47+
48+
```math
49+
A = \begin{bmatrix} a_{0,0} & a_{0,1} & a_{0,2} \\ a_{1,0} & a_{1,1} & a_{1,2} \\ a_{2,0} & a_{2,1} & a_{2,2} \end{bmatrix}
50+
```
51+
52+
<!-- <div class="equation" align="center" data-raw-text="A = \begin{bmatrix} a_{0,0} & a_{0,1} & a_{0,2} \\ a_{1,0} & a_{1,1} & a_{1,2} \\ a_{2,0} & a_{2,1} & a_{2,2} \end{bmatrix}" data-equation="eq:diagonal_example">
53+
<img src="" alt="Example matrix.">
54+
<br>
55+
</div> -->
56+
57+
<!-- </equation> -->
58+
59+
the main diagonal is `[ a_{0,0}, a_{1,1}, a_{2,2} ]`, the super-diagonal `k = 1` is `[ a_{0,1}, a_{1,2} ]`, and the sub-diagonal `k = -1` is `[ a_{1,0}, a_{2,1} ]`.
4360

4461
</section>
4562

4663
<!-- /.intro -->
4764

65+
<!-- Package usage documentation. -->
66+
4867
<section class="usage">
4968

5069
## Usage
@@ -55,7 +74,7 @@ var diagonal = require( '@stdlib/ndarray/diagonal' );
5574

5675
#### diagonal( x\[, options] )
5776

58-
Returns a read-only view of the diagonal of a matrix (or stack of matrices) `x`.
77+
Returns a read-only view of the diagonal of a matrix (or stack of matrices).
5978

6079
```javascript
6180
var array = require( '@stdlib/ndarray/array' );
@@ -81,6 +100,8 @@ The function accepts the following options:
81100

82101
<!-- /.usage -->
83102

103+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
104+
84105
<section class="notes">
85106

86107
## Notes
@@ -92,6 +113,8 @@ The function accepts the following options:
92113

93114
<!-- /.notes -->
94115

116+
<!-- Package usage examples. -->
117+
95118
<section class="examples">
96119

97120
## Examples
@@ -128,6 +151,8 @@ console.log( ndarray2array( y ) );
128151

129152
<!-- /.examples -->
130153

154+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
155+
131156
<section class="references">
132157

133158
</section>

lib/node_modules/@stdlib/ndarray/diagonal/docs/repl.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
Each provided dimension index must reside on the interval [-ndims, ndims-1].
1111

12-
The diagonal offset `options.k` is interpreted as `column - row`.
13-
Accordingly, when `options.k = 0`, the function returns the main diagonal;
14-
when `options.k > 0`, the function returns the diagonal above the main
15-
diagonal; and when `options.k < 0`, the function returns the diagonal
16-
below the main diagonal.
17-
1812
Parameters
1913
----------
2014
x: ndarray
@@ -24,13 +18,19 @@
2418
Function options.
2519

2620
options.k: integer (optional)
27-
Diagonal offset. Default: 0.
21+
Diagonal offset. The diagonal offset is interpreted as
22+
`column - row`. Accordingly, when `options.k = 0`, the function
23+
returns the main diagonal; when `options.k > 0`, the function returns
24+
the diagonal above the main diagonal; and when `options.k < 0`, the
25+
function returns the diagonal below the main diagonal. Default: 0.
2826

2927
options.dims: ArrayLikeObject<integer> (optional)
3028
Dimension indices defining the plane from which to extract the
31-
diagonal. Must contain exactly two unique dimension indices. If less
32-
than zero, an index is resolved relative to the last dimension, with
33-
the last dimension corresponding to the value `-1`. Default: [ -2, -1 ].
29+
diagonal. The first element specifies the row-like dimension. The
30+
second element specifies the column-like dimension. Must contain
31+
exactly two unique dimension indices. If less than zero, an index is
32+
resolved relative to the last dimension, with the last dimension
33+
corresponding to the value `-1`. Default: [ -2, -1 ].
3434

3535
Returns
3636
-------

lib/node_modules/@stdlib/ndarray/diagonal/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ interface Options {
5050
* @param x - input array
5151
* @param options - function options
5252
* @param options.k - diagonal offset (default: 0)
53-
* @param options.dims - dimension indices defining the plane from which to extract the diagonal.
53+
* @param options.dims - dimension indices defining the plane from which to extract the diagonal (default: [-2, -1])
5454
* @returns output array
5555
*
5656
* @example

lib/node_modules/@stdlib/ndarray/diagonal/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var format = require( '@stdlib/string/format' );
4343
* @param {ndarray} x - input array
4444
* @param {Options} [options] - function options
4545
* @param {integer} [options.k=0] - diagonal offset
46-
* @param {IntegerArray} [options.dims=[-2,-1]] - dimension indices defining the plane from which to extract the diagonal.
46+
* @param {IntegerArray} [options.dims=[-2,-1]] - dimension indices defining the plane from which to extract the diagonal
4747
* @throws {TypeError} first argument must be an ndarray
4848
* @throws {TypeError} options argument must be an object
4949
* @throws {TypeError} `k` option must be an integer

0 commit comments

Comments
 (0)