Module vectors
Vectors, handles, and inner products.
We recommend using these functions and classes when possible.
Otherwise, you can write your own vector class and/or vector handle,
see documentation Interfacing with your data.
-
class vectors.InnerProductTrapz(*grids)[source]
Inner product of n-dim arrays on grid using the trapezoidal rule.
- Args:
- grids: 1D arrays of grid points, in the order of the dims.
- x_grid: 1D array of grid points in x-dimension;
y_grid: 1D array of grid points in y-dimension; ...
Usage:
nx = 10
ny = 11
x_grid = 1 - N.cos(N.linspace(0, N.pi, nx))
y_grid = N.linspace(0, 1.0, ny)**2
my_trapz = InnerProductTrapz(x_grid, y_grid)
v1 = N.random.random((nx,ny))
v2 = N.random.random((nx,ny))
IP_v1_v2 = my_trapz(v1, v2)
-
inner_product(vec1, vec2)[source]
Takes the inner product.
-
class vectors.VecHandle(base_vec_handle=None, scale=None)[source]
Recommended base class for vector handles (not required).
-
get()[source]
Get a vector, using the private _get function. If available,
the base vector will be subtracted from the specified vector. Then, if
a scale factor is specified, the base-subtracted vector will be scaled.
The scaled, base-subtracted vector is then returned.
-
put(vec)[source]
Put a vector to file or memory using the _put function.
-
class vectors.VecHandleArrayText(vec_path, base_vec_handle=None, scale=None)[source]
Gets and puts array vector objects to text files.
-
class vectors.VecHandleInMemory(vec=None, base_vec_handle=None, scale=None)[source]
Gets and puts vectors in memory.
-
class vectors.VecHandlePickle(vec_path, base_vec_handle=None, scale=None)[source]
Gets and puts any vector object to pickle files.
-
class vectors.Vector[source]
Recommended base class for vector objects (not required).
-
vectors.inner_product_array_uniform(vec1, vec2)[source]
Takes inner product of numpy arrays without weighting.