npm

Join us for the upcoming webinar, "Enterprise JavaScript done right: the tools you love, the security you need."Sign up here »

blas-dscal

1.0.0 • Public • Published

dscal

NPM version Build Status Coverage Status Dependencies

Scales elements of x by a constant alpha.

Installation

$ npm install blas-dscal

Usage

var scal = require( 'blas-dscal' );

scal( N, alpha, x, stride, offset )

Scales elements of x by a constant alpha.

var x = [ 1, 2, 3, 4, 5 ];
 
scal( x.length, 5, x, 1, 0 );
// x => [ 5, 10, 15, 20, 25 ]

The function accepts the following parameters:

  • N: number of elements to scale.
  • alpha: scalar constant.
  • x: input array or typed array.
  • stride: index increment.
  • offset: starting index.

The N, stride, and offset parameters determine which elements in x are scaled. For example, to scale every other value starting from the second element,

var x = [ 1, 2, 3, 4, 5, 6 ];
 
var N = Math.floor( x.length / 2 );
var stride = 2;
var offset = 1;
 
scal( N, 5, x, stride, offset );
// x => [ 1, 10, 3, 20, 5, 30 ]

If any of the following conditions are met

  • N <= 0
  • stride <= 0
  • offset < 0

the function returns undefined.

Notes

  • This module corresponds to the BLAS level 1 function dscal.

Examples

var scal = require( 'blas-dscal' );
 
var x;
var i;
 
= new Float64Array( 100 );
for ( i = 0; i < x.length; i++ ) {
    x[ i ] = Math.round( Math.random() * 100 );
}
console.log( x );
 
dscal( x.length, 5, x, 1, 0 );
console.log( x );

To run the example code from the top-level application directory,

$ node ./examples/index.js

Tests

Unit

This repository uses tape for unit tests. To run the tests, execute the following command in the top-level application directory:

$ make test

All new feature development should have corresponding unit tests to validate correct functionality.

Test Coverage

This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

$ make test-cov

Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

$ make view-cov

Browser Support

This repository uses Testling for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory:

$ make test-browsers

To view the tests in a local web browser,

$ make view-browser-tests

License

MIT license.

Copyright

Copyright © 2016. The Compute.io Authors.

install

npm i blas-dscal

Downloadsweekly downloads

2

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability