Previous topic

pycrtools.core.plot

Next topic

pycrtools.core.workspaces

This Page

pycrtools.core.vector

BoolArray
BoolVec c++ standard template library (STL) vector of type ‘bool’
ComplexArray
ComplexVec c++ standard template library (STL) vector of type ‘complex’
CoordinateTypes
FFTWPlanManyDft
FFTWPlanManyDftC2r
FFTWPlanManyDftR2c
FloatArray
FloatVec c++ standard template library (STL) vector of type ‘float’
IntArray
IntVec c++ standard template library (STL) vector of type ‘int’
StringArray
StringVec c++ standard template library (STL) vector of type ‘str’
TBB2Data
TBBData
TYPE
VecToString(self[, maxlen]) see help of ‘hPrettyString’
Vec_add(vec1, val) Provides the + operator for adding two vectors or a vector and a scalar.
Vec_div(vec1, val) Provides the / operator for dividing two vectors or a vector by a scalar.
Vec_iadd(vec1, vec2) Provides the += operator for adding two vectors in place.
Vec_idiv(vec1, vec2) Provides the /= operator for adding two vectors in place.
Vec_imul(vec1, vec2) Provides the *= operator for addig two vectors in place.
Vec_isub(vec1, vec2) Provides the -= operator for adding two vectors in place.
Vec_mul(vec1, val) Provides the * operator for multiplying two vectors or a vector and a scalar.
Vec_neg(vec1) Provides the - operator for a vector.
Vec_pos(vec1) Provides the + operator for a vector (which is its identity: +vec = vec).
Vec_pow(vec1, val) Provides the ** operator for raising a vector to a power.
Vec_rdiv(vec1, val) Provides the / operator for dividing two vectors or a vector by a scalar.
Vec_rsub(vec1, val) Provides the - operator for subtracting two vectors or a vector and a scalar.
Vec_sub(vec1, val) Provides the - operator for subtracting two vectors or a vector and a scalar.
Vector([Type, size, fill, copy, properties]) The basic Boost Python STL vector constructor takes no arguments and hence is a litte cumbersome to use.
asval(self) Return the argument as a single value.
asvec(self) Return the argument as a vector, if possible, otherwise as list.
atype
basetype((IntVec) -> <type >) basetype(FloatArray) -> <type ‘float’>
btype str(object=’‘) -> string
extendflat(self, l) Appending all elements in a list of lists to a one-dimensional vector with a flat data structure (just 1D).
fftw_flags
fftw_sign
hVector_getinitargs(self) Get arguments for hVector constructor.
hVector_getstate(self) Get current state of hVector object for pickling.
hVector_list(self) Retrieve the STL vector as a python list.
hVector_repr(self[, maxlen]) Returns a human readable string representation of the vector.
hVector_setstate(self, state) Restore state of hVector object for unpickling.
hVector_val(self) Retrieve the contents of the vector as python values: either as a single value, if the vector just contains a single value, or otherwise return a python list.
hVector_vec(self) Convenience method that allows one to treat hArrays and hVectors in the same way, i.e.
hWEIGHTS
isVector(vec) Returns true if the argument is one of the standard c++ vectors i.e.
multiply_list(l) Multiplies all elements of a list with each other and returns the result.
type2array((float) -> Vec(0)=[]) Creates an array with elements of type ‘basetype’.
type2vector((float) -> Vec(0)=[]) Creates a vector with elements of type ‘basetype’.
typename(btype) basetype(float) -> “float”
v
vtype c++ standard template library (STL) vector of type ‘str’

Basic types for Vectors and hArrays.

pycrtools.core.vector.VecToString(self, maxlen=100)

see help of ‘hPrettyString’

pycrtools.core.vector.Vec_add(vec1, val)

Provides the + operator for adding two vectors or a vector and a scalar. The result will be a new vector.

pycrtools.core.vector.Vec_div(vec1, val)

Provides the / operator for dividing two vectors or a vector by a scalar. The result will be a new vector.

pycrtools.core.vector.Vec_iadd(vec1, vec2)

Provides the += operator for adding two vectors in place. vec1 += vec2 will add all elements in vec2 to the corresponding elements in vec1 and store the result in vec1.

pycrtools.core.vector.Vec_idiv(vec1, vec2)

Provides the /= operator for adding two vectors in place. vec1 /= vec2 will divide all elements in vec1 by the corresponding elements in vec2 and store the result in vec1.

pycrtools.core.vector.Vec_imul(vec1, vec2)

Provides the *= operator for addig two vectors in place. vec1 *= vec2 will multiply all elements in vec1 with the corresponding elements in vec2 and store the result in vec1.

pycrtools.core.vector.Vec_isub(vec1, vec2)

Provides the -= operator for adding two vectors in place. vec1 -= vec2 will subtract all elements in vec2 from the corresponding elements in vec1 and store the result in vec1.

pycrtools.core.vector.Vec_mul(vec1, val)

Provides the * operator for multiplying two vectors or a vector and a scalar. The result will be a new vector.

pycrtools.core.vector.Vec_neg(vec1)

Provides the - operator for a vector. Will return a copy of the vector where all elmements are multiplied by -1.

pycrtools.core.vector.Vec_pos(vec1)

Provides the + operator for a vector (which is its identity: +vec = vec).

pycrtools.core.vector.Vec_pow(vec1, val)

Provides the ** operator for raising a vector to a power. Returns a new vector.

pycrtools.core.vector.Vec_rdiv(vec1, val)

Provides the / operator for dividing two vectors or a vector by a scalar. The result will be a new vector.

pycrtools.core.vector.Vec_rsub(vec1, val)

Provides the - operator for subtracting two vectors or a vector and a scalar. The result will be a new vector.

pycrtools.core.vector.Vec_sub(vec1, val)

Provides the - operator for subtracting two vectors or a vector and a scalar. The result will be a new vector.

pycrtools.core.vector.Vector(Type=None, size=-1, fill=None, copy=None, properties=None)

The basic Boost Python STL vector constructor takes no arguments and hence is a litte cumbersome to use. Here we provide a wrapper function that is useful for interactive use. If speed is of the essence, use the original vector constructors: BoolVec(), IntVec(), FloatVec(), ComplexVec(), StringVec()

Type - type of vector (int, float,complex,bool, str) or an array/vector/list where they type can be deduced from.

size - length of the vector

fill - a value or vector/list that is used to fill the vector with

copy - a vector which is used to copy content and properties from (other keywords have priority though)

properties - assume the properties of this vector if provided (other keywords have priority though)

Usage:

Vector(Type)
will create an empty vector of type Type, where Type is a basic Python type, i.e. bool, int, float, complex, str.
Vector(Type,size)
will create an vector of type Type, with length size.
Vector(Type,size,fill)
will create an vector of type Type, with length size and initialized with the value fill.
Vector([1,2,3,...]) or Vector((1,2,3,...))
if a list or a tuple is provided as first argument then a vector is created of the type of the first element in the list or tuple (here an integer) and filled with the contents of the list or tuple.

Vector() defaults to a float vector.

Note, that size and fill take precedence over the list and tuple input. Hence if you create a vector with Vector([1,2,3],size=2) it will contain only [1,2]. Vector([1,2,3],size=2,fill=4) will give [4,4].

Example:

v = Vector(int,10,fill=range(10)) -> v = Vector(int, 10, fill=[0,1,2,3,4,5,6,7,8,9]) vv = Vector(copy=v) -> vv = Vector(int, 10, fill=[0,1,2,3,4,5,6,7,8,9])

pycrtools.core.vector.asval(self)

Return the argument as a single value. If it is a list/tuple/vector/array, return the first element.

pycrtools.core.vector.asvec(self)

Return the argument as a vector, if possible, otherwise as list. If None, return None.

pycrtools.core.vector.extendflat(self, l)

Appending all elements in a list of lists to a one-dimensional vector with a flat data structure (just 1D).

Usage::
>>> vector.extendflat([[e1-1,e1-2,...],[e2-1,e2-2,...],..])
-> [e1-1,e1-2,...,e2-1,e2-2,...]
pycrtools.core.vector.hVector_getinitargs(self)

Get arguments for hVector constructor.

Warning

This is not the hVector factory function but the constructor for the actual type. E.g. IntArray.__init__()

pycrtools.core.vector.hVector_getstate(self)

Get current state of hVector object for pickling.

pycrtools.core.vector.hVector_list(self)

Retrieve the STL vector as a python list.

Usage:

>>> vec.list()
-> [x1,x2,x3, ...]
pycrtools.core.vector.hVector_repr(self, maxlen=100)

Returns a human readable string representation of the vector.

pycrtools.core.vector.hVector_setstate(self, state)

Restore state of hVector object for unpickling.

pycrtools.core.vector.hVector_val(self)

Retrieve the contents of the vector as python values: either as a single value, if the vector just contains a single value, or otherwise return a python list.

Usage:

>>> vec.val()
-> a   (if length == 1)
>>> vec.val()
-> [a,b,c,...]   (if length > 1)
pycrtools.core.vector.hVector_vec(self)

Convenience method that allows one to treat hArrays and hVectors in the same way, i.e. using the vec() method returns the intrinsic vector for both.

Usage::
>>> vector.vec()
-> vector
pycrtools.core.vector.isVector(vec)

Returns true if the argument is one of the standard c++ vectors i.e. those listed in hAllVectorTypes.

Usage::
>>> isVector(vec)
-> True or False
pycrtools.core.vector.multiply_list(l)

Multiplies all elements of a list with each other and returns the result.

Usage:

>>> multiply_list([n1,n2,...])
-> n1*n2*n3 ....