8000 feat: add C implementation for `math/base/special/heaviside` by anandkaranubc · Pull Request #6972 · stdlib-js/stdlib · GitHub
[go: up one dir, main page]

Skip to content

feat: add C implementation for math/base/special/heaviside #6972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 21 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add support for enums
  • Loading branch information
anandkaranubc committed May 10, 2025
commit adfae95de9dea106910e088b868c3b4f1eb5857c
49 changes: 49 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2021 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';

// MAIN //

/**
* Returns an object mapping supported function continuity type strings to enumeration constants.
*
* @private
* @returns {Object} object mapping supported function continuity types to enumeration constants
*
* @example
* var table = enumeration();
* // returns <Object>
*/
function enumeration() {
return {
// Half-maximum:
'half-maximum': 0,
// Left-continuous:

Check failure on line 37 in lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Missing empty line before comment
'left-continuous': 1,
// Right-continuous:

Check failure on line 39 in lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Missing empty line before comment
'right-continuous': 2,
// Discontinuous:

Check failure on line 41 in lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Missing empty line before comment
'discontinuous': 3
};
}


// EXPORTS //

module.exports = enumeration;
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2021 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 objectInverse = require( '@stdlib/utils/object-inverse' );
var enumeration = require( './enum.js' );


// VARIABLES //

var hash = objectInverse( enumeration(), {
'duplicates': false
});


// MAIN //

/**
* Returns the data type string associated with a strided array data type enumeration constant.
*
* @param {integer} dtype - data type enumeration constant
* @returns {(string|null)} data type string or null
*
* @example
* var str2enum = require( '@stdlib/strided/base/dtype-str2enum' );
*
* var v = str2enum( 'float64' );
* // returns <number>
*
* var dt = enum2str( v );
* // returns 'float64'
*/
function enum2str( dtype ) {
var v = hash[ dtype ];
return ( typeof v === 'string' ) ? v : null; // note: we include this guard to prevent walking the prototype chain
}


// EXPORTS //

module.exports = enum2str;
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// MODULES //

var addon = require( './../src/addon.node' );
var str2enum = require( './str2enum.js' );


// MAIN //
Expand Down Expand Up @@ -54,7 +55,7 @@ var addon = require( './../src/addon.node' );
* // returns NaN
*/
function heaviside( x, continuity ) {
return addon( x, continuity );
return addon( x, str2enum( continuity ) );
}


Expand Down
Loading
0