Changeset 35092
- Timestamp:
- Feb 6, 2013, 11:14:02 AM (13 years ago)
- Location:
- branches/eam_branches/ipp-20121219/Ohana/src/libfits/table
- Files:
-
- 2 edited
-
F_get_column.c (modified) (2 diffs)
-
F_set_column.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20121219/Ohana/src/libfits/table/F_get_column.c
r33648 r35092 96 96 } 97 97 if (!strcmp (type, "int64_t")) { 98 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 99 # ifdef BYTE_SWAP 100 SWAP_DBLE; 101 # endif 102 *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; 98 if ((Bzero == 0.0) && (Bscale == 1.0)) { 99 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 100 # ifdef BYTE_SWAP 101 SWAP_DBLE; 102 # endif 103 *(int64_t *)Pout = *(int64_t *)Pin; 104 } 105 } else { 106 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 107 # ifdef BYTE_SWAP 108 SWAP_DBLE; 109 # endif 110 *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; 111 } 103 112 } 104 113 } … … 243 252 } 244 253 if (!strcmp (type, "int64_t")) { 245 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 246 # ifdef BYTE_SWAP 247 SWAP_DBLE; 248 # endif 249 *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; 254 // XXX 64 bit int operations with Bzero & Bscale are inaccurate even with doubles 255 if ((Bzero == 0.0) && (Bscale == 1.0)) { 256 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 257 # ifdef BYTE_SWAP 258 SWAP_DBLE; 259 # endif 260 *(int64_t *)Pout = *(int64_t *)Pin; 261 } 262 } else { 263 for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) { 264 # ifdef BYTE_SWAP 265 SWAP_DBLE; 266 # endif 267 *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; 268 } 250 269 } 251 270 } -
branches/eam_branches/ipp-20121219/Ohana/src/libfits/table/F_set_column.c
r33648 r35092 102 102 } 103 103 } 104 if (!strcmp (type, "int64_t")) { 105 // XXX 64 bit int operations with Bzero & Bscale are inaccurate even with doubles 106 if ((Bzero == 0.0) && (Bscale == 1.0)) { 107 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { 108 *(int64_t *)Pout = *(int64_t *)Pin; 109 # ifdef BYTE_SWAP 110 SWAP_DBLE; 111 # endif 112 } 113 } else { 114 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { 115 *(int64_t *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 116 # ifdef BYTE_SWAP 117 SWAP_DBLE; 118 # endif 119 } 120 } 121 } 104 122 if (!strcmp (type, "float")) { 105 123 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { … … 228 246 } 229 247 } 248 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "char")) { 249 int NbytesIn = 1; 250 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 251 *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale; 252 # ifdef BYTE_SWAP 253 SWAP_DBLE; 254 # endif 255 } 256 } 230 257 if (!strcmp (outtype, "float") && !strcmp (intype, "char")) { 231 258 int NbytesIn = 1; … … 272 299 } 273 300 } 301 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "short")) { 302 int NbytesIn = 2; 303 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 304 *(int64_t *)Pout = (*(short *)Pin - Bzero) / Bscale; 305 # ifdef BYTE_SWAP 306 SWAP_DBLE; 307 # endif 308 } 309 } 274 310 if (!strcmp (outtype, "float") && !strcmp (intype, "short")) { 275 311 int NbytesIn = 2; … … 316 352 } 317 353 } 354 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "int")) { 355 int NbytesIn = 4; 356 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 357 *(int64_t *)Pout = (*(int *)Pin - Bzero) / Bscale; 358 # ifdef BYTE_SWAP 359 SWAP_DBLE; 360 # endif 361 } 362 } 318 363 if (!strcmp (outtype, "float") && !strcmp (intype, "int")) { 319 364 int NbytesIn = 4; … … 329 374 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 330 375 *(double *)Pout = (*(int *)Pin - Bzero) / Bscale; 376 # ifdef BYTE_SWAP 377 SWAP_DBLE; 378 # endif 379 } 380 } 381 382 /** input == int64_t **/ 383 if (!strcmp (outtype, "char") && !strcmp (intype, "int64_t")) { 384 int NbytesIn = 8; 385 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 386 *(char *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 387 } 388 } 389 if (!strcmp (outtype, "short") && !strcmp (intype, "int64_t")) { 390 int NbytesIn = 8; 391 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 392 *(short *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 393 # ifdef BYTE_SWAP 394 SWAP_BYTE; 395 # endif 396 } 397 } 398 if (!strcmp (outtype, "int") && !strcmp (intype, "int64_t")) { 399 int NbytesIn = 8; 400 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 401 *(int *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 402 # ifdef BYTE_SWAP 403 SWAP_WORD; 404 # endif 405 } 406 } 407 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "int64_t")) { 408 int NbytesIn = 8; 409 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 410 *(int64_t *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 411 # ifdef BYTE_SWAP 412 SWAP_DBLE; 413 # endif 414 } 415 } 416 if (!strcmp (outtype, "float") && !strcmp (intype, "int64_t")) { 417 int NbytesIn = 8; 418 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 419 *(float *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 420 # ifdef BYTE_SWAP 421 SWAP_WORD; 422 # endif 423 } 424 } 425 if (!strcmp (outtype, "double") && !strcmp (intype, "int64_t")) { 426 int NbytesIn = 8; 427 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 428 *(double *)Pout = (*(int64_t *)Pin - Bzero) / Bscale; 331 429 # ifdef BYTE_SWAP 332 430 SWAP_DBLE; … … 360 458 } 361 459 } 460 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "float")) { 461 int NbytesIn = 4; 462 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 463 *(int64_t *)Pout = (*(float *)Pin - Bzero) / Bscale; 464 # ifdef BYTE_SWAP 465 SWAP_DBLE; 466 # endif 467 } 468 } 362 469 if (!strcmp (outtype, "float") && !strcmp (intype, "float")) { 363 470 int NbytesIn = 4; … … 401 508 # ifdef BYTE_SWAP 402 509 SWAP_WORD; 510 # endif 511 } 512 } 513 if (!strcmp (outtype, "int64_t") && !strcmp (intype, "double")) { 514 int NbytesIn = 8; 515 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 516 *(int64_t *)Pout = (*(double *)Pin - Bzero) / Bscale; 517 # ifdef BYTE_SWAP 518 SWAP_DBLE; 403 519 # endif 404 520 }
Note:
See TracChangeset
for help on using the changeset viewer.
