![]() |
GWOLLUM 4.2.0
Tools for gravitational-wave analyses
|
Generic C utility functions. More...
#include "Config.h"

Go to the source code of this file.
Macros | |
| #define | GOLDENNUMBER 1.6180339887498949025257388711906969547271728515625 |
| \((1+\sqrt{5})/2)\) | |
| #define | LN10 2.30258509299404590109361379290930926799774169921875 |
| \(\ln(10)\) | |
| #define | LN2 0.6931471805599453094172321214581766 |
| \(\ln(2)\) | |
| #define | PIOVERTWO 1.5707963267948965579989817342720925807952880859375 |
| \(\pi/2\) | |
| #define | SQRT2 1.4142135623730951454746218587388284504413604736328125 |
| \(\sqrt{2}\) | |
Functions | |
| bool | CopyFile (error_code &aErrorCode, const string aFrom, const string aTo, const bool aOverwrite=false) |
| Copy a file to a destination. | |
| bool | CreateDirectory (error_code &aErrorCode, const string aPath) |
| Creates a directory. | |
| string | GetFileNameFromPath (const string filepathname) |
| Returns the file name given the file path. | |
| double | GetMedian (const unsigned int aSize, double *aVect) |
| Returns the median value of an array of doubles. | |
| double * | GetTukeyWindow (const unsigned int aSize, const double aAlpha) |
| Returns a Tukey window. | |
| vector< string > | Glob (const char *pattern) |
| C utility to extract a list of files. | |
| int | GwlPrintVersion (void) |
| Prints the version. | |
| bool | IsPowerOfTwo (unsigned int x) |
| Tests if an integer is a power of 2. | |
| bool | ListDirectories (vector< string > &subdir, const string maindir) |
| Returns a list of sub-directories. | |
| void | MakeStereoSoundFile (const string aFileName, const unsigned int aN, const unsigned int aSamplingRate, double *aAmplitudeLeft, double *aAmplitudeRight, const double aScale=1.0, const int aOffset=0) |
| C utility to generate a WAV file. | |
| double | medianbiasfactor (const unsigned int nn) |
| Returns the bias factor when computing a median with a finite number of samples. | |
| unsigned int | NextPowerOfTwo (double x) |
| Returns the next power of 2. | |
| unsigned int | RemoveFileOrDirectory (error_code &aErrorCode, const string aPath) |
| Removes a file or a directory. | |
| string | ReplaceAll (string str, const string &from, const string &to) |
| Replaces all occurences of a sub-string by another sub-string. | |
| vector< string > | SplitString (const string stringtodivide, const char separator=' ') |
| Splits a string into sub-strings. | |
| string | StringToUpper (string stringtoconvert) |
| Transforms a string to uppercase. | |
Generic C utility functions.
| #define GOLDENNUMBER 1.6180339887498949025257388711906969547271728515625 |
\((1+\sqrt{5})/2)\)
| #define LN10 2.30258509299404590109361379290930926799774169921875 |
\(\ln(10)\)
| #define LN2 0.6931471805599453094172321214581766 |
\(\ln(2)\)
| #define PIOVERTWO 1.5707963267948965579989817342720925807952880859375 |
\(\pi/2\)
| #define SQRT2 1.4142135623730951454746218587388284504413604736328125 |
\(\sqrt{2}\)
| bool CopyFile | ( | error_code & | aErrorCode, |
| const string | aFrom, | ||
| const string | aTo, | ||
| const bool | aOverwrite = false |
||
| ) |
Copy a file to a destination.
| [out] | aErrorCode | Platform-dependent error code: see std::error_code. |
| [in] | aFrom | Path to the original file. It must exist. |
| [in] | aTo | Path to destination. This can be either a directory or a file path. |
| [in] | aOverwrite | Set this flag to true to overwrite the destimation if the file already exists. |
|
inline |
Creates a directory.
This is equivalent to mkdir -p.
| [out] | aErrorCode | Platform-dependent error code: see std::error_code. |
| [in] | aPath | Path to directory to create. |
|
inline |
Returns the file name given the file path.
For example "myprog.exe" is returned from:
| [in] | filepathname | File path. |
| double GetMedian | ( | const unsigned int | aSize, |
| double * | aVect | ||
| ) |
Returns the median value of an array of doubles.
The input vector is sorted. Then the median value is returned.
| [in] | aSize | Array size. |
| [in,out] | aVect | Pointer to the input array. The array values are sorted after calling this function. |
| double * GetTukeyWindow | ( | const unsigned int | aSize, |
| const double | aAlpha | ||
| ) |
Returns a Tukey window.
| [in] | aSize | Window size. |
| [in] | aAlpha | Total fraction of the window used to transition from 0 to 1 and 1 to 0. =0: rectangle, =1: HAnn window. |
| vector< string > Glob | ( | const char * | pattern | ) |
C utility to extract a list of files.
| [in] | pattern | File pattern. |
| int GwlPrintVersion | ( | void | ) |
Prints the version.
This function also checks the GWOLLUM environment:
$GWOLLUM_DATA must point to an existing directory.$GWOLLUM_PIX must point to an existing directory.
|
inline |
Tests if an integer is a power of 2.
| [in] | x | Integer to test. |
| bool ListDirectories | ( | vector< string > & | subdir, |
| const string | maindir | ||
| ) |
Returns a list of sub-directories.
The vector 'subdir' is filled with directories contained in 'maindir'
| [out] | subdir | List of sub-directories. |
| [in] | maindir | Path to the main directory. |
| void MakeStereoSoundFile | ( | const string | aFileName, |
| const unsigned int | aN, | ||
| const unsigned int | aSamplingRate, | ||
| double * | aAmplitudeLeft, | ||
| double * | aAmplitudeRight, | ||
| const double | aScale = 1.0, |
||
| const int | aOffset = 0 |
||
| ) |
C utility to generate a WAV file.
| [in] | aFileName | Output .wav file name. |
| [in] | aN | Number of samples. |
| [in] | aSamplingRate | Sampling rate [Hz]. |
| [in] | aAmplitudeLeft | Amplitudes for left audio. |
| [in] | aAmplitudeRight | Amplitudes for right audio. |
| [in] | aScale | Scale factor ("volume") applied to amplitudes. |
| [in] | aOffset | Offset applied to the number of samples. |
| double medianbiasfactor | ( | const unsigned int | nn | ) |
Returns the bias factor when computing a median with a finite number of samples.
The bias factor is (see Eq. B12 in gr-qc/0509116):
\[ \alpha = \sum_{l=1}^{n}{\frac{(-1)^{l+1}}{l}}. \]
| [in] | nn | Number of samples \(n\). |
|
inline |
Returns the next power of 2.
| [in] | x | Value from which to get the next power of 2. |
|
inline |
Removes a file or a directory.
| [out] | aErrorCode | Platform-dependent error code: see std::error_code. |
| [in] | aPath | Path to the file/directory to remove. |
| string ReplaceAll | ( | string | str, |
| const string & | from, | ||
| const string & | to | ||
| ) |
Replaces all occurences of a sub-string by another sub-string.
All occurences of substring 'from' are replaced by 'to'.
| [in] | str | String to modify. |
| [in] | from | Substring to replace from. |
| [in] | to | Substring to replace to. |
| vector< string > SplitString | ( | const string | stringtodivide, |
| const char | separator = ' ' |
||
| ) |
Splits a string into sub-strings.
A string is divided into an array of words. The separator defines where to break the string. The separator should be a single character.
| [in] | stringtodivide | String to divide. |
| [in] | separator | Separator. |
| string StringToUpper | ( | string | stringtoconvert | ) |
Transforms a string to uppercase.
| [in] | stringtoconvert | String to transform. |