/usr/include/relion-1.4/src/macros.h is in librelion-dev-common 1.4+dfsg-3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | /***************************************************************************
*
* Author: "Sjors H.W. Scheres"
* MRC Laboratory of Molecular Biology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This complete copyright notice must be included in any revised version of the
* source code. Additional authorship citations may be added, but existing
* author citations must be preserved.
***************************************************************************/
/***************************************************************************
*
* Authors: Carlos Oscar S. Sorzano (coss@cnb.csic.es)
*
* Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* All comments concerning this program package may be sent to the
* e-mail address 'xmipp@cnb.csic.es'
***************************************************************************/
#ifndef MACROS_H
#define MACROS_H
#ifndef _CYGWIN
#ifdef __APPLE__
#include <limits.h>
#else
#include <values.h>
#endif
#endif
#ifndef MINFLOAT
#define MINFLOAT -1e30
#endif
#ifndef MAXFLOAT
#define MAXFLOAT 1e30
#endif
#ifdef FLOAT_PRECISION
#define DOUBLE float
#define MY_MPI_DOUBLE MPI_FLOAT
#else
#define DOUBLE double
#define MY_MPI_DOUBLE MPI_DOUBLE
#endif
//#define DEBUG
//#define DEBUG_CHECKSIZES
/// @defgroup Macros Macros
/// @ingroup DataLibrary
//@{
/// @name Constants
//@{
/** Pi
* @ingroup MacrosConstants
*/
#ifndef PI
#define PI 3.14159265358979323846
#endif
/** Equal accuracy
*
* In a comparison if two values are closer than this epsilon they are said to
* be the same. Actually For double precision calculations set to 1e-6, for single-precision set to 1e-4 (finding symmetry subgroups will go wrong otherwise)
*/
#ifdef FLOAT_PRECISION
#define XMIPP_EQUAL_ACCURACY 1e-4
#else
#define XMIPP_EQUAL_ACCURACY 1e-6
#endif
//@}
/// @name Numerical functions
//@{
/** Absolute value
*
* Valid for any kind of number (int, short, float, etc)
*
* @code
* x = ABS(x);
* @endcode
*/
#ifndef ABS
#define ABS(x) (((x) >= 0) ? (x) : (-(x)))
#endif
/** Sign of
*
* Valid for any kind of number (int, short, float, etc). It returns +1 or -1
*
* @code
* if (SGN(x) == -1)
* std::cout << "x is negative" << std::endl;
* @endcode
*/
#ifndef SGN
#define SGN(x) (((x) >= 0) ? 1 : -1)
#endif
/** Sign of, considering 0 as 0
*
* Valid for any kind of number (int, short, float, etc). It returns +1 if the
* number is positive, -1 if the number is negative, and 0 if the number is 0.
*
* @code
* if (SGN0(x) == -1)
* std::cout << "x is negative" << std::endl;
* @endcode
*/
#ifndef SGN0
#define SGN0(x) (((x) >= 0) ? (((x) == 0) ? 0:1) : -1)
#endif
/** Minimum
*
* Valid for any kind of numbers (int, short, float, etc).
*
* @code
* min_val = XMIPP_MIN(x, y);
* @endcode
*/
#ifndef XMIPP_MIN
#define XMIPP_MIN(x, y) (((x) >= (y)) ? (y) : (x))
#endif
/** Maximum
*
* Valid for any kind of numbers (int, short, float, etc).
*
* @code
* max_val = XMIPP_MAX(x, y);
* @endcode
*/
#ifndef XMIPP_MAX
#define XMIPP_MAX(x,y) (((x)>=(y))?(x):(y))
#endif
/** Round to next integer
*
* Valid for any kind of numbers (int, short, float, etc). The result is of type
* integer.
*
* @code
* a = ROUND(-0.8); // a = -1
* a = ROUND(-0.2); // a = 0
* a = ROUND(0.2); // a = 0
* a = ROUND(0.8); // a = 1
* @endcode
*/
#ifndef ROUND
#define ROUND(x) (((x) > 0) ? (int)((x) + 0.5) : (int)((x) - 0.5))
#endif
/** Round to next larger integer
*
* Valid for any kind of numbers (int, short, float, etc). The result is of type
* integer.
*
* @code
* a = CEIL(-0.8); // a = 0
* a = CEIL(-0.2); // a = 0
* a = CEIL(0.2); // a = 1
* a = CEIL(0.8); // a = 1
* @endcode
*/
#define CEIL(x) (((x) == (int)(x)) ? (int)(x):(((x) > 0) ? (int)((x) + 1) : (int)(x)))
/** Round to next smaller integer
*
* Valid for any kind of numbers (int, short, float, etc). The result is of type
* integer.
*
* @code
* a = FLOOR(-0.8); // a = -1
* a = FLOOR(-0.2); // a = -1
* a = FLOOR(0.2); // a = 0
* a = FLOOR(0.8); // a = 0
* @endcode
*/
#define FLOOR(x) (((x) == (int)(x)) ? (int)(x):(((x) > 0) ? (int)(x) : (int)((x) - 1)))
/** Return the fractional part of a value
*
* The fractional part of 3.7 is 0.7 and of -3.7 is -0.7.
*/
#define FRACTION(x) ((x) - (int)(x))
/** Clip in a saturation fashion
*
* CLIP is a macro which acts like a saturation curve, a value x is "clipped" to
* a range defined by x0 and xF, for example the output values for the following
* x and CLIP(x,-2,2) would be
*
* @code
* x = ... -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 ...
* output = ... -2 -2 -2 -2 -2 -2 -2 -1 0 1 2 2 2 2 2 2 2 ...
* @endcode
*/
#define CLIP(x, x0, xF) (((x) < (x0)) ? (x0) : (((x) > (xF)) ? (xF) : (x)))
/** Wrapping for integers
*
* intWRAP performs a wrapping in the integer set, when the cycle is finsihed it
* begins again. For example, for intWRAP(x,-2,2) would be
*
* @code
* x = ... -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 ...
* output = ... 2 -2 -1 0 1 2 -2 -1 0 1 2 -2 -1 0 1 2 -2 ...
* @endcode
*/
#define intWRAP(x, x0, xF) (((x) >= (x0) && (x) <= (xF)) ? (x) : ((x) < (x0)) ? ((x) - (int)(((x) - (x0) + 1) / ((xF) - (x0) + 1) - 1) * ((xF) - (x0) + 1)) : ((x) - (int)(((x) - (xF) - 1) / ((xF) - (x0) + 1) + 1) * ((xF) - (x0) + 1)))
/** Wrapping for real numbers
*
* realWRAP is used to keep a floating number between a range with a wrapping
* fashion. For instance, it is used in trigonometry to say that an angle of
* 5*PI is the same as PI, ie, to keep an angle in the range 0...2*PI
*
* @code
* Corrected_angle = realWRAP(angle, 0, 2*PI);
* @endcode
*/
#define realWRAP(x, x0, xF) (((x) >= (x0) && (x) <= (xF)) ? (x) : ((x) < (x0)) ? ((x) - (int)(((x) - (x0)) / ((xF) - (x0)) - 1) * ((xF) - (x0))) : ((x) - (int)(((x) - (xF)) / ((xF) - (x0)) + 1) * ((xF) - (x0))))
/** Degrees to radians
*
* @code
* angle_in_radians = DEG2RAD(ang_in_degrees);
* @endcode
*/
#define DEG2RAD(d) ((d) * PI / 180)
/** Radians to degrees
*
* @code
* angle_in_degrees = RAD2DEG(ang_in_radians);
* @endcode
*/
#define RAD2DEG(r) ((r) * 180 / PI)
/** Cosine in degrees
*
* @code
* if (COSD(90) == 0)
* std::cout << "This is in degrees!\n";
* @endcode
*/
#define COSD(x) cos(PI * (x) / 180.)
/** ArcCosine in degrees
*
* @code
* if (ACOSD(0.5) == 60)
* std::cout << "This is in degrees!\n";
* @endcode
*/
#define ACOSD(x) acos((x)) * 180. / PI
/** Sine in degrees
*
* @code
* if (SIND(90) == 1)
* std::cout << "This is in degrees!\n";
* @endcode
*/
#define SIND(x) sin(PI * (x) / 180.)
/** ArcSine in degrees
*
* @code
* if (ASIND(0.5) == 30.)
* std::cout << "This is in degrees!\n";
* @endcode
*/
#define ASIND(x) asin((x)) * 180. / PI
/** SINC function
*
* The sinc function is defined as sin(PI*x)/(PI*x).
*/
#define SINC(x) (((x) < 0.0001 && (x) > -0.0001) ? 1 : sin(PI * (x)) / (PI * (x)))
/** Returns next positive power_class of 2
*
* It is supposed that the given number is positive although it's not needed to
* be an integer
*
* @code
* next_power = NEXT_POWER_OF_2(1000); // next_power = 1024
* @endcode
*/
#define NEXT_POWER_OF_2(x) pow(2, ceil(log((DOUBLE) x) / log(2.0)-XMIPP_EQUAL_ACCURACY) )
/** Linear interpolation
*
* From low (when a=0) to high (when a=1). The following value is returned
* (equal to (a*h)+((1-a)*l)
*/
#define LIN_INTERP(a, l, h) ((l) + ((h) - (l)) * (a))
/** XOR
*
* Logical Xor
*/
#define XOR(a, b) (((a) && !(b)) || (!(a) && (b)))
//@}
/// @name Miscellaneous
//@{
/** Swap two values
*
* It uses a temporal variable which must be of the same type as the two
* parameters
*/
#define SWAP(a, b, tmp) { tmp = a; a = b; b = tmp; }
/** Starting point for Xmipp volume/image
*
* Given a size (in some direction), this function returns the first index for
* a volume/image/array with this size. The formula is -(int) ((float) (size)
* / 2.0)
*/
#define FIRST_XMIPP_INDEX(size) -(long int)((float) (size) / 2.0)
/** Starting point for Xmipp volume/image
* @ingroup MacrosMisc
*
* Given a size (in some direction), this function returns the first index for a
* volume/image/array with this size. The formula is FIRST_XMIPP_INDEX(size) +
* (size) - 1
*/
#define LAST_XMIPP_INDEX(size) FIRST_XMIPP_INDEX(size) + (size) - 1
//@}
//@}
#endif
|