div.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 namespace Gecode { namespace Int {
00035
00036 template<class IntType>
00037 forceinline IntType
00038 ceil_div_pp(IntType x, IntType y) {
00039 assert((x >= 0) && (y >= 0));
00040
00041
00042
00043
00044
00045 return ((x % y) == 0) ? x/y : (x/y + 1);
00046 }
00047 template<class IntType>
00048 forceinline IntType
00049 floor_div_pp(IntType x, IntType y) {
00050 assert((x >= 0) && (y >= 0));
00051 return x / y;
00052 }
00053
00054 template<class IntType>
00055 forceinline IntType
00056 ceil_div_px(IntType x, IntType y) {
00057 assert(x >= 0);
00058 return (y >= 0) ? ceil_div_pp(x,y) : -floor_div_pp(x,-y);
00059 }
00060 template<class IntType>
00061 forceinline IntType
00062 floor_div_px(IntType x, IntType y) {
00063 assert(x >= 0);
00064 return (y >= 0) ? floor_div_pp(x,y) : -ceil_div_pp(x,-y);
00065 }
00066
00067 template<class IntType>
00068 forceinline IntType
00069 ceil_div_xp(IntType x, IntType y) {
00070 assert(y >= 0);
00071 return (x >= 0) ? ceil_div_pp(x,y) : -floor_div_pp(-x,y);
00072 }
00073 template<class IntType>
00074 forceinline IntType
00075 floor_div_xp(IntType x, IntType y) {
00076 assert(y >= 0);
00077 return (x >= 0) ? floor_div_pp(x,y) : -ceil_div_pp(-x,y);
00078 }
00079
00080 template<class IntType>
00081 forceinline IntType
00082 ceil_div_xx(IntType x, IntType y) {
00083 return (x >= 0) ? ceil_div_px(x,y) : -floor_div_px(-x,y);
00084 }
00085 template<class IntType>
00086 forceinline IntType
00087 floor_div_xx(IntType x, IntType y) {
00088 return (x >= 0) ? floor_div_px(x,y) : -ceil_div_px(-x,y);
00089 }
00090
00091 }}
00092
00093
00094