view src/include/utils.hpp @ 30:d22bce6382d7

Finalise removal of all namespaces, one namespace to rule them all.
author Jordi Gutiérrez Hermoso <jordigh@gmail.com>
date Wed, 03 Feb 2010 19:30:20 -0600
parents 24f3c4ed5c84
children bb8a95bf2aa4
line wrap: on
line source

/*! \file utils.hpp
 * \brief Defines some miscellaneous functions.
 *
 *  \file utils.cpp
 *  \brief Implementations and instantiations of the functions and
 *  classes declared in utils.hpp
 */

#ifndef __UTILS_HPP__ 
#define __UTILS_HPP__

#include <string>
#include <map>
#include <set>
#include "linalg.hpp"

namespace kwantxi{
  ///Clears whitespace from front and back of string s.
  std::string trim(const std::string& s);

  ///Does map m contain thing?
  template<typename K, typename V> 
  bool contains(const std::map<K,V>& m, K thing);
  ///Does set s contain thing?
  template<typename E>
  bool contains(const std::set<E>& s, E thing);

  ///Does set s1 include set s2?
  template<typename E>
  bool includes(const std::set<E>& s1, const std::set<E>& s2);

  ///Reads matrices from filenames.
  kwantxi::matrix read_matrix(std::string filename);
  ///Reads vectors from filenames.
  kwantxi::vector read_vector(std::string filename);

  /*! \brief Reads map<point,double> from a matrix.  
   *
   *Last column is the value at each point which is represented in
   *turn by the rest of the row.
   */
  std::map<kwantxi::point, double> read_pd_map(std::string filename);

  ///Outputs some information about generic exceptions.
  void show_exception(kwantxi::error exc);

}

#endif