@stdlib/lapack-base-dlaswp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
package/NOTICE ADDED
@@ -0,0 +1 @@
1
+ Copyright (c) 2016-2024 The Stdlib Authors.
package/README.md ADDED
@@ -0,0 +1,384 @@
1
+ <!--
2
+
3
+ @license Apache-2.0
4
+
5
+ Copyright (c) 2024 The Stdlib Authors.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+ -->
20
+
21
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
32
+ # dlaswp
33
+
34
+ [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
35
+
36
+ > Perform a series of row interchanges on an input matrix.
37
+
38
+ <section class = "usage">
39
+
40
+ ## Usage
41
+
42
+ ```javascript
43
+ var dlaswp = require( '@stdlib/lapack-base-dlaswp' );
44
+ ```
45
+
46
+ #### dlaswp( N, A, LDA, k1, k2, IPIV, incx )
47
+
48
+ Perform a series of row interchanges on an input matrix `A` using pivot indices stored in `IPIV`.
49
+
50
+ ```javascript
51
+ var Int32Array = require( '@stdlib/array-int32' );
52
+ var Float64Array = require( '@stdlib/array-float64' );
53
+
54
+ var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
55
+ var IPIV = new Int32Array( [ 2, 0, 1 ] );
56
+
57
+ dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 );
58
+ // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
59
+ ```
60
+
61
+ The function has the following parameters:
62
+
63
+ - **order**: storage layout.
64
+ - **N**: number of columns in `A`.
65
+ - **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array].
66
+ - **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`).
67
+ - **k1**: index of first row to interchange when `incx` is positive and the index of the last row to interchange when `incx` is negative.
68
+ - **k2**: index of last row to interchange when `incx` is positive and the index of the first row to interchange when `incx` is negative.
69
+ - **IPIV**: vector of pivot indices as an [`Int32Array`][mdn-int32array]. Must contain at least `k1+(k2-k1)*abs(incx)` elements. Only the elements in positions `k1` through `k1+(k2-k1)*abs(incx)` are accessed.
70
+ - **incx**: increment between successive values of `IPIV`. Elements from `IPIV` are accessed according to `IPIV[k1+(k-k1)*abs(incx)] = j`, thus implying that rows `k` and `j` should be interchanged. If `incx` is negative, the pivots are applied in reverse order.
71
+
72
+ The sign of the increment parameter `incx` determines the order in which pivots are applied. For example, to apply pivots in reverse order,
73
+
74
+ ```javascript
75
+ var Int32Array = require( '@stdlib/array-int32' );
76
+ var Float64Array = require( '@stdlib/array-float64' );
77
+
78
+ var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
79
+ var IPIV = new Int32Array( [ 2, 0, 1 ] );
80
+
81
+ dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, -1 );
82
+ // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
83
+ ```
84
+
85
+ To perform strided access over `IPIV`, provide an `abs(incx)` value greater than one. For example, to access every other element in `IPIV`,
86
+
87
+ ```javascript
88
+ var Int32Array = require( '@stdlib/array-int32' );
89
+ var Float64Array = require( '@stdlib/array-float64' );
90
+
91
+ var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
92
+ var IPIV = new Int32Array( [ 2, 999, 0, 999, 1 ] );
93
+
94
+ dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 2 );
95
+ // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
96
+ ```
97
+
98
+ Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
99
+
100
+ <!-- eslint-disable stdlib/capitalized-comments -->
101
+
102
+ ```javascript
103
+ var Int32Array = require( '@stdlib/array-int32' );
104
+ var Float64Array = require( '@stdlib/array-float64' );
105
+
106
+ // Initial arrays...
107
+ var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
108
+ var IPIV0 = new Int32Array( [ 0, 2, 0, 1] );
109
+
110
+ // Create offset views...
111
+ var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
112
+ var IPIV1 = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
113
+
114
+ dlaswp( 'row-major', 2, A1, 2, 0, 2, IPIV1, 1 );
115
+ // A0 => <Float64Array>[ 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
116
+ ```
117
+
118
+ #### dlaswp.ndarray( N, A, sa1, sa2, oa, k1, k2, inck, IPIV, si, oi )
119
+
120
+ Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics.
121
+
122
+ ```javascript
123
+ var Int32Array = require( '@stdlib/array-int32' );
124
+ var Float64Array = require( '@stdlib/array-float64' );
125
+
126
+ var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
127
+ var IPIV = new Int32Array( [ 2, 0, 1 ] );
128
+
129
+ dlaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
130
+ // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
131
+ ```
132
+
133
+ The function has the following additional parameters:
134
+
135
+ - **N**: number of columns in `A`.
136
+ - **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array].
137
+ - **sa1**: stride of the first dimension of `A`.
138
+ - **sa2**: stride of the second dimension of `A`.
139
+ - **oa**: starting index for `A`.
140
+ - **k1**: index of first row to interchange when `inck` is positive and the index of the last row to interchange when `inck` is negative.
141
+ - **k2**: index of last row to interchange when `inck` is positive and the index of the first row to interchange when `inck` is negative.
142
+ - **inck**: direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order).
143
+ - **IPIV**: vector of pivot indices as an [`Int32Array`][mdn-int32array].
144
+ - **si**: index increment for `IPIV`.
145
+ - **oi**: starting index for `IPIV`.
146
+
147
+ While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example,
148
+
149
+ <!-- eslint-disable max-len -->
150
+
151
+ ```javascript
152
+ var Int32Array = require( '@stdlib/array-int32' );
153
+ var Float64Array = require( '@stdlib/array-float64' );
154
+
155
+ var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
156
+ var IPIV = new Int32Array( [ 0, 0, 2, 0, 1 ] );
157
+
158
+ dlaswp.ndarray( 2, A, 2, 1, 4, 0, 2, 1, IPIV, 1, 2 );
159
+ // A => <Float64Array>[ 0.0, 0.0, 0.0, 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
160
+ ```
161
+
162
+ </section>
163
+
164
+ <!-- /.usage -->
165
+
166
+ <section class="notes">
167
+
168
+ ## Notes
169
+
170
+ - Both functions access `k2-k1+1` elements from `IPIV`.
171
+ - While `dlaswp` conflates the order in which pivots are applied with the order in which elements in `IPIV` are accessed, the `ndarray` method delineates control of those behaviors with separate parameters `inck` and `si`.
172
+ - `dlaswp()` corresponds to the [LAPACK][LAPACK] level 1 function [`dlaswp`][lapack-dlaswp].
173
+
174
+ </section>
175
+
176
+ <!-- /.notes -->
177
+
178
+ <section class="examples">
179
+
180
+ ## Examples
181
+
182
+ <!-- eslint no-undef: "error" -->
183
+
184
+ ```javascript
185
+ var Float64Array = require( '@stdlib/array-float64' );
186
+ var Int32Array = require( '@stdlib/array-int32' );
187
+ var ndarray2array = require( '@stdlib/ndarray-base-to-array' );
188
+ var dlaswp = require( '@stdlib/lapack-base-dlaswp' );
189
+
190
+ // Specify matrix meta data:
191
+ var shape = [ 4, 2 ];
192
+ var strides = [ 1, 4 ];
193
+ var offset = 0;
194
+ var order = 'column-major';
195
+
196
+ // Create a matrix stored in linear memory:
197
+ var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
198
+ console.log( ndarray2array( A, shape, strides, offset, order ) );
199
+
200
+ // Define a vector of pivot indices:
201
+ var IPIV = new Int32Array( [ 2, 0, 3, 1 ] );
202
+
203
+ // Interchange rows:
204
+ dlaswp( order, shape[ 1 ], A, strides[ 1 ], 0, shape[ 0 ]-1, IPIV, 1 );
205
+ console.log( ndarray2array( A, shape, strides, offset, order ) );
206
+ ```
207
+
208
+ </section>
209
+
210
+ <!-- /.examples -->
211
+
212
+ <!-- C interface documentation. -->
213
+
214
+ * * *
215
+
216
+ <section class="c">
217
+
218
+ ## C APIs
219
+
220
+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
221
+
222
+ <section class="intro">
223
+
224
+ </section>
225
+
226
+ <!-- /.intro -->
227
+
228
+ <!-- C usage documentation. -->
229
+
230
+ <section class="installation">
231
+
232
+ ## Installation
233
+
234
+ ```bash
235
+ npm install @stdlib/lapack-base-dlaswp
236
+ ```
237
+
238
+ </section>
239
+
240
+ <section class="usage">
241
+
242
+ ### Usage
243
+
244
+ ```c
245
+ TODO
246
+ ```
247
+
248
+ #### TODO
249
+
250
+ TODO.
251
+
252
+ ```c
253
+ TODO
254
+ ```
255
+
256
+ TODO
257
+
258
+ ```c
259
+ TODO
260
+ ```
261
+
262
+ </section>
263
+
264
+ <!-- /.usage -->
265
+
266
+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
267
+
268
+ <section class="notes">
269
+
270
+ </section>
271
+
272
+ <!-- /.notes -->
273
+
274
+ <!-- C API usage examples. -->
275
+
276
+ <section class="examples">
277
+
278
+ ### Examples
279
+
280
+ ```c
281
+ TODO
282
+ ```
283
+
284
+ </section>
285
+
286
+ <!-- /.examples -->
287
+
288
+ </section>
289
+
290
+ <!-- /.c -->
291
+
292
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
293
+
294
+ <section class="related">
295
+
296
+ </section>
297
+
298
+ <!-- /.related -->
299
+
300
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
301
+
302
+
303
+ <section class="main-repo" >
304
+
305
+ * * *
306
+
307
+ ## Notice
308
+
309
+ This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
310
+
311
+ For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
312
+
313
+ #### Community
314
+
315
+ [![Chat][chat-image]][chat-url]
316
+
317
+ ---
318
+
319
+ ## License
320
+
321
+ See [LICENSE][stdlib-license].
322
+
323
+
324
+ ## Copyright
325
+
326
+ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
327
+
328
+ </section>
329
+
330
+ <!-- /.stdlib -->
331
+
332
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
333
+
334
+ <section class="links">
335
+
336
+ [npm-image]: http://img.shields.io/npm/v/@stdlib/lapack-base-dlaswp.svg
337
+ [npm-url]: https://npmjs.org/package/@stdlib/lapack-base-dlaswp
338
+
339
+ [test-image]: https://github.com/stdlib-js/lapack-base-dlaswp/actions/workflows/test.yml/badge.svg?branch=v0.1.0
340
+ [test-url]: https://github.com/stdlib-js/lapack-base-dlaswp/actions/workflows/test.yml?query=branch:v0.1.0
341
+
342
+ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/lapack-base-dlaswp/main.svg
343
+ [coverage-url]: https://codecov.io/github/stdlib-js/lapack-base-dlaswp?branch=main
344
+
345
+ <!--
346
+
347
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/lapack-base-dlaswp.svg
348
+ [dependencies-url]: https://david-dm.org/stdlib-js/lapack-base-dlaswp/main
349
+
350
+ -->
351
+
352
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
353
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
354
+
355
+ [stdlib]: https://github.com/stdlib-js/stdlib
356
+
357
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
358
+
359
+ [umd]: https://github.com/umdjs/umd
360
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
361
+
362
+ [deno-url]: https://github.com/stdlib-js/lapack-base-dlaswp/tree/deno
363
+ [deno-readme]: https://github.com/stdlib-js/lapack-base-dlaswp/blob/deno/README.md
364
+ [umd-url]: https://github.com/stdlib-js/lapack-base-dlaswp/tree/umd
365
+ [umd-readme]: https://github.com/stdlib-js/lapack-base-dlaswp/blob/umd/README.md
366
+ [esm-url]: https://github.com/stdlib-js/lapack-base-dlaswp/tree/esm
367
+ [esm-readme]: https://github.com/stdlib-js/lapack-base-dlaswp/blob/esm/README.md
368
+ [branches-url]: https://github.com/stdlib-js/lapack-base-dlaswp/blob/main/branches.md
369
+
370
+ [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/lapack-base-dlaswp/main/LICENSE
371
+
372
+ [lapack]: https://www.netlib.org/lapack/explore-html/
373
+
374
+ [lapack-dlaswp]: https://www.netlib.org/lapack/explore-html/d7/d6b/dlaswp_8f_source.html
375
+
376
+ [mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
377
+
378
+ [mdn-int32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
379
+
380
+ [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
381
+
382
+ </section>
383
+
384
+ <!-- /.links -->
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security
2
+
3
+ > Policy for reporting security vulnerabilities.
4
+
5
+ See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import dlaswp from '../docs/types/index';
3
+ export = dlaswp;
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";var R=function(v,r){return function(){return r||v((r={exports:{}}).exports,r),r.exports}};var F=R(function(rr,c){
2
+ var H=require('@stdlib/ndarray-base-assert-is-row-major/dist'),J=require('@stdlib/math-base-special-floor/dist'),Q=require('@stdlib/blas-base-dswap/dist').ndarray,_=32;function U(v,r,o,n,a,e,q,u,y,t,m){var i,s,E,w,b,h,f,j,x,l,g,p;if(u>0?i=q-e:i=e-q,i+=1,H([o,n])){for(f=m,j=0,l=e;j<i;j++,l+=u)w=y[f],w!==l&&Q(v,r,n,a+l*o,r,n,a+w*o),f+=t;return r}if(s=J(v/_)*_,s!==0)for(x=0;x<s;x+=_)for(f=m,j=0,l=e;j<i;j++,l+=u){if(w=y[f],w!==l)for(b=a+l*o,h=a+w*o,g=x;g<x+_;g++)p=g*n,E=r[b+p],r[b+p]=r[h+p],r[h+p]=E;f+=t}if(s!==v)for(f=m,j=0,l=e;j<i;j++,l+=u){if(w=y[f],w!==l)for(b=a+l*o,h=a+w*o,g=s;g<v;g++)p=g*n,E=r[b+p],r[b+p]=r[h+p],r[h+p]=E;f+=t}return r}c.exports=U
3
+ });var K=R(function(ar,C){
4
+ var W=require('@stdlib/blas-base-assert-is-layout/dist'),X=require('@stdlib/math-base-special-max/dist'),B=require('@stdlib/error-tools-fmtprodmsg/dist'),Y=F();function $(v,r,o,n,a,e,q,u){var y,t,m,i,s;if(!W(v))throw new TypeError(B('1xhFx',v));if(v==="row-major"&&n<X(1,r))throw new RangeError(B('1xhG4',r,n));if(u>0)t=1,s=a;else if(u<0)t=-1,s=a+(a-e)*u,y=a,a=e,e=y;else return o;return v==="column-major"?(m=1,i=n):(m=n,i=1),Y(r,o,m,i,0,a,e,t,q,u,s)}C.exports=$
5
+ });var S=R(function(er,M){
6
+ var d=F();function L(v,r,o,n,a,e,q,u,y,t,m){var i;return u<0?(m+=q*t,t*=-1,i=e,e=q,q=i,u=-1):(m+=e*t,u=1),d(v,r,o,n,a,e,q,u,y,t,m)}M.exports=L
7
+ });var z=R(function(ur,Z){
8
+ var D=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),T=K(),N=S();D(T,"ndarray",N);Z.exports=T
9
+ });var V=require("path").join,P=require('@stdlib/utils-try-require/dist'),I=require('@stdlib/assert-is-error/dist'),k=z(),O,G=P(V(__dirname,"./native.js"));I(G)?O=k:O=G;module.exports=O;
10
+ /** @license Apache-2.0 */
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/base.js", "../lib/dlaswp.js", "../lib/ndarray.js", "../lib/main.js", "../lib/index.js"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isRowMajor = require( '@stdlib/ndarray-base-assert-is-row-major' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar dswap = require( '@stdlib/blas-base-dswap' ).ndarray;\n\n\n// VARIABLES //\n\nvar BLOCK_SIZE = 32;\n\n\n// MAIN //\n\n/**\n* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`.\n*\n* @private\n* @param {PositiveInteger} N - number of columns in `A`\n* @param {Float64Array} A - input matrix\n* @param {integer} strideA1 - stride of the first dimension of `A`\n* @param {integer} strideA2 - stride of the second dimension of `A`\n* @param {NonNegativeInteger} offsetA - index offset for `A`\n* @param {NonNegativeInteger} k1 - index of first row to interchange\n* @param {NonNegativeInteger} k2 - index of last row to interchange\n* @param {integer} inck - direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order)\n* @param {Int32Array} IPIV - vector of pivot indices\n* @param {integer} strideIPIV - `IPIV` stride length\n* @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV`\n* @returns {Float64Array} permuted matrix `A`\n*\n* @example\n* var Int32Array = require( '@stdlib/array-int32' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var IPIV = new Int32Array( [ 2, 0, 1 ] );\n* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* dlaswp( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );\n* // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]\n*/\nfunction dlaswp( N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params\n\tvar nrows;\n\tvar n32;\n\tvar tmp;\n\tvar row;\n\tvar ia1;\n\tvar ia2;\n\tvar ip;\n\tvar i;\n\tvar j;\n\tvar k;\n\tvar n;\n\tvar o;\n\n\t// Compute the number of rows to be interchanged:\n\tif ( inck > 0 ) {\n\t\tnrows = k2 - k1;\n\t} else {\n\t\tnrows = k1 - k2;\n\t}\n\tnrows += 1;\n\n\t// If the order is row-major, we can delegate to the Level 1 routine `dswap` for interchanging rows...\n\tif ( isRowMajor( [ strideA1, strideA2 ] ) ) {\n\t\tip = offsetIPIV;\n\t\tfor ( i = 0, k = k1; i < nrows; i++, k += inck ) {\n\t\t\trow = IPIV[ ip ];\n\t\t\tif ( row !== k ) {\n\t\t\t\tdswap( N, A, strideA2, offsetA+(k*strideA1), A, strideA2, offsetA+(row*strideA1) ); // eslint-disable-line max-len\n\t\t\t}\n\t\t\tip += strideIPIV;\n\t\t}\n\t\treturn A;\n\t}\n\t// If the order is column-major, we need to use loop tiling to ensure efficient cache access when accessing matrix elements...\n\tn32 = floor( N/BLOCK_SIZE ) * BLOCK_SIZE;\n\tif ( n32 !== 0 ) {\n\t\tfor ( j = 0; j < n32; j += BLOCK_SIZE ) {\n\t\t\tip = offsetIPIV;\n\t\t\tfor ( i = 0, k = k1; i < nrows; i++, k += inck ) {\n\t\t\t\trow = IPIV[ ip ];\n\t\t\t\tif ( row !== k ) {\n\t\t\t\t\tia1 = offsetA + ( k*strideA1 );\n\t\t\t\t\tia2 = offsetA + ( row*strideA1 );\n\t\t\t\t\tfor ( n = j; n < j+BLOCK_SIZE; n++ ) {\n\t\t\t\t\t\to = n * strideA2;\n\t\t\t\t\t\ttmp = A[ ia1+o ];\n\t\t\t\t\t\tA[ ia1+o ] = A[ ia2+o ];\n\t\t\t\t\t\tA[ ia2+o ] = tmp;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tip += strideIPIV;\n\t\t\t}\n\t\t}\n\t}\n\tif ( n32 !== N ) {\n\t\tip = offsetIPIV;\n\t\tfor ( i = 0, k = k1; i < nrows; i++, k += inck ) {\n\t\t\trow = IPIV[ ip ];\n\t\t\tif ( row !== k ) {\n\t\t\t\tia1 = offsetA + ( k*strideA1 );\n\t\t\t\tia2 = offsetA + ( row*strideA1 );\n\t\t\t\tfor ( n = n32; n < N; n++ ) {\n\t\t\t\t\to = n * strideA2;\n\t\t\t\t\ttmp = A[ ia1+o ];\n\t\t\t\t\tA[ ia1+o ] = A[ ia2+o ];\n\t\t\t\t\tA[ ia2+o ] = tmp;\n\t\t\t\t}\n\t\t\t}\n\t\t\tip += strideIPIV;\n\t\t}\n\t}\n\treturn A;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dlaswp;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isLayout = require( '@stdlib/blas-base-assert-is-layout' );\nvar max = require( '@stdlib/math-base-special-max' );\nvar format = require( '@stdlib/string-format' );\nvar base = require( './base.js' );\n\n\n// MAIN //\n\n/**\n* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`.\n*\n* @param {string} order - storage layout\n* @param {PositiveInteger} N - number of columns in `A`\n* @param {Float64Array} A - input matrix\n* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)\n* @param {NonNegativeInteger} k1 - index of first row to interchange\n* @param {NonNegativeInteger} k2 - index of last row to interchange\n* @param {Int32Array} IPIV - vector of pivot indices\n* @param {integer} incx - increment between successive values of `IPIV`\n* @throws {TypeError} first argument must be a valid order\n* @throws {RangeError} fourth argument must be greater than or equal to max(1,N)\n* @returns {Float64Array} permuted matrix `A`\n*\n* @example\n* var Int32Array = require( '@stdlib/array-int32' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var IPIV = new Int32Array( [ 2, 0, 1 ] );\n* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 );\n* // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]\n*/\nfunction dlaswp( order, N, A, LDA, k1, k2, IPIV, incx ) {\n\tvar tmp;\n\tvar inc;\n\tvar sa1;\n\tvar sa2;\n\tvar io;\n\tif ( !isLayout( order ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) );\n\t}\n\tif ( order === 'row-major' && LDA < max( 1, N ) ) {\n\t\tthrow new RangeError( format( 'invalid argument. Fourth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) );\n\t}\n\tif ( incx > 0 ) {\n\t\tinc = 1;\n\t\tio = k1;\n\t} else if ( incx < 0 ) {\n\t\tinc = -1;\n\t\tio = k1 + ( (k1-k2) * incx );\n\t\ttmp = k1;\n\t\tk1 = k2;\n\t\tk2 = tmp;\n\t} else {\n\t\treturn A;\n\t}\n\tif ( order === 'column-major' ) {\n\t\tsa1 = 1;\n\t\tsa2 = LDA;\n\t} else { // order === 'row-major'\n\t\tsa1 = LDA;\n\t\tsa2 = 1;\n\t}\n\treturn base( N, A, sa1, sa2, 0, k1, k2, inc, IPIV, incx, io );\n}\n\n\n// EXPORTS //\n\nmodule.exports = dlaswp;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar base = require( './base.js' );\n\n\n// MAIN //\n\n/**\n* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`.\n*\n* @param {PositiveInteger} N - number of columns in `A`\n* @param {Float64Array} A - input matrix\n* @param {integer} strideA1 - stride of the first dimension of `A`\n* @param {integer} strideA2 - stride of the second dimension of `A`\n* @param {NonNegativeInteger} offsetA - index offset for `A`\n* @param {NonNegativeInteger} k1 - index of first row to interchange\n* @param {NonNegativeInteger} k2 - index of last row to interchange\n* @param {integer} inck - direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order)\n* @param {Int32Array} IPIV - vector of pivot indices\n* @param {integer} strideIPIV - `IPIV` stride length\n* @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV`\n* @returns {Float64Array} permuted matrix `A`\n*\n* @example\n* var Int32Array = require( '@stdlib/array-int32' );\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var IPIV = new Int32Array( [ 2, 0, 1 ] );\n* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* dlaswp( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );\n* // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]\n*/\nfunction dlaswp( N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params\n\tvar tmp;\n\tif ( inck < 0 ) {\n\t\toffsetIPIV += k2 * strideIPIV;\n\t\tstrideIPIV *= -1;\n\t\ttmp = k1;\n\t\tk1 = k2;\n\t\tk2 = tmp;\n\t\tinck = -1;\n\t} else {\n\t\toffsetIPIV += k1 * strideIPIV;\n\t\tinck = 1;\n\t}\n\treturn base( N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = dlaswp;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar dlaswp = require( './dlaswp.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dlaswp, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dlaswp;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* LAPACK routine to perform a series of row interchanges on an input matrix.\n*\n* @module @stdlib/lapack-base-dlaswp\n*\n* @example\n* var Int32Array = require( '@stdlib/array-int32' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dlaswp = require( '@stdlib/lapack-base-dlaswp' );\n*\n* var IPIV = new Int32Array( [ 2, 0, 1 ] );\n* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 );\n* // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]\n*/\n\n// MODULES //\n\nvar join = require( 'path' ).join;\nvar tryRequire = require( '@stdlib/utils-try-require' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar main = require( './main.js' );\n\n\n// MAIN //\n\nvar dlaswp;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdlaswp = main;\n} else {\n\tdlaswp = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dlaswp;\n"],
5
+ "mappings": "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",
6
+ "names": ["require_base", "__commonJSMin", "exports", "module", "isRowMajor", "floor", "dswap", "BLOCK_SIZE", "dlaswp", "N", "A", "strideA1", "strideA2", "offsetA", "k1", "k2", "inck", "IPIV", "strideIPIV", "offsetIPIV", "nrows", "n32", "tmp", "row", "ia1", "ia2", "ip", "i", "j", "k", "n", "o", "require_dlaswp", "__commonJSMin", "exports", "module", "isLayout", "max", "format", "base", "dlaswp", "order", "N", "A", "LDA", "k1", "k2", "IPIV", "incx", "tmp", "inc", "sa1", "sa2", "io", "require_ndarray", "__commonJSMin", "exports", "module", "base", "dlaswp", "N", "A", "strideA1", "strideA2", "offsetA", "k1", "k2", "inck", "IPIV", "strideIPIV", "offsetIPIV", "tmp", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dlaswp", "ndarray", "join", "tryRequire", "isError", "main", "dlaswp", "tmp"]
7
+ }
@@ -0,0 +1,121 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ // TypeScript Version: 4.1
20
+
21
+ /// <reference types="@stdlib/types"/>
22
+
23
+ import { Layout } from '@stdlib/types/blas';
24
+
25
+ /**
26
+ * Interface describing `dlaswp`.
27
+ */
28
+ interface Routine {
29
+ /**
30
+ * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`.
31
+ *
32
+ * @param order - storage layout
33
+ * @param N - number of columns in `A`
34
+ * @param A - input matrix
35
+ * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
36
+ * @param k1 - index of first row to interchange
37
+ * @param k2 - index of last row to interchange
38
+ * @param IPIV - vector of pivot indices
39
+ * @param incx - increment between successive values of `IPIV`
40
+ * @returns permuted matrix `A`
41
+ *
42
+ * @example
43
+ * var Int32Array = require( '@stdlib/array-int32' );
44
+ * var Float64Array = require( '@stdlib/array-float64' );
45
+ *
46
+ * var IPIV = new Int32Array( [ 2, 0, 1 ] );
47
+ * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
48
+ *
49
+ * dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 );
50
+ * // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
51
+ */
52
+ ( order: Layout, N: number, A: Float64Array, LDA: number, k1: number, k2: number, IPIV: Int32Array, incx: number ): Float64Array;
53
+
54
+ /**
55
+ * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics.
56
+ *
57
+ * @param N - number of columns in `A`
58
+ * @param A - input matrix
59
+ * @param strideA1 - stride of the first dimension of `A`
60
+ * @param strideA2 - stride of the second dimension of `A`
61
+ * @param offsetA - index offset for `A`
62
+ * @param k1 - index of first row to interchange
63
+ * @param k2 - index of last row to interchange
64
+ * @param inck - direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order)
65
+ * @param IPIV - vector of pivot indices
66
+ * @param strideIPIV - `IPIV` stride length
67
+ * @param offsetIPIV - index offset for `IPIV`
68
+ * @returns permuted matrix `A`
69
+ *
70
+ * @example
71
+ * var Int32Array = require( '@stdlib/array-int32' );
72
+ * var Float64Array = require( '@stdlib/array-float64' );
73
+ *
74
+ * var IPIV = new Int32Array( [ 2, 0, 1 ] );
75
+ * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
76
+ *
77
+ * dlaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
78
+ * // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
79
+ */
80
+ ndarray( N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, k1: number, k2: number, inck: number, IPIV: Int32Array, strideIPIV: number, offsetIPIV: number ): Float64Array;
81
+ }
82
+
83
+ /**
84
+ * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`.
85
+ *
86
+ * @param order - storage layout
87
+ * @param N - number of columns in `A`
88
+ * @param A - input matrix
89
+ * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
90
+ * @param k1 - index of first row to interchange
91
+ * @param k2 - index of last row to interchange
92
+ * @param IPIV - vector of pivot indices
93
+ * @param incx - increment between successive values of `IPIV`
94
+ * @returns permuted matrix `A`
95
+ *
96
+ * @example
97
+ * var Int32Array = require( '@stdlib/array-int32' );
98
+ * var Float64Array = require( '@stdlib/array-float64' );
99
+ *
100
+ * var IPIV = new Int32Array( [ 2, 0, 1 ] );
101
+ * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
102
+ *
103
+ * dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 );
104
+ * // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
105
+ *
106
+ * @example
107
+ * var Int32Array = require( '@stdlib/array-int32' );
108
+ * var Float64Array = require( '@stdlib/array-float64' );
109
+ *
110
+ * var IPIV = new Int32Array( [ 2, 0, 1 ] );
111
+ * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
112
+ *
113
+ * dlaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
114
+ * // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
115
+ */
116
+ declare var dlaswp: Routine;
117
+
118
+
119
+ // EXPORTS //
120
+
121
+ export = dlaswp;
package/lib/base.js ADDED
@@ -0,0 +1,140 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var isRowMajor = require( '@stdlib/ndarray-base-assert-is-row-major' );
24
+ var floor = require( '@stdlib/math-base-special-floor' );
25
+ var dswap = require( '@stdlib/blas-base-dswap' ).ndarray;
26
+
27
+
28
+ // VARIABLES //
29
+
30
+ var BLOCK_SIZE = 32;
31
+
32
+
33
+ // MAIN //
34
+
35
+ /**
36
+ * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`.
37
+ *
38
+ * @private
39
+ * @param {PositiveInteger} N - number of columns in `A`
40
+ * @param {Float64Array} A - input matrix
41
+ * @param {integer} strideA1 - stride of the first dimension of `A`
42
+ * @param {integer} strideA2 - stride of the second dimension of `A`
43
+ * @param {NonNegativeInteger} offsetA - index offset for `A`
44
+ * @param {NonNegativeInteger} k1 - index of first row to interchange
45
+ * @param {NonNegativeInteger} k2 - index of last row to interchange
46
+ * @param {integer} inck - direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order)
47
+ * @param {Int32Array} IPIV - vector of pivot indices
48
+ * @param {integer} strideIPIV - `IPIV` stride length
49
+ * @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV`
50
+ * @returns {Float64Array} permuted matrix `A`
51
+ *
52
+ * @example
53
+ * var Int32Array = require( '@stdlib/array-int32' );
54
+ * var Float64Array = require( '@stdlib/array-float64' );
55
+ *
56
+ * var IPIV = new Int32Array( [ 2, 0, 1 ] );
57
+ * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
58
+ *
59
+ * dlaswp( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
60
+ * // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
61
+ */
62
+ function dlaswp( N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params
63
+ var nrows;
64
+ var n32;
65
+ var tmp;
66
+ var row;
67
+ var ia1;
68
+ var ia2;
69
+ var ip;
70
+ var i;
71
+ var j;
72
+ var k;
73
+ var n;
74
+ var o;
75
+
76
+ // Compute the number of rows to be interchanged:
77
+ if ( inck > 0 ) {
78
+ nrows = k2 - k1;
79
+ } else {
80
+ nrows = k1 - k2;
81
+ }
82
+ nrows += 1;
83
+
84
+ // If the order is row-major, we can delegate to the Level 1 routine `dswap` for interchanging rows...
85
+ if ( isRowMajor( [ strideA1, strideA2 ] ) ) {
86
+ ip = offsetIPIV;
87
+ for ( i = 0, k = k1; i < nrows; i++, k += inck ) {
88
+ row = IPIV[ ip ];
89
+ if ( row !== k ) {
90
+ dswap( N, A, strideA2, offsetA+(k*strideA1), A, strideA2, offsetA+(row*strideA1) ); // eslint-disable-line max-len
91
+ }
92
+ ip += strideIPIV;
93
+ }
94
+ return A;
95
+ }
96
+ // If the order is column-major, we need to use loop tiling to ensure efficient cache access when accessing matrix elements...
97
+ n32 = floor( N/BLOCK_SIZE ) * BLOCK_SIZE;
98
+ if ( n32 !== 0 ) {
99
+ for ( j = 0; j < n32; j += BLOCK_SIZE ) {
100
+ ip = offsetIPIV;
101
+ for ( i = 0, k = k1; i < nrows; i++, k += inck ) {
102
+ row = IPIV[ ip ];
103
+ if ( row !== k ) {
104
+ ia1 = offsetA + ( k*strideA1 );
105
+ ia2 = offsetA + ( row*strideA1 );
106
+ for ( n = j; n < j+BLOCK_SIZE; n++ ) {
107
+ o = n * strideA2;
108
+ tmp = A[ ia1+o ];
109
+ A[ ia1+o ] = A[ ia2+o ];
110
+ A[ ia2+o ] = tmp;
111
+ }
112
+ }
113
+ ip += strideIPIV;
114
+ }
115
+ }
116
+ }
117
+ if ( n32 !== N ) {
118
+ ip = offsetIPIV;
119
+ for ( i = 0, k = k1; i < nrows; i++, k += inck ) {
120
+ row = IPIV[ ip ];
121
+ if ( row !== k ) {
122
+ ia1 = offsetA + ( k*strideA1 );
123
+ ia2 = offsetA + ( row*strideA1 );
124
+ for ( n = n32; n < N; n++ ) {
125
+ o = n * strideA2;
126
+ tmp = A[ ia1+o ];
127
+ A[ ia1+o ] = A[ ia2+o ];
128
+ A[ ia2+o ] = tmp;
129
+ }
130
+ }
131
+ ip += strideIPIV;
132
+ }
133
+ }
134
+ return A;
135
+ }
136
+
137
+
138
+ // EXPORTS //
139
+
140
+ module.exports = dlaswp;
package/lib/dlaswp.js ADDED
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var isLayout = require( '@stdlib/blas-base-assert-is-layout' );
24
+ var max = require( '@stdlib/math-base-special-max' );
25
+ var format = require( '@stdlib/string-format' );
26
+ var base = require( './base.js' );
27
+
28
+
29
+ // MAIN //
30
+
31
+ /**
32
+ * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`.
33
+ *
34
+ * @param {string} order - storage layout
35
+ * @param {PositiveInteger} N - number of columns in `A`
36
+ * @param {Float64Array} A - input matrix
37
+ * @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
38
+ * @param {NonNegativeInteger} k1 - index of first row to interchange
39
+ * @param {NonNegativeInteger} k2 - index of last row to interchange
40
+ * @param {Int32Array} IPIV - vector of pivot indices
41
+ * @param {integer} incx - increment between successive values of `IPIV`
42
+ * @throws {TypeError} first argument must be a valid order
43
+ * @throws {RangeError} fourth argument must be greater than or equal to max(1,N)
44
+ * @returns {Float64Array} permuted matrix `A`
45
+ *
46
+ * @example
47
+ * var Int32Array = require( '@stdlib/array-int32' );
48
+ * var Float64Array = require( '@stdlib/array-float64' );
49
+ *
50
+ * var IPIV = new Int32Array( [ 2, 0, 1 ] );
51
+ * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
52
+ *
53
+ * dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 );
54
+ * // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
55
+ */
56
+ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incx ) {
57
+ var tmp;
58
+ var inc;
59
+ var sa1;
60
+ var sa2;
61
+ var io;
62
+ if ( !isLayout( order ) ) {
63
+ throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) );
64
+ }
65
+ if ( order === 'row-major' && LDA < max( 1, N ) ) {
66
+ throw new RangeError( format( 'invalid argument. Fourth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) );
67
+ }
68
+ if ( incx > 0 ) {
69
+ inc = 1;
70
+ io = k1;
71
+ } else if ( incx < 0 ) {
72
+ inc = -1;
73
+ io = k1 + ( (k1-k2) * incx );
74
+ tmp = k1;
75
+ k1 = k2;
76
+ k2 = tmp;
77
+ } else {
78
+ return A;
79
+ }
80
+ if ( order === 'column-major' ) {
81
+ sa1 = 1;
82
+ sa2 = LDA;
83
+ } else { // order === 'row-major'
84
+ sa1 = LDA;
85
+ sa2 = 1;
86
+ }
87
+ return base( N, A, sa1, sa2, 0, k1, k2, inc, IPIV, incx, io );
88
+ }
89
+
90
+
91
+ // EXPORTS //
92
+
93
+ module.exports = dlaswp;
package/lib/index.js ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ /**
22
+ * LAPACK routine to perform a series of row interchanges on an input matrix.
23
+ *
24
+ * @module @stdlib/lapack-base-dlaswp
25
+ *
26
+ * @example
27
+ * var Int32Array = require( '@stdlib/array-int32' );
28
+ * var Float64Array = require( '@stdlib/array-float64' );
29
+ * var dlaswp = require( '@stdlib/lapack-base-dlaswp' );
30
+ *
31
+ * var IPIV = new Int32Array( [ 2, 0, 1 ] );
32
+ * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
33
+ *
34
+ * dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 );
35
+ * // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
36
+ */
37
+
38
+ // MODULES //
39
+
40
+ var join = require( 'path' ).join;
41
+ var tryRequire = require( '@stdlib/utils-try-require' );
42
+ var isError = require( '@stdlib/assert-is-error' );
43
+ var main = require( './main.js' );
44
+
45
+
46
+ // MAIN //
47
+
48
+ var dlaswp;
49
+ var tmp = tryRequire( join( __dirname, './native.js' ) );
50
+ if ( isError( tmp ) ) {
51
+ dlaswp = main;
52
+ } else {
53
+ dlaswp = tmp;
54
+ }
55
+
56
+
57
+ // EXPORTS //
58
+
59
+ module.exports = dlaswp;
package/lib/main.js ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
24
+ var dlaswp = require( './dlaswp.js' );
25
+ var ndarray = require( './ndarray.js' );
26
+
27
+
28
+ // MAIN //
29
+
30
+ setReadOnly( dlaswp, 'ndarray', ndarray );
31
+
32
+
33
+ // EXPORTS //
34
+
35
+ module.exports = dlaswp;
package/lib/ndarray.js ADDED
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var base = require( './base.js' );
24
+
25
+
26
+ // MAIN //
27
+
28
+ /**
29
+ * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`.
30
+ *
31
+ * @param {PositiveInteger} N - number of columns in `A`
32
+ * @param {Float64Array} A - input matrix
33
+ * @param {integer} strideA1 - stride of the first dimension of `A`
34
+ * @param {integer} strideA2 - stride of the second dimension of `A`
35
+ * @param {NonNegativeInteger} offsetA - index offset for `A`
36
+ * @param {NonNegativeInteger} k1 - index of first row to interchange
37
+ * @param {NonNegativeInteger} k2 - index of last row to interchange
38
+ * @param {integer} inck - direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order)
39
+ * @param {Int32Array} IPIV - vector of pivot indices
40
+ * @param {integer} strideIPIV - `IPIV` stride length
41
+ * @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV`
42
+ * @returns {Float64Array} permuted matrix `A`
43
+ *
44
+ * @example
45
+ * var Int32Array = require( '@stdlib/array-int32' );
46
+ * var Float64Array = require( '@stdlib/array-float64' );
47
+ *
48
+ * var IPIV = new Int32Array( [ 2, 0, 1 ] );
49
+ * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
50
+ *
51
+ * dlaswp( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
52
+ * // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
53
+ */
54
+ function dlaswp( N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params
55
+ var tmp;
56
+ if ( inck < 0 ) {
57
+ offsetIPIV += k2 * strideIPIV;
58
+ strideIPIV *= -1;
59
+ tmp = k1;
60
+ k1 = k2;
61
+ k2 = tmp;
62
+ inck = -1;
63
+ } else {
64
+ offsetIPIV += k1 * strideIPIV;
65
+ inck = 1;
66
+ }
67
+ return base( N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ); // eslint-disable-line max-len
68
+ }
69
+
70
+
71
+ // EXPORTS //
72
+
73
+ module.exports = dlaswp;
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@stdlib/lapack-base-dlaswp",
3
+ "version": "0.1.0",
4
+ "description": "Perform a series of row interchanges on an input matrix.",
5
+ "license": "Apache-2.0",
6
+ "author": {
7
+ "name": "The Stdlib Authors",
8
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9
+ },
10
+ "contributors": [
11
+ {
12
+ "name": "The Stdlib Authors",
13
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14
+ }
15
+ ],
16
+ "main": "./lib",
17
+ "directories": {
18
+ "doc": "./docs",
19
+ "lib": "./lib",
20
+ "dist": "./dist"
21
+ },
22
+ "types": "./docs/types",
23
+ "scripts": {},
24
+ "homepage": "https://stdlib.io",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git://github.com/stdlib-js/lapack-base-dlaswp.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/stdlib-js/stdlib/issues"
31
+ },
32
+ "dependencies": {
33
+ "@stdlib/assert-is-error": "^0.2.2",
34
+ "@stdlib/blas-base-assert-is-layout": "^0.0.2",
35
+ "@stdlib/blas-base-dswap": "^0.3.0",
36
+ "@stdlib/math-base-special-floor": "^0.2.3",
37
+ "@stdlib/math-base-special-max": "^0.3.0",
38
+ "@stdlib/ndarray-base-assert-is-row-major": "^0.2.2",
39
+ "@stdlib/string-format": "^0.2.2",
40
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
41
+ "@stdlib/utils-try-require": "^0.2.2",
42
+ "@stdlib/error-tools-fmtprodmsg": "^0.2.2"
43
+ },
44
+ "devDependencies": {},
45
+ "engines": {
46
+ "node": ">=0.10.0",
47
+ "npm": ">2.7.0"
48
+ },
49
+ "os": [
50
+ "aix",
51
+ "darwin",
52
+ "freebsd",
53
+ "linux",
54
+ "macos",
55
+ "openbsd",
56
+ "sunos",
57
+ "win32",
58
+ "windows"
59
+ ],
60
+ "keywords": [
61
+ "stdlib",
62
+ "stdmath",
63
+ "mathematics",
64
+ "math",
65
+ "lapack",
66
+ "dlaswp",
67
+ "interchange",
68
+ "swap",
69
+ "exchange",
70
+ "permute",
71
+ "permutedims",
72
+ "linear",
73
+ "algebra",
74
+ "subroutines",
75
+ "array",
76
+ "ndarray",
77
+ "float64",
78
+ "double",
79
+ "float64array"
80
+ ],
81
+ "funding": {
82
+ "type": "opencollective",
83
+ "url": "https://opencollective.com/stdlib"
84
+ }
85
+ }