## ndarray-blas-level1-complexpublic

# ndarray-blas-level1-complex

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 = a_i = ;`

- Interleave the real and imaginary components:

`var a = a_r = a a_i = a;`

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 = ; var x = ;var y = ; var x_r = x x_i = x y_r = y y_i = y; cblas1;`

## Credits

(c) 2015 Ricky Reusser. MIT License