You are a guest. Restricted access. Read more.

Numeric Python

<<back

JNumeric is a collection of extension modules to provide high-performance multidimensional numeric arrays to the Python programming language. This package closely follows NumPy CPython package which is described in NumPy Tutorial. There is a however a number of differences discussed below. Since JNumeric is implemented in Java, you can access Java libraries.

Here is a simple example how to with arrays:

Let us find all packages of JNumeric:

>>> import jnumeric
>>> dir(jnumeric)

As example, consider “JNumeric” that provides high-performance arrays:

>>> from jnumeric.JNumeric import *
>>> a = array(10)
>>> b = array( [[1,0],[0,1]])
>>> print b

Print methods associated with array a as:

print dir(a)

SCaVis allows to interface JNumeric fast arrays with other Java classes and graphical canvases for plotting similar to CPython when interfacing NumPy with MathPlot. For example, this script generate two arrays, transform them to sqrt() (for X) and exp() (for Y) and plot on interactive canvas: We use the Java classes jhplot.P1D and jhplot.HPlot to perform this task:

Differences compared to CPython NumPy

  • There is no multiarray module.
  • Uumath is a submodule of the Numeric package.
  • Ones acts like zeros if no typecode is given instead of defaulting to Int.
  • Int refers to native (Int32) int type rather than largest (Int64) type.
  • a[0] doesn't work for zeros sized arrays – use a1) or a[…].
  • Some of the unfuncs that should have been returning ints, returned types that matched their arguments (logical_and for example). Also, some of the documented ufuncs are missing from CNumeric.
  • Changed the behaviour of dot. Now dot acts on axis -1/0 by default, since it now accepts two axes arguments, this is not as big a deal as it once was.
  • Astype does not make a copy if the type matches the current type. (This matches the behaviour of asarray).
  • There are several functions missing that should be added: cross_correlate, sarray, dump, dumps, load, loads (pickle functions) divide_safe, negative, invert, left_shift, right_shift, fmod, hypot, around, sign
Navigation

Print/export