|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 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 | +# dtypeChars |
| 22 | + |
| 23 | +> List of ndarray data type single letter character abbreviations. |
| 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 dtypeChars = require( '@stdlib/ndarray/base/dtype-chars' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### dtypeChars( \[kind] ) |
| 44 | + |
| 45 | +Returns a list of ndarray data type single letter character abbreviations. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var out = dtypeChars(); |
| 49 | +// e.g., returns [ 'r', 'j', 'c', 'z', ... ] |
| 50 | +``` |
| 51 | + |
| 52 | +When not provided a data type "kind", the function returns an array containing the single letter character abbreviations for all support ndarray [data types][@stdlib/ndarray/dtypes]. To return the subset of data type single letter character abbreviations belonging to a specified data type kind, provide a `kind` argument. |
| 53 | + |
| 54 | +```javascript |
| 55 | +var out = dtypeChars( 'floating_point' ); |
| 56 | +// returns [...] |
| 57 | +``` |
| 58 | + |
| 59 | +The function supports the following data type kinds: |
| 60 | + |
| 61 | +- `floating_point`: floating-point data types. |
| 62 | +- `real_floating_point`: real-valued floating-point data types. |
| 63 | +- `complex_floating_point`: complex-valued floating-point data types. |
| 64 | +- `boolean`: boolean data types. |
| 65 | +- `integer`: integer data types. |
| 66 | +- `signed_integer`: signed integer data types. |
| 67 | +- `unsigned_integer`: unsigned integer data types. |
| 68 | +- `real`: real-valued data types. |
| 69 | +- `numeric`: numeric data types. |
| 70 | +- `typed`: typed data types. |
| 71 | +- `integer_index`: integer index data types. |
| 72 | +- `boolean_index`: boolean index data types. |
| 73 | +- `mask_index`: mask index data types. |
| 74 | +- `typed_index`: typed index data types. |
| 75 | +- `index`: index data types. |
| 76 | +- `all`: all data types. |
| 77 | + |
| 78 | +Additionally, the function supports extending the "kinds" listed above by appending an `_and_generic` suffix to the kind name (e.g., `real_and_generic`). |
| 79 | + |
| 80 | +```javascript |
| 81 | +var out = dtypeChars( 'floating_point_and_generic' ); |
| 82 | +// returns [...] |
| 83 | +``` |
| 84 | + |
| 85 | +</section> |
| 86 | + |
| 87 | +<!-- /.usage --> |
| 88 | + |
| 89 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 90 | + |
| 91 | +<section class="notes"> |
| 92 | + |
| 93 | +</section> |
| 94 | + |
| 95 | +<!-- /.notes --> |
| 96 | + |
| 97 | +<!-- Package usage examples. --> |
| 98 | + |
| 99 | +<section class="examples"> |
| 100 | + |
| 101 | +## Examples |
| 102 | + |
| 103 | +<!-- eslint no-undef: "error" --> |
| 104 | + |
| 105 | +```javascript |
| 106 | +var contains = require( '@stdlib/array/base/assert/contains' ).factory; |
| 107 | +var dtypeChars = require( '@stdlib/ndarray/base/dtype-chars' ); |
| 108 | + |
| 109 | +var isdtypeChar = contains( dtypeChars() ); |
| 110 | + |
| 111 | +var bool = isdtypeChar( 'd' ); |
| 112 | +// returns true |
| 113 | + |
| 114 | +bool = isdtypeChar( 'k' ); |
| 115 | +// returns true |
| 116 | + |
| 117 | +bool = isdtypeChar( 'b' ); |
| 118 | +// returns true |
| 119 | + |
| 120 | +bool = isdtypeChar( '~' ); |
| 121 | +// returns false |
| 122 | +``` |
| 123 | + |
| 124 | +</section> |
| 125 | + |
| 126 | +<!-- /.examples --> |
| 127 | + |
| 128 | +<!-- 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. --> |
| 129 | + |
| 130 | +<section class="references"> |
| 131 | + |
| 132 | +</section> |
| 133 | + |
| 134 | +<!-- /.references --> |
| 135 | + |
| 136 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 137 | + |
| 138 | +<section class="related"> |
| 139 | + |
| 140 | +</section> |
| 141 | + |
| 142 | +<!-- /.related --> |
| 143 | + |
| 144 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 145 | + |
| 146 | +<section class="links"> |
| 147 | + |
| 148 | +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray/tree/main/dtypes |
| 149 | + |
| 150 | +</section> |
| 151 | + |
| 152 | +<!-- /.links --> |
0 commit comments