time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

native.js (1479B)


      1 /**
      2 * @license Apache-2.0
      3 *
      4 * Copyright (c) 2021 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 // MODULES //
     22 
     23 var serialize = require( './../../../../base/serialize-meta-data' );
     24 var addon = require( './../src/addon.node' );
     25 
     26 
     27 // MAIN //
     28 
     29 /**
     30 * Wrapper function exposing the C API to JavaScript.
     31 *
     32 * @private
     33 * @param {ndarray} x - input array
     34 * @param {ndarray} y - destination array
     35 * @returns {ndarray} `y`
     36 *
     37 * @example
     38 * var Float64Array = require( '@stdlib/array/float64' );
     39 * var ndarray = require( '@stdlib/ndarray/ctor' );
     40 *
     41 * var xbuf = new Float64Array( 10 );
     42 * var ybuf = new Float64Array( x.length );
     43 *
     44 * var x = new ndarray( 'float64', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
     45 * var y = new ndarray( x.dtype, ybuf, x.shape, x.strides, x.offset, x.order );
     46 *
     47 * wrapper( x, y );
     48 */
     49 function wrapper( x, y ) {
     50 	addon( x.data, serialize( x ), y.data, serialize( y ) );
     51 	return y;
     52 }
     53 
     54 
     55 // EXPORTS //
     56 
     57 module.exports = wrapper;