Changeset a35b458 in mainline for uspace/lib/math/generic/trig.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/math/generic/trig.c
r3061bc1 ra35b458 64 64 float32_t ret = 0; 65 65 float32_t nom = 1; 66 66 67 67 for (unsigned int i = 0; i < TAYLOR_DEGREE_32; i++) { 68 68 nom *= arg; 69 69 70 70 if ((i % 4) == 0) 71 71 ret += nom / factorials[i]; … … 73 73 ret -= nom / factorials[i]; 74 74 } 75 75 76 76 return ret; 77 77 } … … 93 93 float64_t ret = 0; 94 94 float64_t nom = 1; 95 95 96 96 for (unsigned int i = 0; i < TAYLOR_DEGREE_64; i++) { 97 97 nom *= arg; 98 98 99 99 if ((i % 4) == 0) 100 100 ret += nom / factorials[i]; … … 102 102 ret -= nom / factorials[i]; 103 103 } 104 104 105 105 return ret; 106 106 } … … 122 122 float32_t ret = 1; 123 123 float32_t nom = 1; 124 124 125 125 for (unsigned int i = 0; i < TAYLOR_DEGREE_32; i++) { 126 126 nom *= arg; 127 127 128 128 if ((i % 4) == 1) 129 129 ret -= nom / factorials[i]; … … 131 131 ret += nom / factorials[i]; 132 132 } 133 133 134 134 return ret; 135 135 } … … 151 151 float64_t ret = 1; 152 152 float64_t nom = 1; 153 153 154 154 for (unsigned int i = 0; i < TAYLOR_DEGREE_64; i++) { 155 155 nom *= arg; 156 156 157 157 if ((i % 4) == 1) 158 158 ret -= nom / factorials[i]; … … 160 160 ret += nom / factorials[i]; 161 161 } 162 162 163 163 return ret; 164 164 } … … 179 179 { 180 180 unsigned int period = arg / (M_PI / 4); 181 181 182 182 switch (period) { 183 183 case 0: … … 212 212 { 213 213 unsigned int period = arg / (M_PI / 4); 214 214 215 215 switch (period) { 216 216 case 0: … … 245 245 { 246 246 unsigned int period = arg / (M_PI / 4); 247 247 248 248 switch (period) { 249 249 case 0: … … 278 278 { 279 279 unsigned int period = arg / (M_PI / 4); 280 280 281 281 switch (period) { 282 282 case 0: … … 308 308 { 309 309 float32_t base_arg = fmod_f32(arg, 2 * M_PI); 310 310 311 311 if (base_arg < 0) 312 312 return -base_sin_32(-base_arg); 313 313 314 314 return base_sin_32(base_arg); 315 315 } … … 327 327 { 328 328 float64_t base_arg = fmod_f64(arg, 2 * M_PI); 329 329 330 330 if (base_arg < 0) 331 331 return -base_sin_64(-base_arg); 332 332 333 333 return base_sin_64(base_arg); 334 334 } … … 346 346 { 347 347 float32_t base_arg = fmod_f32(arg, 2 * M_PI); 348 348 349 349 if (base_arg < 0) 350 350 return base_cos_32(-base_arg); 351 351 352 352 return base_cos_32(base_arg); 353 353 } … … 365 365 { 366 366 float64_t base_arg = fmod_f64(arg, 2 * M_PI); 367 367 368 368 if (base_arg < 0) 369 369 return base_cos_64(-base_arg); 370 370 371 371 return base_cos_64(base_arg); 372 372 }
Note:
See TracChangeset
for help on using the changeset viewer.