Skip to content

Commit 5a4f6ed

Browse files
vivekmaurya001kgrytegunjjoshistdlib-bot
authored
feat: add constants/float32/ln-half
PR-URL: #3333 Closes: #3332 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]> Signed-off-by: Gunj Joshi <[email protected]> Signed-off-by: Athan <[email protected]> Co-authored-by: Gunj Joshi <[email protected]> Co-authored-by: stdlib-bot <[email protected]>
1 parent a04a9e3 commit 5a4f6ed

File tree

10 files changed

+476
-0
lines changed

10 files changed

+476
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2024 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+
# FLOAT32_LN_HALF
22+
23+
> [Natural logarithm][@stdlib/math/base/special/lnf] of `1/2` as a single-precision floating-point number.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var FLOAT32_LN_HALF = require( '@stdlib/constants/float32/ln-half' );
31+
```
32+
33+
#### FLOAT32_LN_HALF
34+
35+
[Natural logarithm][@stdlib/math/base/special/lnf] of `1/2` as a single-precision floating-point number.
36+
37+
```javascript
38+
var bool = ( FLOAT32_LN_HALF === -0.6931471824645996 );
39+
// returns true
40+
```
41+
42+
</section>
43+
44+
<!-- /.usage -->
45+
46+
<section class="examples">
47+
48+
## Examples
49+
50+
<!-- TODO: better example -->
51+
52+
<!-- eslint no-undef: "error" -->
53+
54+
```javascript
55+
var FLOAT32_LN_HALF = require( '@stdlib/constants/float32/ln-half' );
56+
57+
console.log( FLOAT32_LN_HALF );
58+
// => -0.6931471824645996
59+
```
60+
61+
</section>
62+
63+
<!-- /.examples -->
64+
65+
<!-- C interface documentation. -->
66+
67+
* * *
68+
69+
<section class="c">
70+
71+
## C APIs
72+
73+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
74+
75+
<section class="intro">
76+
77+
</section>
78+
79+
<!-- /.intro -->
80+
81+
<!-- C usage documentation. -->
82+
83+
<section class="usage">
84+
85+
### Usage
86+
87+
```c
88+
#include "stdlib/constants/float32/ln_half.h"
89+
```
90+
91+
#### STDLIB_CONSTANT_FLOAT32_LN_HALF
92+
93+
Macro for the [natural logarithm][@stdlib/math/base/special/lnf] of `1/2` as a single-precision floating-point number.
94+
95+
</section>
96+
97+
<!-- /.usage -->
98+
99+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
100+
101+
<section class="notes">
102+
103+
</section>
104+
105+
<!-- /.notes -->
106+
107+
<!-- C API usage examples. -->
108+
109+
<section class="examples">
110+
111+
</section>
112+
113+
<!-- /.examples -->
114+
115+
</section>
116+
117+
<!-- /.c -->
118+
119+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
120+
121+
<section class="related">
122+
123+
</section>
124+
125+
<!-- /.related -->
126+
127+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
128+
129+
<section class="links">
130+
131+
[@stdlib/math/base/special/lnf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/ln
132+
133+
</section>
134+
135+
<!-- /.links -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
{{alias}}
3+
Natural logarithm of `1/2` as a single-precision floating-point number.
4+
5+
Examples
6+
--------
7+
> {{alias}}
8+
-0.6931471824645996
9+
10+
See Also
11+
--------
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 4.1
20+
21+
/**
22+
* Natural logarithm of `1/2` as a single-precision floating-point number.
23+
*
24+
* @example
25+
* var val = FLOAT32_LN_HALF;
26+
* // returns -0.6931471824645996
27+
*/
28+
declare const FLOAT32_LN_HALF: number;
29+
30+
31+
// EXPORTS //
32+
33+
export = FLOAT32_LN_HALF;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import FLOAT32_LN_HALF = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The export is a number...
25+
{
26+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
27+
FLOAT32_LN_HALF; // $ExpectType number
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
var FLOAT32_LN_HALF = require( './../lib' );
22+
23+
console.log( FLOAT32_LN_HALF );
24+
// => -0.6931471824645996
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#ifndef STDLIB_CONSTANTS_FLOAT32_LN_HALF_H
20+
#define STDLIB_CONSTANTS_FLOAT32_LN_HALF_H
21+
22+
/**
23+
* Macro for the natural logarithm of 1/2 as a single-precision floating-point number.
24+
*/
25+
#define STDLIB_CONSTANT_FLOAT32_LN_HALF -0.6931471824645996f
26+
27+
#endif // !STDLIB_CONSTANTS_FLOAT32_LN_HALF_H
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
/**
22+
* Natural logarithm of `1/2` as a single-precision floating-point number.
23+
*
24+
* @module @stdlib/constants/float32/ln-half
25+
* @type {number}
26+
*
27+
* @example
28+
* var LN_HALF = require( '@stdlib/constants/float32/ln-half' );
29+
* // returns -0.6931471824645996
30+
*/
31+
32+
// MODULES //
33+
34+
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
35+
36+
37+
// MAIN //
38+
39+
/**
40+
* Natural logarithm of `1/2` as a single-precision floating-point number.
41+
*
42+
* ```tex
43+
* \ln (1/2)
44+
* ```
45+
*
46+
* @constant
47+
* @type {number}
48+
* @default -0.6931471824645996
49+
*/
50+
var FLOAT32_LN_HALF = float64ToFloat32(-0.69314718055994530941723212145817656807550013436025525412); // eslint-disable-line max-len
51+
52+
53+
// EXPORTS //
54+
55+
module.exports = FLOAT32_LN_HALF;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"options": {},
3+
"fields": [
4+
{
5+
"field": "src",
6+
"resolve": true,
7+
"relative": true
8+
},
9+
{
10+
"field": "include",
11+
"resolve": true,
12+
"relative": true
13+
},
14+
{
15+
"field": "libraries",
16+
"resolve": false,
17+
"relative": false
18+
},
19+
{
20+
"field": "libpath",
21+
"resolve": true,
22+
"relative": false
23+
}
24+
],
25+
"confs": [
26+
{
27+
"src": [],
28+
"include": [
29+
"./include"
30+
],
31+
"libraries": [],
32+
"libpath": [],
33+
"dependencies": []
34+
}
35+
]
36+
}

0 commit comments

Comments
 (0)