Changeset 35101 for trunk/Ohana/src/libfits/table/F_set_column.c
- Timestamp:
- Feb 6, 2013, 3:20:55 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libfits/table/F_set_column.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/table/F_set_column.c
r33648 r35101 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.
