SynAPSE  0.6.0
Synergistic Analysis of Phase Space Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Functions
Assert Namespace Reference

List of common assertions that throw an Exceptions::Exception if not satistified. More...

Functions

void IsWithinBounds (const std::string &location, const size_t n, const size_t i)
 Asserts that the index that is accessed is within bounds. More...
 
void IsProbability (const std::string &location, const std::string &what, const double &p, const bool nonzero=true, const bool noncert=true)
 Asserts that the value represents a probability (0 < p < 1) More...
 
template<typename T >
void IsNonZero (const std::string &location, const std::string &what, const T &value)
 Asserts that a value is non zero. More...
 
template<typename T >
void IsGreater (const std::string &location, const std::string &what, const T &value, const T &limit, const bool strictly=false)
 Asserts that a value is greater than another. More...
 
template<typename T >
void IsLower (const std::string &location, const std::string &what, const T &value, const T &limit, const bool strictly=false)
 Asserts that a value is lower than another. More...
 
template<typename T >
void IsEqual (const std::string &location, const std::string &what, const T &a, const T &b)
 Asserts that the values are equal. More...
 
template<typename T >
void IsNotEmpty (const std::string &location, const std::string &what, const std::vector< T > &vector)
 Asserts that a vector is not empty. More...
 
template<typename T >
void HasAtLeast (const std::string &location, const std::string &what, const std::vector< T > &vector, const size_t n)
 Asserts that a vector has at least n elements. More...
 
template<typename T >
void HasAtMost (const std::string &location, const std::string &what, const std::vector< T > &vector, const size_t n)
 Asserts that a vector has at most n elements. More...
 
template<typename T >
void SameSize (const std::string &location, const std::string &what, const std::vector< T > &va, const std::vector< T > &vb)
 Asserts that two vectors have the same size. More...
 
template<typename T >
void SameSize (const std::string &location, const std::string &what, const std::vector< std::vector< T >> &ma, const std::vector< std::vector< T >> &mb)
 Asserts that two matrices have the same size. More...
 
template<typename T >
void Multiplicable (const std::string &location, const std::string &what, const std::vector< std::vector< T >> &ma, const std::vector< std::vector< T >> &mb)
 Asserts that two matrices are multiplicable. More...
 
template<typename T >
void IsSquare (const std::string &location, const std::string &what, const std::vector< std::vector< T >> &matrix)
 Asserts that a matrix is square. More...
 
template<typename T >
void IsSymmetric (const std::string &location, const std::string &what, const std::vector< std::vector< T >> &matrix)
 Asserts that a matrix is symmetric. More...
 
template<typename T1 , typename T2 >
void Contains (const std::string &location, const std::string &what, const std::map< T1, T2 > &map, const T1 &key)
 Asserts that a map contains a specific entry. More...
 

Detailed Description

List of common assertions that throw an Exceptions::Exception if not satistified.

Simplifies the code down the line. All the assertions take two common inputs:

Function Documentation

template<typename T1 , typename T2 >
void Assert::Contains ( const std::string &  location,
const std::string &  what,
const std::map< T1, T2 > &  map,
const T1 &  key 
)

Asserts that a map contains a specific entry.

Parameters
locationName of the function that called the assert
whatName of the object to check
mapMap to check
keyKey to look for
template<typename T >
void Assert::HasAtLeast ( const std::string &  location,
const std::string &  what,
const std::vector< T > &  vector,
const size_t  n 
)

Asserts that a vector has at least n elements.

Parameters
locationName of the function that called the assert
whatName of the object to check
vectorVector to check
nMinimum number of elements
template<typename T >
void Assert::HasAtMost ( const std::string &  location,
const std::string &  what,
const std::vector< T > &  vector,
const size_t  n 
)

Asserts that a vector has at most n elements.

Parameters
locationName of the function that called the assert
whatName of the object to check
vectorVector to check
nMaximum number of elements
template<typename T >
void Assert::IsEqual ( const std::string &  location,
const std::string &  what,
const T &  a,
const T &  b 
)

Asserts that the values are equal.

Parameters
locationName of the function that called the assert
whatName of the object to check
aFirst value
bSecond value
template<typename T >
void Assert::IsGreater ( const std::string &  location,
const std::string &  what,
const T &  value,
const T &  limit,
const bool  strictly = false 
)

Asserts that a value is greater than another.

Parameters
locationName of the function that called the assert
whatName of the object to check
valueValue to check
limitMinimum value
strictlyIf true, must be strictly greater
template<typename T >
void Assert::IsLower ( const std::string &  location,
const std::string &  what,
const T &  value,
const T &  limit,
const bool  strictly = false 
)

Asserts that a value is lower than another.

Parameters
locationName of the function that called the assert
whatName of the object to check
valueValue to check
limitMaximum value
strictlyIf true, must be strictly lower
template<typename T >
void Assert::IsNonZero ( const std::string &  location,
const std::string &  what,
const T &  value 
)

Asserts that a value is non zero.

Parameters
locationName of the function that called the assert
whatName of the object to check
valueValue to check
template<typename T >
void Assert::IsNotEmpty ( const std::string &  location,
const std::string &  what,
const std::vector< T > &  vector 
)

Asserts that a vector is not empty.

Parameters
locationName of the function that called the assert
whatName of the object to check
vectorVector to check
void Assert::IsProbability ( const std::string &  location,
const std::string &  what,
const double &  p,
const bool  nonzero = true,
const bool  noncert = true 
)

Asserts that the value represents a probability (0 < p < 1)

Parameters
locationName of the function that called the assert
whatName of the object to check
pValue to check
nonzeroCheck that it is non zero
noncertCheck that it is non certain
template<typename T >
void Assert::IsSquare ( const std::string &  location,
const std::string &  what,
const std::vector< std::vector< T >> &  matrix 
)

Asserts that a matrix is square.

Parameters
locationName of the function that called the assert
whatName of the object to check
matrixMatrix to check
template<typename T >
void Assert::IsSymmetric ( const std::string &  location,
const std::string &  what,
const std::vector< std::vector< T >> &  matrix 
)

Asserts that a matrix is symmetric.

Parameters
locationName of the function that called the assert
whatName of the object to check
matrixMatrix to check
void Assert::IsWithinBounds ( const std::string &  location,
const size_t  n,
const size_t  i 
)

Asserts that the index that is accessed is within bounds.

Parameters
locationName of the function that called the assert
nSize of the vector
iIndex
template<typename T >
void Assert::Multiplicable ( const std::string &  location,
const std::string &  what,
const std::vector< std::vector< T >> &  ma,
const std::vector< std::vector< T >> &  mb 
)

Asserts that two matrices are multiplicable.

Parameters
locationName of the function that called the assert
whatName of the object to check
maFirst matrix
mbSecond matrix
template<typename T >
void Assert::SameSize ( const std::string &  location,
const std::string &  what,
const std::vector< T > &  va,
const std::vector< T > &  vb 
)

Asserts that two vectors have the same size.

Parameters
locationName of the function that called the assert
whatName of the object to check
vaFirst vector
vbSecond vector
template<typename T >
void Assert::SameSize ( const std::string &  location,
const std::string &  what,
const std::vector< std::vector< T >> &  ma,
const std::vector< std::vector< T >> &  mb 
)

Asserts that two matrices have the same size.

Parameters
locationName of the function that called the assert
whatName of the object to check
maFirst matrix
mbSecond matrix