Previous topic

pycrtools.core.hftools.mTBB

Next topic

pycrtools.core.htypes

This Page

pycrtools.core.hftools.mVector

pycrtools.core.hftools.mVector.hElem()

hElem(vec, N)

Return the nth element of the vector

Parameters

vec Vector to output
N Zero-based index of element in vector to return.

Usage

``hElem(vec,N) -> vec_N``

See also

hFirst(), hLast(), hElem()

Example

v=Vector(range(5))
v.elem(3) -> 3
pycrtools.core.hftools.mVector.hFirst()

hFirst(vec)

Return the first element of the vector

Parameters

vec Vector to output

Usage

``hFirst(vec) -> vec_0``

See also

hFirst(), hLast(), hElem()

Example

v=Vector(range(5)) -> Vector(int, 5, fill=[0,1,2,3,4])
v.first() -> 0
pycrtools.core.hftools.mVector.hLast()

hLast(vec)

Return the last element of the vector

Parameters

vec Vector to output

Usage

``hLast(vec) -> vec[len(vec)-1]``

See also

hFirst(), hLast(), hElem()

Example

v=Vector(range(5)) -> Vector(int, 5, fill=[0,1,2,3,4])
v.last() -> 4
pycrtools.core.hftools.mVector.hFill()

hFill(vec, fill_value)

Fills a vector with a constant value.

Parameters

vec Vector to fill
fill_value Fill value

Usage

hFill(vec,0) -> [0,0,0,...]

vec.fill(0) -> [0,0,0,...]

See also

hSet()

hFill(vec, fillvec)

Fills a vector with the content of another vector.

Parameters

vec Vector to fill
fillvec Vector of values to fill it with

Description

If fillvec is shorther than vec, the procedure will wrap around and start from the beginning of fillvec again. Hence, in this case fillvec will appear repeated multiple times in vec.

Usage

hFill(vec,[0,1,2]) -> [0,1,2,0,1,2,...]

vec.fill([0,1,2]) -> [0,1,2,0,1,2,...]

pycrtools.core.hftools.mVector.hFill()

hFill(vec, fill_value)

Fills a vector with a constant value.

Parameters

vec Vector to fill
fill_value Fill value

Usage

hFill(vec,0) -> [0,0,0,...]

vec.fill(0) -> [0,0,0,...]

See also

hSet()

hFill(vec, fillvec)

Fills a vector with the content of another vector.

Parameters

vec Vector to fill
fillvec Vector of values to fill it with

Description

If fillvec is shorther than vec, the procedure will wrap around and start from the beginning of fillvec again. Hence, in this case fillvec will appear repeated multiple times in vec.

Usage

hFill(vec,[0,1,2]) -> [0,1,2,0,1,2,...]

vec.fill([0,1,2]) -> [0,1,2,0,1,2,...]

pycrtools.core.hftools.mVector.hSet()

hSet(vec, indexlist, val)

Sets certain elements specified in an indexlist to a constant value.

Parameters

vec Vector of in which to set elements.
indexlist Index list containing the positions of the elements to be set, (e.g. [0,2,4,...] will set every second element).
val Value to assign to the indexed elements.

Usage

vec.set(indexlist,val) -> set elements in vec at the positions given in indexlist to value 'val'

See also

hFill(), hCopy()

Example

vec=hArray(range(10))
indx=hArray([2,4])
vec.set(indx,99)
vec -> hArray(int, [10], fill=[0, 1, 99, 3, 99, 5, 6, 7, 8, 9]) # len=10 slice=[0:10])

hSet(vec, indexlist, vecfrom)

Sets certain elements specified in an indexlist to values in seconde list

Parameters

vec Vector of in which to set elements.
indexlist Index list containing the positions of the elements to be set, (e.g. [0,2,4,...] will set every second element).
vecfrom Value to assign to the indexed elements from.

Description

If ‘fromvec’ is too short it will wrap around until all values are filled.

Usage

vec.set(indexlist,[a_0,a_i,...]) -> set elements in vec at the positions given in indexlist to the values in the last argument.

See also

hFill(), hCopy()

Example

vec=hArray(range(10))
indx=hArray([2,4])
vec.set(indx,99)
vec -> hArray(int, [10], fill=[0, 1, 99, 3, 99, 5, 6, 7, 8, 9]) # len=10 slice=[0:10])

hSet(vec, index, val)

Sets a certain element specified by an index to a constant value.

Parameters

vec Vector of in which to set elements.
index Index containing the positions of the elements to be set.
val Value to assign to the indexed elements.

Usage

vec.set(index,val) -> set element in vec at the positions given by index to value 'val'

See also

hFill(), hCopy()

Example

vec=hArray(range(10))
indx=2
vec.set(indx,99)
vec -> hArray(int, [10], fill=[0, 1, 99, 3, 4, 5, 6, 7, 8, 9]) # len=10 slice=[0:10])
pycrtools.core.hftools.mVector.hSet()

hSet(vec, indexlist, val)

Sets certain elements specified in an indexlist to a constant value.

Parameters

vec Vector of in which to set elements.
indexlist Index list containing the positions of the elements to be set, (e.g. [0,2,4,...] will set every second element).
val Value to assign to the indexed elements.

Usage

vec.set(indexlist,val) -> set elements in vec at the positions given in indexlist to value 'val'

See also

hFill(), hCopy()

Example

vec=hArray(range(10))
indx=hArray([2,4])
vec.set(indx,99)
vec -> hArray(int, [10], fill=[0, 1, 99, 3, 99, 5, 6, 7, 8, 9]) # len=10 slice=[0:10])

hSet(vec, indexlist, vecfrom)

Sets certain elements specified in an indexlist to values in seconde list

Parameters

vec Vector of in which to set elements.
indexlist Index list containing the positions of the elements to be set, (e.g. [0,2,4,...] will set every second element).
vecfrom Value to assign to the indexed elements from.

Description

If ‘fromvec’ is too short it will wrap around until all values are filled.

Usage

vec.set(indexlist,[a_0,a_i,...]) -> set elements in vec at the positions given in indexlist to the values in the last argument.

See also

hFill(), hCopy()

Example

vec=hArray(range(10))
indx=hArray([2,4])
vec.set(indx,99)
vec -> hArray(int, [10], fill=[0, 1, 99, 3, 99, 5, 6, 7, 8, 9]) # len=10 slice=[0:10])

hSet(vec, index, val)

Sets a certain element specified by an index to a constant value.

Parameters

vec Vector of in which to set elements.
index Index containing the positions of the elements to be set.
val Value to assign to the indexed elements.

Usage

vec.set(index,val) -> set element in vec at the positions given by index to value 'val'

See also

hFill(), hCopy()

Example

vec=hArray(range(10))
indx=2
vec.set(indx,99)
vec -> hArray(int, [10], fill=[0, 1, 99, 3, 4, 5, 6, 7, 8, 9]) # len=10 slice=[0:10])
pycrtools.core.hftools.mVector.hSet()

hSet(vec, indexlist, val)

Sets certain elements specified in an indexlist to a constant value.

Parameters

vec Vector of in which to set elements.
indexlist Index list containing the positions of the elements to be set, (e.g. [0,2,4,...] will set every second element).
val Value to assign to the indexed elements.

Usage

vec.set(indexlist,val) -> set elements in vec at the positions given in indexlist to value 'val'

See also

hFill(), hCopy()

Example

vec=hArray(range(10))
indx=hArray([2,4])
vec.set(indx,99)
vec -> hArray(int, [10], fill=[0, 1, 99, 3, 99, 5, 6, 7, 8, 9]) # len=10 slice=[0:10])

hSet(vec, indexlist, vecfrom)

Sets certain elements specified in an indexlist to values in seconde list

Parameters

vec Vector of in which to set elements.
indexlist Index list containing the positions of the elements to be set, (e.g. [0,2,4,...] will set every second element).
vecfrom Value to assign to the indexed elements from.

Description

If ‘fromvec’ is too short it will wrap around until all values are filled.

Usage

vec.set(indexlist,[a_0,a_i,...]) -> set elements in vec at the positions given in indexlist to the values in the last argument.

See also

hFill(), hCopy()

Example

vec=hArray(range(10))
indx=hArray([2,4])
vec.set(indx,99)
vec -> hArray(int, [10], fill=[0, 1, 99, 3, 99, 5, 6, 7, 8, 9]) # len=10 slice=[0:10])

hSet(vec, index, val)

Sets a certain element specified by an index to a constant value.

Parameters

vec Vector of in which to set elements.
index Index containing the positions of the elements to be set.
val Value to assign to the indexed elements.

Usage

vec.set(index,val) -> set element in vec at the positions given by index to value 'val'

See also

hFill(), hCopy()

Example

vec=hArray(range(10))
indx=2
vec.set(indx,99)
vec -> hArray(int, [10], fill=[0, 1, 99, 3, 4, 5, 6, 7, 8, 9]) # len=10 slice=[0:10])
pycrtools.core.hftools.mVector.hCopy()

hCopy(out, in)

Copy input array to a numpy ndarray.

Parameters

out Numpy vector
in Input vector

Description

WARNING! Be careful with this function as it automatically typecasts to the type of the output array. In general you should always use matched types.

If the input vector is shorter than the output vector, it will be copied multiple times until the output vector is filled.

hCopy(in, out)

Copy from input numpy ndarray to an output array.

Parameters

in Input vector
out Numpy vector

Description

WARNING! Be carefull with this function as it automatically typecasts to the type of the output array. In general you should always use matched types.

If the input vector is shorter than the output vector, it will be copied mutliple times until the output vector is filled.

hCopy(vecout, vecin)

Copies a vector to another one without resizing them.

Parameters

vecout Vector containing a copy of the input values
vecin Input vector

Description

If the input vector is shorter than the output vector, it will be copied mutliple times until the output vector is filled. Use vec.resize first if you want to ensure that both vectors have the same size.

Usage

vec1.copy(vec2) -> copy elements of vec2 to vec1

hCopy(vecout, vecin, indexlist, number_of_elements)

Copies all elements provided in an indexlist from one vector to another (no resizing is done!).

Parameters

vecout Vector containing a copy of the input values
vecin Input vector
indexlist Index list containing the positions of the elements to be copied over, (e.g. [0,2,4,...] will copy every second element).
number_of_elements Maximum number of elements to be copied, if this value is <0, then copying will be repeated until the output vector is filled.

Description

If the index vector is shorter than the output vector, the (indexed part of the) input vector will be copied multiple times until the output vector is filled. Use vec.resize first if you want to ensure that both vectors have the same size. If number_of_elements is larger than 0 and smaller than the length of the index vector, the remaining elements in the index vector are simply ignored.

See also

hFindGreaterThan(), hRedistribute(), hFill()

pycrtools.core.hftools.mVector.hCopy()

hCopy(out, in)

Copy input array to a numpy ndarray.

Parameters

out Numpy vector
in Input vector

Description

WARNING! Be careful with this function as it automatically typecasts to the type of the output array. In general you should always use matched types.

If the input vector is shorter than the output vector, it will be copied multiple times until the output vector is filled.

hCopy(in, out)

Copy from input numpy ndarray to an output array.

Parameters

in Input vector
out Numpy vector

Description

WARNING! Be carefull with this function as it automatically typecasts to the type of the output array. In general you should always use matched types.

If the input vector is shorter than the output vector, it will be copied mutliple times until the output vector is filled.

hCopy(vecout, vecin)

Copies a vector to another one without resizing them.

Parameters

vecout Vector containing a copy of the input values
vecin Input vector

Description

If the input vector is shorter than the output vector, it will be copied mutliple times until the output vector is filled. Use vec.resize first if you want to ensure that both vectors have the same size.

Usage

vec1.copy(vec2) -> copy elements of vec2 to vec1

hCopy(vecout, vecin, indexlist, number_of_elements)

Copies all elements provided in an indexlist from one vector to another (no resizing is done!).

Parameters

vecout Vector containing a copy of the input values
vecin Input vector
indexlist Index list containing the positions of the elements to be copied over, (e.g. [0,2,4,...] will copy every second element).
number_of_elements Maximum number of elements to be copied, if this value is <0, then copying will be repeated until the output vector is filled.

Description

If the index vector is shorter than the output vector, the (indexed part of the) input vector will be copied multiple times until the output vector is filled. Use vec.resize first if you want to ensure that both vectors have the same size. If number_of_elements is larger than 0 and smaller than the length of the index vector, the remaining elements in the index vector are simply ignored.

See also

hFindGreaterThan(), hRedistribute(), hFill()

pycrtools.core.hftools.mVector.hFlip()

hFlip(vec)

Will reverse the order of elements in a vector, such the data will run from right to left rather than left to right.

Parameters

vec Input and output vector.

Description

The order of the elements in the vector will be reversed. Same as hReverse.

Usage

vec = [a_0,a_1,....,a_n-1,a_n]

vec.flip() ->  [a_n,a_n-1,a_n-2,...,a_0]

See also

hReverse()

pycrtools.core.hftools.mVector.hReverse()

hReverse(vec)

Will reverse the order of elements in a vector, such the data will run from right to left rather than left to right.

Parameters

vec Input and output vector.

Description

The order of the elements in the vector will be reversed (same as hFlip()).

Usage

vec = [a_0,a_1,....,a_n-1,a_n]

vec.reverse() ->  [a_n,a_n-1,a_n-2,...,a_0]

See also

hFlip()

pycrtools.core.hftools.mVector.hPrettyString()

hPrettyString(vec, maxlen)

Returns the contents of a vector (up to a maximum length) as a pretty string for printing

Parameters

vec Vector to output
maxlen Maximum length to output (all if negative).

Usage

hPrettyString(vec,start_slice,end_slice,maxlen) -> "[vec_0,vec_1,vec_3,...,vec_n-2,vec_n-1,vec_n]"

Example

>>> a=hArray(range(10))
>>> hPrettyString(a.vec(),8)
'[0,1,2,3,...,6,7,8,9]'

>>> hPrettyString(a.vec(),10)
'[0,1,2,3,4,5,6,7,8,9]'

>>> hPrettyString(a.vec(),12)
'[0,1,2,3,4,5,6,7,8,9]'

>>> hPrettyString(a.vec(),1)
'[0,...,9]'

>>> hPrettyString(a.vec(),0)
'[0,...,9]'

hPrettyString(vec, start_slice, end_slice, maxlen)

Returns the contents of a slice of a vector (up to a maximum length) as a pretty string for printing

Parameters

vec Vector to output
start_slice Start index.
end_slice End index).
maxlen Maximum length to output (all if negative).

Usage

hPrettyString(vec,start_slice,end_slice,maxlen) -> "[vec_0,vec_1,vec_3,...,vec_n-2,vec_n-1,vec_n]"

Example

>>> a=hArray(range(10))
>>> hPrettyString(a.vec(),0,10,8)
'[0,1,2,3,...,6,7,8,9]'

>>> hPrettyString(a.vec(),0,10,10)
'[0,1,2,3,4,5,6,7,8,9]'

>>> hPrettyString(a.vec(),0,10,12)
'[0,1,2,3,4,5,6,7,8,9]'

>>> hPrettyString(a.vec(),0,10,1)
'[0,...,9]'

>>> hPrettyString(a.vec(),0,10,0)
'[0,...,9]'

>>> hPrettyString(a.vec(),4,10,8)
'[4,5,6,7,8,9]'

>>> hPrettyString(a.vec(),4,10,4)
'[4,5,...,8,9]'
pycrtools.core.hftools.mVector.hPrettyString()

hPrettyString(vec, maxlen)

Returns the contents of a vector (up to a maximum length) as a pretty string for printing

Parameters

vec Vector to output
maxlen Maximum length to output (all if negative).

Usage

hPrettyString(vec,start_slice,end_slice,maxlen) -> "[vec_0,vec_1,vec_3,...,vec_n-2,vec_n-1,vec_n]"

Example

>>> a=hArray(range(10))
>>> hPrettyString(a.vec(),8)
'[0,1,2,3,...,6,7,8,9]'

>>> hPrettyString(a.vec(),10)
'[0,1,2,3,4,5,6,7,8,9]'

>>> hPrettyString(a.vec(),12)
'[0,1,2,3,4,5,6,7,8,9]'

>>> hPrettyString(a.vec(),1)
'[0,...,9]'

>>> hPrettyString(a.vec(),0)
'[0,...,9]'

hPrettyString(vec, start_slice, end_slice, maxlen)

Returns the contents of a slice of a vector (up to a maximum length) as a pretty string for printing

Parameters

vec Vector to output
start_slice Start index.
end_slice End index).
maxlen Maximum length to output (all if negative).

Usage

hPrettyString(vec,start_slice,end_slice,maxlen) -> "[vec_0,vec_1,vec_3,...,vec_n-2,vec_n-1,vec_n]"

Example

>>> a=hArray(range(10))
>>> hPrettyString(a.vec(),0,10,8)
'[0,1,2,3,...,6,7,8,9]'

>>> hPrettyString(a.vec(),0,10,10)
'[0,1,2,3,4,5,6,7,8,9]'

>>> hPrettyString(a.vec(),0,10,12)
'[0,1,2,3,4,5,6,7,8,9]'

>>> hPrettyString(a.vec(),0,10,1)
'[0,...,9]'

>>> hPrettyString(a.vec(),0,10,0)
'[0,...,9]'

>>> hPrettyString(a.vec(),4,10,8)
'[4,5,6,7,8,9]'

>>> hPrettyString(a.vec(),4,10,4)
'[4,5,...,8,9]'
pycrtools.core.hftools.mVector.hPPrint()

hPPrint(vec, maxlen)

Prints the contents of a vector (up to a maximum length) as a pretty string

Parameters

vec Vector to output
maxlen Maximum length to output.

Usage

hPrettyString(vec,3) -> '[vec_0,vec_1,vec_3,...]'

hPPrint(vec)

Prints the entire contents of a vector as a pretty string

Parameters

vec Vector to output

Usage

hPrettyString(vec) -> '[vec_0,vec_1,vec_3,...]'

pycrtools.core.hftools.mVector.hPPrint()

hPPrint(vec, maxlen)

Prints the contents of a vector (up to a maximum length) as a pretty string

Parameters

vec Vector to output
maxlen Maximum length to output.

Usage

hPrettyString(vec,3) -> '[vec_0,vec_1,vec_3,...]'

hPPrint(vec)

Prints the entire contents of a vector as a pretty string

Parameters

vec Vector to output

Usage

hPrettyString(vec) -> '[vec_0,vec_1,vec_3,...]'

pycrtools.core.hftools.mVector.hFillRange()

hFillRange(vec, start, increment)

Fills a vector with a series of values starting at a start value and then increasing by an increment until it is filled

Parameters

vec Vector to fill.
start Start value of the range.
increment Increment (to multiply loop variable with).

Usage

hFillRange(vec,-2.5,2.) -> [-2.5,-0.5,1.5,3.5,...]

vec.fillrange(start,increment) -> vec=[start, start+1*increment, start+2*increment ...]

pycrtools.core.hftools.mVector.hFillRangeVec()

hFillRangeVec(vec, start, increment)

Fills a vector of vectors with a series of values starting with a start vector and then increasing by an increment vector until it is filled

Parameters

vec Vector to fill - assumed to have sub-vectors of length N.
start Vector with N start values, i.e. one for each element of the sub-vectors in vec.
increment Vector with N Increment (to multiply loop variable with) values, i.e. one for each element of the sub-vectors in vec..

Description

The length of vec should be a multiple of the size of start.

Looping Behaviour:

Function fill loop over every element of vec. The size of start``determines the size of the sub-vectors. ``increment will be wrapped if it is shorter than vec (so, you can use the same increment for all elements of the sub-vector).

Usage

vec.fillrangevec([start],[increment]) -> vec=[start_0,start_1,..., start_0+1*increment_0, start_1+1*increment_1, ..., start_0+2*increment_0, start_1+2*increment_1, ...]

Example

#Create points which lie on a circle around the origin
#First create spherical coordinates with fillrangevec
ary=hArray(float,[8,3])
ary.fillrangevec(hArray([0.0,0.0,25.]),hArray([pi/4.,0.,0.]))
# ary -> hArray(float, [8L, 3L], fill=[0,0,25,0,0.785398,25,0,1.5708,25,0,2.35619,25,0,3.14159,25,0,3.92699,25,0,4.71239,25,0,5.49779,25]) # len=24 slice=[0:24])

#Then convert to Cartesian
xyz=hArray(float,[8,3]);
hCoordinateConvert(ary,CoordinateTypes.AzElRadius,xyz,CoordinateTypes.Cartesian,False)
#xyz -> hArray(float, [8L, 3L], fill=[0,25,0,0,17.6777,17.6777,0,1.53081e-15,25,-0,-17.6777,17.6777,-0,-25,3.06162e-15,-0,-17.6777,-17.6777,-0,-4.59243e-15,-25,0,17.6777,-17.6777]) # len=24 slice=[0:24])
pycrtools.core.hftools.mVector.hZipper()

hZipper(vec, vecA, vecB)

Combines two vectors into one where the elements of the vectors follow each other alternating between the input vectors. Equivalent to python ‘zip’.

Parameters

vec Vector to fill
vecA Input vector #1 of values to fill it with
vecB Input vector #2 of values to fill it with

Description

If the input vectors are shorther than vec they will wrap around and start from the beginning.

Usage

hZipper(vec,vecA,vecB) -> vec=[vecA_0,vecB_0,vecA_1,vecB_1,...,vecA_n,vecB_n]

vec.zipper(vecA,vecB) -> vec=[vecA_0,vecB_0,vecA_1,vecB_1,...,vecA_n,vecB_n]

pycrtools.core.hftools.mVector.hNew()

hNew(vec)

Make and return a new vector of the same size and type as the input vector.

Parameters

vec Input vector
pycrtools.core.hftools.mVector.hResize()

hResize(vec, newsize)

Resize a vector to a new length.

Parameters

vec Input vector
newsize New size of vector

hResize(vec, newsize, fill)

Resize a vector to a new length and fill new elements in vector with a specific value.

Parameters

vec Input vector
newsize New size
fill Value to fill new vector elements with

hResize(vec1, vec2)

Resize an STL vector to the same length as a second vector.

Parameters

vec1 Input vector to be resized
vec2 Reference vector

hResize(vec1, vec2)

Resize a casa vector to the same length as a second vector.

Parameters

vec1 Input vector to be resized
vec2 Reference vector
pycrtools.core.hftools.mVector.hResize()

hResize(vec, newsize)

Resize a vector to a new length.

Parameters

vec Input vector
newsize New size of vector

hResize(vec, newsize, fill)

Resize a vector to a new length and fill new elements in vector with a specific value.

Parameters

vec Input vector
newsize New size
fill Value to fill new vector elements with

hResize(vec1, vec2)

Resize an STL vector to the same length as a second vector.

Parameters

vec1 Input vector to be resized
vec2 Reference vector

hResize(vec1, vec2)

Resize a casa vector to the same length as a second vector.

Parameters

vec1 Input vector to be resized
vec2 Reference vector
pycrtools.core.hftools.mVector.hResize()

hResize(vec, newsize)

Resize a vector to a new length.

Parameters

vec Input vector
newsize New size of vector

hResize(vec, newsize, fill)

Resize a vector to a new length and fill new elements in vector with a specific value.

Parameters

vec Input vector
newsize New size
fill Value to fill new vector elements with

hResize(vec1, vec2)

Resize an STL vector to the same length as a second vector.

Parameters

vec1 Input vector to be resized
vec2 Reference vector

hResize(vec1, vec2)

Resize a casa vector to the same length as a second vector.

Parameters

vec1 Input vector to be resized
vec2 Reference vector
pycrtools.core.hftools.mVector.hResize()

hResize(vec, newsize)

Resize a vector to a new length.

Parameters

vec Input vector
newsize New size of vector

hResize(vec, newsize, fill)

Resize a vector to a new length and fill new elements in vector with a specific value.

Parameters

vec Input vector
newsize New size
fill Value to fill new vector elements with

hResize(vec1, vec2)

Resize an STL vector to the same length as a second vector.

Parameters

vec1 Input vector to be resized
vec2 Reference vector

hResize(vec1, vec2)

Resize a casa vector to the same length as a second vector.

Parameters

vec1 Input vector to be resized
vec2 Reference vector
pycrtools.core.hftools.mVector.hConvert()

hConvert(vec1, vec2)

Copies and converts a vector to a vector of another type.

Parameters

vec1 Output vector containing a copy of the input values converted to a new type
vec2 Numeric input vector

Usage

vec1.convert(vec2) -> Copy vec1 to vec2

pycrtools.core.hftools.mVector.hConvertResize()

hConvertResize(vecout, vecin)

Copies and converts a vector to a vector of another type and resizes the output vector.

Parameters

vecout Vector containing a copy of the input values converted to a new type
vecin Numeric input vector

Usage

vec1.convert(vec2) -> Copy vec1 to vec2

pycrtools.core.hftools.mVector.hCopy()

hCopy(out, in)

Copy input array to a numpy ndarray.

Parameters

out Numpy vector
in Input vector

Description

WARNING! Be careful with this function as it automatically typecasts to the type of the output array. In general you should always use matched types.

If the input vector is shorter than the output vector, it will be copied multiple times until the output vector is filled.

hCopy(in, out)

Copy from input numpy ndarray to an output array.

Parameters

in Input vector
out Numpy vector

Description

WARNING! Be carefull with this function as it automatically typecasts to the type of the output array. In general you should always use matched types.

If the input vector is shorter than the output vector, it will be copied mutliple times until the output vector is filled.

hCopy(vecout, vecin)

Copies a vector to another one without resizing them.

Parameters

vecout Vector containing a copy of the input values
vecin Input vector

Description

If the input vector is shorter than the output vector, it will be copied mutliple times until the output vector is filled. Use vec.resize first if you want to ensure that both vectors have the same size.

Usage

vec1.copy(vec2) -> copy elements of vec2 to vec1

hCopy(vecout, vecin, indexlist, number_of_elements)

Copies all elements provided in an indexlist from one vector to another (no resizing is done!).

Parameters

vecout Vector containing a copy of the input values
vecin Input vector
indexlist Index list containing the positions of the elements to be copied over, (e.g. [0,2,4,...] will copy every second element).
number_of_elements Maximum number of elements to be copied, if this value is <0, then copying will be repeated until the output vector is filled.

Description

If the index vector is shorter than the output vector, the (indexed part of the) input vector will be copied multiple times until the output vector is filled. Use vec.resize first if you want to ensure that both vectors have the same size. If number_of_elements is larger than 0 and smaller than the length of the index vector, the remaining elements in the index vector are simply ignored.

See also

hFindGreaterThan(), hRedistribute(), hFill()

pycrtools.core.hftools.mVector.hCopy()

hCopy(out, in)

Copy input array to a numpy ndarray.

Parameters

out Numpy vector
in Input vector

Description

WARNING! Be careful with this function as it automatically typecasts to the type of the output array. In general you should always use matched types.

If the input vector is shorter than the output vector, it will be copied multiple times until the output vector is filled.

hCopy(in, out)

Copy from input numpy ndarray to an output array.

Parameters

in Input vector
out Numpy vector

Description

WARNING! Be carefull with this function as it automatically typecasts to the type of the output array. In general you should always use matched types.

If the input vector is shorter than the output vector, it will be copied mutliple times until the output vector is filled.

hCopy(vecout, vecin)

Copies a vector to another one without resizing them.

Parameters

vecout Vector containing a copy of the input values
vecin Input vector

Description

If the input vector is shorter than the output vector, it will be copied mutliple times until the output vector is filled. Use vec.resize first if you want to ensure that both vectors have the same size.

Usage

vec1.copy(vec2) -> copy elements of vec2 to vec1

hCopy(vecout, vecin, indexlist, number_of_elements)

Copies all elements provided in an indexlist from one vector to another (no resizing is done!).

Parameters

vecout Vector containing a copy of the input values
vecin Input vector
indexlist Index list containing the positions of the elements to be copied over, (e.g. [0,2,4,...] will copy every second element).
number_of_elements Maximum number of elements to be copied, if this value is <0, then copying will be repeated until the output vector is filled.

Description

If the index vector is shorter than the output vector, the (indexed part of the) input vector will be copied multiple times until the output vector is filled. Use vec.resize first if you want to ensure that both vectors have the same size. If number_of_elements is larger than 0 and smaller than the length of the index vector, the remaining elements in the index vector are simply ignored.

See also

hFindGreaterThan(), hRedistribute(), hFill()

pycrtools.core.hftools.mVector.hCopyVec()

hCopyVec(vecout, vecin, indexlist, number_of_elements, veclen)

Copies all vectors of an array pointed to by an indexlist from one vector to another (no resizing is done!).

Parameters

vecout Vector containing a copy of the input values
vecin Input vector
indexlist Index list containing the positions of the elements to be copied over, (e.g. [0,2,4,...] will copy every second element).
number_of_elements Maximum number of elements to be copied, if this value is <0, then copying will be repeated until the output vector is filled.
veclen Length of the (sub-)vectors to copy.

Description

If the index vector is shorter than the output vector, the (indexed part of the) input vector will be copied multiple times until the output vector is filled. Use vec.resize first if you want to ensure that both vectors have the same size. If number_of_elements is larger than 0 and smaller than the length of the index vector, the remaining elements in the index vector are simply ignored.

If the index list is smaller than the number of elements to copy, then the indexlist will be wrapped and restarted from the beginning

See also

hFindGreaterThan(), hCopy()

Example

v1=hArray(float,[3,3],fill=range(9));
indx=hArray([0,2])
v2=hArray(properties=v1)
hCopyVec(v2,v1,indx,2,3) # -> hArray(float, [3L, 3L], fill=[0,1,2,6,7,8,0,0,0]) # len=9 slice=[0:9])
pycrtools.core.hftools.mVector.hShift()

hShift(vecout, vecin, N)

Shift the contents of a vector by a fixed number of samples, copying to another vector and wrapping the content that falls off at the end to the beginning

Parameters

vecout Vector containing a copy of the input vector shifted by N samples
vecin Input vector
N Shift input vector by N samples (shift left if negative).

Usage

vecout.shift(vecin,N) -> vecout contains vecin shifted by N samples (+ = right,  - = left)

Example

vecin=hArray(float,[9],fill=range(9)) # hArray(float, [9L], fill=[0,1,2,3,4,5,6,7,8]) # len=9 slice=[0:9])
vecout=hArray(float,[9],fill=0)       # hArray(float, [9L], fill=[0,0,0,0,0,0,0,0,0]) # len=9 slice=[0:9])

vecout.shift(vecin,3)
vecout                                # hArray(float, [9L], fill=[6,7,8,0,1,2,3,4,5]) # len=9 slice=[0:9])

vecout.shift(vecin,-3)
vecout                                # hArray(float, [9L], fill=[3,4,5,6,7,8,0,1,2]) # len=9 slice=[0:9])
pycrtools.core.hftools.mVector.hRedistribute()

hRedistribute(vec, invec, offset, stride)

Redistributes the values in one vector sequentially into another vector, given an offset and stride (interval) - can be used for a transpose operation

Parameters

vec Output vector
invec Input Vector
offset Offset from first element in output vector
stride Stride (interval) between subsequent elements in the output Vector

Description

Operation will stop whenever the end of one of the vectors is reached.

Usage

vec=[0,1,2,3]

vec.redistribute(invec,0,2) -> invec = [0,0,0,1,0,0,2,0,0,3,0,0]

pycrtools.core.hftools.mVector.hTranspose()

hTranspose(vec, invec, ncolumns)

Transposes the values in one vector given a certain 2D shape (lowest indices only) and return result in a second vector

Parameters

vec Output vector
invec Input Vector
ncolumns Number of columns in input vector (i.e., width of a row, or the last and fastest running index)

Description

Operation will stop whenever the end of one of the input vector is reached.

Usage

invec=[0,1,2,3,4,5]; ncolumns=2

hTranspose(outvec,invec,ncolumns) -> outvec = [0,2,4,1,3,5]

Example

>>>  x=hArray(range(6),[3,2])
>>>  y=hArray(int,[2,3],fill=-1)

>>>  x.mprint()
[0,1]
[2,3]
[4,5]

>>>  hTranspose(y,x,2)
>>>  y.mprint()
[0,2,4]
[1,3,5]

hTranspose(vec, invec, nrows, ncolumns)

Transposes the values in one vector given a certain 2D shape and return result in a second vector (can be applied to higher dimensions as well).

Parameters

vec Output vector
invec Input Vector
nrows Number of rows in input vector (i.e., width of a column, or the slower running index)
ncolumns Number of columns in input vector (i.e., width of a row, or the faster running index)

Description

Operation will stop whenever the end of one of the input vector is reached.

Usage

invec=[0,1,2,3,4,5]; ncolumns=2

hTranspose(outvec,invec,ncolumns) -> outvec = [0,2,4,1,3,5]

Example

>>>  x=hArray(range(6),[3,2])
>>>  y=hArray(int,[2,3],fill=-1)
>>>  x.mprint()
[0,1]
[2,3]
[4,5]

>>>  hTranspose(y,x,2)
>>>  y.mprint()
[0,2,4]
[1,3,5]
pycrtools.core.hftools.mVector.hTranspose()

hTranspose(vec, invec, ncolumns)

Transposes the values in one vector given a certain 2D shape (lowest indices only) and return result in a second vector

Parameters

vec Output vector
invec Input Vector
ncolumns Number of columns in input vector (i.e., width of a row, or the last and fastest running index)

Description

Operation will stop whenever the end of one of the input vector is reached.

Usage

invec=[0,1,2,3,4,5]; ncolumns=2

hTranspose(outvec,invec,ncolumns) -> outvec = [0,2,4,1,3,5]

Example

>>>  x=hArray(range(6),[3,2])
>>>  y=hArray(int,[2,3],fill=-1)

>>>  x.mprint()
[0,1]
[2,3]
[4,5]

>>>  hTranspose(y,x,2)
>>>  y.mprint()
[0,2,4]
[1,3,5]

hTranspose(vec, invec, nrows, ncolumns)

Transposes the values in one vector given a certain 2D shape and return result in a second vector (can be applied to higher dimensions as well).

Parameters

vec Output vector
invec Input Vector
nrows Number of rows in input vector (i.e., width of a column, or the slower running index)
ncolumns Number of columns in input vector (i.e., width of a row, or the faster running index)

Description

Operation will stop whenever the end of one of the input vector is reached.

Usage

invec=[0,1,2,3,4,5]; ncolumns=2

hTranspose(outvec,invec,ncolumns) -> outvec = [0,2,4,1,3,5]

Example

>>>  x=hArray(range(6),[3,2])
>>>  y=hArray(int,[2,3],fill=-1)
>>>  x.mprint()
[0,1]
[2,3]
[4,5]

>>>  hTranspose(y,x,2)
>>>  y.mprint()
[0,2,4]
[1,3,5]
pycrtools.core.hftools.mVector.hVectorLength()

hVectorLength(vec)

Returns the lengths or norm of a vector (i.e. Sqrt(Sum_i(xi*+2))).

Parameters

vec Numeric input vector

See also

hVectorSeparation()

hVectorLength(vec1, vec2)

Returns the absolute length of a vector between two N-dim vectors, i.e. Sqrt(Sum_i((x2_i-x1_i)^2)).

Parameters

vec1 Numeric input vector
vec2 Numeric input vector

See also

hVectorSeparation()

pycrtools.core.hftools.mVector.hVectorLength()

hVectorLength(vec)

Returns the lengths or norm of a vector (i.e. Sqrt(Sum_i(xi*+2))).

Parameters

vec Numeric input vector

See also

hVectorSeparation()

hVectorLength(vec1, vec2)

Returns the absolute length of a vector between two N-dim vectors, i.e. Sqrt(Sum_i((x2_i-x1_i)^2)).

Parameters

vec1 Numeric input vector
vec2 Numeric input vector

See also

hVectorSeparation()

pycrtools.core.hftools.mVector.hVectorSeparation()

hVectorSeparation(vec, vec1, vec2)

Returns the length of the difference of two vectors (i.e., their separation).

Parameters

vec Numeric output vector containing length of vec1-vec2
vec1 Numeric input vector
vec2 Numeric input vector

Description

This function will loop over the first input vector, if it is shorter than the last input vector. The length of the vector to sum (i.e., the number elements to sum over) is determined by the first vector.

The length of the output vector should then be len(vec)=len(vec1)/len(vec2).

Usage

separation.vectorseparation(vec1,vec2) # separation -> |vec1-vec2|

See also

hVectorLength()

Example

ary=hArray(float,[3,3],fill=range(9))
sep=hArray(float,[3])
sep.vectorseparation(hArray([1.,1,1]),ary)
#sep -> hArray(float, [3L], fill=[1.41421,5.38516,10.4881]) # len=3 slice=[0:3])
pycrtools.core.hftools.mVector.hNormalize()

hNormalize(vec)

Normalizes a vector to length unity.

Parameters

vec Numeric input and output vector