View | Details | Raw Unified | Return to bug 1276
Collapse All | Expand All

(-)a/src/wifi/model/nist-error-rate-model.cc (-34 / +105 lines)
 Lines 16-21    Link Here 
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
17
 *
18
 * Author: Gary Pei <guangyu.pei@boeing.com>
18
 * Author: Gary Pei <guangyu.pei@boeing.com>
19
 * Optimized by: Darwin Astudillo <darwin.astudillo@enseeiht.fr>
19
 */
20
 */
20
#include "nist-error-rate-model.h"
21
#include "nist-error-rate-model.h"
21
#include "wifi-phy.h"
22
#include "wifi-phy.h"
 Lines 101-156    Link Here 
101
  double pms = pow (1 - pe, nbits);
102
  double pms = pow (1 - pe, nbits);
102
  return pms;
103
  return pms;
103
}
104
}
105
106
//double NistErrorRateModel::powNist(double a, double b) {
107
//    int tmp = (*(1 + (int *)&a));
108
//    int tmp2 = (int)(b * (tmp - 1072632447) + 1072632447);
109
//    double p = 0.0;
110
//    *(1 + (int * )&p) = tmp2;
111
//    return p;
112
//}
113
104
double
114
double
105
NistErrorRateModel::CalculatePe (double p, uint32_t bValue) const
115
NistErrorRateModel::CalculatePe (double p, uint32_t bValue) const
106
{
116
{
107
  double D = sqrt (4.0 * p * (1.0 - p));
117
  double D = sqrt (4.0 * p * (1.0 - p));
108
  double pe = 1.0;
118
  double pe = 1.0;
119
// The code modified below there is not beautiful but is fastest.
109
  if (bValue == 1)
120
  if (bValue == 1)
110
    {
121
    {
111
      // code rate 1/2, use table 3.1.1
122
      // code rate 1/2, use table 3.1.1
112
      pe = 0.5 * ( 36.0 * pow (D, 10.0)
123
//      pe = 0.5 * ( 36.0 * pow (D, 10.0)
113
                   + 211.0 * pow (D, 12.0)
124
//                   + 211.0 * pow (D, 12.0)
114
                   + 1404.0 * pow (D, 14.0)
125
//                   + 1404.0 * pow (D, 14.0)
115
                   + 11633.0 * pow (D, 16.0)
126
//                   + 11633.0 * pow (D, 16.0)
116
                   + 77433.0 * pow (D, 18.0)
127
//                   + 77433.0 * pow (D, 18.0)
117
                   + 502690.0 * pow (D, 20.0)
128
//                   + 502690.0 * pow (D, 20.0)
118
                   + 3322763.0 * pow (D, 22.0)
129
//                   + 3322763.0 * pow (D, 22.0)
119
                   + 21292910.0 * pow (D, 24.0)
130
//                   + 21292910.0 * pow (D, 24.0)
120
                   + 134365911.0 * pow (D, 26.0)
131
//                   + 134365911.0 * pow (D, 26.0)
121
                   );
132
//                   );
133
	  double multi = D * D;
134
	  double acum = multi * multi * multi * multi * multi;
135
	  double pe = 18.0 * acum;
136
	  acum *= multi;	// 12
137
	  pe += 105.5 * acum;
138
	  acum *= multi;	// 14
139
	  pe += 702.0 * acum;
140
	  acum *= multi;	// 16
141
	  pe += 5816.5 * acum;
142
	  acum *= multi;	// 18
143
	  pe += 38716.5 * acum;
144
	  acum *= multi;	// 20
145
	  pe += 251345 * acum;
146
	  acum *= multi;	// 22
147
	  pe += 1661381.5 * acum;
148
	  acum *= multi;	// 24
149
	  pe += 10646455.0 * acum;
150
	  acum *= multi;	// 26
151
	  pe += 67182955.5 * acum;
122
    }
152
    }
123
  else if (bValue == 2)
153
  else if (bValue == 2)
124
    {
154
    {
125
      // code rate 2/3, use table 3.1.2
155
      // code rate 2/3, use table 3.1.2
126
      pe = 1.0 / (2.0 * bValue) *
156
//      pe = 1.0 / (2.0 * bValue) *
127
        ( 3.0 * pow (D, 6.0)
157
//        ( 3.0 * pow (D, 6.0)
128
          + 70.0 * pow (D, 7.0)
158
//          + 70.0 * pow (D, 7.0)
129
          + 285.0 * pow (D, 8.0)
159
//          + 285.0 * pow (D, 8.0)
130
          + 1276.0 * pow (D, 9.0)
160
//          + 1276.0 * pow (D, 9.0)
131
          + 6160.0 * pow (D, 10.0)
161
//          + 6160.0 * pow (D, 10.0)
132
          + 27128.0 * pow (D, 11.0)
162
//          + 27128.0 * pow (D, 11.0)
133
          + 117019.0 * pow (D, 12.0)
163
//          + 117019.0 * pow (D, 12.0)
134
          + 498860.0 * pow (D, 13.0)
164
//          + 498860.0 * pow (D, 13.0)
135
          + 2103891.0 * pow (D, 14.0)
165
//          + 2103891.0 * pow (D, 14.0)
136
          + 8784123.0 * pow (D, 15.0)
166
//          + 8784123.0 * pow (D, 15.0)
137
        );
167
//        );
168
	  double acum = D * D * D * D * D * D;
169
      pe = 0.75 * acum;
170
      acum *= D;  // 7
171
      pe =+ 17.5 * acum;
172
      acum *= D;  // 8
173
      pe =+ 71.25 * acum;
174
      acum *= D;  // 9
175
      pe =+ 319.0 * acum;
176
      acum *= D;  // 10
177
      pe =+ 1540.0 * acum;
178
      acum *= D;  // 11
179
      pe =+ 6782.0 * acum;
180
      acum *= D;  // 12
181
      pe =+ 29254.75 * acum;
182
      acum *= D;  // 13
183
      pe =+ 124715.0 * acum;
184
      acum *= D;  // 14
185
      pe =+ 525972.75 * acum;
186
      acum *= D;  // 15
187
      pe =+ 2196030.75 * acum;
138
    }
188
    }
139
  else if (bValue == 3)
189
  else if (bValue == 3)
140
    {
190
    {
141
      // code rate 3/4, use table 3.1.2
191
      // code rate 3/4, use table 3.1.2
142
      pe = 1.0 / (2.0 * bValue) *
192
//      pe = 1.0 / (2.0 * bValue) *
143
        ( 42.0 * pow (D, 5.0)
193
//        ( 42.0 * pow (D, 5.0)
144
          + 201.0 * pow (D, 6.0)
194
//          + 201.0 * pow (D, 6.0)
145
          + 1492.0 * pow (D, 7.0)
195
//          + 1492.0 * pow (D, 7.0)
146
          + 10469.0 * pow (D, 8.0)
196
//          + 10469.0 * pow (D, 8.0)
147
          + 62935.0 * pow (D, 9.0)
197
//          + 62935.0 * pow (D, 9.0)
148
          + 379644.0 * pow (D, 10.0)
198
//          + 379644.0 * pow (D, 10.0)
149
          + 2253373.0 * pow (D, 11.0)
199
//          + 2253373.0 * pow (D, 11.0)
150
          + 13073811.0 * pow (D, 12.0)
200
//          + 13073811.0 * pow (D, 12.0)
151
          + 75152755.0 * pow (D, 13.0)
201
//          + 75152755.0 * pow (D, 13.0)
152
          + 428005675.0 * pow (D, 14.0)
202
//          + 428005675.0 * pow (D, 14.0)
153
        );
203
//        );
204
	  double acum = D * D * D * D * D;
205
      pe = 42.0 * acum;
206
      acum *= D;  // 6
207
      pe += 201.0 * acum;
208
      acum *= D;  // 7
209
      pe += 1492.0 * acum;
210
      acum *= D;  // 8
211
      pe += 10469.0 * acum;
212
      acum *= D;  // 9
213
      pe += 62935.0 * acum;
214
      acum *= D;  // 10
215
      pe += 379644.0 * acum;
216
      acum *= D;  // 11
217
      pe += 2253373.0 * acum;
218
      acum *= D;  // 12
219
      pe += 13073811.0 * acum;
220
      acum *= D;  // 13
221
      pe += 75152755.0 * acum;
222
      acum *= D;  // 14
223
      pe += 428005675.0 * acum;
224
      pe *= 1.0 / 6.0;
154
    }
225
    }
155
  else
226
  else
156
    {
227
    {

Return to bug 1276