# RunKit + #### Try any Node.js package right in your browser

This is a `playground` to test code. It runs a full `Node.js` environment and already has all of `npm`’s 1,000,000+ packages pre-installed, including `vect` with all `npm` packages installed. Try it out:

var vect = require("vect")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

# vect

A (Multidimensional) Lightweight Vector Computation Library

NOTE that this library makes an assumption that vectors are simply lists (`Array`) of `numbers`, such as `[1, 2, 3, 4]`.

## Install

`npm install {}` or just add `vect.min.js` to your page.

## API

Summary:

### Addition - `vect.add()`

Adds `n` vectors, returning a vector `Array`.

``````vect.add([1, 2, 3], [3, 2, 1]); // x
``````

### Magnitude - `vect.mag(a)`, or `vect.magnitude(a)`

Computes the magnitude of a vector `a`, returning a `number`.

``````vect.mag([1, 2, 3]); // x
``````

### Dot Product - `vect.dot(a, b)`

Computes the dot product of two vectors `a` and `b`, returning a `number`.

``````vect.dot([1, 2, 3], [3, 2, 1]); //
``````

### Cosine Similarity (Angle) - `vect.angle(a, b)`

Computes the cosine similarity (or angle between) two vectors `a` and `b`, returning a `number`.

``````vect.angle([1, 2, 3], [1, 2, 3]); // 1
``````

## Change Log

`0.0.1` - Initial release.