00001 00002 // This file is part of SPart, Spatially Located Workload Partitioner. 00003 00004 // Copyright (C) 2011, The Ohio State University 00005 // SPart developed by Erdeniz O. Bas, Erik Saule and Umit V. Catalyurek 00006 00007 // For questions, comments, suggestions, bugs please send e-mail to: 00008 // Umit V. Catalyurek catalyurek.1@osu.edu 00009 00010 // SPart is free software; you can redistribute it and/or modify it under 00011 // the terms of the GNU General Public License as published by the Free 00012 // Software Foundation; either version 2 or (at your option) any later 00013 // version. 00014 00015 // SPart is distributed in the hope that it will be useful, but WITHOUT 00016 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00017 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00018 // for more details. 00019 00020 // You should have received a copy of the GNU General Public License 00021 // along with SPart; if not, write to the Free Software Foundation, Inc., 00022 // 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 00023 00024 // As a special exception, if other files instantiate templates or use 00025 // macros or inline functions from this file, or you compile this file 00026 // and link it with other works to produce a work based on this file, 00027 // this file does not by itself cause the resulting work to be covered by 00028 // the GNU General Public License. However the source code for this file 00029 // must still be made available in accordance with section (3) of the GNU 00030 // General Public License. 00031 00032 // This exception does not invalidate any other reasons why a work based 00033 // on this file might be covered by the GNU General Public License. 00034 00035 // The full text of the GPL license version 2 is available in "gpl.txt". 00036 00037 #ifndef __CONSTRAINT_HPP__ 00038 #define __CONSTRAINT_HPP__ 00039 00040 namespace util 00041 { 00051 template < typename Pr> 00052 bool constraint_psa(const Pr& psa); 00053 template <typename Pr, typename output> 00054 void output_psa (const Pr& psa, output& out); 00055 00056 template < typename Pr> 00057 bool constraint_psa(const Pr& psa) 00058 { 00059 for (int i=0; i < psa.prefixsizeX(); i++) 00060 if (psa[i][0] != 0) return false; 00061 00062 for (int j=0; j < psa.prefixsizeY(); j++) 00063 if (psa[0][j] != 0) return false; 00064 00065 for (int i=1; i< psa.prefixsizeX(); i++) 00066 { 00067 for (int j=1; j< psa.prefixsizeY(); j++) 00068 { 00069 if (psa[i][j] < psa[i-1][j]) return false; 00070 if (psa[i][j] < psa[i][j-1]) return false; 00071 if (psa[i][j] < 0) return false; 00072 } 00073 } 00074 return true; 00075 } 00076 00084 template <typename Pr, typename output> 00085 void output_psa (const Pr& psa, output& out) 00086 { 00087 out<<psa.prefixsizeX()-1<<" "<<psa.prefixsizeY()-1<<std::endl; 00088 00089 for (int i=1; i < psa.prefixsizeX(); i++) 00090 { 00091 for (int j=1; j < psa.prefixsizeY(); j++) 00092 { 00093 out << psa[i][j] + psa[i-1][j-1] - psa[i-1][j] - psa[i][j-1] <<std::endl; 00094 } 00095 } 00096 00097 } 00098 00099 } 00100 00101 #endif 00102