time-to-botec

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

README.md (2947B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 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 # Casting Modes
     22 
     23 > List of ndarray casting modes.
     24 
     25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     26 
     27 <section class="intro">
     28 
     29 </section>
     30 
     31 <!-- /.intro -->
     32 
     33 <!-- Package usage documentation. -->
     34 
     35 <section class="usage">
     36 
     37 ## Usage
     38 
     39 ```javascript
     40 var modes = require( '@stdlib/ndarray/casting-modes' );
     41 ```
     42 
     43 #### modes()
     44 
     45 Returns a list of ndarray casting modes.
     46 
     47 ```javascript
     48 var out = modes();
     49 // returns [ 'none', 'equiv', 'safe', 'same-kind', 'unsafe' ]
     50 ```
     51 
     52 The output `array` contains the following modes:
     53 
     54 -   `none`: only allow casting between identical types.
     55 -   `equiv`: allow casting between identical and byte swapped types.
     56 -   `safe`: only allow "safe" casts.
     57 -   `same-kind`: allow "safe" casts and casts within the same kind (e.g., between signed integers or between floats).
     58 -   `unsafe`: allow casting between all types (including between integers and floats).
     59 
     60 </section>
     61 
     62 <!-- /.usage -->
     63 
     64 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     65 
     66 <section class="notes">
     67 
     68 </section>
     69 
     70 <!-- /.notes -->
     71 
     72 <!-- Package usage examples. -->
     73 
     74 <section class="examples">
     75 
     76 ## Examples
     77 
     78 <!-- eslint no-undef: "error" -->
     79 
     80 ```javascript
     81 var indexOf = require( '@stdlib/utils/index-of' );
     82 var modes = require( '@stdlib/ndarray/casting-modes' );
     83 
     84 var MODES = modes();
     85 var bool;
     86 
     87 function isMode( str ) {
     88     if ( indexOf( MODES, str ) === -1 ) {
     89         return false;
     90     }
     91     return true;
     92 }
     93 
     94 bool = isMode( 'none' );
     95 // returns true
     96 
     97 bool = isMode( 'equiv' );
     98 // returns true
     99 
    100 bool = isMode( 'safe' );
    101 // returns true
    102 
    103 bool = isMode( 'same-kind' );
    104 // returns true
    105 
    106 bool = isMode( 'unsafe' );
    107 // returns true
    108 
    109 bool = isMode( 'beep' );
    110 // returns false
    111 ```
    112 
    113 </section>
    114 
    115 <!-- /.examples -->
    116 
    117 <!-- 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. -->
    118 
    119 <section class="references">
    120 
    121 </section>
    122 
    123 <!-- /.references -->
    124 
    125 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    126 
    127 <section class="links">
    128 
    129 </section>
    130 
    131 <!-- /.links -->