From 633d7f2aca005e76a3f6cae2953c7e0c4316a5f6 Mon Sep 17 00:00:00 2001 From: Manvith <148960168+manvith2003@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:26:27 +0530 Subject: [PATCH 1/2] feat: add constants/float32/sqrt-half --- .../constants/float32/sqrt-half/README.md | 147 ++++++++++++++++++ .../constants/float32/sqrt-half/docs/repl.txt | 12 ++ .../float32/sqrt-half/docs/types/index.d.ts | 33 ++++ .../float32/sqrt-half/docs/types/test.ts | 28 ++++ .../float32/sqrt-half/examples/index.js | 24 +++ .../stdlib/constants/float64/sqrt_half.h | 27 ++++ .../constants/float32/sqrt-half/lib/index.js | 51 ++++++ .../constants/float32/sqrt-half/manifest.json | 36 +++++ .../constants/float32/sqrt-half/package.json | 69 ++++++++ .../constants/float32/sqrt-half/test/test.js | 40 +++++ 10 files changed, 467 insertions(+) create mode 100644 lib/node_modules/@stdlib/constants/float32/sqrt-half/README.md create mode 100644 lib/node_modules/@stdlib/constants/float32/sqrt-half/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/constants/float32/sqrt-half/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/constants/float32/sqrt-half/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/constants/float32/sqrt-half/examples/index.js create mode 100644 lib/node_modules/@stdlib/constants/float32/sqrt-half/include/stdlib/constants/float64/sqrt_half.h create mode 100644 lib/node_modules/@stdlib/constants/float32/sqrt-half/lib/index.js create mode 100644 lib/node_modules/@stdlib/constants/float32/sqrt-half/manifest.json create mode 100644 lib/node_modules/@stdlib/constants/float32/sqrt-half/package.json create mode 100644 lib/node_modules/@stdlib/constants/float32/sqrt-half/test/test.js diff --git a/lib/node_modules/@stdlib/constants/float32/sqrt-half/README.md b/lib/node_modules/@stdlib/constants/float32/sqrt-half/README.md new file mode 100644 index 000000000000..5d12735f7e36 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/sqrt-half/README.md @@ -0,0 +1,147 @@ + + +# FLOAT32_SQRT_HALF + +> [Square root][@stdlib/math/base/special/sqrtf] of `1/2` as a single-precision floating-point number. + +
+ +## Usage + +```javascript +var FLOAT32_SQRT_HALF = require( '@stdlib/constants/float32/sqrt-half' ); +``` + +#### FLOAT32_SQRT_HALF + +[Square root][@stdlib/math/base/special/sqrtf] of `1/2` as a single-precision floating-point number. + +```javascript +var bool = ( FLOAT32_SQRT_HALF === 0.7071067690849304 ); +// returns true +``` + +
+ + + +
+ +## Examples + + + + + +```javascript +var FLOAT32_SQRT_HALF = require( '@stdlib/constants/float32/sqrt-half' ); + +console.log( FLOAT32_SQRT_HALF ); +// => 0.7071067690849304 +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/constants/float32/sqrt_half.h" +``` + +#### STDLIB_CONSTANT_FLOAT64_SQRT_HALF + +Macro for the [square root][@stdlib/math/base/special/sqrtf] of `1/2` as a single-precision floating-point number. + +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/constants/float32/sqrt-half/docs/repl.txt b/lib/node_modules/@stdlib/constants/float32/sqrt-half/docs/repl.txt new file mode 100644 index 000000000000..78cf9befb202 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/sqrt-half/docs/repl.txt @@ -0,0 +1,12 @@ + +{{alias}} + Square root of `1/2` as a single-precision floating-point number. + + Examples + -------- + > {{alias}} + 0.7071067690849304 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/constants/float32/sqrt-half/docs/types/index.d.ts b/lib/node_modules/@stdlib/constants/float32/sqrt-half/docs/types/index.d.ts new file mode 100644 index 000000000000..77b5a0db3f8c --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/sqrt-half/docs/types/index.d.ts @@ -0,0 +1,33 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Square root of `1/2` as a single-precision floating-point number. +* +* @example +* var val = FLOAT32_SQRT_HALF; +* // returns 0.7071067690849304 +*/ +declare const FLOAT32_SQRT_HALF: number; + + +// EXPORTS // + +export = FLOAT32_SQRT_HALF; diff --git a/lib/node_modules/@stdlib/constants/float32/sqrt-half/docs/types/test.ts b/lib/node_modules/@stdlib/constants/float32/sqrt-half/docs/types/test.ts new file mode 100644 index 000000000000..6dc670fc7229 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/sqrt-half/docs/types/test.ts @@ -0,0 +1,28 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import FLOAT32_SQRT_HALF = require( './index' ); + + +// TESTS // + +// The export is a number... +{ + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + FLOAT32_SQRT_HALF; // $ExpectType number +} diff --git a/lib/node_modules/@stdlib/constants/float32/sqrt-half/examples/index.js b/lib/node_modules/@stdlib/constants/float32/sqrt-half/examples/index.js new file mode 100644 index 000000000000..91b981a20688 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/sqrt-half/examples/index.js @@ -0,0 +1,24 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var FLOAT32_SQRT_HALF = require( './../lib' ); + +console.log( FLOAT32_SQRT_HALF ); +// => 0.7071067690849304 diff --git a/lib/node_modules/@stdlib/constants/float32/sqrt-half/include/stdlib/constants/float64/sqrt_half.h b/lib/node_modules/@stdlib/constants/float32/sqrt-half/include/stdlib/constants/float64/sqrt_half.h new file mode 100644 index 000000000000..00d381505943 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/sqrt-half/include/stdlib/constants/float64/sqrt_half.h @@ -0,0 +1,27 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_CONSTANTS_FLOAT32_SQRT_HALF_H +#define STDLIB_CONSTANTS_FLOAT32_SQRT_HALF_H + +/** +* Macro for the square root of 1/2 as a single-precision floating-point number. +*/ +#define STDLIB_CONSTANT_FLOAT32_SQRT_HALF 0.7071067690849304f + +#endif // !STDLIB_CONSTANTS_FLOAT32_SQRT_HALF_H diff --git a/lib/node_modules/@stdlib/constants/float32/sqrt-half/lib/index.js b/lib/node_modules/@stdlib/constants/float32/sqrt-half/lib/index.js new file mode 100644 index 000000000000..f1f357560ca6 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/sqrt-half/lib/index.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Square root of `1/2` as a single-precision floating-point number. +* +* @module @stdlib/constants/float32/sqrt-half +* @type {number} +* +* @example +* var FLOAT32_SQRT_HALF = require( '@stdlib/constants/float32/sqrt-half' ); +* // returns 0.7071067690849304 +*/ + + +// MAIN // + +/** +* Square root of `1/2` as a single-precision floating-point number. +* +* ```tex +* \sqrt{\frac{1}{2}} +* ``` +* +* @constant +* @type {number} +* @default 0.7071067690849304 +*/ +var FLOAT32_SQRT_HALF = 0.7071067690849304; + + +// EXPORTS // + +module.exports = FLOAT32_SQRT_HALF; diff --git a/lib/node_modules/@stdlib/constants/float32/sqrt-half/manifest.json b/lib/node_modules/@stdlib/constants/float32/sqrt-half/manifest.json new file mode 100644 index 000000000000..844d692f6439 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/sqrt-half/manifest.json @@ -0,0 +1,36 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [] + } + ] +} diff --git a/lib/node_modules/@stdlib/constants/float32/sqrt-half/package.json b/lib/node_modules/@stdlib/constants/float32/sqrt-half/package.json new file mode 100644 index 000000000000..b14d601552eb --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/sqrt-half/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/constants/float32/sqrt-half", + "version": "0.0.0", + "description": "Square root of 1/2 as a single-precision floating-point number.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "constant", + "const", + "mathematics", + "math", + "sqrt", + "square", + "root", + "half", + "sqrt1_2", + "math.sqrt1_2", + "ieee754", + "single", + "floating-point", + "float32" + ] +} diff --git a/lib/node_modules/@stdlib/constants/float32/sqrt-half/test/test.js b/lib/node_modules/@stdlib/constants/float32/sqrt-half/test/test.js new file mode 100644 index 000000000000..a0429ffe3b4e --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float32/sqrt-half/test/test.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var sqrtf = require( '@stdlib/math/base/special/sqrtf' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var FLOAT32_SQRT_HALF = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a number', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof FLOAT32_SQRT_HALF, 'number', 'main export is a number' ); + t.end(); +}); + +tape( 'the exported value is a single-precision floating-point number equal to the square root of 1/2', function test( t ) { + t.equal( FLOAT32_SQRT_HALF, float64ToFloat32( sqrtf( 1/2 ) ), 'equals sqrtf(1/2)' ); + t.end(); +}); From 6de72958993167fe3ebb49d71ac9840394095f31 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sat, 7 Dec 2024 19:59:48 +0000 Subject: [PATCH 2/2] fix: resolve lint errors --- .../@stdlib/constants/float32/sqrt-half/README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/node_modules/@stdlib/constants/float32/sqrt-half/README.md b/lib/node_modules/@stdlib/constants/float32/sqrt-half/README.md index 5d12735f7e36..4d23e3590006 100644 --- a/lib/node_modules/@stdlib/constants/float32/sqrt-half/README.md +++ b/lib/node_modules/@stdlib/constants/float32/sqrt-half/README.md @@ -120,12 +120,6 @@ Macro for the [square root][@stdlib/math/base/special/sqrtf] of `1/2` as a singl @@ -138,8 +132,6 @@ Macro for the [square root][@stdlib/math/base/special/sqrtf] of `1/2` as a singl -[@stdlib/constants/float32/ln-two]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/constants/float32/ln-two -