Library of Assembled Shared Sources
basic_ops.h File Reference
#include "num_common.h"
#include <cmath>
#include "basic_ops.inl"
Include dependency graph for basic_ops.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  lass::num::lass::util::Exception
 type of all exceptions in lass More...
 
class  lass::num::lass::util::EnforceFailure
 Exception thrown by enforcers. More...
 
struct  lass::num::lass::util::impl::TruePredicate
 Predicate for enforcers using operator! More...
 
struct  lass::num::lass::util::impl::EqualPredicate
 value must be equal to closure More...
 
struct  lass::num::lass::util::impl::UnequalPredicate
 value must be different than closure More...
 
struct  lass::num::lass::util::impl::GreaterEqualPredicate
 value must be greater than or equal to closure More...
 
struct  lass::num::lass::util::impl::IndexPredicate
 value must be in range [0, closure) More...
 
struct  lass::num::lass::util::impl::StreamPredicate
 Predicate to enforce a stream to be a in good state. More...
 
struct  lass::num::lass::util::impl::DefaultRaiser
 Throw a runtime error. More...
 
struct  lass::num::lass::util::impl::ZeroRaiser
 Throws an run time exception for raising LASS_ENFORCE_ZERO. More...
 
struct  lass::num::lass::util::impl::ClibRaiser
 Throws a run time exception for raisng LASS_ENFORCE_CLIB. More...
 
struct  lass::num::lass::util::impl::ClibWarner
 Prints warning to std::cerr for LASS_WARN_CLIB. More...
 
struct  lass::num::lass::util::impl::ClibRcRaiser
 Throws a run time exception for raisng LASS_ENFORCE_CLIB_RC. More...
 
struct  lass::num::lass::util::impl::ClibRcWarner
 Throws a run time exception for raisng LASS_ENFORCE_CLIB_RC. More...
 
struct  lass::num::lass::util::impl::ComRaiser
 Throws an run time exception for raising LASS_ENFORCE_COM. More...
 
struct  lass::num::lass::util::impl::IndexRaiser
 Throw a range error for LASS_ENFORCE_INDEX. More...
 
class  lass::num::lass::util::impl::Enforcer< PredicateType, RaiserType, T, ClosureType >
 Helper class of the enforce macro's. More...
 
class  lass::num::lass::meta::True
 meta true More...
 
struct  lass::num::lass::meta::False
 meta false More...
 
class  lass::num::lass::meta::Bool< flag >
 meta boolean type More...
 
struct  lass::num::lass::meta::Not< Operand >
 meta NOT More...
 
struct  lass::num::lass::meta::And< Operand1, Operand2 >
 meta AND More...
 
struct  lass::num::lass::meta::Or< Operand1, Operand2 >
 meta OR More...
 
struct  lass::num::lass::meta::Xor< Operand1, Operand2 >
 meta XOR More...
 
class  lass::num::lass::io::ProxyOStream
 A proxy output stream can distribute output to multiple destination streams. More...
 
class  lass::num::lass::util::NonCopyable
 use as base class if derived should not be copyable More...
 
class  lass::num::lass::io::ProxyMan
 manages the four proxy streams. More...
 
struct  lass::num::lass::meta::Select< Condition, TrueType, FalseType >
 Select a type based on a meta condition that evaluates to meta::True or meta::False. More...
 

Namespaces

namespace  lass
 Library for Assembled Shared Sources.
 
namespace  lass::num
 numeric types and traits.
 
namespace  lass::meta
 library for template meta programming
 
namespace  lass::io
 streams, binary streams, vrmlstreams, ...
 
namespace  lass::util
 general utility, debug facilities, ...
 
namespace  lass::stde
 lass extensions to the standard library
 

Functions

template<typename T>
lass::num::abs (const T &x)
 if x < 0 return -x, else return x.
 
template<typename T>
lass::num::sign (const T &x)
 if x < 0 return -1, else if x > 0 return 1, else return 0.
 
template<typename T>
lass::num::sqr (const T &x)
 return x * x
 
template<typename T>
lass::num::inv (const T &x)
 return x ^ -1
 
template<typename T>
lass::num::cubic (const T &x)
 return x * x * x
 
template<typename T>
lass::num::pow (const T &x, const T &p)
 return exp(p * log(x));
 
template<typename T>
lass::num::log2 (const T &x)
 return log(x) / log(2)
 
template<typename T>
lass::num::log10 (const T &x)
 return log(x) / log(10)
 
template<typename T>
lass::num::norm (const T &x)
 return norm of x as if x is real part of complex number: sqr(x)
 
template<typename T>
lass::num::conj (const T &x)
 return conjugate as if x is a complex number: x
 
template<typename T>
const T & lass::num::clamp (const T &x, const T &min, const T &max)
 if x < min return min, else if x > max return max, else return x.
 
template<typename T>
lass::num::lerp (const T &a, const T &b, const T &f)
 linear interpolation between a and b
 
template<typename PredicateType, typename RaiserType, typename T, typename C>
Enforcer< PredicateType, RaiserType, T &, const C & > lass::num::lass::util::impl::makeEnforcer (T &t, const C &closure, const char *locus)
 helper function to create enforcers
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::tolower (const std::basic_string< Char, Traits, Alloc > &input, const std::locale &locale)
 convert std::basic_string to lower case by using user locale
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::toupper (const std::basic_string< Char, Traits, Alloc > &input, const std::locale &locale)
 convert std::basic_string to upper case by using user locale
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::replace_all (const std::basic_string< Char, Traits, Alloc > &input, const std::basic_string< Char, Traits, Alloc > &to_be_replaced, const std::basic_string< Char, Traits, Alloc > &replacement)
 replace all instances of to_be_replaced in input by replacement.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::replace_all (const std::basic_string< Char, Traits, Alloc > &input, const Char *to_be_replaced, const Char *replacement)
 replace all instances of to_be_replaced in input by replacement.
 
template<typename Char, typename Traits, typename Alloc>
bool lass::num::lass::stde::begins_with (const std::basic_string< Char, Traits, Alloc > &input, const std::basic_string< Char, Traits, Alloc > &prefix)
 returns true if input begins with the input prefix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::num::lass::stde::begins_with (const std::basic_string< Char, Traits, Alloc > &input, const Char *prefix)
 returns true if input begins with the input prefix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::num::lass::stde::begins_with (const std::basic_string< Char, Traits, Alloc > &input, Char prefix)
 returns true if input begins with the input prefix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::num::lass::stde::ends_with (const std::basic_string< Char, Traits, Alloc > &input, const std::basic_string< Char, Traits, Alloc > &suffix)
 returns true if input ends with the input suffix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::num::lass::stde::ends_with (const std::basic_string< Char, Traits, Alloc > &input, const Char *suffix)
 returns true if input ends with the input suffix
 
template<typename Char, typename Traits, typename Alloc>
bool lass::num::lass::stde::ends_with (const std::basic_string< Char, Traits, Alloc > &input, Char suffix)
 returns true if input ends with the input suffix
 
template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::num::lass::stde::split (const std::basic_string< Char, Traits, Alloc > &to_be_split)
 Reflects the Python function split without seperator argument.
 
template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::num::lass::stde::split (const std::basic_string< Char, Traits, Alloc > &to_be_split, const std::basic_string< Char, Traits, Alloc > &seperator, size_t max_split)
 Reflects the Python function split without seperator argument.
 
template<typename Char, typename Traits, typename Alloc>
std::vector< std::basic_string< Char, Traits, Alloc > > lass::num::lass::stde::split (const std::basic_string< Char, Traits, Alloc > &to_be_split, const Char *seperator, size_t max_split)
 Reflects the Python function split without seperator argument.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::lstrip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped, const std::basic_string< Char, Traits, Alloc > &to_be_removed)
 Return a copy of the string to_be_stripped with leading characters removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::lstrip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped)
 Return a copy of the string to_be_stripped with leading whitespace removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::rstrip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped, const std::basic_string< Char, Traits, Alloc > &to_be_removed)
 Return a copy of the string to_be_stripped with trailing characters removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::rstrip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped)
 Return a copy of the string to_be_stripped with trailing whitespace removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::strip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped, const std::basic_string< Char, Traits, Alloc > &to_be_removed)
 Return a copy of the string to_be_stripped with both leading and trailing characters removed.
 
template<typename Char, typename Traits, typename Alloc>
std::basic_string< Char, Traits, Alloc > lass::num::lass::stde::strip (const std::basic_string< Char, Traits, Alloc > &to_be_stripped)
 Return a copy of the string to_be_stripped with leading and trailing whitespace removed.
 
template<typename T>
void lass::num::lass::util::setBit (T &a_bits, size_t a_bit)
 Set a bit high.
 
template<typename T>
void lass::num::lass::util::clearBit (T &a_bits, size_t a_bit)
 set a bit low.
 
template<typename T>
void lass::num::lass::util::flipBit (T &a_bits, size_t a_bit)
 flip state of a bit (low->high, high->low).
 
template<typename T>
void lass::num::lass::util::setBitIf (T &a_bits, size_t a_bit, bool a_condition)
 set a bit high if (and only if) a condition is fullfilled.
 
template<typename T>
void lass::num::lass::util::clearBitIf (T &a_bits, size_t a_bit, bool a_condition)
 set a bit low if (and only if) a condition is fullfilled is true.
 
template<typename T>
void lass::num::lass::util::flipBitIf (T &a_bits, size_t a_bit, bool a_condition)
 flip a bit if (and only if) a condition is fullfilled (low->high, high->low).
 
template<typename T>
void lass::num::lass::util::setBitTo (T &a_bits, size_t a_bit, bool a_state)
 set a bit to a given state.
 
template<typename T>
bool lass::num::lass::util::checkBit (T a_bits, size_t a_bit)
 return true if a bit is set high.
 
template<typename T>
void lass::num::lass::util::setMasked (T &a_bits, const T &a_mask)
 Set masked bits high.
 
template<typename T>
void lass::num::lass::util::clearMasked (T &a_bits, const T &a_mask)
 Set masked bits low.
 
template<typename T>
void lass::num::lass::util::flipMasked (T &a_bits, const T &a_mask)
 flip masked bits.
 
template<typename T>
void lass::num::lass::util::setMaskedIf (T &a_bits, const T &a_mask, bool a_condition)
 Set masked bits high if (and only if) a condition is fullfilled.
 
template<typename T>
void lass::num::lass::util::clearMaskedIf (T &a_bits, const T &a_mask, bool a_condition)
 Set masked bits low if (and only if) a condition is fullfilled.
 
template<typename T>
void lass::num::lass::util::flipMaskedIf (T &a_bits, const T &a_mask, bool a_condition)
 Flip the masked bits if (and only if) a condition is fullfilled.
 
template<typename T>
void lass::num::lass::util::setMaskedTo (T &a_bits, const T &a_mask, bool a_state)
 Set the masked bits to a given state if (and only if) a condition is fullfilled.
 
template<typename T>
bool lass::num::lass::util::checkMaskedAll (T a_bits, const T &a_mask)
 Check the masked bits and return true if they are ALL set.
 
template<typename T>
bool lass::num::lass::util::checkMaskedSome (T a_bits, const T &a_mask)
 Check the masked bits and return true if at least one is set.
 
template<typename T>
size_t lass::num::lass::util::countBits (T bits)
 returns number of set bits in bits
 

Variables

const size_t lass::num::lass::util::impl::bitsInByte [256]
 lookup table of number of bits in a byte
 

Detailed Description

Author
Bram de Greve (bram@.nosp@m.coca.nosp@m.mware.nosp@m..com)
Tom De Muer (tom@c.nosp@m.ocam.nosp@m.ware..nosp@m.com)

*** BEGIN LICENSE INFORMATION ***

The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://lass.sourceforge.net/cpal-license. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.

Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.

The Original Code is LASS - Library of Assembled Shared Sources.

The Initial Developer of the Original Code is Bram de Greve and Tom De Muer. The Original Developer is the Initial Developer.

All portions of the code written by the Initial Developer are: Copyright (C) 2004-2011 the Initial Developer. All Rights Reserved.

Contributor(s):

Alternatively, the contents of this file may be used under the terms of the GNU General Public License Version 2 or later (the GPL), in which case the provisions of GPL are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of the GPL and not to allow others to use your version of this file under the CPAL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL License. If you do not delete the provisions above, a recipient may use your version of this file under either the CPAL or the GPL.

*** END LICENSE INFORMATION ***

Definition in file basic_ops.h.