|
| 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 | +# Coversine |
| 22 | + |
| 23 | +> Compute the [coversed sine][coversed-sine] of a single-precision floating-point number (in radians). |
| 24 | +
|
| 25 | +<section class="intro"> |
| 26 | + |
| 27 | +The [coversed sine][coversed-sine] is defined as |
| 28 | + |
| 29 | +<!-- <equation class="equation" label="eq:coversine" align="center" raw="\operatorname{coversin}(\theta) = 1 - \sin \theta" alt="Coversed sine."> --> |
| 30 | + |
| 31 | +```math |
| 32 | +\mathop{\mathrm{coversin}}(\theta) = 1 - \sin \theta |
| 33 | +``` |
| 34 | + |
| 35 | +<!-- <div class="equation" align="center" data-raw-text="\operatorname{coversin}(\theta) = 1 - \sin \theta" data-equation="eq:coversine"> |
| 36 | + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/coversin/docs/img/equation_coversine.svg" alt="Coversed sine."> |
| 37 | + <br> |
| 38 | +</div> --> |
| 39 | + |
| 40 | +<!-- </equation> --> |
| 41 | + |
| 42 | +</section> |
| 43 | + |
| 44 | +<!-- /.intro --> |
| 45 | + |
| 46 | +<section class="usage"> |
| 47 | + |
| 48 | +## Usage |
| 49 | + |
| 50 | +```javascript |
| 51 | +var coversinf = require( '@stdlib/math/base/special/coversinf' ); |
| 52 | +``` |
| 53 | + |
| 54 | +#### coversinf( x ) |
| 55 | + |
| 56 | +Computes the [coversed sine][coversed-sine] of a single-precision floating-point number (in radians). |
| 57 | + |
| 58 | +```javascript |
| 59 | +var v = coversinf( 0.0 ); |
| 60 | +// returns 1.0 |
| 61 | + |
| 62 | +v = coversinf( 3.141592653589793/2.0 ); |
| 63 | +// returns 0.0 |
| 64 | + |
| 65 | +v = coversinf( -3.141592653589793/6.0 ); |
| 66 | +// returns 1.5 |
| 67 | +``` |
| 68 | + |
| 69 | +</section> |
| 70 | + |
| 71 | +<!-- /.usage --> |
| 72 | + |
| 73 | +<section class="examples"> |
| 74 | + |
| 75 | +## Examples |
| 76 | + |
| 77 | +<!-- eslint no-undef: "error" --> |
| 78 | + |
| 79 | +```javascript |
| 80 | +var uniform = require( '@stdlib/random/array/uniform' ); |
| 81 | +var logEachMap = require( '@stdlib/console/log-each-map' ); |
| 82 | +var TWO_PI = require( '@stdlib/constants/float32/two-pi' ); |
| 83 | +var coversinf = require( '@stdlib/math/base/special/coversinf' ); |
| 84 | + |
| 85 | +var opts = { |
| 86 | + 'dtype': 'float32' |
| 87 | +}; |
| 88 | +var x = uniform( 100, 0.0, TWO_PI, opts ); |
| 89 | + |
| 90 | +logEachMap( 'coversinf(%0.4f) = %0.4f', x, coversinf ); |
| 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/coversinf.h" |
| 121 | +``` |
| 122 | + |
| 123 | +#### stdlib_base_coversinf( x ) |
| 124 | + |
| 125 | +Computes the [coversed sine][coversed-sine] of a single-precision floating-point number (in radians). |
| 126 | + |
| 127 | +```c |
| 128 | +float out = stdlib_base_coversinf( 0.0f ); |
| 129 | +// returns 1.0f |
| 130 | + |
| 131 | +out = stdlib_base_coversinf( 3.141592653589793f / 2.0f ); |
| 132 | +// returns 0.0f |
| 133 | +``` |
| 134 | + |
| 135 | +The function accepts the following arguments: |
| 136 | + |
| 137 | +- **x**: `[in] float` input value. |
| 138 | + |
| 139 | +```c |
| 140 | +float stdlib_base_coversinf( const float x ); |
| 141 | +``` |
| 142 | +
|
| 143 | +</section> |
| 144 | +
|
| 145 | +<!-- /.usage --> |
| 146 | +
|
| 147 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 148 | +
|
| 149 | +<section class="notes"> |
| 150 | +
|
| 151 | +</section> |
| 152 | +
|
| 153 | +<!-- /.notes --> |
| 154 | +
|
| 155 | +<!-- C API usage examples. --> |
| 156 | +
|
| 157 | +<section class="examples"> |
| 158 | +
|
| 159 | +### Examples |
| 160 | +
|
| 161 | +```c |
| 162 | +#include "stdlib/math/base/special/coversinf.h" |
| 163 | +#include <stdio.h> |
| 164 | +
|
| 165 | +int main( void ) { |
| 166 | + const float x[] = { 0.0f, 0.523f, 0.785f, 1.047f, 3.14f }; |
| 167 | +
|
| 168 | + float y; |
| 169 | + int i; |
| 170 | + for ( i = 0; i < 5; i++ ) { |
| 171 | + y = stdlib_base_coversinf( x[ i ] ); |
| 172 | + printf( "coversinf(%f) = %f\n", x[ i ], y ); |
| 173 | + } |
| 174 | +} |
| 175 | +``` |
| 176 | + |
| 177 | +</section> |
| 178 | + |
| 179 | +<!-- /.examples --> |
| 180 | + |
| 181 | +</section> |
| 182 | + |
| 183 | +<!-- /.c --> |
| 184 | + |
| 185 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 186 | + |
| 187 | +<section class="related"> |
| 188 | + |
| 189 | +</section> |
| 190 | + |
| 191 | +<!-- /.related --> |
| 192 | + |
| 193 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 194 | + |
| 195 | +<section class="links"> |
| 196 | + |
| 197 | +[coversed-sine]: https://en.wikipedia.org/wiki/Versine |
| 198 | + |
| 199 | +<!-- <related-links> --> |
| 200 | + |
| 201 | +<!-- </related-links> --> |
| 202 | + |
| 203 | +</section> |
| 204 | + |
| 205 | +<!-- /.links --> |
0 commit comments