1 #if !defined( MAPPING_INCLUDED ) /* Include this file only once */ 2 #define MAPPING_INCLUDED 3 /* 4 *++ 5 * Name: 6 * mapping.h 7 8 * Type: 9 * C include file. 10 11 * Purpose: 12 * Define the interface to the Mapping class. 13 14 * Invocation: 15 * #include "mapping.h" 16 17 * Description: 18 * This include file defines the interface to the Mapping class and 19 * provides the type definitions, function prototypes and macros, etc. 20 * needed to use this class. 21 * 22 * The Mapping class provides basic facilities for transforming a 23 * set of points to give a new set of points and for resampling 24 * grids of data. However, it does not have a constructor 25 * function. This is because the class only forms a template for 26 * deriving new classes which themselves implement specific forms 27 * of coordinate transformation. They do this by extending the 28 * protected astTransform method provided by this class. 29 30 * Inheritance: 31 * The Mapping class inherits from the Object class. 32 33 * Attributes Over-Ridden: 34 * None. 35 36 * New Attributes Defined: 37 * Nin (integer) 38 * A read-only attribute giving the number of input coordinate 39 * values required per point by a Mapping (i.e. the number of 40 * dimensions of the space in which input points reside). 41 * Nout (integer) 42 * A read-only attribute giving the number of output coordinate 43 * values generated per point by a Mapping (i.e. the number of 44 * dimensions of the space in which output points reside). 45 * Invert (integer) 46 * A boolean value (0 or 1) which controls which of a Mapping's 47 * two possible coordinate transformations is considered the 48 * "forward" transformation and which is the "inverse" 49 * transformation. If this value is zero (the default), the 50 * behaviour will be as defined when the Mapping was first 51 * created. If it is non-zero, the transformations will be 52 * inter-changed, so that the Mapping displays the inverse of 53 * its original behaviour. 54 * 55 * Note that inverting the boolean sense of the Invert attribute 56 * will cause the values of the Nin/Nout and 57 * TranForward/TranInverse attributes to be interchanged. 58 * Report (integer) 59 * A boolean value (0 or 1) which controls whether to report 60 * coordinate values when a Mapping is used to transform a set 61 * of points. If this value is zero (the default), no report is 62 * made. If it is non-zero, the coordinates of each point 63 * (before and after transformation) are reported by writing 64 * them to standard output. 65 * 66 * This attribute is intended as an aid to debugging and to save 67 * having to report values explicitly in simple programs. 68 * Unlike other attributes, the value of the Report attribute is 69 * not inherited when a Mapping is copied (its value is 70 * initially undefined, and therefore defaults to zero, in any 71 * copy). 72 * IsSimple (boolean) 73 * A read-only attribute indicating if the Mapping has been 74 * simpified. 75 * TranForward (integer) 76 * A read-only boolean value (0 or 1) which indicates whether a 77 * Mapping is able to transform coordinates in the "forward" 78 * direction (i.e. converting input coordinates into output 79 * coordinates). 80 * TranInverse (integer) 81 * A read-only boolean value (0 or 1) which indicates whether a 82 * Mapping is able to transform coordinates in the "inverse" 83 * direction (i.e. converting output coordinates back into input 84 * coordinates). 85 86 * Methods Over-Ridden: 87 * Public: 88 * None. 89 * 90 * Protected: 91 * astClearAttrib 92 * Clear an attribute value for a Mapping. 93 * astGetAttrib 94 * Get an attribute value for a Mapping. 95 * astSetAttrib 96 * Set an attribute value for a Mapping. 97 * astTestAttrib 98 * Test if an attribute value has been set for a Mapping. 99 100 * New Methods Defined: 101 * Public: 102 * astDecompose 103 * Decompose a Mapping into two component Mappings. 104 * astInvert 105 * Invert a Mapping. 106 * astLinearApprox 107 * Form a linear approximation to a Mapping 108 * astMapBox 109 * Find a bounding box for a Mapping. 110 * astQuadApprox 111 * Form a quadratic approximation to a Mapping 112 * astRate 113 * Find rate of change of a Mapping output 114 * astRebin<X> 115 * Rebin a region of a data grid. 116 * astRebinSeq<X> 117 * Rebin a region of a sequence of data grids. 118 * astResample<X> 119 * Resample a region of a data grid. 120 * astSimplify 121 * Simplify a Mapping. 122 * astTran1 123 * Transform 1-dimensional coordinates. 124 * astTran2 125 * Transform 2-dimensional coordinates. 126 * astTranGrid 127 * Transform an N-dimensional regular grid of positions. 128 * astTranN 129 * Transform N-dimensional coordinates. 130 * astTranP (C only) 131 * Transform N-dimensional coordinates held in separate arrays. 132 * 133 * Protected: 134 * astClearInvert 135 * Clear the Invert attribute value for a Mapping. 136 * astClearReport 137 * Clear the Report attribute value for a Mapping. 138 * astGetInvert 139 * Get the Invert attribute value for a Mapping. 140 * astGetIsSimple 141 * Get the IsSimple attribute. 142 * astGetNin 143 * Get the number of input coordinates for a Mapping. 144 * astGetNout 145 * Get the number of output coordinates for a Mapping. 146 * astGetReport 147 * Get the Report attribute value for a Mapping. 148 * astGetTranForward 149 * Determine if a Mapping can perform a "forward" coordinate 150 * transformation. 151 * astGetTranInverse 152 * Determine if a Mapping can perform an "inverse" coordinate 153 * transformation. 154 * astMapList 155 * Decompose a Mapping into a sequence of simpler Mappings. 156 * astMapSplit 157 * Select a subset of Mapping inputs. 158 * astMapMerge 159 * Simplify a sequence of Mappings. 160 * astReportPoints 161 * Report the effect of transforming a set of points using a Mapping. 162 * astSetInvert 163 * Set the Invert attribute value for a Mapping. 164 * astSetReport 165 * Set the Report attribute value for a Mapping. 166 * astTestInvert 167 * Test if an Invert attribute value has been set for a Mapping. 168 * astTestReport 169 * Test if an Report attribute value has been set for a Mapping. 170 * astTransform 171 * Transform a set of points. 172 173 * Other Class Functions: 174 * Public: 175 * astIsAMapping 176 * Test class membership. 177 * 178 * Protected: 179 * astCheckMapping 180 * Validate class membership. 181 * astInitMapping 182 * Initialise a Mapping. 183 * astInitMappingVtab 184 * Initialise the virtual function table for the Mapping class. 185 * astLoadMapping 186 * Load a Mapping. 187 188 * Macros: 189 * Public: 190 * AST__BLOCKAVE 191 * Block averaging interpolation. 192 * AST__GAUSS 193 * Use exp(-k*x*x) spreading. 194 * AST__LINEAR 195 * Simple linear interpolation. 196 * AST__NEAREST 197 * Use nearest pixel centre. 198 * AST__SINC 199 * Use sinc(pi*x) interpolation. 200 * AST__SINCCOS 201 * Use sinc(pi*x)*cos(k*pi*x) interpolation. 202 * AST__SINCGAUSS 203 * Use sinc(pi*x)*exp(-k*x*x) interpolation. 204 * AST__SINCSINC 205 * Use sinc(pi*x)*sinc(k*pi*x) interpolation. 206 * AST__SOMB 207 * Use somb(pi*x) interpolation. 208 * AST__SOMBCOS 209 * Use somb(pi*x)*cos(k*pi*x) interpolation. 210 * AST__UINTERP 211 * Use general user-defined sub-pixel interpolation algorithm. 212 * AST__UKERN1 213 * Use user-defined 1-d interpolation kernel. 214 * AST__URESAMP1, 2, 3 & 4 215 * Flags reserved for user-defined purposes. 216 * AST__USEBAD 217 * Recognise bad pixels? 218 * AST__CONSERVEFLUX 219 * Conserve flux in astResample? 220 * AST__REBININIT 221 * Initialise a new sequnece of calls to astRebinSeq<X> 222 * AST__REBINEND 223 * End a sequnece of calls to astRebinSeq<X> 224 * AST__NOBAD 225 * Leave bad output pixels unchanged in calls to astResample<X> 226 * AST__USEVAR 227 * Use variance arrays? 228 229 * Type Definitions: 230 * Public: 231 * AstMapping 232 * Mapping object type. 233 * 234 * Protected: 235 * AstMappingVtab 236 * Mapping virtual function table type. 237 238 * Feature Test Macros: 239 * astCLASS 240 * If the astCLASS macro is undefined, only public symbols are 241 * made available, otherwise protected symbols (for use in other 242 * class implementations) are defined. This macro also affects 243 * the reporting of error context information, which is only 244 * provided for external calls to the AST library. 245 246 * Copyright: 247 * Copyright (C) 1997-2006 Council for the Central Laboratory of the 248 * Research Councils 249 250 * Licence: 251 * This program is free software: you can redistribute it and/or 252 * modify it under the terms of the GNU Lesser General Public 253 * License as published by the Free Software Foundation, either 254 * version 3 of the License, or (at your option) any later 255 * version. 256 * 257 * This program is distributed in the hope that it will be useful, 258 * but WITHOUT ANY WARRANTY; without even the implied warranty of 259 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 260 * GNU Lesser General Public License for more details. 261 * 262 * You should have received a copy of the GNU Lesser General 263 * License along with this program. If not, see 264 * <http://www.gnu.org/licenses/>. 265 266 * Authors: 267 * RFWS: R.F. Warren-Smith (Starlink) 268 * MBT: Mark Taylor (Starlink) 269 * DSB: David S. Berry (Starlink) 270 271 * History: 272 * 30-JAN-1996 (RFWS): 273 * Original version. 274 * 12-JUL-1996 (RFWS): 275 * Updated to support the external interface plus various other 276 * additions. 277 * 12-DEC-1996 (RFWS): 278 * Added the astMapList method. 279 * 13-DEC-1996 (RFWS): 280 * Added the astMapMerge method. 281 * 13-DEC-1996 (RFWS): 282 * Added the astSimplify method. 283 * 28-MAY-1998 (RFWS): 284 * Added the astMapBox method. 285 * 12-NOV-1998 (RFWS): 286 * Added astResample<X> and associated code. 287 * 24-NOV-2000 (MBT): 288 * Added AST__BLOCKAVE interpolation scheme. 289 * 9-JAN-2001 (DSB): 290 * Changed in and out arguments for TranN from type "double (*)[]" 291 * to "double *". 292 * 8-JAN-2003 (DSB): 293 * Added protected astInitMappingVtab method. 294 * 10-JUL-2003 (DSB): 295 * Added method astRate. 296 * 20-SEP-2004 (DSB): 297 * Added method astLinearApprox. 298 * 30-JUN-2005 (DSB): 299 * Added method astRebin 300 * 1-SEP-2005 (DSB): 301 * Added method astRebinSeq 302 * 31-JAN-2006 (DSB): 303 * Added IsSimple attribute. 304 * 2-MAR-2006 (DSB): 305 * Use HAVE_LONG_DOUBLE in place of AST_LONG_DOUBLE 306 * 8-MAR-2006 (DSB): 307 * Add astTranGrid. 308 * 5-MAY-2009 (DSB): 309 * Add astRemoveRegions. 310 * 26-FEB-2010 (DSB): 311 * Added method astQuadApprox. 312 *-- 313 */ 314 315 /* Include files. */ 316 /* ============== */ 317 318 /* Configuration results */ 319 /* --------------------- */ 320 #if HAVE_CONFIG_H 321 #include <config.h> 322 #endif 323 324 /* Interface definitions. */ 325 /* ---------------------- */ 326 #include "object.h" /* Base Object class */ 327 #include "pointset.h" /* Sets of points/coordinates */ 328 #include "channel.h" /* I/O channels */ 329 330 /* C header files. */ 331 /* --------------- */ 332 #include <stddef.h> 333 #include <stdint.h> 334 335 /* Macros. */ 336 /* ======= */ 337 338 /* Sizes of global arrays */ 339 340 #if defined(astCLASS) || defined(astFORTRAN77) 341 #define STATUS_PTR status 342 #else 343 #define STATUS_PTR astGetStatusPtr 344 #endif 345 #define AST__MAPPING_GETATTRIB_BUFF_LEN 50 346 #define AST__MAPPING_RATEFUN_MAX_CACHE 5 347 348 /* Resampling flags. */ 349 /* ----------------- */ 350 /* These macros define flag values which may be passed to 351 astResample<X> (via the "flags" argument) to provide control over 352 resampling operations. */ 353 #define AST__URESAMP1 (1) /* Flags reserved for user-defined purposes */ 354 #define AST__URESAMP2 (2) 355 #define AST__URESAMP3 (4) 356 #define AST__URESAMP4 (8) 357 #define AST__USEVAR (16) /* Use variance arrays? */ 358 #define AST__USEBAD (32) /* Recognise bad pixels? */ 359 #define AST__CONSERVEFLUX (64) /* Conserve flux? */ 360 #define AST__REBININIT (128) /* Initialise a new sequence of calls to astRebinSeq? */ 361 #define AST__REBINEND (256) /* End a sequence of calls to astRebinSeq? */ 362 #define AST__GENVAR (512) /* Generate output variances when rebinning? */ 363 #define AST__VARWGT (1024) /* Use input variances as weights? */ 364 #define AST__NOBAD (2048) /* Leave bad output values unchanged? */ 365 #define AST__DISVAR (4096) /* Generate distribution (not mean) variance? */ 366 #define AST__NONORM (8192) /* No normalisation required at end? */ 367 368 /* These macros identify standard sub-pixel interpolation algorithms 369 for use by astResample<X>. They are used by giving the macro's 370 value for the "interp" argument. */ 371 #define AST__UKERN1 (1) /* User-supplied 1-d interpolation kernel */ 372 #if 0 /* Not yet implemented */ 373 #define AST__UKERNN (2) /* User-supplied n-d interpolation kernel */ 374 #endif 375 #define AST__UINTERP (3) /* User-supplied interpolation function */ 376 #define AST__NEAREST (4) /* Use pixel with nearest centre */ 377 #define AST__LINEAR (5) /* Simple linear interpolation */ 378 #define AST__SINC (6) /* sinc(pi*x) interpolation */ 379 #define AST__SINCSINC (7) /* sinc(pi*x)*sinc(k*pi*x) interpolation */ 380 #define AST__SINCCOS (8) /* sinc(pi*x)*cos(k*pi*x) interpolation */ 381 #define AST__SINCGAUSS (9) /* sinc(pi*x)*exp(-k*x*x) interpolation */ 382 #define AST__BLOCKAVE (10) /* Block averaging interpolation */ 383 #define AST__GAUSS (11) /* exp(-k*x*x) spreading */ 384 #define AST__SOMB (12) /* somp(pi*x) interpolation */ 385 #define AST__SOMBCOS (13) /* somp(pi*x)*cos(k*pi*x) interpolation */ 386 387 /* 64 bit types */ 388 #if HAVE_INT64_T && HAVE_UINT64_T 389 #include <stdint.h> 390 typedef int64_t INT_BIG; 391 typedef uint64_t UINT_BIG; 392 393 #elif SIZEOF_LONG == 8 394 typedef long int INT_BIG; 395 typedef unsigned long int UINT_BIG; 396 397 #elif SIZEOF_LONG_LONG == 8 398 typedef long long int INT_BIG; 399 typedef unsigned long long int UINT_BIG; 400 401 #else 402 #define INT_BIG "no int64_t type available" 403 #define UINT_BIG "no uint64_t type available" 404 #endif 405 406 407 408 /* Type Definitions. */ 409 /* ================= */ 410 /* Mapping structure. */ 411 /* ------------------ */ 412 /* This structure contains all information that is unique to each 413 object in the class (e.g. its instance variables). */ 414 typedef struct AstMapping { 415 416 /* Attributes inherited from the parent class. */ 417 AstObject object; /* Parent class structure */ 418 419 /* Attributes specific to objects in this class. */ 420 char invert; /* Mapping inverted? */ 421 char issimple; /* Has Mapping been simplified? */ 422 int nin; /* Number of input coordinates */ 423 int nout; /* Number of output coordinates */ 424 char report; /* Report when converting coordinates? */ 425 char tran_forward; /* Forward transformation defined? */ 426 char tran_inverse; /* Inverse transformation defined? */ 427 } AstMapping; 428 429 /* Virtual function table. */ 430 /* ----------------------- */ 431 /* This table contains all information that is the same for all 432 objects in the class (e.g. pointers to its virtual functions). */ 433 #if defined(astCLASS) /* Protected */ 434 typedef struct AstMappingVtab { 435 436 /* Properties (e.g. methods) inherited from the parent class. */ 437 AstObjectVtab object_vtab; /* Parent class virtual function table */ 438 439 /* A Unique identifier to determine class membership. */ 440 AstClassIdentifier id; 441 442 /* Properties (e.g. methods) specific to this class. */ 443 AstMapping *(* RemoveRegions)( AstMapping *, int * ); 444 AstMapping *(* Simplify)( AstMapping *, int * ); 445 AstPointSet *(* Transform)( AstMapping *, AstPointSet *, int, AstPointSet *, int * ); 446 double (* Rate)( AstMapping *, double *, int, int, int * ); 447 int (* DoNotSimplify)( AstMapping *, int * ); 448 int (* GetInvert)( AstMapping *, int * ); 449 int (* GetIsSimple)( AstMapping *, int * ); 450 int (* GetNin)( AstMapping *, int * ); 451 int (* GetNout)( AstMapping *, int * ); 452 int (* GetReport)( AstMapping *, int * ); 453 int (* GetTranForward)( AstMapping *, int * ); 454 int (* GetTranInverse)( AstMapping *, int * ); 455 int (* GetIsLinear)( AstMapping *, int * ); 456 int (* LinearApprox)( AstMapping *, const double *, const double *, double, double *, int * ); 457 int (* MapMerge)( AstMapping *, int, int, int *, AstMapping ***, int **, int * ); 458 int (* QuadApprox)( AstMapping *, const double[2], const double[2], int, int, double *, double *, int * ); 459 int (* TestInvert)( AstMapping *, int * ); 460 int (* TestReport)( AstMapping *, int * ); 461 void (* ClearInvert)( AstMapping *, int * ); 462 void (* ClearReport)( AstMapping *, int * ); 463 void (* Decompose)( AstMapping *, AstMapping **, AstMapping **, int *, int *, int *, int * ); 464 void (* Invert)( struct AstMapping *, int * ); 465 void (* MapBox)( AstMapping *, const double [], const double [], int, int, double *, double *, double [], double [], int * ); 466 int (* MapList)( AstMapping *, int, int, int *, AstMapping ***, int **, int * ); 467 int *(* MapSplit)( AstMapping *, int, const int *, AstMapping **, int * ); 468 void (* ReportPoints)( AstMapping *, int, AstPointSet *, AstPointSet *, int * ); 469 void (* SetInvert)( AstMapping *, int, int * ); 470 void (* SetReport)( AstMapping *, int, int * ); 471 void (* Tran1)( AstMapping *, int, const double [], int, double [], int * ); 472 void (* Tran2)( AstMapping *, int, const double [], const double [], int, double [], double [], int * ); 473 void (* TranGrid)( AstMapping *, int, const int[], const int[], double, int, int, int, int, double *, int * ); 474 void (* TranN)( AstMapping *, int, int, int, const double *, int, int, int, double *, int * ); 475 void (* TranP)( AstMapping *, int, int, const double *[], int, int, double *[], int * ); 476 477 #define DECLARE_GENERIC_ALL(X,Xtype) \ 478 int (* Resample##X)( AstMapping *, int, const int [], const int [], \ 479 const Xtype [], const Xtype [], int, \ 480 void (*)( void ), const double [], int, double, int, \ 481 Xtype, int, const int [], const int [], \ 482 const int [], const int [], Xtype [], Xtype [], int * ); \ 483 484 DECLARE_GENERIC_ALL(B,signed char) 485 DECLARE_GENERIC_ALL(D,double) 486 DECLARE_GENERIC_ALL(F,float) 487 DECLARE_GENERIC_ALL(I,int) 488 DECLARE_GENERIC_ALL(K,INT_BIG) 489 DECLARE_GENERIC_ALL(L,long int) 490 DECLARE_GENERIC_ALL(S,short int) 491 DECLARE_GENERIC_ALL(UB,unsigned char) 492 DECLARE_GENERIC_ALL(UI,unsigned int) 493 DECLARE_GENERIC_ALL(UK,UINT_BIG) 494 DECLARE_GENERIC_ALL(UL,unsigned long int) 495 DECLARE_GENERIC_ALL(US,unsigned short int) 496 497 #if HAVE_LONG_DOUBLE /* Not normally implemented */ 498 DECLARE_GENERIC_ALL(LD,long double) 499 #endif 500 501 #undef DECLARE_GENERIC_ALL 502 503 #define DECLARE_GENERIC_DFI(X,Xtype) \ 504 void (* Rebin##X)( AstMapping *, double, int, const int [], const int [], \ 505 const Xtype [], const Xtype [], int, const double [], int, \ 506 double, int, Xtype, int, const int [], const int [], \ 507 const int [], const int [], Xtype [], Xtype [], int * ); \ 508 void (* RebinSeq##X)( AstMapping *, double, int, const int [], const int [], \ 509 const Xtype [], const Xtype [], int, const double [], \ 510 int, double, int, Xtype, int, const int [], \ 511 const int [], const int [], const int [], Xtype [], \ 512 Xtype [], double [], int64_t *, int * ); 513 514 DECLARE_GENERIC_DFI(D,double) 515 DECLARE_GENERIC_DFI(F,float) 516 DECLARE_GENERIC_DFI(I,int) 517 518 #if HAVE_LONG_DOUBLE /* Not normally implemented */ 519 DECLARE_GENERIC_DFI(LD,long double) 520 #endif 521 522 #undef DECLARE_GENERIC_DFI 523 524 } AstMappingVtab; 525 526 527 #if defined(THREAD_SAFE) 528 529 /* Define a structure holding all data items that are global within this 530 class. */ 531 typedef struct AstMappingGlobals { 532 AstMappingVtab Class_Vtab; 533 int Class_Init; 534 char GetAttrib_Buff[ AST__MAPPING_GETATTRIB_BUFF_LEN + 1 ]; 535 AstMapping *Unsimplified_Mapping; 536 int Rate_Disabled; 537 AstPointSet *RateFun_Pset1_Cache[ AST__MAPPING_RATEFUN_MAX_CACHE ]; 538 AstPointSet *RateFun_Pset2_Cache[ AST__MAPPING_RATEFUN_MAX_CACHE ]; 539 int RateFun_Next_Slot; 540 int RateFun_Pset_Size[ AST__MAPPING_RATEFUN_MAX_CACHE ]; 541 } AstMappingGlobals; 542 543 #endif 544 #endif 545 546 /* Function prototypes. */ 547 /* ==================== */ 548 /* Prototypes for standard class functions. */ 549 /* ---------------------------------------- */ 550 astPROTO_CHECK(Mapping) /* Check class membership */ 551 astPROTO_ISA(Mapping) /* Test class membership */ 552 553 /* NB. There is no constructor function for this class. */ 554 555 #if defined(astCLASS) /* Protected */ 556 557 /* Initialiser. */ 558 AstMapping *astInitMapping_( void *, size_t, int, AstMappingVtab *, 559 const char *, int, int, int, int, int * ); 560 561 /* Vtab initialiser. */ 562 void astInitMappingVtab_( AstMappingVtab *, const char *, int * ); 563 564 /* Loader. */ 565 AstMapping *astLoadMapping_( void *, size_t, AstMappingVtab *, 566 const char *, AstChannel *channel, int * ); 567 568 /* Thread-safe initialiser for all global data used by this module. */ 569 #if defined(THREAD_SAFE) 570 void astInitMappingGlobals_( AstMappingGlobals * ); 571 #endif 572 #endif 573 574 /* Prototypes for member functions. */ 575 /* -------------------------------- */ 576 #define PROTO_GENERIC_ALL(X,Xtype) \ 577 int astResample##X##_( AstMapping *, int, const int [], const int [], \ 578 const Xtype [], const Xtype [], int, \ 579 void (*)( void ), const double [], int, double, int, \ 580 Xtype, int, const int [], const int [], \ 581 const int [], const int [], Xtype [], Xtype [], int * ); \ 582 583 PROTO_GENERIC_ALL(B,signed char) 584 PROTO_GENERIC_ALL(D,double) 585 PROTO_GENERIC_ALL(F,float) 586 PROTO_GENERIC_ALL(I,int) 587 PROTO_GENERIC_ALL(K,INT_BIG) 588 PROTO_GENERIC_ALL(L,long int) 589 PROTO_GENERIC_ALL(S,short int) 590 PROTO_GENERIC_ALL(UB,unsigned char) 591 PROTO_GENERIC_ALL(UI,unsigned int) 592 PROTO_GENERIC_ALL(UK,UINT_BIG) 593 PROTO_GENERIC_ALL(UL,unsigned long int) 594 PROTO_GENERIC_ALL(US,unsigned short int) 595 596 #if HAVE_LONG_DOUBLE /* Not normally implemented */ 597 PROTO_GENERIC_ALL(LD,long double) 598 #endif 599 600 #undef PROTO_GENERIC_ALL 601 602 #define PROTO_GENERIC_DFI(X,Xtype) \ 603 void astRebin##X##_( AstMapping *, double, int, const int [], const int [], \ 604 const Xtype [], const Xtype [], int, const double [], int, \ 605 double, int, Xtype, int, const int [], const int [], \ 606 const int [], const int [], Xtype [], Xtype [], int * ); \ 607 void astRebinSeq##X##_( AstMapping *, double, int, const int [], const int [], \ 608 const Xtype [], const Xtype [], int, const double [], \ 609 int, double, int, Xtype, int, const int [], \ 610 const int [], const int [], const int [], Xtype [], \ 611 Xtype [], double [], int64_t *, int * ); 612 613 PROTO_GENERIC_DFI(D,double) 614 PROTO_GENERIC_DFI(F,float) 615 PROTO_GENERIC_DFI(I,int) 616 617 #if HAVE_LONG_DOUBLE /* Not normally implemented */ 618 PROTO_GENERIC_DFI(LD,long double) 619 #endif 620 621 #undef PROTO_GENERIC_DFI 622 623 AstMapping *astRemoveRegions_( AstMapping *, int * ); 624 AstMapping *astSimplify_( AstMapping *, int * ); 625 void astInvert_( AstMapping *, int * ); 626 int astLinearApprox_( AstMapping *, const double *, const double *, double, double *, int * ); 627 int astQuadApprox_( AstMapping *, const double[2], const double[2], int, int, double *, double *, int * ); 628 void astTran1_( AstMapping *, int, const double [], int, double [], int * ); 629 void astTran2_( AstMapping *, int, const double [], const double [], int, double [], double [], int * ); 630 void astTranGrid_( AstMapping *, int, const int[], const int[], double, int, int, int, int, double *, int * ); 631 void astTranN_( AstMapping *, int, int, int, const double *, int, int, int, double *, int * ); 632 void astTranP_( AstMapping *, int, int, const double *[], int, int, double *[], int * ); 633 634 #if defined(astCLASS) /* Protected */ 635 void astDecompose_( AstMapping *, AstMapping **, AstMapping **, int *, int *, int *, int * ); 636 void astMapBox_( AstMapping *, const double [], const double [], int, int, double *, double *, double [], double [], int * ); 637 double astRate_( AstMapping *, double *, int, int, int * ); 638 int *astMapSplit_( AstMapping *, int, const int *, AstMapping **, int * ); 639 #else 640 void astDecomposeId_( AstMapping *, AstMapping **, AstMapping **, int *, int *, int *, int * ); 641 void astMapBoxId_( AstMapping *, const double [], const double [], int, int, double *, double *, double [], double [], int * ); 642 double astRateId_( AstMapping *, double *, int, int, int * ); 643 void astMapSplitId_( AstMapping *, int, const int *, int *, AstMapping **, int * ); 644 #endif 645 646 #if defined(astCLASS) /* Protected */ 647 int astRateState_( int, int * ); 648 AstPointSet *astTransform_( AstMapping *, AstPointSet *, int, AstPointSet *, int * ); 649 int astGetInvert_( AstMapping *, int * ); 650 int astGetIsSimple_( AstMapping *, int * ); 651 int astGetNin_( AstMapping *, int * ); 652 int astGetNout_( AstMapping *, int * ); 653 int astGetReport_( AstMapping *, int * ); 654 int astGetTranForward_( AstMapping *, int * ); 655 int astGetTranInverse_( AstMapping *, int * ); 656 int astGetIsLinear_( AstMapping *, int * ); 657 int astDoNotSimplify_( AstMapping *, int * ); 658 int astMapMerge_( AstMapping *, int, int, int *, AstMapping ***, int **, int * ); 659 int astTestInvert_( AstMapping *, int * ); 660 int astTestReport_( AstMapping *, int * ); 661 void astClearInvert_( AstMapping *, int * ); 662 void astClearReport_( AstMapping *, int * ); 663 int astMapList_( AstMapping *, int, int, int *, AstMapping ***, int **, int * ); 664 void astReportPoints_( AstMapping *, int, AstPointSet *, AstPointSet *, int * ); 665 void astSetInvert_( AstMapping *, int, int * ); 666 void astSetReport_( AstMapping *, int, int * ); 667 #endif 668 669 /* Function interfaces. */ 670 /* ==================== */ 671 /* These macros are wrap-ups for the functions defined by this class to make 672 them easier to invoke (e.g. to avoid type mis-matches when passing pointers 673 to objects from derived classes). */ 674 675 /* Interfaces to standard class functions. */ 676 /* --------------------------------------- */ 677 /* Some of these functions provide validation, so we cannot use them to 678 validate their own arguments. We must use a cast when passing object 679 pointers (so that they can accept objects from derived classes). */ 680 681 /* Check class membership. */ 682 #define astCheckMapping(this) astINVOKE_CHECK(Mapping,this,0) 683 #define astVerifyMapping(this) astINVOKE_CHECK(Mapping,this,1) 684 685 /* Test class membership. */ 686 #define astIsAMapping(this) astINVOKE_ISA(Mapping,this) 687 688 /* NB. There is no constructor function for this class. */ 689 690 #if defined(astCLASS) /* Protected */ 691 692 /* Initialiser. */ 693 #define astInitMapping(mem,size,init,vtab,name,nin,nout,tran_forward,tran_inverse) \ 694 astINVOKE(O,astInitMapping_(mem,size,init,vtab,name,nin,nout,tran_forward,tran_inverse,STATUS_PTR)) 695 696 /* Vtab Initialiser. */ 697 #define astInitMappingVtab(vtab,name) astINVOKE(V,astInitMappingVtab_(vtab,name,STATUS_PTR)) 698 /* Loader. */ 699 #define astLoadMapping(mem,size,vtab,name,channel) \ 700 astINVOKE(O,astLoadMapping_(mem,size,vtab,name,astCheckChannel(channel),STATUS_PTR)) 701 #endif 702 703 /* Interfaces to member functions. */ 704 /* ------------------------------- */ 705 /* Here we make use of astCheckMapping (et al.) to validate Mapping 706 pointers before use. This provides a contextual error report if a 707 pointer to the wrong sort of object is supplied. */ 708 #if HAVE_LONG_DOUBLE /* Not normally implemented */ 709 #define astResampleLD(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 710 astINVOKE(V,astResampleLD_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 711 #endif 712 713 #define astInvert(this) \ 714 astINVOKE(V,astInvert_(astCheckMapping(this),STATUS_PTR)) 715 #define astLinearApprox(this,lbnd,ubnd,tol,fit) \ 716 astINVOKE(V,astLinearApprox_(astCheckMapping(this),lbnd,ubnd,tol,fit,STATUS_PTR)) 717 #define astQuadApprox(this,lbnd,ubnd,nx,ny,fit,rms) \ 718 astINVOKE(V,astQuadApprox_(astCheckMapping(this),lbnd,ubnd,nx,ny,fit,rms,STATUS_PTR)) 719 #define astRebinD(this,wlim,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 720 astINVOKE(V,astRebinD_(astCheckMapping(this),wlim,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 721 #define astRebinF(this,wlim,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 722 astINVOKE(V,astRebinF_(astCheckMapping(this),wlim,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 723 #define astRebinI(this,wlim,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 724 astINVOKE(V,astRebinI_(astCheckMapping(this),wlim,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 725 #define astRebinSeqD(this,wlim,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,weights,nused) \ 726 astINVOKE(V,astRebinSeqD_(astCheckMapping(this),wlim,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,weights,nused,STATUS_PTR)) 727 #define astRebinSeqF(this,wlim,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,weights,nused) \ 728 astINVOKE(V,astRebinSeqF_(astCheckMapping(this),wlim,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,weights,nused,STATUS_PTR)) 729 #define astRebinSeqI(this,wlim,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,weights,nused) \ 730 astINVOKE(V,astRebinSeqI_(astCheckMapping(this),wlim,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,weights,nused,STATUS_PTR)) 731 #define astResampleD(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 732 astINVOKE(V,astResampleD_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 733 #define astResampleF(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 734 astINVOKE(V,astResampleF_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 735 #define astResampleL(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 736 astINVOKE(V,astResampleL_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 737 #define astResampleUL(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 738 astINVOKE(V,astResampleUL_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 739 #define astResampleI(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 740 astINVOKE(V,astResampleI_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 741 #define astResampleUI(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 742 astINVOKE(V,astResampleUI_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 743 #define astResampleK(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 744 astINVOKE(V,astResampleK_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 745 #define astResampleUK(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 746 astINVOKE(V,astResampleUK_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 747 #define astResampleS(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 748 astINVOKE(V,astResampleS_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 749 #define astResampleUS(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 750 astINVOKE(V,astResampleUS_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 751 #define astResampleB(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 752 astINVOKE(V,astResampleB_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 753 #define astResampleUB(this,ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var) \ 754 astINVOKE(V,astResampleUB_(astCheckMapping(this),ndim_in,lbnd_in,ubnd_in,in,in_var,interp,finterp,params,flags,tol,maxpix,badval,ndim_out,lbnd_out,ubnd_out,lbnd,ubnd,out,out_var,STATUS_PTR)) 755 #define astRemoveRegions(this) astINVOKE(O,astRemoveRegions_(astCheckMapping(this),STATUS_PTR)) 756 #define astSimplify(this) astINVOKE(O,astSimplify_(astCheckMapping(this),STATUS_PTR)) 757 #define astTran1(this,npoint,xin,forward,xout) \ 758 astINVOKE(V,astTran1_(astCheckMapping(this),npoint,xin,forward,xout,STATUS_PTR)) 759 #define astTran2(this,npoint,xin,yin,forward,xout,yout) \ 760 astINVOKE(V,astTran2_(astCheckMapping(this),npoint,xin,yin,forward,xout,yout,STATUS_PTR)) 761 #define astTranGrid(this,ncoord_in,lbnd,ubnd,tol,maxpix,forward,ncoord_out,outdim,out) \ 762 astINVOKE(V,astTranGrid_(astCheckMapping(this),ncoord_in,lbnd,ubnd,tol,maxpix,forward,ncoord_out,outdim,out,STATUS_PTR)) 763 #define astTranN(this,npoint,ncoord_in,indim,in,forward,ncoord_out,outdim,out) \ 764 astINVOKE(V,astTranN_(astCheckMapping(this),npoint,ncoord_in,indim,in,forward,ncoord_out,outdim,out,STATUS_PTR)) 765 #define astTranP(this,npoint,ncoord_in,ptr_in,forward,ncoord_out,ptr_out) \ 766 astINVOKE(V,astTranP_(astCheckMapping(this),npoint,ncoord_in,ptr_in,forward,ncoord_out,ptr_out,STATUS_PTR)) 767 768 #if defined(astCLASS) /* Protected */ 769 #define astDecompose(this,map1,map2,series,inv1,inv2) \ 770 astINVOKE(V,astDecompose_(astCheckMapping(this),(AstMapping **)(map1),(AstMapping **)(map2),series,inv1,inv2,STATUS_PTR)) 771 #define astMapBox(this,lbnd_in,ubnd_in,forward,coord_out,lbnd_out,ubnd_out,xl,xu) \ 772 astINVOKE(V,astMapBox_(astCheckMapping(this),lbnd_in,ubnd_in,forward,coord_out,lbnd_out,ubnd_out,xl,xu,STATUS_PTR)) 773 #define astRate(this,at,ax1,ax2) \ 774 astINVOKE(V,astRate_(astCheckMapping(this),at,ax1,ax2,STATUS_PTR)) 775 #define astMapSplit(this,nin,in,map) \ 776 astINVOKE(V,astMapSplit_(this,nin,in,map,STATUS_PTR)) 777 #else 778 #define astDecompose(this,map1,map2,series,inv1,inv2) \ 779 astINVOKE(V,astDecomposeId_(astCheckMapping(this),(AstMapping **)(map1),(AstMapping **)(map2),series,inv1,inv2,STATUS_PTR)) 780 #define astMapBox(this,lbnd_in,ubnd_in,forward,coord_out,lbnd_out,ubnd_out,xl,xu) \ 781 astINVOKE(V,astMapBoxId_(astCheckMapping(this),lbnd_in,ubnd_in,forward,coord_out,lbnd_out,ubnd_out,xl,xu,STATUS_PTR)) 782 #define astRate(this,at,ax1,ax2) \ 783 astINVOKE(V,astRateId_(astCheckMapping(this),at,ax1,ax2,STATUS_PTR)) 784 #define astMapSplit(this,nin,in,out,map) \ 785 astINVOKE(V,astMapSplitId_(astCheckMapping(this),nin,in,out,map,STATUS_PTR)) 786 #endif 787 788 #if defined(astCLASS) /* Protected */ 789 #define astRateState(disabled) astRateState_(disabled,STATUS_PTR) 790 #define astClearInvert(this) \ 791 astINVOKE(V,astClearInvert_(astCheckMapping(this),STATUS_PTR)) 792 #define astClearReport(this) \ 793 astINVOKE(V,astClearReport_(astCheckMapping(this),STATUS_PTR)) 794 #define astGetInvert(this) \ 795 astINVOKE(V,astGetInvert_(astCheckMapping(this),STATUS_PTR)) 796 #define astGetIsSimple(this) \ 797 astINVOKE(V,astGetIsSimple_(astCheckMapping(this),STATUS_PTR)) 798 #define astGetNin(this) \ 799 astINVOKE(V,astGetNin_(astCheckMapping(this),STATUS_PTR)) 800 #define astGetNout(this) \ 801 astINVOKE(V,astGetNout_(astCheckMapping(this),STATUS_PTR)) 802 #define astGetReport(this) \ 803 astINVOKE(V,astGetReport_(astCheckMapping(this),STATUS_PTR)) 804 #define astGetTranForward(this) \ 805 astINVOKE(V,astGetTranForward_(astCheckMapping(this),STATUS_PTR)) 806 #define astGetTranInverse(this) \ 807 astINVOKE(V,astGetTranInverse_(astCheckMapping(this),STATUS_PTR)) 808 #define astGetIsLinear(this) \ 809 astINVOKE(V,astGetIsLinear_(astCheckMapping(this),STATUS_PTR)) 810 #define astMapList(this,series,invert,nmap,map_list,invert_list) \ 811 astINVOKE(V,astMapList_(this,series,invert,nmap,map_list,invert_list,STATUS_PTR)) 812 #define astMapMerge(this,where,series,nmap,map_list,invert_list) \ 813 astINVOKE(V,astMapMerge_(astCheckMapping(this),where,series,nmap,map_list,invert_list,STATUS_PTR)) 814 #define astReportPoints(this,forward,in_points,out_points) \ 815 astINVOKE(V,astReportPoints_(astCheckMapping(this),forward,astCheckPointSet(in_points),astCheckPointSet(out_points),STATUS_PTR)) 816 #define astSetInvert(this,value) \ 817 astINVOKE(V,astSetInvert_(astCheckMapping(this),value,STATUS_PTR)) 818 #define astSetReport(this,value) \ 819 astINVOKE(V,astSetReport_(astCheckMapping(this),value,STATUS_PTR)) 820 #define astTestInvert(this) \ 821 astINVOKE(V,astTestInvert_(astCheckMapping(this),STATUS_PTR)) 822 #define astTestReport(this) \ 823 astINVOKE(V,astTestReport_(astCheckMapping(this),STATUS_PTR)) 824 #define astDoNotSimplify(this) \ 825 astINVOKE(V,astDoNotSimplify_(astCheckMapping(this),STATUS_PTR)) 826 827 /* Since a NULL PointSet pointer is acceptable here, we must omit the argument 828 checking in that case. (But unfortunately, "out" then gets evaluated 829 twice - this is unlikely to matter, but is there a better way?) */ 830 #define astTransform(this,in,forward,out) \ 831 astINVOKE(O,astTransform_(astCheckMapping(this),astCheckPointSet(in),forward,(out)?astCheckPointSet(out):NULL,STATUS_PTR)) 832 #endif 833 #endif 834 835 836 837 838 839