26 #ifndef CORE_XMIPP_FUNCS_H 27 #define CORE_XMIPP_FUNCS_H 41 #include <sys/times.h> 44 #include <sys/types.h> 94 #define TSINCVALUE(Tsinc, x,y) \ 96 int TSINCVALUEaux=(int)(x * Tsinc.isampl); \ 97 y=Tsinc.tabulatedsinc[ABS(TSINCVALUEaux)]; \ 104 int aux=(int)(val * isampl);
105 return tabulatedsinc[
ABS(aux)];
111 no_elem = (int)(xmax / sampl);
112 tabulatedsinc =
new double[
no_elem];
113 tabulatedsinc[0] = 1;
116 double xx = (double)
i * sampl *
PI;
117 tabulatedsinc[
i] = sin(xx) / xx;
163 void build_I0table();
169 double v_,
int N_,
double vtable_=0.,
173 double I0table_maxerror();
180 double sinhwin(
double x)
const;
183 double i0win(
double x)
const;
193 return i0table[ (int) xt];
203 #if defined(__APPLE__) || defined(__MINGW32__) 207 void sin_cos(
double angle,
double * sine,
double * cosine);
238 double tstudent1D(
double x,
double df,
double sigma,
double mu = 0);
317 void computeStats(
const std::vector<T> &V,
double& avg,
double& stddev,
318 T& minval, T& maxval)
326 minval = maxval = V[0];
328 size_t nmax=V.size();
330 for(
size_t n=0;
n<
nmax; ++
n, ++ptr)
338 else if (val < minval)
345 stddev = stddev / nmax - avg * avg;
346 stddev *= nmax / (nmax - 1);
349 stddev =
sqrt(static_cast< double >(
ABS(stddev)));
366 size_t nmax=V.size();
368 for(
size_t n=0;
n<
nmax; ++
n, ++ptr)
378 stddev = stddev / nmax - avg * avg;
379 stddev *= nmax / (nmax - 1);
382 stddev =
sqrt(static_cast< double >(
ABS(stddev)));
393 size_t nmax=V.size();
394 for(
size_t n=0;
n<
nmax; ++
n, ++ptr)
407 template <
typename T>
410 std::complex< double >* _complex,
413 T* aux_real = (T*) _real;
414 T* aux_imag = (T*) _imag;
415 double* aux_complex = (
double*) _complex;
419 *aux_complex++ = (double)(*aux_real++);
420 *aux_complex++ = (double)(*aux_imag++);
430 template <
typename T>
433 std::complex< double >* _complex,
436 T* aux_ampl = (T*) _ampl;
437 T* aux_phase = (T*) _phase;
438 double* aux_complex = (
double*) _complex;
442 double ampl = (double)(*aux_ampl++);
443 double phase = (double)(*aux_phase++);
444 *aux_complex++ = ampl * cos(phase);
445 *aux_complex++ = ampl * sin(phase);
455 template <
typename T>
461 T* aux_real = (T*) _real;
462 T* aux_imag = (T*) _imag;
463 double* aux_complex = (
double*) _complex;
467 *aux_real++ = (T)(*aux_complex++);
468 *aux_imag++ = (T)(*aux_complex++);
478 template <
typename T>
484 T* aux_ampl = (T*) _ampl;
485 T* aux_phase = (T*) _phase;
486 double* aux_complex = (
double*) _complex;
490 double re = *aux_complex++;
491 double im = *aux_complex++;
492 *aux_ampl++ =
sqrt(re * re + im * im);
493 *aux_phase++ = atan2(im, re);
620 double gaus_from_x0(
double x0,
double mean = 0,
double stddev = 1);
669 double chi2_from_t0(
double t0,
double degrees_of_freedom);
817 #if defined _NO_TIME || defined __MINGW32__ 820 struct tm* localtime_r (
const time_t *clock,
struct tm *result);
839 #if !defined _NO_TIME && !defined __MINGW32__ 867 #if !defined _NO_TIME && !defined __MINGW32__ 903 #if !defined _NO_TIME && !defined __MINGW32__ 958 size_t toc(
const char * msg=NULL,
bool inSecs=
true);
962 #if !defined _NO_TIME && !defined __MINGW32__ 1039 virtual void OnInitOperation(
unsigned long _est_it) = 0;
1048 virtual void OnReportOperation(
const std::string& _rsOp) = 0;
1061 virtual void OnProgress(
unsigned long _it) = 0;
1118 virtual void OnInitOperation(
unsigned long _est_it);
1128 virtual void OnProgress(
unsigned long _it);
1134 virtual void OnReportOperation(
const std::string& _rsOp);
1173 size_t xmippFREAD(
void* dest,
size_t size,
size_t nitems, FILE*& fp,
1174 bool reverse =
false);
1187 bool reverse =
false);
1194 void mapFile(
const FileName &filename,
char*&map,
size_t &size,
int &fileDescriptor,
bool readOnly=
true);
1197 void unmapFile(
char *&map,
size_t &size,
int& fileDescriptor);
1203 #define little22bigendian(x) swapbytes((unsigned char*)& x,sizeof(x)) double cdf_gauss(double x)
void init_progress_bar(long total)
void TimeMessage(const std::string &message)
double student_outside_probb(double p, double degrees_of_freedom)
double student_within_t0(double t0, double degrees_of_freedom)
Tabsinc(const double dd, const int xx)
double gaus_up_to_x0(double x0, double mean=0, double stddev=1)
double cdf_tstudent(int k, double t)
double rnd_student_t(double nu)
virtual const bool & OnUserCancel() const
bool IsLittleEndian(void)
void swapbytes(char *v, unsigned long n)
char * getCurrentTimeString()
int solve_2nd_degree_eq(double a, double b, double c, double &x1, double &x2, double prec=XMIPP_EQUAL_ACCURACY)
void sqrt(Image< double > &op)
void annotate_processor_time(ProcessorTimeStamp *time)
size_t divide_equally(size_t N, size_t size, size_t rank, size_t &first, size_t &last)
virtual const unsigned & getVerbosity() const
double icdf_gauss(double p)
void processMemUsage(double &vm_usage, double &resident_set)
double elapsed_time(ProcessorTimeStamp &time, bool _IN_SECS=true)
double time_to_go(ProcessorTimeStamp &time, double fraction_done)
double cdf_FSnedecor(int d1, int d2, double x)
double student_up_to_t0(double t0, double degrees_of_freedom)
void RealImag2Complex(const T *_real, const T *_imag, std::complex< double > *_complex, int length)
void init_random_generator(int seed=-1)
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
double chi2_from_t0(double t0, double degrees_of_freedom)
size_t divide_equally_group(size_t N, size_t size, size_t myself)
double student_from_t0(double t0, double degrees_of_freedom)
double gaussian2D(double x, double y, double sigmaX, double sigmaY, double ang, double muX=0, double muY=0)
double rnd_log(double a, double b)
void unmapFile(char *&map, size_t &size, int &fileDescriptor)
double student_outside_t0(double t0, double degrees_of_freedom)
virtual unsigned & setVerbosity()
void computeAvgStddev(const std::vector< T > &V, double &avg, double &stddev)
struct tms ProcessorTimeStamp
#define XMIPP_EQUAL_ACCURACY
void progress_bar(long act_time)
bool compareTwoFiles(const FileName &fn1, const FileName &fn2, size_t offset=0)
binary comparison of two files skipping first "offset" bytes
double chi2_up_to_t0(double t0, double degrees_of_freedom)
double icdf_FSnedecor(int d1, int d2, double p)
void Complex2AmplPhase(const std::complex< double > *_complex, T *_ampl, T *_phase, int length)
__host__ __device__ float length(float2 v)
double gaus_within_x0(double x0, double mean=0, double stddev=1)
void print_elapsed_time(ProcessorTimeStamp &time, bool _IN_SECS=true)
void computeStats(const std::vector< T > &V, double &avg, double &stddev, T &minval, T &maxval)
double tstudent1D(double x, double df, double sigma, double mu=0)
int get_window_size() const
double i0win_tab(double x) const
virtual bool & setCancel()
size_t xmippFWRITE(const void *src, size_t size, size_t nitems, FILE *&fp, bool reverse=false)
size_t xmippFREAD(void *dest, size_t size, size_t nitems, FILE *&fp, bool reverse=false)
void mapFile(const FileName &filename, char *&map, size_t &size, int &fileDescriptor, bool readOnly=true)
void initConstant(std::vector< T > &V, T &value)
double operator()(double val) const
void Complex2RealImag(const std::complex< double > *_complex, T *_real, T *_imag, int length)
std::vector< double > dump_table() const
std::vector< double > i0table
void annotate_time(TimeStamp *time)
unsigned int randomize_random_generator()
void AmplPhase2Complex(const T *_ampl, const T *_phase, std::complex< double > *_complex, int length)
double gaus_outside_x0(double x0, double mean=0, double stddev=1)
void acum_time(ProcessorTimeStamp *orig, ProcessorTimeStamp *dest)
double gaus_from_x0(double x0, double mean=0, double stddev=1)
double gaussian1D(double x, double sigma, double mu=0)