Vector Operations

Javascript has arrays, but it does not support vector style mathematical operations such as array addition, scalar multiplication, etc.  This module includes function to handle some of these vector operations.

Copyright 2012, Lance Larsen
Licensed under the MIT license
Summary
Vector OperationsJavascript has arrays, but it does not support vector style mathematical operations such as array addition, scalar multiplication, etc.
Functions
SxVScalar times Vector function
SpVScalar plus Vector function
VpVVector plus Vector function
linspacelinspace creates a new vector with the indicated length.

Functions

SxV

Scalar times Vector function

PARAMETERS

sA scalar value to multiply each element of the vector by
vThe vector

RETURNS

s*v

SpV

Scalar plus Vector function

PARAMETERS

sScalar value to add to each element in the vector
vThe vector

RETURNS

v+s

VpV

Vector plus Vector function

PARAMETERS

v1the first vector to add
v2the second vector to add

RETURNS

v1 + v2

linspace

linspace creates a new vector with the indicated length.  The values are either a range of evenly spaced numbers from beginning with xmin and ending with xmax, or the results of calling a callback with each number in the range xmin to xmax.

PARAMETERS

xminThe minimum value for the range
xmaxThe maximum value for the range
lengthThe length of the vector to create
callback(Optional) A function of the form callback(xval) that takes values one at a time in the range xmin to xmax and return a value to include in the vector.

RETURNS

the generated vector (i.e. array)

Close