Skip to content
The fundamental shard for scientific computing with V
C V Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Start of ndimg Feb 11, 2020
consts Overhaul to core ndarray (#1) Jan 3, 2020
examples README Feb 10, 2020
ext Start of ndimg Feb 11, 2020
la
ndimg more img Feb 11, 2020
nn Start of ndimg Feb 11, 2020
num Start of ndimg Feb 11, 2020
static [DOC] Readme plot Jan 10, 2020
.editorconfig Moving stuff around Dec 29, 2019
.gitignore Start of ndimg Feb 11, 2020
.gitmodules doc start Jan 10, 2020
LICENSE Create LICENSE (#7) Feb 10, 2020
Makefile
README.md
v.mod vmod Dec 29, 2019
vnum.v README Feb 10, 2020

README.md

vnum development has been suspended until 0.2. There are too many missing features regarding generics and interfaces that further work just doesn't make any sense for now, and would need to be re-written later anyways. If you would like to become a member of the core team once 0.2 hits, contact me.

vnum logo

vnum is the core shard needed for scientific computing with V. It is looking for core developer team members to continue working on the library. If you are interested, contact Chris.

It provides:

  • An n-dimensional NdArray data structure
  • sophisticated reduction, elementwise, and accumulation operations
  • data structures that can easily be passed to C libraries
  • powerful linear algebra routines backed by LAPACK and BLAS.

Installation

Using vpm

$ v install christopherzimmerman.vnum
$ ln -sf ~/.vmodules/christopherzimmerman/vnum/ ~/.vmodules/vnum

vnum requires LAPACK and OPENBLAS to be installed on linux, and the Accelerate framework on darwin. Please review your OS's installation instructions to install these libraries. If you wish you to use vnum without these, the num module will still function as normal.

Basic Usage

>>> import vnum.num
>>> num.seq(30)
[ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17,
 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]

vnum provides vectorized operations on ndarrays.

>>> a := num.seq(12).reshape([3, 2, 2])
>>> num.sum_axis(a, 1)
[[ 2,  4],
 [10, 12],
 [18, 20]]

Use the vnum.linalg module for powerful BLAS backed routines.

>>> import vnum.num
>>> import vnum.la
>>> a := num.seq(60).reshape([3, 4, 5])
>>> b := num.seq(24).reshape([4, 3, 2])
>>> res := la.tensordot(a, b, [1, 0], [0, 1])
>>> res
[[4400, 4730],
 [4532, 4874],
 [4664, 5018],
 [4796, 5162],
 [4928, 5306]]

Basic support for Machine Learning is being added in the vnum.nn module. Here is a basic example learning the XOR function

>>> import vnum.nn
>>> import vnum.num
>>> features := num.from_int([0, 0, 0, 1, 1, 0, 1, 1], [4, 2])
>>> labels := num.from_int([0, 1, 1, 0], [4, 1])
>>> mut m := nn.new(0.7, 10000, 3, "sigmoid")
>>> m.learn(features, labels)
>>> m.predict(features)
[[ 0.0387387],
 [  0.976217],
 [  0.976216],
 [0.00880164]]

For Numpy Users

NumPy Vnum
np.array([[1.,2.,3.], [4.,5.,6.]]) num.from_int([1, 2, 3, 4, 5, 6], [2, 3])
np.arange(10) num.seq(10)
np.linspace(0, 10, 11) num.linspace(0, 10, 11)
np.ones((3, 4, 5)) num.ones([3, 4, 5])
np.zeros((3, 4, 5)) num.zeros((3, 4, 5))
np.zeros((3, 4, 5), order='F') num.zeros([3, 4, 5]).copy('F')
np.full((3, 4), 7) num.full([3, 4], 7)
a[-1] a.get([-1])
a[1, 4] a.get([1, 4])
a[1] a.slice([1])
a[0:5] a.slice([0, 5])
a[1:4:2] a.slice([1, 4, 2])
a.T a.t()
mat1.dot(mat2) la.matmul(mat2, mat2)
np.sum(a, axis=1) num.sum_axis(1)
np.diag(a) num.diag(a)
a[:] = 3 a.fill(3)
a[:] = b a.assign(b)
np.concatenate((a, b), axis=1) num.concatenate([a, b], 1)

License

BSD-3

Core Team

Contributing

vnum requires help in many different ways to continue to grow as a module. Contributions such as high level documentation and code quality checks are needed just as much as API enhancements. If you are considering larger scale contributions that extend beyond minor enhancements and bug fixes, contact Chris Zimmerman in order to be added to the organization to gain access to review and merge permissions.

You can’t perform that action at this time.