Files | Defines

General Number Utilities

Files

file  eg_nummacros.h
 

This file provide the user interface and function definitions for general number utilities.


Defines

#define EGabs(var)
 a general macro to return the absolute value of the given variable
#define EGmax(a, b)
 given two variables (of the same type, and of some predefined type) return the maximum value among the two of them.
#define EGmin(a, b)
 given two variables (of the same type, and of some predefined type) return the minimum value among the two of them.
#define EGswap(N1, N2, Ntmp)
 Given tree numbers N1, N2 and Ntmp, swap values of N1 and N2 using Ntmp as a temporal number. The variables should be of some primitive type of C for this macro to work.

Detailed Description

Here we put some utilities common for number.

History:
Revision 0.0.2
  • 2007-10-08
    • Move EGabs, EGswap, EGmin and EGmax to this file

Define Documentation

#define EGabs (   var  ) 
Value:
({\
    const typeof(var) __EGav = (var);\
    (__EGav < 0) ? -__EGav : __EGav;})

a general macro to return the absolute value of the given variable

Parameters:
var variable whose absolute value we want to compute.
Returns:
value of the absolute value of the given variable, note that this macro will only work in built-in types, and will use the default comparison for those internal types.

Definition at line 75 of file eg_nummacros.h.

#define EGmax (   a,
  b 
)
Value:
({\
  const typeof(a) __EGma = (a);\
  const typeof(b) __EGmb = (b);\
  (__EGma > __EGmb ? __EGma : __EGmb);})

given two variables (of the same type, and of some predefined type) return the maximum value among the two of them.

Definition at line 56 of file eg_nummacros.h.

#define EGmin (   a,
  b 
)
Value:
({\
  const typeof(a) __EGma = (a);\
  const typeof(b) __EGmb = (b);\
  (__EGma < __EGmb ? __EGma : __EGmb);})

given two variables (of the same type, and of some predefined type) return the minimum value among the two of them.

Examples:
eg_dmatrix.ex.c.

Definition at line 64 of file eg_nummacros.h.

Referenced by main().

#define EGswap (   N1,
  N2,
  Ntmp 
)
Value:
do{\
  Ntmp = N1;\
  N1 = N2;\
  N2 = Ntmp;} while(0)

Given tree numbers N1, N2 and Ntmp, swap values of N1 and N2 using Ntmp as a temporal number. The variables should be of some primitive type of C for this macro to work.

Parameters:
N1 first number.
N2 second number.
Ntmp temporal variable.

Definition at line 48 of file eg_nummacros.h.

Referenced by EGcharPermSort().