00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PPL_OR_Matrix_templates_hh
00024 #define PPL_OR_Matrix_templates_hh 1
00025
00026 #include <iostream>
00027
00028 namespace Parma_Polyhedra_Library {
00029
00030 template <typename T>
00031 memory_size_type
00032 OR_Matrix<T>::external_memory_in_bytes() const{
00033 return vec.external_memory_in_bytes();
00034 }
00035
00036 template <typename T>
00037 bool
00038 OR_Matrix<T>::OK() const {
00039 #ifndef NDEBUG
00040 using std::endl;
00041 using std::cerr;
00042 #endif
00043
00044 const dimension_type dim = space_dimension();
00045 if (vec.size() != 2*dim*(dim + 1)) {
00046 #ifndef NDEBUG
00047 cerr << "OR_Matrix has a wrong number of cells:\n"
00048 << "vec.size() is " << vec.size()
00049 << ", expected size is " << 2*dim*(dim+1) << "!\n";
00050 #endif
00051 return false;
00052 }
00053
00054
00055 if (!vec.OK(vec.size(), vec_capacity))
00056 return false;
00057
00058
00059 return true;
00060 }
00061
00062 template <typename T>
00063 void
00064 OR_Matrix<T>::ascii_dump(std::ostream& s) const {
00065 const OR_Matrix<T>& x = *this;
00066 const char separator = ' ';
00067 dimension_type space = x.space_dimension();
00068 s << space << separator << "\n";
00069 for (const_row_iterator i = x.row_begin(),
00070 x_row_end = x.row_end(); i != x_row_end; ++i) {
00071 const_row_reference_type r = *i;
00072 dimension_type rs = i.row_size();
00073 for (dimension_type j = 0; j < rs; ++j) {
00074 using namespace IO_Operators;
00075 s << r[j] << separator;
00076 }
00077 s << "\n";
00078 }
00079 }
00080
00081 PPL_OUTPUT_TEMPLATE_DEFINITIONS(T, OR_Matrix<T>)
00082
00083 template <typename T>
00084 bool
00085 OR_Matrix<T>::ascii_load(std::istream& s) {
00086 dimension_type space;
00087 if (!(s >> space))
00088 return false;
00089 resize_no_copy(space);
00090 for (row_iterator i = row_begin(),
00091 this_row_end = row_end(); i != this_row_end; ++i) {
00092 row_reference_type r_i = *i;
00093 const dimension_type rs = i.row_size();
00094 for (dimension_type j = 0; j < rs; ++j) {
00095 Result r = input(r_i[j], s, ROUND_UP);
00096
00097 if (!s || r == V_CVT_STR_UNK)
00098 return false;
00099 }
00100 }
00101 assert(OK());
00102 return true;
00103 }
00104
00105 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00106
00107 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00108 template <typename T>
00109 std::ostream&
00110 IO_Operators::operator<<(std::ostream& s, const OR_Matrix<T>& m) {
00111 for (typename OR_Matrix<T>::const_row_iterator m_iter = m.row_begin(),
00112 m_end = m.row_end(); m_iter != m_end; ++m_iter) {
00113 typename OR_Matrix<T>::const_row_reference_type r_m = *m_iter;
00114 const dimension_type mr_size = m_iter.row_size();
00115 for (dimension_type j = 0; j < mr_size; ++j)
00116 s << r_m[j] << " ";
00117 s << "\n";
00118 }
00119 return s;
00120 }
00121
00122 }
00123
00124 #endif // !defined(PPL_OR_Matrix_templates_hh)