MBO
 All Data Structures Files Functions Variables Typedefs Enumerations Modules Pages
MboVec.h
Go to the documentation of this file.
1 /*
2 Copyright 2014 Dominic Meiser
3 
4 This file is part of mbo.
5 
6 mbo is free software: you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation, either version 3 of the License, or (at your
9 option) any later version.
10 
11 mbo is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
15 
16 You should have received a copy of the GNU General Public License along
17 with mbo. If not, see <http://www.gnu.org/licenses/>.
18 */
29 #ifndef MBO_VEC_H
30 #define MBO_VEC_H
31 
32 #include <MboExport.h>
33 #include <MboErrors.h>
34 #include <MboIndices.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 struct MboAmplitude;
41 struct MboVec_t;
43 typedef struct MboVec_t *MboVec;
44 
45 
47 MBO_EXPORT MBO_STATUS mboVecCreate(MboGlobInd dim, MboVec *v);
48 
50 MBO_EXPORT MBO_STATUS mboVecDestroy(MboVec *v);
51 
59 MBO_EXPORT MBO_STATUS mboVecUnitVector(MboGlobInd n, MboVec v);
60 
62 MBO_EXPORT MboGlobInd mboVecDim(MboVec v);
63 
73 MBO_EXPORT MBO_STATUS mboVecGetViewRW(MboVec v, struct MboAmplitude **array);
74 
83 MBO_EXPORT MBO_STATUS mboVecGetViewR(MboVec v, struct MboAmplitude **array);
84 
86 MBO_EXPORT MBO_STATUS mboVecReleaseView(MboVec v, struct MboAmplitude **array);
87 
90 MBO_EXPORT MBO_STATUS mboVecAXPY(struct MboAmplitude *a, MboVec x, MboVec y);
91 
97 MBO_EXPORT MBO_STATUS mboVecDot(MboVec x, MboVec y, struct MboAmplitude *result);
98 
106 MBO_EXPORT MBO_STATUS mboVecSwap(MboVec x, MboVec y);
107 
109 MBO_EXPORT MBO_STATUS mboVecSet(struct MboAmplitude *a, MboVec x);
110 
112 MBO_EXPORT MBO_STATUS mboVecSetRandom(MboVec x);
113 
128 MBO_EXPORT MBO_STATUS
129 mboVecKron(int n, MboLocInd *dims, struct MboAmplitude **vecs, MboVec x);
130 
143 MBO_EXPORT MBO_STATUS
144 mboVecMap(int n, MboLocInd *dims,
145  void f(int, MboLocInd *, MboLocInd *, void *, struct MboAmplitude *),
146  void *ctx, MboVec x);
147 
158 MBO_EXPORT MBO_STATUS mboVecDuplicate(MboVec x, MboVec *y);
159 
165 MBO_EXPORT int mboVecCheck(MboVec v);
166 
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif
MBO_EXPORT MBO_STATUS mboVecGetViewR(MboVec v, struct MboAmplitude **array)
Obtain a read-only view of vector data.
MBO_EXPORT MBO_STATUS mboVecSet(struct MboAmplitude *a, MboVec x)
set vector to a constant
MBO_EXPORT MBO_STATUS mboVecSwap(MboVec x, MboVec y)
swap contents of two vectors.
MBO_EXPORT MboGlobInd mboVecDim(MboVec v)
Get dimension of vector.
Error codes used by the MBO library.
MBO_EXPORT MBO_STATUS mboVecSetRandom(MboVec x)
Fill a vector with random numbers.
MBO_EXPORT MBO_STATUS mboVecDestroy(MboVec *v)
Release all resources of a MboVec.
MBO_EXPORT MBO_STATUS mboVecDuplicate(MboVec x, MboVec *y)
Duplicate a vector.
MBO_EXPORT MBO_STATUS mboVecReleaseView(MboVec v, struct MboAmplitude **array)
Release a view of the vector data.
Minimal complex numbers.
Definition: MboAmplitude.h:37
MBO_EXPORT MBO_STATUS mboVecDot(MboVec x, MboVec y, struct MboAmplitude *result)
computes the dot product of two vectors
MBO_STATUS
Error codes used by the MBO library.
Definition: MboErrors.h:33
MBO_EXPORT MBO_STATUS mboVecCreate(MboGlobInd dim, MboVec *v)
Create MboVec of dimension dim.
MBO_EXPORT int mboVecCheck(MboVec v)
Check integrity of MboVec.
MBO_EXPORT MBO_STATUS mboVecAXPY(struct MboAmplitude *a, MboVec x, MboVec y)
y <- a * x + y
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...
long long MboGlobInd
Global indices.
Definition: MboIndices.h:34
struct MboVec_t * MboVec
Data type for representing vectors.
Definition: MboVec.h:43
int MboLocInd
Local indices.
Definition: MboIndices.h:31
Integer types for indices used in mbo library.
MBO_EXPORT MBO_STATUS mboVecGetViewRW(MboVec v, struct MboAmplitude **array)
Obtain a read-write view of the vector data.
MBO_EXPORT MBO_STATUS mboVecKron(int n, MboLocInd *dims, struct MboAmplitude **vecs, MboVec x)
Add outer product of vectors.
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.