time-to-botec

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

README.md (4015B)


      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 # Kronecker Delta
     22 
     23 > Evaluate the [Kronecker delta][kronecker-delta] (single-precision).
     24 
     25 <section class="intro">
     26 
     27 The [Kronecker delta][kronecker-delta] is defined as
     28 
     29 <!-- <equation class="equation" label="eq:kronecker_delta" align="center" raw="\delta_{ij} = \begin{cases} 1 & \textrm{if}\ i = j \\ 0 & \textrm{if}\ i \neq j\end{cases}" alt="Kronecker delta."> -->
     30 
     31 <div class="equation" align="center" data-raw-text="\delta_{ij} = \begin{cases} 1 &amp; \textrm{if}\ i = j \\ 0 &amp; \textrm{if}\ i \neq j\end{cases}" data-equation="eq:kronecker_delta">
     32     <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@b245da8d5397f5cf6a71ec8a0147cf47d876eeb7/lib/node_modules/@stdlib/math/base/special/kronecker-deltaf/docs/img/equation_kronecker_delta.svg" alt="Kronecker delta.">
     33     <br>
     34 </div>
     35 
     36 <!-- </equation> -->
     37 
     38 </section>
     39 
     40 <!-- /.intro -->
     41 
     42 <section class="usage">
     43 
     44 ## Usage
     45 
     46 ```javascript
     47 var kroneckerDeltaf = require( '@stdlib/math/base/special/kronecker-deltaf' );
     48 ```
     49 
     50 #### kroneckerDeltaf( i, j )
     51 
     52 Evaluates the [Kronecker delta][kronecker-delta] (single-precision).
     53 
     54 ```javascript
     55 var v = kroneckerDeltaf( 3.14, 3.14 );
     56 // returns 1.0
     57 
     58 v = kroneckerDeltaf( 3.14, 0.0 );
     59 // returns 0.0
     60 
     61 v = kroneckerDeltaf( NaN, 3.14 );
     62 // returns NaN
     63 
     64 v = kroneckerDeltaf( 3.14, NaN );
     65 // returns NaN
     66 
     67 v = kroneckerDeltaf( NaN, NaN );
     68 // returns NaN
     69 ```
     70 
     71 </section>
     72 
     73 <!-- /.usage -->
     74 
     75 <section class="examples">
     76 
     77 ## Examples
     78 
     79 <!-- eslint no-undef: "error" -->
     80 
     81 ```javascript
     82 var linspace = require( '@stdlib/array/linspace' );
     83 var kroneckerDeltaf = require( '@stdlib/math/base/special/kronecker-deltaf' );
     84 
     85 var x = linspace( -1.0, 1.0, 101 );
     86 var i;
     87 
     88 for ( i = 0; i < x.length; i++ ) {
     89     console.log( 'kronecker(%d,%d) = %d', x[ i ], 0.0, kroneckerDeltaf( x[ i ], 0.0 ) );
     90 }
     91 ```
     92 
     93 </section>
     94 
     95 <!-- /.examples -->
     96 
     97 <!-- C interface documentation. -->
     98 
     99 * * *
    100 
    101 <section class="c">
    102 
    103 ## C APIs
    104 
    105 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
    106 
    107 <section class="intro">
    108 
    109 </section>
    110 
    111 <!-- /.intro -->
    112 
    113 <!-- C usage documentation. -->
    114 
    115 <section class="usage">
    116 
    117 ### Usage
    118 
    119 ```c
    120 #include "stdlib/math/base/special/kronecker_deltaf.h
    121 ```
    122 
    123 #### stdlib_base_kronecker_deltaf( i, j )
    124 
    125 Evaluates the Kronecker delta (single-precision).
    126 
    127 ```c
    128 float v = stdlib_base_kronecker_deltaf( 3.0f, 3.0f );
    129 // returns 1.0f
    130 ```
    131 
    132 The function accepts the following arguments:
    133 
    134 -   **i**: `[in] float` input value.
    135 -   **j**: `[in] float` input value.
    136 
    137 ```c
    138 float stdlib_base_kronecker_delta( const float i, const float j );
    139 ```
    140 
    141 </section>
    142 
    143 <!-- /.usage -->
    144 
    145 <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    146 
    147 <section class="notes">
    148 
    149 </section>
    150 
    151 <!-- /.notes -->
    152 
    153 <!-- C API usage examples. -->
    154 
    155 <section class="examples">
    156 
    157 ### Examples
    158 
    159 ```c
    160 #include "stdlib/math/base/special/kronecker_deltaf.h"
    161 #include <stdio.h>
    162 
    163 int main() {
    164     float x[] = { 3.0f, 4.0f, 5.0f, 5.0f };
    165 
    166     float y;
    167     int i;
    168     for ( i = 0; i < 4; i += 2 ) {
    169         y = stdlib_base_kronecker_deltaf( x[ i ], x[ i+1 ] );
    170         printf( "kronecker_delta(%f, %f) = %f\n", x[ i ], x[ i+1 ], y );
    171     }
    172 }
    173 ```
    174 
    175 </section>
    176 
    177 <!-- /.examples -->
    178 
    179 </section>
    180 
    181 <!-- /.c -->
    182 
    183 <section class="links">
    184 
    185 [kronecker-delta]: https://en.wikipedia.org/wiki/Kronecker_delta
    186 
    187 </section>
    188 
    189 <!-- /.links -->