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