MBO
 All Data Structures Files Functions Variables Typedefs Enumerations Modules Pages
Typedefs | Functions
MboVec

Typedefs

typedef struct MboVec_t * MboVec
 Data type for representing vectors.
 

Functions

MBO_EXPORT MBO_STATUS mboVecCreate (MboGlobInd dim, MboVec *v)
 Create MboVec of dimension dim.
 
MBO_EXPORT MBO_STATUS mboVecDestroy (MboVec *v)
 Release all resources of a MboVec.
 
MBO_EXPORT MBO_STATUS mboVecUnitVector (MboGlobInd n, MboVec v)
 Fill vector with nth unit vector Sets the nth entry in the vector to 1 and all other entries to zero. More...
 
MBO_EXPORT MboGlobInd mboVecDim (MboVec v)
 Get dimension of vector.
 
MBO_EXPORT MBO_STATUS mboVecGetViewRW (MboVec v, struct MboAmplitude **array)
 Obtain a read-write view of the vector data. More...
 
MBO_EXPORT MBO_STATUS mboVecGetViewR (MboVec v, struct MboAmplitude **array)
 Obtain a read-only view of vector data. More...
 
MBO_EXPORT MBO_STATUS mboVecReleaseView (MboVec v, struct MboAmplitude **array)
 Release a view of the vector data.
 
MBO_EXPORT MBO_STATUS mboVecAXPY (struct MboAmplitude *a, MboVec x, MboVec y)
 y <- a * x + y
 
MBO_EXPORT MBO_STATUS mboVecDot (MboVec x, MboVec y, struct MboAmplitude *result)
 computes the dot product of two vectors More...
 
MBO_EXPORT MBO_STATUS mboVecSwap (MboVec x, MboVec y)
 swap contents of two vectors. More...
 
MBO_EXPORT MBO_STATUS mboVecSet (struct MboAmplitude *a, MboVec x)
 set vector to a constant
 
MBO_EXPORT MBO_STATUS mboVecSetRandom (MboVec x)
 Fill a vector with random numbers.
 
MBO_EXPORT MBO_STATUS mboVecKron (int n, MboLocInd *dims, struct MboAmplitude **vecs, MboVec x)
 Add outer product of vectors. More...
 
MBO_EXPORT MBO_STATUS mboVecMap (int n, MboLocInd *dims, void f(int, MboLocInd *, MboLocInd *, void *, struct MboAmplitude *), void *ctx, MboVec x)
 Apply a function to every entry in a vector. More...
 
MBO_EXPORT MBO_STATUS mboVecDuplicate (MboVec x, MboVec *y)
 Duplicate a vector. More...
 
MBO_EXPORT int mboVecCheck (MboVec v)
 Check integrity of MboVec. More...
 

Detailed Description

Function Documentation

MBO_EXPORT int mboVecCheck ( MboVec  v)

Check integrity of MboVec.

Parameters
vThe vector to be checked.
Returns
The number of errors enountered.
See also
MboVec
MBO_EXPORT MBO_STATUS mboVecDot ( MboVec  x,
MboVec  y,
struct MboAmplitude result 
)

computes the dot product of two vectors

Parameters
xvector on left hand side in dot product ("Bra")
yvector on right hand size in dot product ("Ket")
resultthe dot product
MBO_EXPORT MBO_STATUS mboVecDuplicate ( MboVec  x,
MboVec y 
)

Duplicate a vector.

Generates a copy of x. The new vector must be destroyed with mboVecDestroy.

Parameters
xVector to copy
yUpon exit contains the duplicate vector.
See also
mboVecDestroy, MboVec
MBO_EXPORT MBO_STATUS mboVecGetViewR ( MboVec  v,
struct MboAmplitude **  array 
)

Obtain a read-only view of vector data.

The view has to be released using mboVecReleaseView before the vector can be used again. Any modifications to the array lead to undefined behaviour. To obtain a modifiable array use mboVecGetViewRW.

See also
mboVecReleaseView, mboVecGetViewRW
MBO_EXPORT MBO_STATUS mboVecGetViewRW ( MboVec  v,
struct MboAmplitude **  array 
)

Obtain a read-write view of the vector data.

  • The view has to be released using mboVecReleaseView before the vector can be used again. Getting a modifiable array may incur additional synchronization overheads. If the array contents doesn't need to be modified better performance may be obtained with mboVecGetViewR.
See also
mboVecReleaseView, mboVecGetViewR
MBO_EXPORT MBO_STATUS mboVecKron ( int  n,
MboLocInd dims,
struct MboAmplitude **  vecs,
MboVec  x 
)

Add outer product of vectors.

Parameters
nNumber of arrays. n can be obtained from an MboProdSpace object by means of mboProdSpaceSize.
dimsLength of each array. This array has to be at least of length n. dims can be obtained from an MboProdSpace object by means of mboProdSpaceGetDims.
vecsArray of arrays of vectors the outer product of which is taken. Has to contain at least n arrays and vecs[i] has to be at least of length dims[i].
xThe vector to which the result of the outer product is to be added.
See also
mboProdSpaceSize, mboProdSpaceGetDims
MBO_EXPORT MBO_STATUS mboVecMap ( int  n,
MboLocInd dims,
void   fint, MboLocInd *, MboLocInd *, void *, struct MboAmplitude *,
void *  ctx,
MboVec  x 
)

Apply a function to every entry in a vector.

Parameters
nNumber of dimensions.
dimsDimensions of underlying product space.
fFunction to apply to entries. As the first two arguments n and dims are passed to f. The next integer array is the set of indices for a given invocation of f. The last argument is a function defined context. The context is never accessed by mboVecMap.
ctxContext for function application. The context is never accessed by mboVecMap.
xThe vector to which the function is applied.
MBO_EXPORT MBO_STATUS mboVecSwap ( MboVec  x,
MboVec  y 
)

swap contents of two vectors.

The dimensions of the two vectors must match.

Parameters
xFirst vector to swap.
ySecond vector to swap.
MBO_EXPORT MBO_STATUS mboVecUnitVector ( MboGlobInd  n,
MboVec  v 
)

Fill vector with nth unit vector Sets the nth entry in the vector to 1 and all other entries to zero.

Parameters
nDimension in vector to set to 1.
vThe vector to be filled by the unit vector. v must have been previously created with mboVecCreate.
See also
mboVecCreate