include/types.h
author Dmitriy Morozov <morozov@cs.duke.edu>
Mon, 04 Dec 2006 22:39:35 -0500
changeset 3 76a2c73ecbbf
parent 0 d95020656286
child 5 ee9052408c40
permissions -rw-r--r--
Moved config to a separate directory

#ifndef __TYPES_H__
#define __TYPES_H__

#include <iostream>

/* Types */
typedef 	bool					Sign;
typedef		short int				Dimension;
const 		Sign	 				POS = true;
const 		Sign					NEG = false;
typedef		double					RealType;
typedef		unsigned int			SizeType;

typedef 	const unsigned int&		version_type;


/**
 * Rational number type
 */
template<typename T>
class Rational
{
	public:
		typedef			Rational<T>			Self;
	
		Rational(T v);
		Rational(const Self& other);

		Self& operator/=(const Self& rhs);

		/// \name Comparisons
		/// Assume denominator is positive.
		/// @{
		bool operator<(const Self& rhs) const;
		bool operator<=(const Self& rhs) const;
		bool operator>(const Self& rhs) const;
		bool operator>=(const Self& rhs) const;
		/// @}
		
		Self& operator=(const Self& rhs);
		RealType to_real() const;

		std::ostream& operator<<(std::ostream& out) const;

	private:
		T numerator, denominator;
};

#include "types.hpp"

#endif // __TYPES_H__