README.md (3102B)
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 # Contiguous Data Buffer 22 23 > Create a zero-filled contiguous linear ndarray data buffer. 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 buffer = require( '@stdlib/ndarray/base/buffer' ); 41 ``` 42 43 #### buffer( dtype, size ) 44 45 Returns a zero-filled contiguous linear ndarray data buffer. 46 47 ```javascript 48 var buf = buffer( 'float64', 3 ); 49 // returns <Float64Array>[ 0.0, 0.0, 0.0 ] 50 ``` 51 52 The function supports the following data types: 53 54 - `binary`: binary. 55 - `complex64`: single-precision complex floating-point numbers. 56 - `complex128`: double-precision complex floating-point numbers. 57 - `float32`: single-precision floating-point numbers. 58 - `float64`: double-precision floating-point numbers. 59 - `generic`: values of any type. 60 - `int16`: signed 16-bit integers. 61 - `int32`: signed 32-bit integers. 62 - `int8`: signed 8-bit integers. 63 - `uint16`: unsigned 16-bit integers. 64 - `uint32`: unsigned 32-bit integers. 65 - `uint8`: unsigned 8-bit integers. 66 - `uint8c`: unsigned clamped 8-bit integers. 67 68 If provided an unknown or unsupported data type, the function returns `null`. 69 70 ```javascript 71 var buf = buffer( 'float', 3 ); 72 // returns null 73 ``` 74 75 </section> 76 77 <!-- /.usage --> 78 79 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 80 81 <section class="notes"> 82 83 </section> 84 85 <!-- /.notes --> 86 87 <!-- Package usage examples. --> 88 89 <section class="examples"> 90 91 ## Examples 92 93 <!-- eslint no-undef: "error" --> 94 95 ```javascript 96 var dtypes = require( '@stdlib/ndarray/dtypes' ); 97 var buffer = require( '@stdlib/ndarray/base/buffer' ); 98 99 var DTYPES = dtypes(); 100 var buf; 101 var i; 102 103 for ( i = 0; i < DTYPES.length; i++ ) { 104 buf = buffer( DTYPES[ i ], 10 ); 105 console.log( buf ); 106 } 107 ``` 108 109 </section> 110 111 <!-- /.examples --> 112 113 <!-- 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. --> 114 115 <section class="references"> 116 117 </section> 118 119 <!-- /.references --> 120 121 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 122 123 <section class="links"> 124 125 </section> 126 127 <!-- /.links -->