'use strict';

var round = require( '@stdlib/math/base/special/round' );
var randu = require( '@stdlib/math/base/random/randu' );
var daxpy = require( './../lib' ).wasm();

var xbytes;
var ybytes;
var x;
var y;
var i;

// Allocate space on the heap:
xbytes = daxpy.malloc( 100 * 8 ); // 8 bytes per double
ybytes = daxpy.malloc( 100 * 8 );

// Create Float64Array views:
x = new Float64Array( xbytes.buffer, xbytes.byteOffset, 100 );
y = new Float64Array( ybytes.buffer, ybytes.byteOffset, 100 );

// Set data on the heap...
for ( i = 0; i < x.length; i++ ) {
	x[ i ] = round( randu()*100.0 );
	y[ i ] = round( randu()*10.0 );
}
console.log( x );
console.log( y );

daxpy( x.length, 5.0, xbytes, 1, ybytes, -1 );
console.log( y );

// Free allocated memory:
daxpy.free( xbytes );
daxpy.free( ybytes );

'use strict';

var round = require( '@stdlib/math/base/special/round' );
var randu = require( '@stdlib/math/base/random/randu' );
var daxpy = require( './../lib' ).wasm();

var xbytes;
var ybytes;
var x;
var y;
var i;

// Allocate space on the heap:
xbytes = daxpy.malloc( 10 * 8 ); // 8 bytes per double
ybytes = daxpy.malloc( 10 * 8 );

// Create Float64Array views:
x = new Float64Array( xbytes.buffer, xbytes.byteOffset, 10 );
y = new Float64Array( ybytes.buffer, ybytes.byteOffset, 10 );

// Set data on the heap...
for ( i = 0; i < x.length; i++ ) {
	x[ i ] = round( randu()*100.0 );
	y[ i ] = round( randu()*10.0 );
}
console.log( x );
console.log( y );

daxpy( x.length, 5.0, xbytes, 1, ybytes, -1 );
console.log( y );

// Free allocated memory:
daxpy.free( xbytes );
daxpy.free( ybytes );

Reduce array length for easier inspection
Reduce array length for easier inspection
