24 #ifndef _GEMA_VECTOR_UTILS_H_ 25 #define _GEMA_VECTOR_UTILS_H_ 27 #ifndef GM_VECTOR_DEFINED 30 #define GM_VECTOR_DEFINED 40 #if ARMA_VERSION_MAJOR != 5 || ARMA_VERSION_MINOR != 200 41 #error Unexpected Armadillo version. Please check that our internal fiddling done bellow is still valid 55 assert(a.n_elem == b.n_elem);
58 for(
unsigned int i = 0; i<a.n_elem; i++)
60 double d = a[i] - b[i];
76 for(
unsigned int i = 0; i<v.n_elem; i++)
84 if(a.n_elem != b.n_elem)
86 for(
unsigned i = 0; i<a.n_elem; i++)
97 for(
unsigned i = 0; i<a.n_elem; i++)
118 assert(v.vec_state == 1);
119 assert(v.mem_state == 2 || (v.mem_state == 0 && v.n_elem == 0 && v.mem == NULL));
120 arma::access::rw(v.mem) = data;
121 arma::access::rw(v.mem_state) = 2;
122 arma::access::rw(v.n_rows) = nlin;
123 arma::access::rw(v.n_cols) = 1;
124 arma::access::rw(v.n_elem) = nlin;
137 assert(v.vec_state == 1);
140 arma::access::rw(v.mem) = NULL;
141 arma::access::rw(v.mem_state) = 0;
142 arma::access::rw(v.n_rows) = 0;
143 arma::access::rw(v.n_cols) = 1;
144 arma::access::rw(v.n_elem) = 0;
146 else if(v.mem_state == 0)
149 arma::access::rw(v.mem) = NULL;
169 assert(v.vec_state == 1);
170 assert(v.mem_state == 2);
172 arma::access::rw(v.n_rows) = nlin;
173 arma::access::rw(v.n_cols) = 1;
174 arma::access::rw(v.n_elem) = nlin;
178 char format =
'g',
int precision = -1);
#define GM_DOUBLECMP_ABSTOL
Tolerância absoluta entre valores para comparar valores próximos de zero.
Definition: gmDoubleCmp.h:64
double distance(const GmVector &a, const GmVector &b)
Returns the distance between vectors a and b.
Definition: gmVectorUtils.h:67
double equal(const GmVector &a, const GmVector &b, double relTol=GM_DOUBLECMP_RELTOL, double absTol=GM_DOUBLECMP_ABSTOL)
Check to see if two vectors are equal comparing values using GmDoubleCmp::equal.
Definition: gmVectorUtils.h:82
void resetVectorMemory(GmVector &v)
Updates a vector that was prepared with setVectorMemory() to a common empty column vector....
Definition: gmVectorUtils.h:132
bool equal(double a, double b, double relTol=GM_DOUBLECMP_RELTOL, double absTol=GM_DOUBLECMP_ABSTOL)
Funcao para comparar se dois números reais são iguais usando uma tolerância recebida como parâmetro.
Definition: gmDoubleCmp.h:71
void fillFromLuaTable(GmVector &v, LuaTable &t)
Resizes and fills the vector v to receive the data stored in a lua table.
Definition: gmVectorUtils.cpp:60
double sqrDistance(const GmVector &a, const GmVector &b)
Returns the squared distance between vectors a and b.
Definition: gmVectorUtils.h:53
Functions for comparing double values.
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVectorUtils.h:32
double isZero(const GmVector &a, double absTol)
Check to see if a vector is zero using GmDoubleCmp::isZero over each component.
Definition: gmVectorUtils.h:95
void print(const GmVector &v, const GmLogCategory &logger, GmLogLevel level, int fieldWidth, char format, int precision)
Prints the vector using the specified logger, level and precision fields. Values are separated by spa...
Definition: gmVectorUtils.cpp:34
Groups utilitary routines for working with vectors.
Definition: gmVectorUtils.cpp:30
QString toString(const GmVector &v, int fieldWidth, char format, int precision, bool noBraces)
Serializes the vector to a string using the specified precision fields. Coordinates are surrounded by...
Definition: gmVectorUtils.cpp:48
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
GmLogLevel
Available log levels list.
Definition: gmLog.h:36
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
#define GM_DOUBLECMP_RELTOL
Tolerância relativa entre valores = 0.000001%.
Definition: gmDoubleCmp.h:61
bool isZero(double a, double absTol)
Funcao para comparar se o valor a é ou não igual a zero dada uma tolerância absoluta.
Definition: gmDoubleCmp.h:93
void setVectorSize(GmVector &v, int nlin)
Updates the logical vector size WITHOUT changin the used memory area. DANGEROUS. Should be used only ...
Definition: gmVectorUtils.h:164
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
bool hasSharedMemory(GmVector &v)
Is this vector operating over a shared memory (set by setVectorMemory())?
Definition: gmVectorUtils.h:156
void setVectorMemory(GmVector &v, double *data, int nlin)
Updates the memory area used internally by a vector. DANGEROUS. Should be used only by the bold ones ...
Definition: gmVectorUtils.h:113
double sqrNorm(const GmVector &v)
Returns the squared norm of vector v.
Definition: gmVectorUtils.h:73
Declaration of support functions and macros for information logging.