Xmipp
v3.23.11-Nereus
|
#include <complex>
#include "xmipp_macros.h"
#include <vector>
#include <unistd.h>
#include <sys/times.h>
Go to the source code of this file.
Classes | |
class | Tabsinc |
class | KaiserBessel |
class | Timer |
class | BaseListener |
class | TextualListener |
Macros | |
#define | TSINCVALUE(Tsinc, x, y) |
Functions | |
bool | compareTwoFiles (const FileName &fn1, const FileName &fn2, size_t offset=0) |
binary comparison of two files skipping first "offset" bytes More... | |
Numerical functions | |
int | solve_2nd_degree_eq (double a, double b, double c, double &x1, double &x2, double prec=XMIPP_EQUAL_ACCURACY) |
double | gaussian1D (double x, double sigma, double mu=0) |
double | tstudent1D (double x, double df, double sigma, double mu=0) |
double | icdf_gauss (double p) |
double | cdf_gauss (double x) |
double | cdf_tstudent (int k, double t) |
double | cdf_FSnedecor (int d1, int d2, double x) |
double | icdf_FSnedecor (int d1, int d2, double p) |
double | gaussian2D (double x, double y, double sigmaX, double sigmaY, double ang, double muX=0, double muY=0) |
Miscellaneous functions | |
size_t | divide_equally (size_t N, size_t size, size_t rank, size_t &first, size_t &last) |
size_t | divide_equally_group (size_t N, size_t size, size_t myself) |
template<class T > | |
void | computeStats (const std::vector< T > &V, double &avg, double &stddev, T &minval, T &maxval) |
template<class T > | |
void | computeAvgStddev (const std::vector< T > &V, double &avg, double &stddev) |
template<class T > | |
void | initConstant (std::vector< T > &V, T &value) |
Complex functions | |
template<typename T > | |
void | RealImag2Complex (const T *_real, const T *_imag, std::complex< double > *_complex, int length) |
template<typename T > | |
void | AmplPhase2Complex (const T *_ampl, const T *_phase, std::complex< double > *_complex, int length) |
template<typename T > | |
void | Complex2RealImag (const std::complex< double > *_complex, T *_real, T *_imag, int length) |
template<typename T > | |
void | Complex2AmplPhase (const std::complex< double > *_complex, T *_ampl, T *_phase, int length) |
Random functions | |
These functions allow you to work in an easier way with the random functions of the Numerical Recipes. Only an uniform and a gaussian random number generators have been implemented. In fact only a uniform generator exists and the gaussian one is based on a call to it. For this reason, if you initialize the gaussian random generator, you are also initialising the uniform one. Here goes an example for uniform random numbers to show how to use this set of functions. // Initialise according to the clock // Show 10 random numbers between -1 and 1 std::cout << rnd_unif(-1,1) << std::endl; | |
void | init_random_generator (int seed=-1) |
unsigned int | randomize_random_generator () |
double | rnd_unif () |
double | rnd_unif (double a, double b) |
double | rnd_student_t (double nu) |
double | rnd_student_t (double nu, double a, double b) |
double | rnd_gaus () |
double | rnd_gaus (double a, double b) |
double | gaus_within_x0 (double x0, double mean=0, double stddev=1) |
double | gaus_outside_x0 (double x0, double mean=0, double stddev=1) |
double | gaus_up_to_x0 (double x0, double mean=0, double stddev=1) |
double | gaus_from_x0 (double x0, double mean=0, double stddev=1) |
double | student_outside_probb (double p, double degrees_of_freedom) |
double | student_within_t0 (double t0, double degrees_of_freedom) |
double | student_outside_t0 (double t0, double degrees_of_freedom) |
double | student_up_to_t0 (double t0, double degrees_of_freedom) |
double | student_from_t0 (double t0, double degrees_of_freedom) |
double | chi2_up_to_t0 (double t0, double degrees_of_freedom) |
double | chi2_from_t0 (double t0, double degrees_of_freedom) |
double | rnd_log (double a, double b) |
Time managing | |
These functions are used to make time measures of the algorithms. If you know the total amount of work to do then some estimation can be done about how much time is left before finishing. The time functions are very machine dependent, we've tried to accommodate the compilation for several machines, but if still programs do not work, you may configure Xmipp to avoid these time measurements, functions are then substituted by null functions doing nothing. // Variable declaration TimeStamp t0; // Beginning of the program time_config(); ... annotate_processor_time(&t0); // Part to be measured ... // End of part to be measured print_elapsed_time(t0); While for an estimation of time to go you can make it in two ways: one analytical, and another graphical. Analytical: // Variable declaration double to_go; // Beginning of the program time_config(); ... annotate_processor_time(&t0); // Part to be measured { ... // Compute the time to go with the fraction of work already done std::cout << "I think you will be here " << to_go << "seconds more\n"; } // End of part to be measured print_elapsed_time(t0); Alternatively: // Variable declaration TimeStamp t0; double to_go; annotate_time(&t0); // Part to be measured { ... // Compute the time to go with the fraction of work already done std::cout << "I think you will be here " << to_go << "seconds more\n"; } // End of part to be measured print_elapsed_time(t0); Graphical: // Beginning of the program time_config(); ... // Init the progress bar with the total amount of work to do // It is very important that there is no print out to stdout but // the progress bar init_progress_bar(60); // Part to be measured { ... progress_bar(i+1); } // In this case the following call is useless since it has been // already done in the loop, but there are cases where a final call // with the total amount of work is not performed and although the // whole task has been finished it seems that it hasn't as the // progress bar hasn't been called with the final work but with // a quantity a little smaller. progress_bar(60); These functions is not ported to Python. | |
typedef struct tms | ProcessorTimeStamp |
typedef size_t | TimeStamp |
void | time_config () |
void | annotate_processor_time (ProcessorTimeStamp *time) |
void | annotate_time (TimeStamp *time) |
void | acum_time (ProcessorTimeStamp *orig, ProcessorTimeStamp *dest) |
double | elapsed_time (ProcessorTimeStamp &time, bool _IN_SECS=true) |
void | print_elapsed_time (ProcessorTimeStamp &time, bool _IN_SECS=true) |
void | print_elapsed_time (TimeStamp &time, bool _IN_SECS=true) |
double | time_to_go (ProcessorTimeStamp &time, double fraction_done) |
void | init_progress_bar (long total) |
void | progress_bar (long act_time) |
char * | getCurrentTimeString () |
void | TimeMessage (const std::string &message) |
Little/Big endian | |
These set of functions helps you to deal with the little/big endian problems. | |
#define | little22bigendian(x) swapbytes((unsigned char*)& x,sizeof(x)) |
size_t | xmippFREAD (void *dest, size_t size, size_t nitems, FILE *&fp, bool reverse=false) |
size_t | xmippFWRITE (const void *src, 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 | unmapFile (char *&map, size_t &size, int &fileDescriptor) |
void | swapbytes (char *v, unsigned long n) |
bool | IsBigEndian (void) |
void | processMemUsage (double &vm_usage, double &resident_set) |
bool | IsLittleEndian (void) |
void | printMemoryUsed () |
Definition at line 94 of file xmipp_funcs.h.