README.md (2792B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2020 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 # dswap 22 23 > Interchange two double-precision floating-point vectors. 24 25 <section class="intro"> 26 27 </section> 28 29 <!-- /.intro --> 30 31 <section class="usage"> 32 33 ## Usage 34 35 ```javascript 36 var dswap = require( '@stdlib/blas/dswap' ); 37 ``` 38 39 #### dswap( x, y ) 40 41 Interchanges two double-precision floating-point vectors `x` and `y`. 42 43 ```javascript 44 var Float64Array = require( '@stdlib/array/float64' ); 45 var array = require( '@stdlib/ndarray/array' ); 46 47 var x = array( new Float64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] ) ); 48 var y = array( new Float64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] ) ); 49 50 dswap( x, y ); 51 52 var xbuf = x.data; 53 // returns <Float64Array>[ 2.0, 6.0, -1.0, -4.0, 8.0 ] 54 55 var ybuf = y.data; 56 // returns <Float64Array>[ 4.0, 2.0, -3.0, 5.0, -1.0 ] 57 ``` 58 59 The function has the following parameters: 60 61 - **x**: a 1-dimensional [`ndarray`][@stdlib/ndarray/array] whose underlying data type is `float64`. 62 - **y**: a 1-dimensional [`ndarray`][@stdlib/ndarray/array] whose underlying data type is `float64`. 63 64 </section> 65 66 <!-- /.usage --> 67 68 <section class="notes"> 69 70 ## Notes 71 72 - `dswap()` provides a higher-level interface to the [BLAS][blas] level 1 function [`dswap`][@stdlib/blas/base/dswap]. 73 74 </section> 75 76 <!-- /.notes --> 77 78 <section class="examples"> 79 80 ## Examples 81 82 <!-- eslint no-undef: "error" --> 83 84 ```javascript 85 var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); 86 var Float64Array = require( '@stdlib/array/float64' ); 87 var array = require( '@stdlib/ndarray/array' ); 88 var dswap = require( '@stdlib/blas/dswap' ); 89 90 var x = array( new Float64Array( 10 ) ); 91 var y = array( new Float64Array( 10 ) ); 92 93 var rand1 = discreteUniform.factory( 0, 100 ); 94 var rand2 = discreteUniform.factory( 0, 10 ); 95 96 var i; 97 for ( i = 0; i < x.length; i++ ) { 98 x.set( i, rand1() ); 99 y.set( i, rand2() ); 100 } 101 console.log( x.data ); 102 console.log( y.data ); 103 104 dswap( x, y ); 105 console.log( x.data ); 106 console.log( y.data ); 107 ``` 108 109 </section> 110 111 <!-- /.examples --> 112 113 <section class="links"> 114 115 [blas]: http://www.netlib.org/blas 116 117 [@stdlib/blas/base/dswap]: https://www.npmjs.com/package/@stdlib/blas/tree/main/base/dswap 118 119 [@stdlib/ndarray/array]: https://www.npmjs.com/package/@stdlib/ndarray-array 120 121 </section> 122 123 <!-- /.links -->