Changeset 681
- Timestamp:
- May 13, 2004, 3:23:03 PM (22 years ago)
- Location:
- trunk/doc/pslib
- Files:
-
- 2 edited
-
Makefile (modified) (2 diffs)
-
psLibSDRS.tex (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/Makefile
r504 r681 1 # $Id: Makefile,v 1. 2 2004-04-22 21:54:24 price Exp $1 # $Id: Makefile,v 1.3 2004-05-14 01:23:03 eugene Exp $ 2 2 3 3 all : psLibDesign.pdf psLibADD.pdf … … 7 7 @if [ ! -f $*.aux ]; then \ 8 8 echo $(PDFLATEX) $*.tex; \ 9 env TEXINPUTS= .:LaTeX:: $(PDFLATEX) $*.tex; \9 env TEXINPUTS=$(TEXINPUX).:LaTeX:: $(PDFLATEX) $*.tex; \ 10 10 fi && env TEXINPUTS=.:LaTeX:: $(PDFLATEX) $*.tex || $(RM) $*.pdf 11 11 # -
trunk/doc/pslib/psLibSDRS.tex
r673 r681 1 %%% $Id: psLibSDRS.tex,v 1.4 2 2004-05-13 23:42:23 price Exp $1 %%% $Id: psLibSDRS.tex,v 1.43 2004-05-14 01:23:03 eugene Exp $ 2 2 \documentclass[panstarrs]{panstarrs} 3 3 … … 317 317 \code{NULL} pointer. If they are unable to provide the requested 318 318 memory they should attempt to obtain the desired memory by calling the 319 routine registered by \code{psMemExhaustedSetC B} (see319 routine registered by \code{psMemExhaustedSetCallback} (see 320 320 \S\ref{secMemAdvanced}), and if still unsuccessful, call 321 321 \code{psAbort()}. … … 338 338 % 339 339 \begin{itemize} 340 \item when insufficient memory is available (\code{psMemExhaustedC B})341 \item when a memory block is found to be corrupted (\code{psMemProblemC B})342 \item when a specified memory ID is allocated (\code{psMemAllocateC B})343 \item when a specified memory ID is freed (\code{psMemFreeC B})340 \item when insufficient memory is available (\code{psMemExhaustedCallback}) 341 \item when a memory block is found to be corrupted (\code{psMemProblemCallback}) 342 \item when a specified memory ID is allocated (\code{psMemAllocateCallback}) 343 \item when a specified memory ID is freed (\code{psMemFreeCallback}) 344 344 \end{itemize} 345 345 % … … 353 353 four callbacks below. 354 354 355 \subsubsubsection{\tt psMemExhaustedC B}355 \subsubsubsection{\tt psMemExhaustedCallback} 356 356 357 357 If not enough memory is available to satisfy a request by 358 358 \code{psAlloc} or \code{psRealloc}, these functions attempt to find an 359 alternative solution by calling the \code{psMemExhaustedC B}, a359 alternative solution by calling the \code{psMemExhaustedCallback}, a 360 360 function which may be set by the programmer in appropriate 361 361 circumstances, rather than immediately fail. The typical use of such … … 367 367 % 368 368 \begin{verbatim} 369 typedef void (*psMemExhaustedC B)(size_t size);370 psMemExhaustedC B psMemExhaustedCBSet(psMemExhaustedCBfunc);369 typedef void (*psMemExhaustedCallback)(size_t size); 370 psMemExhaustedCallback psMemExhaustedCallbackSet(psMemExhaustedCallback func); 371 371 \end{verbatim} 372 372 % 373 373 The callback function is called with the attempted size and is 374 374 expected to return a pointer to the allocated memory or \code{NULL}. 375 Until the callback function is set with \code{psMemExhaustedC BSet},375 Until the callback function is set with \code{psMemExhaustedCallbackSet}, 376 376 the default callback function immediately returns \code{NULL}, in 377 377 which case \code{psAlloc} will call \code{psAbort}. 378 378 379 \subsubsubsection{\tt psMemProblemC B}379 \subsubsubsection{\tt psMemProblemCallback} 380 380 381 381 At various occasions, the memory manager can check the state of the 382 382 memory stack. If any of these checks discover that the memory stack 383 is corrupted, the \code{psMemProblemC B} is called. The callback383 is corrupted, the \code{psMemProblemCallback} is called. The callback 384 384 has the following form: 385 385 % 386 386 \begin{verbatim} 387 typedef void (*psMemProblemC B)(psMemBlock *ptr, char *file, int lineno);388 psMemProblemC B psMemProblemCBSet(psMemProblemCBfunc);387 typedef void (*psMemProblemCallback)(psMemBlock *ptr, char *file, int lineno); 388 psMemProblemCallback psMemProblemCallbackSet(psMemProblemCallback func); 389 389 \end{verbatim} 390 390 % … … 393 393 are expected. The callback is for informational purposes only. Where 394 394 practical and efficient, the memory manager shall call the routine 395 registered using \code{psMemProblemC BSet} whenever a corrupted block395 registered using \code{psMemProblemCallbackSet} whenever a corrupted block 396 396 of memory is discovered. For example, doubly-freed blocks can be 397 397 detected by checking \code{psMemBlock.refCounter}. 398 398 399 \subsubsubsection{\tt psMemAllocateC B \& psMemFreeCB}399 \subsubsubsection{\tt psMemAllocateCallback \& psMemFreeCallback} 400 400 401 401 Two private variables, \code{p_psMemAllocateID} and … … 411 411 % 412 412 \begin{verbatim} 413 long psMemAllocateC BSetID(long id);414 long psMemFreeC BSetID(long id);413 long psMemAllocateCallbackSetID(long id); 414 long psMemFreeCallbackSetID(long id); 415 415 \end{verbatim} 416 416 % … … 418 418 % 419 419 \begin{verbatim} 420 typedef long (*psMemAllocateC B)(const psMemBlock *ptr);421 psMemAllocateC B psMemAllocateCBSet(psMemAllocateCBfunc);422 typedef long (*psMemFreeC B)(const psMemBlock *ptr);423 psMemFreeC B psMemFreeCBSet(psMemFreeCBfunc);420 typedef long (*psMemAllocateCallback)(const psMemBlock *ptr); 421 psMemAllocateCallback psMemAllocateCallbackSet(psMemAllocateCallback func); 422 typedef long (*psMemFreeCallback)(const psMemBlock *ptr); 423 psMemFreeCallback psMemFreeCallbackSet(psMemFreeCallback func); 424 424 \end{verbatim} 425 425 % … … 428 428 \code{psMemAllocateIDSet} accept the desired ID value and return the 429 429 old value to the user. The return values of the handlers installed by 430 \code{psMemAllocateC BSet} and \code{psMemFreeCBSet} are used to430 \code{psMemAllocateCallbackSet} and \code{psMemFreeCallbackSet} are used to 431 431 increment the values of \code{p_psMemAllocateID} and 432 432 \code{p_psMemFreeID} respectively. For example, a return value of … … 472 472 The routine \code{psMemCheckCorruption} checks the entire heap for 473 473 corruption, calling the routine registered with 474 \code{psMemProblemC BSet} for each block detected as being corrupted.474 \code{psMemProblemCallbackSet} for each block detected as being corrupted. 475 475 The return value is the number of corrupted blocks detected. If the 476 476 argument \code{abort_on_error} is true, \code{psMemCheckCorruption} … … 1202 1202 \begin{verbatim} 1203 1203 typedef enum { 1204 PS_TYPE_ CHAR,///< Character1205 PS_TYPE_S HORT,///< Short integer1206 PS_TYPE_ INT,///< Integer1207 PS_TYPE_ LONG,///< Long integer1208 PS_TYPE_U CHAR,///< Unsigned character1209 PS_TYPE_U SHORT,///< Unsigned short integer1210 PS_TYPE_U INT,///< Unsigned integer1211 PS_TYPE_U LONG,///< Unsigned long integer1212 PS_TYPE_F LOAT,///< Floating point1213 PS_TYPE_ DOUBLE,///< Double-precision floating point1214 PS_TYPE_C OMPLEX,///< Complex numbers consisting of floating point1215 PS_TYPE_OTHER, ///< Something else that's not supported for arithmetic1204 PS_TYPE_S8, ///< Character 1205 PS_TYPE_S16, ///< Short integer 1206 PS_TYPE_S32, ///< Integer 1207 PS_TYPE_S64, ///< Long integer 1208 PS_TYPE_U8, ///< Unsigned character 1209 PS_TYPE_U16, ///< Unsigned short integer 1210 PS_TYPE_U32, ///< Unsigned integer 1211 PS_TYPE_U64, ///< Unsigned long integer 1212 PS_TYPE_F32, ///< Floating point 1213 PS_TYPE_F64, ///< Double-precision floating point 1214 PS_TYPE_C32, ///< Complex numbers consisting of floating point 1215 PS_TYPE_OTHER, ///< Something else that's not supported for arithmetic 1216 1216 } psElemType; 1217 1217 \end{verbatim} … … 1219 1219 section~\ref{sec:arithmetic}. 1220 1220 1221 \subsection{Arrays of Simple Types} 1222 1223 We require several types of basic one-dimensional arrays: arrays of 1224 values of type \code{int}, \code{float}, \code{double}, \code{complex 1225 float}, and \code{void *}. We have defined structures for these types 1226 which are all equivalent. We illustrate them with the example of 1227 \code{psFloatArray}: 1221 \subsection{Simple Vectors} 1222 1223 We require several related types of basic one-dimensional arrays: 1224 arrays of values of type \code{int}, \code{float}, \code{double}, 1225 \code{complex float}, and \code{void *}. We have defined a single 1226 structure, \code{psVector} to represent these concepts: 1228 1227 % 1229 1228 \begin{verbatim} 1230 1229 typedef struct { 1231 psType type; ///< Type of data. Must be first element 1232 int nAlloc; ///< Total number of elements available 1233 int n; ///< Number of elements in use 1234 float *arr; ///< The array data 1235 } psFloatArray; 1230 psType type; ///< vector data type and dimension 1231 const int n; ///< size of vector 1232 const int nalloc; ///< data region relative to parent 1233 union { 1234 psF32 *arr; ///< Pointers to floating-point data (default) 1235 psS8 *arr_S8; ///< Pointers to short-integer data 1236 psS16 *arr_S16; ///< Pointers to short-integer data 1237 psS32 *arr_S32; ///< Pointers to integer data 1238 psS64 *arr_S64; ///< Pointers to long-integer data 1239 psU8 *arr_U18; ///< Pointers to unsigned-short-integer data 1240 psU16 *arr_U16; ///< Pointers to unsigned-short-integer data 1241 psU32 *arr_U32; ///< Pointers to unsigned-integer data 1242 psU64 *arr_U64; ///< Pointers to unsigned-long-integer data 1243 psF32 *arr_F32; ///< Pointers to floating-point data 1244 psF64 *arr_F64; ///< Pointers to double-precision data 1245 psF32 *arr_C32; ///< Pointers to complex floating-point data 1246 void **arr_v; 1247 } arr; 1248 } psVector; 1236 1249 \end{verbatim} 1237 1250 % 1238 1251 In this structure, the argument \code{n} is the length of the array 1239 (the number of elements); \code{nAlloc} is the number of elements 1240 allocated ($s \ge n$). The allocated memory is available at 1241 \code{arr}. The data type is defined by the first element, 1242 \code{psType}. The structure is associated with a constructor and a 1243 destructor: 1244 % 1245 \begin{verbatim} 1246 psFloatArray *psFloatArrayAlloc(int nAlloc); 1247 psFloatArray *psFloatArrayRealloc(psFloatArray *myArray, int nAlloc); 1248 void psFloatArrayFree(psFloatArray *restrict myArray); 1249 \end{verbatim} 1250 % 1251 In these functions, \code{nAlloc} is the number of elements to 1252 allocate. For \code{psFloatArrayAlloc}, the value of 1253 \code{psFloatArray.n} is set to 0. For \code{psFloatArrayRealloc}, if 1254 the value of \code{nAlloc} is smaller than the current value of 1255 \code{psFloatArray.n}, then \code{psFloatArray.n} is set to 1256 \code{nAlloc}, the array is adjusted down to match \code{nAlloc}, and 1257 the extra elements are lost. If \code{nAlloc} is larger than the 1258 current value of \code{psFloatArray.n}, \code{psFloatArray.n} is left 1259 intact. If the value of \code{myArray} is \code{NULL}, then 1260 \code{psFloatArrayRealloc} behaves like \code{psFloatArrayAlloc}. 1261 1262 Basic one-dimensional arrays of all of the types listed above have 1263 equivalent structures, constructors, and destructors to those for 1264 \code{psFloatArray}, with the words \code{float} converted to the 1265 appropriate type. Thus we have: 1266 \begin{verbatim} 1267 psIntArray *psIntArrayAlloc(int nAlloc); 1268 psFloatArray *psFloatArrayAlloc(int nAlloc); 1269 psDoubleArray *psDoubleArrayAlloc(int nAlloc); 1270 psComplexArray *psComplexArrayAlloc(int nAlloc); 1271 \end{verbatim} 1272 and so on for the other functions. The collection of structures and 1273 functions may be easily generated with C pre-processor macros. 1252 (the number of elements); \code{nalloc} is the number of elements 1253 allocated ($nalloc \ge n$). The allocated memory is available in the 1254 union \code{arr} which consists of pointers to each of the defined 1255 primitive data types. Note the parallelism in the names of the types, 1256 union elements, and the psElemType names. This parallelism allows us 1257 to use automatic construction mechanisms effectively. The data type 1258 is defined by the first element, \code{psType}. The 1259 structure is associated with a constructor and a destructor: 1260 % 1261 \begin{verbatim} 1262 psVector *psVectorAlloc(int nalloc, psElemType type); 1263 psVector *psVectorRealloc(const psVector *vector, int nalloc); 1264 void psVectorFree(psVector *restrict vector); 1265 \end{verbatim} 1266 % 1267 In these functions, \code{nalloc} is the number of elements to 1268 allocate. For \code{psVectorAlloc}, the value of \code{psVector.n} is 1269 set to 0. For \code{psVectorRealloc}, if the value of \code{nalloc} 1270 is smaller than the current value of \code{psVector.n}, then 1271 \code{psVector.n} is set to \code{nalloc}, the array is adjusted down 1272 to match \code{nalloc}, and the extra elements are lost. If 1273 \code{nalloc} is larger than the current value of \code{psVector.n}, 1274 \code{psVector.n} is left intact. If the value of \code{myArray} is 1275 \code{NULL}, then \code{psVectorRealloc} must return an error. 1274 1276 1275 1277 \subsection{Arrays of Pointer Types} … … 1312 1314 \code{refCounter}'s should be decremented) --- this is to account for 1313 1315 an array of heterogeneous types. 1316 1317 \subsection{Simple Images} 1318 1319 The most important data product produced by the telescope is an image. 1320 The simplest image is a 2-D collection of pixels, each with some 1321 value. We require a basic image data type: 1322 1323 \begin{verbatim} 1324 typedef struct psImage { 1325 psType type; ///< image data type and dimension 1326 const int ncols, nrows; ///< size of image 1327 const int x0, y0; ///< data region relative to parent 1328 union { 1329 psF32 **rows; ///< Pointers to floating-point data (default) 1330 psS8 **rows_S8; ///< Pointers to char data 1331 psS16 **rows_S16; ///< Pointers to short-integer data 1332 psS32 **rows_S32; ///< Pointers to integer data 1333 psS64 **rows_S64; ///< Pointers to long-integer data 1334 psU8 **rows_U8; ///< Pointers to unsigned-char data 1335 psU16 **rows_U16; ///< Pointers to unsigned-short-integer data 1336 psU32 **rows_U32; ///< Pointers to unsigned-integer data 1337 psU64 **rows_U64; ///< Pointers to unsigned-long-integer data 1338 psF32 **rows_F32; ///< Pointers to floating-point data 1339 psF64 **rows_F64; ///< Pointers to double-precision data 1340 psC32 **rows_C32; ///< Pointers to complex floating-point data 1341 } rows; 1342 const struct psImage *parent; ///< parent, if a subimage 1343 int Nchildren; ///< number of subimages 1344 struct psImage **children; ///< children of this region; array of Nchildren pointers 1345 } psImage; 1346 \end{verbatim} 1347 1348 This structure represents an image consisting of a 2-D array of 1349 pixels. The size of this array is given by the elements \code{(nrows, 1350 ncols)}. The data type of the pixel is defined in the \code{psType 1351 type} entry (specifically, the \code{psElemType} member, \code{type}; 1352 see \ref{sec:arithmetic}). (n.b. that for FITS images, these values 1353 are restricted to the datatypes equivalent to the valid BITPIX values 1354 8, 16, 32, -32, -64). The image represented in the data structure may 1355 represent a subset of the pixels in a complete array, in which case 1356 the image is considered to be the child of that parent array. The 1357 offset of the \code{(0,0)} pixel in this array relative to the parent 1358 array is given by the elements \code{(x0,y0)}: \code{x0} is the 1359 starting column number in the parent image while \code{y0} is the 1360 starting row number. The structure may include references to 1361 subrasters (\code{children, Nchildren}) and/or to a containing array 1362 (\code{parent}). Unless this is image is a child of another image 1363 (represents a subset of the pixels of another image), the image data 1364 is allocated in a contiguous block. 1365 1366 Create an image of a specified width, height, and data type. This 1367 function must allow any of the valid image data types and not restrict 1368 to the valid FITS BITPIX types. 1369 \begin{verbatim} 1370 psImage *psImageAlloc (int width, int height, psElemType type); 1371 \end{verbatim} 1372 where \code{width} and \code{height} specify the size of the image and 1373 \code{type} specifies the data type and the image dimensionality 1374 (which must be 2). 1375 1376 Free the memory associated with a specific image, including the pixel 1377 data. Free the children of the image if they exist. 1378 \begin{verbatim} 1379 void psImageFree(psImage *image); 1380 \end{verbatim} 1381 1382 Free only the pixels for a specified image: 1383 \begin{verbatim} 1384 psImage *psImageFreePixels(psImage *image); 1385 \end{verbatim} 1314 1386 1315 1387 \subsection{Doubly-linked lists} … … 2248 2320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2249 2321 2250 \subsection{Simple Images} 2251 2252 The most important data product produced by the telescope is an image. 2253 The simplest image is a 2-D collection of pixels, each with some 2254 value. We require a basic image data type: 2255 2256 \begin{verbatim} 2257 typedef struct psImage { 2258 psType type; ///< image data type and dimension 2259 const int nx, ny; ///< size of image 2260 const int x0, y0; ///< data region relative to parent 2261 union { 2262 float **rows; ///< Pointers to floating-point data (default) 2263 short int **rows_si; ///< Pointers to short-integer data 2264 int **rows_i; ///< Pointers to integer data 2265 long int **rows_li; ///< Pointers to long-integer data 2266 unsigned short int **rows_usi; ///< Pointers to unsigned-short-integer data 2267 unsigned int **rows_ui; ///< Pointers to unsigned-integer data 2268 unsigned long int **rows_uli; ///< Pointers to unsigned-long-integer data 2269 float **rows_f; ///< Pointers to floating-point data 2270 double **rows_d; ///< Pointers to double-precision data 2271 complex float **rows_complex; ///< Pointers to complex floating-point data 2272 } rows; 2273 const struct psImage *parent; ///< parent, if a subimage 2274 int Nchildren; ///< number of subimages 2275 struct psImage *children; ///< children of this region; array of Nchildren pointers 2276 } psImage; 2277 \end{verbatim} 2278 2279 This structure represents an image consisting of a 2-D array of 2280 pixels. The size of this array is given by the elements \code{(nx, 2281 ny)}. The data type of the pixel is defined in the \code{psType type} 2282 entry (specifically, the \code{psElemType} member, \code{type}; see 2283 \ref{sec:arithmetic}). (n.b. that for FITS images, these values are 2284 restricted to the datatypes equivalent to the valid BITPIX values 8, 2285 16, 32, -32, -64). The image represented in the data structure may 2286 represent a subset of the pixels in a complete array, in which case 2287 the image is considered to be the child of that parent array. The 2288 offset of the \code{(0,0)} pixel in this array relative to the parent 2289 array is given by the elements \code{(x0,y0)}. The structure may 2290 include references to subrasters (\code{children, Nchildren}) and/or 2291 to a containing array (\code{parent}). Unless this is image is a 2292 child of another image (represents a subset of the pixels of another 2293 image), the image data is allocated in a contiguous block. 2322 \subsection{Image Operations} 2323 2324 \subsubsection{Image Structure Manipulation} 2294 2325 2295 2326 We require a variety of functions to manipulate these image … … 2297 2328 various manipulations of the pixels. The required functions are 2298 2329 listed below, and fall into several categories. 2299 2300 \subsubsection{Image Structure Manipulation}2301 2302 Create an image of a specified width, height, and data type. This2303 function must allow any of the valid image data types and not restrict2304 to the valid FITS BITPIX types.2305 \begin{verbatim}2306 psImage *psImageAlloc (int nx, int ny, psElemType type);2307 \end{verbatim}2308 where \code{nx} and \code{ny} specify the size of the image and2309 \code{type} specifies the data type and the image dimensions (which2310 must be 2).2311 2330 2312 2331 Define a subimage of the specified area of the given image. This … … 2321 2340 contained within the raster of the parent image. Note that the 2322 2341 \code{refCounter} for the parent should be incremented. 2323 2324 Free the memory associated with a specific image, including the pixel2325 data. Free the children of the image if they exist.2326 \begin{verbatim}2327 void psImageFree(psImage *image);2328 \end{verbatim}2329 2330 Free only the pixels for a specified image:2331 \begin{verbatim}2332 psImage *psImageFreePixels(psImage *image);2333 \end{verbatim}2334 2342 2335 2343 Create a copy of the specified image, converting the type in the
Note:
See TracChangeset
for help on using the changeset viewer.
