Xmipp  v3.23.11-Nereus
Classes | Macros | Functions
multidim_array.h File Reference
#include "xmipp_macros.h"
#include <sys/mman.h>
#include <complex>
#include "matrix1d.h"
#include "xmipp_random_mode.h"
#include "multidim_array_base.h"
#include "xmipp_memory.h"
#include "axis_view.h"
Include dependency graph for multidim_array.h:

Go to the source code of this file.

Classes

class  Matrix2D< T >
 
class  MultidimArray< T >
 
class  MultidimArray< T >
 

Macros

#define ASSIGNVAL2D(d, i, j)
 
#define ASSIGNVAL2DNODIV(d, i, j)
 
#define ASSIGNVAL1D(d, j)
 
Size
#define checkDimension(dim)   checkDimensionWithDebug(dim,__FILE__,__LINE__)
 

Functions

int bestPrecision (float F, int _width)
 
String floatToString (float F, int _width, int _prec)
 
template<typename T >
void coreArrayByScalar (const MultidimArray< T > &op1, const T &op2, MultidimArray< T > &result, char operation)
 
template<typename T >
void coreScalarByArray (const T &op1, const MultidimArray< T > &op2, MultidimArray< T > &result, char operation)
 
template<typename T >
void coreArrayByArray (const MultidimArray< T > &op1, const MultidimArray< T > &op2, MultidimArray< T > &result, char operation)
 
template<typename T >
void selfCoreArrayByArrayMask (const MultidimArray< T > &op1, const MultidimArray< T > &op2, MultidimArray< T > &result, char operation, const MultidimArray< T > *mask)
 
template<>
std::ostream & operator<< (std::ostream &ostrm, const MultidimArray< std::complex< double > > &v)
 
template<>
bool operator== (const MultidimArray< std::complex< double > > &op1, const MultidimArray< std::complex< double > > &op2)
 
Functions for all multidimensional arrays
template<typename T1 , typename T2 >
void typeCast (const MultidimArray< T1 > &v1, MultidimArray< T2 > &v2)
 
template<typename T1 >
void typeCastComplex (const MultidimArray< T1 > &v1, MultidimArray< std::complex< double > > &v2)
 
template<typename T1 >
void typeCast (const MultidimArray< T1 > &v1, MultidimArray< T1 > &v2)
 
template<typename T >
void typeCast (const MultidimArray< T > &v1, Matrix1D< T > &v2)
 
template<typename T >
bool operator== (const MultidimArray< T > &op1, const MultidimArray< T > &op2)
 
template<typename T >
bool operator!= (const MultidimArray< T > &op1, const MultidimArray< T > &op2)
 
template<typename T >
void cutToCommonSize (MultidimArray< T > &V1, MultidimArray< T > &V2)
 
void sincos (const MultidimArray< double > &x, MultidimArray< double > &s, MultidimArray< double > &c)
 
void planeFit (const MultidimArray< double > &z, const MultidimArray< double > &x, const MultidimArray< double > &y, double &p0, double &p1, double &p2)
 
template<typename T >
void mod (const MultidimArray< T > &x, MultidimArray< T > &m, double y)
 
template<typename T >
std::ostream & operator<< (std::ostream &ostrm, const MultidimArray< T > &v)
 
template<typename T >
void window2D (const MultidimArray< T > &Ibig, MultidimArray< T > &Ismall, size_t y0, size_t x0, size_t yF, size_t xF)
 
template<typename T >
double correlationIndex (const MultidimArray< T > &x, const MultidimArray< T > &y, const MultidimArray< int > *mask=NULL, MultidimArray< double > *Contributions=NULL)
 

Macro Definition Documentation

◆ ASSIGNVAL1D

#define ASSIGNVAL1D (   d,
  j 
)
Value:
if ((j) < j0 || (j) > jF) \
d=outside_value;\
else \
d=A1D_ELEM(*this, j);
#define A1D_ELEM(v, i)
#define j

◆ ASSIGNVAL2D

#define ASSIGNVAL2D (   d,
  i,
  j 
)
Value:
if ((j) < j0 || (j) > jF || (i) < i0 || (i) > iF) \
d=outside_value;\
else \
d=A2D_ELEM(*this, i, j);
#define A2D_ELEM(v, i, j)
#define i
#define j

◆ ASSIGNVAL2DNODIV

#define ASSIGNVAL2DNODIV (   d,
  i,
  j 
)
Value:
b = ((j) < j0 || (j) > jF || (i) < i0 || (i) > iF); \
b ? d=0 : d=A2D_ELEM(*this, i, j);
#define A2D_ELEM(v, i, j)
#define i
doublereal * d
doublereal * b
#define j

◆ checkDimension

#define checkDimension (   dim)    checkDimensionWithDebug(dim,__FILE__,__LINE__)

Check dimension.

returns true if the dimension is equal to the argument and false otherwise It also prints an error message in the latter case.

Definition at line 520 of file multidim_array.h.

Function Documentation

◆ bestPrecision()

int bestPrecision ( float  F,
int  _width 
)

Definition at line 176 of file xmipp_strings.cpp.

177 {
178  // If it is 0
179  if (F == 0)
180  return 1;
181 
182  // Otherwise
183  int exp = FLOOR(log10(ABS(F)));
184  int advised_prec;
185 
186  if (exp >= 0)
187  if (exp > _width - 3)
188  advised_prec = -1;
189  else
190  advised_prec = _width - 2;
191  else
192  {
193  advised_prec = _width + (exp - 1) - 3;
194  if (advised_prec <= 0)
195  advised_prec = -1;
196  }
197 
198  if (advised_prec < 0)
199  advised_prec = -1; // Choose exponential format
200 
201  return advised_prec;
202 }
#define FLOOR(x)
Definition: xmipp_macros.h:240
#define ABS(x)
Definition: xmipp_macros.h:142
void log10(Image< double > &op)

◆ floatToString()

String floatToString ( float  F,
int  _width,
int  _prec 
)

Definition at line 204 of file xmipp_strings.cpp.

205 {
206 #if GCC_VERSION < 30300
207  char aux[15];
208  std::ostrstream outs(aux, sizeof(aux));
209 #else
210 
211  std::ostringstream outs;
212 #endif
213 
214  outs.fill(' ');
215 
216  if (_width != 0)
217  outs.width(_width);
218 
219  if (_prec == 0)
220  _prec = bestPrecision(F, _width);
221 
222  if (_prec == -1 && _width > 7)
223  {
224  outs.precision(_width - 7);
225  outs.setf(std::ios::scientific);
226  }
227  else
228  outs.precision(_prec);
229 
230 #if GCC_VERSION < 30301
231 
232  outs << F << std::ends;
233 #else
234 
235  outs << F;
236 #endif
237 
238 #if GCC_VERSION < 30300
239 
240  return String(aux);
241 #else
242 
243  String retval = outs.str();
244  int i = retval.find('\0');
245 
246  if (i != -1)
247  retval = retval.substr(0, i);
248 
249  return retval;
250 #endif
251 }
int bestPrecision(float F, int _width)
#define i
std::string String
Definition: xmipp_strings.h:34