0.0.1 • Published 7 years ago

vector_js v0.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

Code Climate | Build Status

Vector_ JS

Dealing with N-dimensional Arrays and Vectors....

The Use Cases

  • Machine Learning Requires computing mostly in terms of multi-dimensional vectors and arrays.
  • Complex matrix and array calculations.
  • Simplifying the complex array operations.
  • Image Processing.
  • Text Processing.

Inspiration

Usage

it returns an object with three elements :

Although the arguments can be left empty and the Vector object will be initialised with an empty array as the array property and an empty array as the shape.

You can always change or alter the properties via the Vector methods.

The constructed object for a 2-dimensional array with shape 2,3 (meaning 2 elements having 3 elements each) and the array [1,2,3,4,5,6] looks like this : Object { array: Array2, shape: Array2, size: 6, dim: 2, flat: Array6 }

A Vector Object Has the following properties :

Defines The Structure of the array, i.e., the number of layers inside the array that defines the number of elements and if that element is itself an array, the number of elements inside it. As seen in the above example for the shape 2,3 The array was a 2-d array with 2 elements(arrays) having 3 elements each.

The array itself, containig the data.

The Dimension of the array. For the above case : dim = 2

The total number of elements(scalar) in the n-dimension array

It's the 1-d version of the n-dimensional array.


If you have an array of data that you want to turn into a Vector Object, you can either use the constructor for passing in the array or the static method Vector.array(array).

This will return a new Vector object with the array property equal to the array you passed in.

example : var array = [2,3,4,1,5,7]; var v = Vector.array(array);

You can create a placeholder n-dimensional array for vector filled with zeroes by calling Vector.zeroes(shape)

example : var v = Vector.zeroes(2,3);

v has the array property as : [0,0,0,0,0,0]

This is used by the arrangemethod of the Vector object to fill in the array of the Vector. But it can be used to manually assign the array property.

The fill methods recieves two arguments : 1. Length of the array to be filled. 2. Optional arguments to make the array.

example :

if fill is called without passing the second parameter, it will return an array of length = passed length of random numbers

Returns an array of length 6 with all elements = 1;

Returns an array of length 6 with elements in range 2 to 10.

Used to add two Vector objects,returns a new Vector object.

Turns ndarray into 1d array. Pass in the ndarray as the first argument, and an empty array as the second argument, the flattened array is stored in the second argument.

Vector.flatten(ndarr,emptArr);

  • find_dim(); // Returns the dimension of the Vector/ndarray.
  • calc_shape(array); // Returns the shape of the ndarray.
  • calc_size(shape); // Returns the size of the ndarray(Number of elements in it).
  • arrange(new_array); // Pass in a 1d array and it arranges it in the ndarray.
  • reshape(new_shape); // Change the shape of the array iff size for new_shape == size for old_shhape.
  • resize(new_shape); // Change the shape irrespective of size.

.............................................................................................

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago