@stdlib/ndarray-base-function-object

C APIs for creating and managing ndarray function objects.

https://github.com/stdlib-js/ndarray-base-function-object

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.0%) to scientific vocabulary

Keywords

base c fcn function javascript n-api napi ndarray node node-js nodejs stdlib
Last synced: 4 months ago · JSON representation ·

Repository

C APIs for creating and managing ndarray function objects.

Basic Info
Statistics
  • Stars: 2
  • Watchers: 3
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
base c fcn function javascript n-api napi ndarray node node-js nodejs stdlib
Created over 4 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security

README.md

About stdlib...

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

Function Object

NPM version Build Status Coverage Status <!-- dependencies -->

C APIs for creating and managing ndarray function objects.

## Installation ```bash npm install @stdlib/ndarray-base-function-object ``` Alternatively, - To load the package in a website via a `script` tag without installation and bundlers, use the [ES Module][es-module] available on the [`esm`][esm-url] branch (see [README][esm-readme]). - If you are using Deno, visit the [`deno`][deno-url] branch (see [README][deno-readme] for usage intructions). - For use in Observable, or in browser/node environments, use the [Universal Module Definition (UMD)][umd] build available on the [`umd`][umd-url] branch (see [README][umd-readme]). The [branches.md][branches-url] file summarizes the available branches and displays a diagram illustrating their relationships. To view installation and usage instructions specific to each branch build, be sure to explicitly navigate to the respective README files on each branch, as linked to above.
## Usage ```javascript var headerDir = require( '@stdlib/ndarray-base-function-object' ); ``` #### headerDir Absolute file path for the directory containing header files for C APIs. ```javascript var dir = headerDir; // returns ```
## Examples ```javascript var headerDir = require( '@stdlib/ndarray-base-function-object' ); console.log( headerDir ); ```

## C APIs
### Usage ```c #include "stdlib/ndarray/base/function_object.h" ``` #### ndarrayFunctionObject Structure for grouping ndarray function information. ```c struct ndarrayFunctionObject { // ndarray function name: const char *name; // Number of input ndarrays: int32_t nin; // Number of output ndarrays: int32_t nout; // Total number of ndarray arguments (nin + nout): int32_t narrays; // Array containing ndarray functions: ndarrayFcn *functions; // Number of ndarray functions: int32_t nfunctions; // Array of type "numbers" (as enumerated elsewhere), where the total number of types equals `narrays * nfunctions` and where each set of `narrays` consecutive types (non-overlapping) corresponds to the set of ndarray argument types for a corresponding ndarray function: int32_t *types; // Array of void pointers corresponding to the "data" (e.g., callbacks) which should be passed to a respective ndarray function (note: the number of pointers should match the number of ndarray functions): void **data; }; ``` #### ndarrayFcn Function pointer type for an ndarray function. ```c typedef int8_t (*ndarrayFcn)( struct ndarray *arrays[], void *data ); ``` An `ndarrayFcn` function should accept the following arguments: - **arrays**: `[in] struct ndarray**` array containing pointers to input and output ndarrays. - **data**: `[in] void*` function data (e.g., a callback). An `ndarrayFcn` function should return a status code (with `0` indicating success). #### stdlib_ndarray_function_allocate( \_name, nin, nout, \_functions, nfunctions, \_types, \_data\[] ) Returns a pointer to a dynamically allocated ndarray function object. ```c #include "stdlib/ndarray/base/unary.h" #include "stdlib/ndarray/dtypes.h" #include #include // Define the function(s) we want to apply to ndarrays: double scale( const double x ) { return x * 10.0; } // Define a function name: const char name[] = "unary_ndarray_function"; // Define a list of ndarray functions (in this case, as the function to be applied accepts doubles, we only use ndarray functions which handle doubles as function arguments and, for the purposes of this example, we assume that the output ndarray is always a double-precision floating-point number array): ndarrayFcn functions[] = { stdlib_ndarray_d_d, stdlib_ndarray_f_f_as_d_d, stdlib_ndarray_u_d_as_d_d, stdlib_ndarray_i_d_as_d_d, stdlib_ndarray_t_d_as_d_d, stdlib_ndarray_k_d_as_d_d, stdlib_ndarray_b_d_as_d_d, stdlib_ndarray_s_d_as_d_d }; // Define the **ndarray** argument types for each ndarray function: int32_t types[] = { STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64 }; // Define a list of ndarray function "data" (in this case, callbacks): void *data[] = { (void *)scale, (void *)scale, (void *)scale, (void *)scale, (void *)scale, (void *)scale, (void *)scale, (void *)scale }; // Create a new ndarray function object: struct ndarrayFunctionObject *obj = stdlib_ndarray_function_allocate( name, 1, 1, functions, 8, types, data ); if ( obj == NULL ) { fprintf( stderr, "Error allocating memory.\n" ); exit( 1 ); } // Free allocated memory: stdlib_ndarray_function_free( obj ); ``` The function accepts the following arguments: - **name**: `[in] char*` ndarray function name. - **nin**: `[in] int32_t` number of input ndarrays. - **nout**: `[in] int32_t` number of output ndarrays. - **functions**: `[in] ndarrayFcn*` array containing ndarray functions. - **nfunctions**: `[in] int32_t` number of ndarray functions. - **types**: `[in] int32_t*` array of type "numbers", where the total number of types equals `(nin+nout)*nfunctions` and where each set of `nin+nout` consecutive types (non-overlapping) corresponds to the set of ndarray argument types for a corresponding ndarray function. - **data**: `[in] void*` array of void pointers corresponding to the "data" (e.g., callbacks) which should be passed to a respective ndarray function. ```c struct ndarrayFunctionObject * stdlib_ndarray_function_allocate( const char *name, int32_t nin, int32_t nout, ndarrayFcn *functions, int32_t nfunctions, int32_t *types, void *data[] ) ``` The function returns a pointer to a dynamically allocated ndarray function or, if unable to allocate memory, a null pointer. The **user** is responsible for freeing the allocated memory. #### stdlib_ndarray_function_free( \*obj ) Frees an ndarray function object's allocated memory. ```c #include "stdlib/ndarray/base/unary.h" #include "stdlib/ndarray/dtypes.h" #include #include // Define the function(s) we want to apply to ndarrays: double scale( const double x ) { return x * 10.0; } // Define a function name: const char name[] = "unary_ndarray_function"; // Define a list of ndarray functions: ndarrayFcn functions[] = { stdlib_ndarray_d_d }; // Define the **ndarray** argument types for each ndarray function: int32_t types[] = { STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64 }; // Define a list of ndarray function "data" (in this case, callbacks): void *data[] = { (void *)scale }; // Create a new ndarray function object: struct ndarrayFunctionObject *obj = stdlib_ndarray_function_allocate( name, 1, 1, functions, 1, types, data ); if ( obj == NULL ) { fprintf( stderr, "Error allocating memory.\n" ); exit( 1 ); } // ... // Free allocated memory: stdlib_ndarray_function_free( obj ); ``` The function accepts the following arguments: - **obj**: `[in] ndarrayFunctionObject*` ndarray function object. ```c void stdlib_ndarray_function_free( struct ndarrayFunctionObject *obj ) ``` #### stdlib_ndarray_function_dispatch_index_of( \_obj, \_types ) Returns the first index of a function whose signature satisfies a provided list of array types. ```c #include "stdlib/ndarray/base/unary.h" #include "stdlib/ndarray/dtypes.h" #include #include // Define the function(s) we want to apply to ndarrays: double scale( const double x ) { return x * 10.0; } // ... // Define a function name: const char name[] = "unary_ndarray_function"; // Define a list of ndarray functions: ndarrayFcn functions[] = { stdlib_ndarray_d_d, stdlib_ndarray_f_f_as_d_d }; // Define the **ndarray** argument types for each ndarray function: int32_t types[] = { STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64 }; // Define a list of ndarray function "data" (in this case, callbacks): void *data[] = { (void *)scale, (void *)scale }; // Create a new ndarray function object: struct ndarrayFunctionObject *obj = stdlib_ndarray_function_allocate( name, 1, 1, functions, 2, types, data ); if ( obj == NULL ) { fprintf( stderr, "Error allocating memory.\n" ); exit( 1 ); } // ... // Define a list of types on which to dispatch: int32_t itypes[] = { STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64 }; // Find a function satisfying the list of types: int64_t idx = stdlib_ndarray_function_dispatch_index_of( obj, itypes ); if ( idx < 0 ) { fprintf( stderr, "Unable to find function.\n" ); exit( 1 ); } // ... // Free allocated memory: stdlib_ndarray_function_free( obj ); ``` The function accepts the following arguments: - **obj**: `[in] ndarrayFunctionObject*` ndarray function object. - **types**: `[in] int32_t*` list of array types on which to dispatch. ```c int64_t stdlib_ndarray_function_dispatch_index_of( const struct ndarrayFunctionObject *obj, const int32_t *types ) ``` If a function is found, the function returns the index of the function, and the function returns `-1` if unable to find a function.

* * * ## Notice This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. #### Community [![Chat][chat-image]][chat-url] --- ## License See [LICENSE][stdlib-license]. ## Copyright Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors].

Owner

  • Name: stdlib
  • Login: stdlib-js
  • Kind: organization

Standard library for JavaScript.

Citation (CITATION.cff)

cff-version: 1.2.0
title: stdlib
message: >-
  If you use this software, please cite it using the
  metadata from this file.

type: software

authors:
  - name: The Stdlib Authors
    url: https://github.com/stdlib-js/stdlib/graphs/contributors

repository-code: https://github.com/stdlib-js/stdlib
url: https://stdlib.io

abstract: |
  Standard library for JavaScript and Node.js.

keywords:
  - JavaScript
  - Node.js
  - TypeScript
  - standard library
  - scientific computing
  - numerical computing
  - statistical computing

license: Apache-2.0 AND BSL-1.0

date-released: 2016

GitHub Events

Total
  • Push event: 11
Last Year
  • Push event: 11

Committers

Last synced: almost 2 years ago

All Time
  • Total Commits: 41
  • Total Committers: 1
  • Avg Commits per committer: 41.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 11
  • Committers: 1
  • Avg Commits per committer: 11.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
stdlib-bot n****y@s****o 41
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • npm 52 last-month
  • Total dependent packages: 5
  • Total dependent repositories: 3
  • Total versions: 10
  • Total maintainers: 4
npmjs.org: @stdlib/ndarray-base-function-object

C APIs for creating and managing ndarray function objects.

  • Homepage: https://stdlib.io
  • License: Apache-2.0
  • Latest release: 0.2.2
    published over 1 year ago
  • Versions: 10
  • Dependent Packages: 5
  • Dependent Repositories: 3
  • Downloads: 52 Last month
Rankings
Dependent packages count: 3.7%
Dependent repos count: 6.7%
Average: 13.0%
Stargazers count: 15.0%
Forks count: 15.9%
Downloads: 23.6%
Funding
  • type: opencollective
  • url: https://opencollective.com/stdlib
Last synced: 4 months ago

Dependencies

package.json npm
  • @stdlib/assert-is-browser ^0.0.x development
  • @stdlib/ndarray-base-unary ^0.0.x development
  • @stdlib/ndarray-dtypes ^0.0.x development
  • istanbul ^0.4.1 development
  • tap-spec 5.x.x development
  • tape git+https://github.com/kgryte/tape.git#fix/globby development
  • @stdlib/ndarray-ctor ^0.0.x
  • @stdlib/utils-library-manifest ^0.0.x
.github/workflows/cancel.yml actions
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/close_pull_requests.yml actions
  • superbrothers/close-pull-request v3 composite
.github/workflows/examples.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/npm_downloads.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • actions/upload-artifact v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/productionize.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • stdlib-js/bundle-action main composite
  • stdlib-js/transform-errors-action main composite
.github/workflows/publish.yml actions
  • JS-DevTools/npm-publish v1 composite
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/test.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/test_bundles.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • denoland/setup-deno v1 composite
.github/workflows/test_coverage.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • codecov/codecov-action v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/test_install.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite