time-to-botec

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

README.md (3099B)


      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 # isBufferLengthCompatibleShape
     22 
     23 > Determine if a buffer length is compatible with an array shape.
     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 <!-- eslint-disable id-length -->
     40 
     41 ```javascript
     42 var isBufferLengthCompatibleShape = require( '@stdlib/ndarray/base/assert/is-buffer-length-compatible-shape' );
     43 ```
     44 
     45 #### isBufferLengthCompatibleShape( len, shape )
     46 
     47 Returns a `boolean` indicating if a buffer `length` is compatible with a provided `shape` array.
     48 
     49 <!-- eslint-disable id-length -->
     50 
     51 ```javascript
     52 var shape = [ 2, 2 ];
     53 
     54 var bool = isBufferLengthCompatibleShape( 10, shape );
     55 // returns true
     56 
     57 bool = isBufferLengthCompatibleShape( 3, shape );
     58 // returns false
     59 ```
     60 
     61 </section>
     62 
     63 <!-- /.usage -->
     64 
     65 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     66 
     67 <section class="notes">
     68 
     69 </section>
     70 
     71 <!-- /.notes -->
     72 
     73 <!-- Package usage examples. -->
     74 
     75 <section class="examples">
     76 
     77 ## Examples
     78 
     79 <!-- eslint-disable id-length -->
     80 
     81 <!-- eslint no-undef: "error" -->
     82 
     83 ```javascript
     84 var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
     85 var isBufferLengthCompatibleShape = require( '@stdlib/ndarray/base/assert/is-buffer-length-compatible-shape' );
     86 
     87 var shape;
     88 var bool;
     89 var len;
     90 var i;
     91 
     92 len = 500; // buffer length
     93 
     94 shape = [ 0, 0, 0 ];
     95 for ( i = 0; i < 100; i++ ) {
     96     // Generate a random array shape:
     97     shape[ 0 ] = discreteUniform( 1, 10 );
     98     shape[ 1 ] = discreteUniform( 1, 10 );
     99     shape[ 2 ] = discreteUniform( 1, 10 );
    100 
    101     // Determine if the buffer length is compatible with the shape array:
    102     bool = isBufferLengthCompatibleShape( len, shape );
    103     console.log( 'Buffer length: %d. Shape: %s. Compatible: %s.', len, shape.join( 'x' ), bool );
    104 }
    105 ```
    106 
    107 </section>
    108 
    109 <!-- /.examples -->
    110 
    111 <!-- 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. -->
    112 
    113 <section class="references">
    114 
    115 </section>
    116 
    117 <!-- /.references -->
    118 
    119 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    120 
    121 <section class="links">
    122 
    123 </section>
    124 
    125 <!-- /.links -->