BLAS Level 1 operations for complex-valued ndarrays

Usage

This library implements the basic vector operations of the Level 1 Basic Linear Algebra Subprograms (BLAS). Many of these functions are also implemented in ndarray-ops—which also has functions that are not included in BLAS. So the right answer is probably some blend of the two. This library exists mainly to frame things in a relatively standard, coherent framework.

NB: This library performs no checks to ensure you're only passing one-dimensional vectors. That's either a bug or a feature, depending on how you think about it.

Function

Operation

Description

swap(x_r,x_i,y_r,y_i)

Swap the elements of x and y

scal(alpha_r,alpha_i,x_r,x_i)

Multiple vector x by scalar alpha

copy(x_r,x_i,y_r,y_i)

Copy x into y

axpy(alpha_r,alpha_i, x_r,x_i, y_r,y_i)

Multiple x by alpha and add it to y

cpsc(alpha_r,alpha_i, x_r,x_i, y_r,y_i)

Multiply x by alpha and assign it to y

dotu(x_r,x_i,y_r,y_i)

Calculate the product transpose(x) * y.

doth(x_r,x_i,y_r,y_i)

Calculate the product conj(x) * y.

nrm2(x_r,x_i)

Calculate the 2-norm of x

asum(x_r,x_i)

Calculate the 1-norm of x

iamax(x_r,x_i)

Not yet implemented

A note on working with complex ndarrays

ndarrays only hold real numbers of varying types and javascript has no native complex type, so the best we can do for now is to try to encapsulate a decent amount of that. This library deals with vectors, but to start with the more general case of storing, for example, the matrix

,

here are two methods:

Store the real and imaginary components in multiple arrays:

var a_r =ndarray([1,3,7,-2,1,-5],[2,3]),

a_i =ndarray([2,4,8,4,-2,6],[2,3]);

Interleave the real and imaginary components:

var a =ndarray([1,2,3,4,7,8,-2,4,1,-2,-5,6],[2,3,2]),

a_r =a.pick(null,null,0),

a_i =a.pick(null,null,1);

In this example, there's an additional final dimension of the array. This applies to vectors, matrices, and higher-dimensional arrays.

I won't comment on the relative effiency of each method.

Example

Usage should be pretty straightforward. There aren't really any options or variations.

var cblas1 =require('ndarray-blas-level1-complex');