Xmipp  v3.23.11-Nereus
tools.h
Go to the documentation of this file.
1 /*
2 
3 CONDOR 1.06 - COnstrained, Non-linear, Direct, parallel Optimization
4  using trust Region method for high-computing load,
5  noisy functions
6 Copyright (C) 2004 Frank Vanden Berghen
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation version 2
11 of the License.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 
22 If you want to include this tools in any commercial product,
23 you can contact the author at fvandenb@iridia.ulb.ac.be
24 
25 */
26 //
27 // Header file for tools
28 //
29 
30 
31 #ifndef _MPI_TOOLS_H_
32 #define _MPI_TOOLS_H_
33 
34 #include <math.h>
35 #include <iosfwd>
36 
37 //#define SWAP(a,b) {tempr=(a); (a)=(b); (b)=tempr;}
38 
39 #define maxDWORD 4294967295 //2^32-1;
40 #define INF 1.7E+308
41 #define EOL 10
42 #ifndef PI
43  #define PI 3.1415926535897932384626433832795
44 #endif
45 #define ROOT2 1.41421356
46 
47 inline double condorAbs( const double t1 )
48 {
49  return t1 > 0.0 ? t1 : -t1;
50 }
51 
52 inline double sign( const double a )
53  // equivalent to sign(1,a)
54 {
55  return a<0?-1:1;
56 }
57 
58 inline double sign( const double t1, const double t2 )
59 {
60  if(t2>=0) return condorAbs(t1);
61  return -condorAbs(t1);
62 }
63 
64 inline double isInt( const double a)
65 {
66  return condorAbs(a-floor( a + 0.5 ))<1e-4;
67 }
68 
69 inline double mmin( const double t1, const double t2 )
70 {
71  return t1 < t2 ? t1 : t2;
72 }
73 
74 inline unsigned mmin( const unsigned t1, const unsigned t2 )
75 {
76  return t1 < t2 ? t1 : t2;
77 }
78 
79 inline int mmin( const int t1, const int t2 )
80 {
81  return t1 < t2 ? t1 : t2;
82 }
83 
84 inline double mmax( const double t1, const double t2 )
85 {
86  return t1 > t2 ? t1 : t2;
87 }
88 
89 inline unsigned mmax( const unsigned t1, const unsigned t2 )
90 {
91  return t1 > t2 ? t1 : t2;
92 }
93 
94 inline int mmax( int t1, int t2 )
95 {
96  return t1 > t2 ? t1 : t2;
97 }
98 
99 inline double sqr( const double& t )
100 {
101  return t*t;
102 }
103 
104 inline double CondorRound (double a)
105 {
106  return (int)(a+.5);
107 }
108 
109 unsigned long choose( unsigned n, unsigned k );
110 double rand1();
111 void initRandom(int i=0);
112 double euclidianNorm(int i, double *xp);
113 
114 #include "Vector.h"
115 #include "Matrix.h"
116 
117 //void saveValue(Vector tmp,double valueOF, Matrix data);
118 
119 char emptyline(const char *line);
120 char *GetRidOfTheEOL(char *tline);
121 char *removeQuotes(char *t);
122 char **getNameTable(const char *line, int *ncolumn);
123 char *stringDuplicate(const char *l);
124 char isEmpty(const char *line);
125 char *removeAllEOL(char *t);
126 char *loadFile(FILE *f);
127 const char *skipLine(const char *l);
128 const char *skipSpaces(const char *l);
129 void deleteFile(const char *l);
130 
131 #endif /* _MPI_TOOLS_H_ */
132 
char isEmpty(const char *line)
Definition: tools.cpp:165
__host__ __device__ float2 floor(const float2 v)
void deleteFile(const char *l)
Definition: tools.cpp:280
double mmin(const double t1, const double t2)
Definition: tools.h:69
double rand1()
Definition: tools.cpp:88
char ** getNameTable(const char *line, int *ncolumn)
Definition: tools.cpp:204
char * removeQuotes(char *t)
Definition: tools.cpp:194
#define i
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
const char * skipSpaces(const char *l)
Definition: tools.cpp:171
unsigned long choose(unsigned n, unsigned k)
Definition: tools.cpp:38
double sqr(const double &t)
Definition: tools.h:99
char * GetRidOfTheEOL(char *tline)
Definition: tools.cpp:185
double euclidianNorm(int i, double *xp)
Definition: tools.cpp:113
char * removeAllEOL(char *t)
Definition: tools.cpp:246
double mmax(const double t1, const double t2)
Definition: tools.h:84
double * f
const char * skipLine(const char *l)
Definition: tools.cpp:257
double condorAbs(const double t1)
Definition: tools.h:47
char * loadFile(FILE *f)
Definition: tools.cpp:265
char * stringDuplicate(const char *l)
Definition: tools.cpp:234
double CondorRound(double a)
Definition: tools.h:104
double sign(const double a)
Definition: tools.h:52
double isInt(const double a)
Definition: tools.h:64
char emptyline(const char *line)
int * n
doublereal * a
void initRandom(int i=0)
Definition: tools.cpp:101