$treeview $search $mathjax
|
Palabos
Version 1.1
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /* This file is part of the Palabos library. 00002 * 00003 * Copyright (C) 2011 FlowKit Sarl 00004 * Avenue de Chailly 23 00005 * 1012 Lausanne, Switzerland 00006 * E-mail contact: contact@flowkit.com 00007 * 00008 * The most recent release of Palabos can be downloaded at 00009 * <http://www.palabos.org/> 00010 * 00011 * The library Palabos is free software: you can redistribute it and/or 00012 * modify it under the terms of the GNU Affero General Public License as 00013 * published by the Free Software Foundation, either version 3 of the 00014 * License, or (at your option) any later version. 00015 * 00016 * The library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Affero General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Affero General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00028 #ifndef ROUND_OFF_POLICY_H 00029 #define ROUND_OFF_POLICY_H 00030 00031 #include "core/globalDefs.h" 00032 00033 namespace plb { 00034 00035 00037 00040 template<typename T, template<typename U> class Descriptor> 00041 inline T fullF(T fBar, plint iPop) { 00042 return fBar + Descriptor<T>::SkordosFactor()*Descriptor<T>::t[iPop]; 00043 } 00044 00046 00049 template<typename T, template<typename U> class Descriptor> 00050 inline T fBar(T fullF, plint iPop) { 00051 return fullF - Descriptor<T>::SkordosFactor()*Descriptor<T>::t[iPop]; 00052 } 00053 00054 template<typename T> 00055 struct NoOptimizationRoundOffPolicy { 00056 static int SkordosFactor() { 00057 return 0; 00058 } 00059 static T rhoBar(T rho) { 00060 return rho; 00061 } 00062 static T fullRho(T rhoBar) { 00063 return rhoBar; 00064 } 00065 static T invRho(T rhoBar) { 00066 return (T)1 / rhoBar; 00067 } 00068 static T rhoMinus1(T rhoBar) { 00069 return rhoBar - (T)1; 00070 } 00071 }; 00072 00073 template<typename T> 00074 struct DefaultRoundOffPolicy { 00075 static int SkordosFactor() { 00076 return 1; 00077 } 00078 static T rhoBar(T rho) { 00079 return rho - (T)1; 00080 } 00081 static T fullRho(T rhoBar) { 00082 return rhoBar + (T)1; 00083 } 00084 static T invRho(T rhoBar) { 00085 return (T)1 / (rhoBar + (T)1); 00086 } 00087 static T rhoMinus1(T rhoBar) { 00088 return rhoBar; 00089 } 00090 }; 00091 00092 template<typename T> 00093 struct LinearRoundOffPolicy { 00094 static int SkordosFactor() { 00095 return 1; 00096 } 00097 static T rhoBar(T rho) { 00098 return rho - (T)1; 00099 } 00100 static T fullRho(T rhoBar) { 00101 return rhoBar + (T)1; 00102 } 00103 static T invRho(T rhoBar) { 00104 return (T)1 - rhoBar; 00105 } 00106 static T rhoMinus1(T rhoBar) { 00107 return rhoBar; 00108 } 00109 }; 00110 00111 template<typename T> 00112 struct Order2RoundOffPolicy { 00113 static int SkordosFactor() { 00114 return 1; 00115 } 00116 static T rhoBar(T rho) { 00117 return rho - (T)1; 00118 } 00119 static T fullRho(T rhoBar) { 00120 return rhoBar + (T)1; 00121 } 00122 static T invRho(T rhoBar) { 00123 return (T)1 - rhoBar + rhoBar*rhoBar; 00124 } 00125 static T rhoMinus1(T rhoBar) { 00126 return rhoBar; 00127 } 00128 }; 00129 00130 template<typename T> 00131 struct Order3RoundOffPolicy { 00132 static int SkordosFactor() { 00133 return 1; 00134 } 00135 static T rhoBar(T rho) { 00136 return rho - (T)1; 00137 } 00138 static T fullRho(T rhoBar) { 00139 return rhoBar + (T)1; 00140 } 00141 static T invRho(T rhoBar) { 00142 return (T)1 - rhoBar + rhoBar*rhoBar - rhoBar*rhoBar*rhoBar; 00143 } 00144 static T rhoMinus1(T rhoBar) { 00145 return rhoBar; 00146 } 00147 }; 00148 00149 } // namespace plb 00150 00151 #endif
1.6.3
1.6.3