time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (2691B)


      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 # gswap
     22 
     23 > Interchange two 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 gswap = require( '@stdlib/blas/gswap' );
     37 ```
     38 
     39 #### gswap( x, y )
     40 
     41 Interchanges two 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 gswap( 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] or an array-like object.
     62 -   **y**: a 1-dimensional [`ndarray`][@stdlib/ndarray/array] or an array-like object.
     63 
     64 </section>
     65 
     66 <!-- /.usage -->
     67 
     68 <section class="notes">
     69 
     70 ## Notes
     71 
     72 -   `gswap()` provides a higher-level interface to the [BLAS][blas] level 1 function [`gswap`][@stdlib/blas/base/gswap].
     73 -   In general, for best performance, especially for large vectors, provide 1-dimensional [`ndarrays`][@stdlib/ndarray/array] whose underlying data type is either `float64` or `float32`.
     74 
     75 </section>
     76 
     77 <!-- /.notes -->
     78 
     79 <section class="examples">
     80 
     81 ## Examples
     82 
     83 <!-- eslint no-undef: "error" -->
     84 
     85 ```javascript
     86 var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
     87 var gswap = require( '@stdlib/blas/gswap' );
     88 
     89 var rand1 = discreteUniform.factory( 0, 100 );
     90 var rand2 = discreteUniform.factory( 0, 10 );
     91 
     92 var x = [];
     93 var y = [];
     94 var i;
     95 for ( i = 0; i < 10; i++ ) {
     96     x.push( rand1() );
     97     y.push( rand2() );
     98 }
     99 console.log( x );
    100 console.log( y );
    101 
    102 gswap( x, y );
    103 console.log( x );
    104 console.log( y );
    105 ```
    106 
    107 </section>
    108 
    109 <!-- /.examples -->
    110 
    111 <section class="links">
    112 
    113 [blas]: http://www.netlib.org/blas
    114 
    115 [@stdlib/blas/base/gswap]: https://www.npmjs.com/package/@stdlib/blas/tree/main/base/gswap
    116 
    117 [@stdlib/ndarray/array]: https://www.npmjs.com/package/@stdlib/ndarray-array
    118 
    119 </section>
    120 
    121 <!-- /.links -->