- Timestamp:
- Jun 6, 2015, 7:55:16 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/table/F_set_column.c
r38366 r38404 1 1 # include <ohana.h> 2 2 # include <gfitsio.h> 3 4 # define SWAP_NONE 5 6 # ifdef BYTE_SWAP 3 7 # define SWAP_BYTE { \ 4 8 char tmp; \ … … 14 18 tmp = Pout[2]; Pout[2] = Pout[5]; Pout[5] = tmp; \ 15 19 tmp = Pout[3]; Pout[3] = Pout[4]; Pout[4] = tmp; } 20 # else 21 # define SWAP_BYTE 22 # define SWAP_WORD 23 # define SWAP_DBLE 24 # endif 16 25 17 26 /***********************/ … … 239 248 // if (!strcmp (intype, #ITYPE)) { 240 249 250 int directCopy = (Bzero == 0.0) && (Bscale == 1.0); 251 252 # define SET_VALUES(OUTNAME, OUTTYPE, INNAME, INTYPE, SWAP_OP, NBYTES_IN) \ 253 if (!strcmp (outtype, OUTNAME) && !strcmp (intype, INNAME)) { \ 254 int NbytesIn = NBYTES_IN; \ 255 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { \ 256 if (directCopy) { \ 257 *(OUTTYPE *)Pout = *(INTYPE *)Pin; \ 258 } else { \ 259 *(OUTTYPE *)Pout = (*(INTYPE *)Pin - Bzero) / Bscale; \ 260 } \ 261 if (!nativeOrder) { SWAP_OP; }}} 262 263 SET_VALUES("char", char, "char", char, SWAP_NONE, 1); 264 SET_VALUES("byte", char, "char", char, SWAP_NONE, 1); 265 SET_VALUES("short", short, "char", char, SWAP_BYTE, 1); 266 SET_VALUES("int", int, "char", char, SWAP_WORD, 1); 267 SET_VALUES("int64_t", int64_t, "char", char, SWAP_DBLE, 1); 268 SET_VALUES("double", double, "char", char, SWAP_DBLE, 1); 269 SET_VALUES("float", float, "char", char, SWAP_WORD, 1); 270 271 SET_VALUES("char", char, "byte", char, SWAP_NONE, 1); 272 SET_VALUES("byte", char, "byte", char, SWAP_NONE, 1); 273 SET_VALUES("short", short, "byte", char, SWAP_BYTE, 1); 274 SET_VALUES("int", int, "byte", char, SWAP_WORD, 1); 275 SET_VALUES("int64_t", int64_t, "byte", char, SWAP_DBLE, 1); 276 SET_VALUES("float", float, "byte", char, SWAP_DBLE, 1); 277 SET_VALUES("double", double, "byte", char, SWAP_WORD, 1); 278 279 SET_VALUES("char", char, "short", short, SWAP_NONE, 2); 280 SET_VALUES("byte", char, "short", short, SWAP_NONE, 2); 281 SET_VALUES("short", short, "short", short, SWAP_BYTE, 2); 282 SET_VALUES("int", int, "short", short, SWAP_WORD, 2); 283 SET_VALUES("int64_t", int64_t, "short", short, SWAP_DBLE, 2); 284 SET_VALUES("float", float, "short", short, SWAP_DBLE, 2); 285 SET_VALUES("double", double, "short", short, SWAP_WORD, 2); 286 287 SET_VALUES("char", char, "int", int, SWAP_NONE, 4); 288 SET_VALUES("byte", char, "int", int, SWAP_NONE, 4); 289 SET_VALUES("short", short, "int", int, SWAP_BYTE, 4); 290 SET_VALUES("int", int, "int", int, SWAP_WORD, 4); 291 SET_VALUES("int64_t", int64_t, "int", int, SWAP_DBLE, 4); 292 SET_VALUES("float", float, "int", int, SWAP_DBLE, 4); 293 SET_VALUES("double", double, "int", int, SWAP_WORD, 4); 294 295 SET_VALUES("char", char, "int64_t", int64_t, SWAP_NONE, 8); 296 SET_VALUES("byte", char, "int64_t", int64_t, SWAP_NONE, 8); 297 SET_VALUES("short", short, "int64_t", int64_t, SWAP_BYTE, 8); 298 SET_VALUES("int", int, "int64_t", int64_t, SWAP_WORD, 8); 299 SET_VALUES("int64_t", int64_t, "int64_t", int64_t, SWAP_DBLE, 8); 300 SET_VALUES("float", float, "int64_t", int64_t, SWAP_DBLE, 8); 301 SET_VALUES("double", double, "int64_t", int64_t, SWAP_WORD, 8); 302 303 SET_VALUES("char", char, "float", float, SWAP_NONE, 4); 304 SET_VALUES("byte", char, "float", float, SWAP_NONE, 4); 305 SET_VALUES("short", short, "float", float, SWAP_BYTE, 4); 306 SET_VALUES("int", int, "float", float, SWAP_WORD, 4); 307 SET_VALUES("int64_t", int64_t, "float", float, SWAP_DBLE, 4); 308 SET_VALUES("float", float, "float", float, SWAP_DBLE, 4); 309 SET_VALUES("double", double, "float", float, SWAP_WORD, 4); 310 311 SET_VALUES("char", char, "double", double, SWAP_NONE, 8); 312 SET_VALUES("byte", char, "double", double, SWAP_NONE, 8); 313 SET_VALUES("short", short, "double", double, SWAP_BYTE, 8); 314 SET_VALUES("int", int, "double", double, SWAP_WORD, 8); 315 SET_VALUES("int64_t", int64_t, "double", double, SWAP_DBLE, 8); 316 SET_VALUES("float", float, "double", double, SWAP_DBLE, 8); 317 SET_VALUES("double", double, "double", double, SWAP_WORD, 8); 318 319 # if (0) 241 320 /** input == char **/ 242 321 if (!strcmp (outtype, "char") && !strcmp (intype, "char")) { 243 322 int NbytesIn = 1; 244 323 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { 245 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 324 if (directCopy) { *(char *)Pout = *(char *)Pin; } else { 325 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 326 } 246 327 } 247 328 } … … 249 330 int NbytesIn = 1; 250 331 for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) { 251 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 332 if (directCopy) { *(char *)Pout = *(char *)Pin; } else { 333 *(char *)Pout = (*(char *)Pin - Bzero) / Bscale; 334 } 252 335 } 253 336 } … … 255 338 int NbytesIn = 1; 256 339 for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { 257 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale; 340 if (directCopy) { *(short *)Pout = *(char *)Pin; } else { 341 *(short *)Pout = (*(char *)Pin - Bzero) / Bscale; 342 } 258 343 # ifdef BYTE_SWAP 259 344 if (!nativeOrder) { SWAP_BYTE; } … … 651 736 } 652 737 } 738 # endif 653 739 654 740 /* check array space */
Note:
See TracChangeset
for help on using the changeset viewer.
