rarray.h

Go to the documentation of this file.
00001 /* 
00002 rarray.h
00003 Igor Terentyev.
00004 ********************************************************************************
00005 */
00021 /*============================================================================*/
00022 
00023 #ifndef __RARRAY_H_
00024 #define __RARRAY_H_
00025 /*----------------------------------------------------------------------------*/
00026 
00027 #include "utils.h"
00028 #include "exchangeinfo.h"
00029 
00030 /*----------------------------------------------------------------------------*/
00038 typedef struct
00039 {
00041   int n;    
00043   int gs;   
00045   int ge;   
00047   int n0;   
00049   int gs0;  
00051   int ge0;  
00052 } INFODIM;
00053 /*----------------------------------------------------------------------------*/
00059 typedef struct
00060 {
00062   int ndim; 
00064   ireal *_s;
00066   ireal *_s0;      
00071   INFODIM _dims[RARR_MAX_NDIM];  
00072   /* added 03.11.12 WWS: multidim array access */
00073   /* revised 03.13 WWS: offset index ranges [s0,e0]*/
00074   ireal * restrict _s1;
00075 #if RARR_MAX_NDIM > 1
00076   ireal ** restrict _s2;
00077   ireal ** _s02;
00078 #endif
00079 #if RARR_MAX_NDIM > 2
00080   ireal *** restrict _s3;
00081   ireal *** _s03;
00082 #endif
00083 #if RARR_MAX_NDIM > 3
00084   ireal **** restrict _s4;
00085   ireal **** _s04;
00086 #endif
00087 #if RARR_MAX_NDIM > 4
00088   ireal ***** restrict _s5;
00089   ireal ***** _s05;
00090 #endif
00091 } RARR;
00092 /*----------------------------------------------------------------------------*/
00093 /*
00094 Functions' parameters.
00095 
00096 RARR *arr        :  array pointer.
00097 int ndim         :  number of dimensions.
00098 int idim         :  dimension number.
00099 IPNT gs, ge      :  global indices of the array start, end.
00100 IPNT ls, le      :  local indices of the array start, end.
00101 IPNT n           :  array size.
00102 IPNT os, oe      :  array start, end offsets (>0 - inside, <0 - outside).
00103 IPNT gi          :  global indices.
00104 IPNT li          :  local indices.
00105 ireal r           :  array value.
00106 FILE* stream     :  output stream.
00107 const char* path :  file name.
00108 
00109 int return       :  error code.
00110 */
00111 /*----------------------------------------------------------------------------*/
00120 int ra_getdim(IPNT s, IPNT e);
00121 /*----------------------------------------------------------------------------*/
00127 int ra_setnull(RARR *arr);
00128 /*----------------------------------------------------------------------------*/
00129 /* 
00130 Create array (STORAGE ALLOCATION).
00131 Calls ra_declare and then ra_allocate.
00132 */
00133 typedef int (RA_CREATE_FUN)(RARR *arr, IPNT v1, IPNT v2);
00134 /*----------------------------------------------------------------------------*/
00144 int ra_create_s(RARR *arr, IPNT gs, IPNT n);
00145 /*----------------------------------------------------------------------------*/
00155 int ra_create_e(RARR *arr, IPNT ge, IPNT n);
00156 /*----------------------------------------------------------------------------*/
00166 int ra_create(RARR *arr, IPNT gs, IPNT ge);
00167 /*----------------------------------------------------------------------------*/
00168 /*
00169 Declare array. Works like create, but does not allocate memory.
00170 Use ra_allocate to allocate memory for declared array.
00171 */
00182 int ra_declare_s(RARR *arr, IPNT gs, IPNT n);
00183 /*----------------------------------------------------------------------------*/
00195 int ra_declare_e(RARR *arr, IPNT ge, IPNT n);
00196 /*----------------------------------------------------------------------------*/
00208 int ra_declare(RARR *arr, IPNT gs, IPNT ge);
00209 /*----------------------------------------------------------------------------*/
00217 int ra_allocate(RARR *arr);
00218 /*----------------------------------------------------------------------------*/
00226 int ra_destroy(RARR *arr);
00227 /*----------------------------------------------------------------------------*/
00228 /* 
00229 Set array (NO STORAGE ALLOCATION). 
00230 */
00231 typedef int (RA_SET_FUN)(RARR *arr, const IPNT v1, const IPNT v2);
00240 int ra_greset_s(RARR *arr, const IPNT gs, const IPNT n);
00241 /*----------------------------------------------------------------------------*/
00250 int ra_greset_e(RARR *arr, const IPNT ge, const IPNT n);
00251 /*----------------------------------------------------------------------------*/
00260 int ra_greset(RARR *arr, const IPNT gs, const IPNT ge);
00261 /*----------------------------------------------------------------------------*/
00271 int ra_offset_s(RARR *arr, const IPNT os, const IPNT n);
00272 /*----------------------------------------------------------------------------*/
00281 int ra_offset_e(RARR *arr, const IPNT oe, const IPNT n);
00282 /*----------------------------------------------------------------------------*/
00291 int ra_offset(RARR *arr, const IPNT os, const IPNT oe);
00292 /*----------------------------------------------------------------------------*/
00300 int ra_dump(const RARR *arr, FILE* stream);
00301 /*----------------------------------------------------------------------------*/
00310 int ra_print(RARR *arr, FILE* stream);
00311 /*----------------------------------------------------------------------------*/
00320 int ra_fprint(RARR *arr, const char *path);
00321 /*----------------------------------------------------------------------------*/
00330 int ra_write(RARR *arr, FILE* stream);
00331 /*----------------------------------------------------------------------------*/
00340 int ra_fwrite(RARR *arr, const char *path);
00341 /*----------------------------------------------------------------------------*/
00349 int ra_read(RARR *arr, FILE* stream);
00350 /*----------------------------------------------------------------------------*/
00358 int ra_fread(RARR *arr, const char *path);
00359 /*----------------------------------------------------------------------------*/
00370 int ra_printslice(RARR *arr, FILE* stream, int idim, int islice);
00371 /*----------------------------------------------------------------------------*/
00382 int ra_fprintslice(RARR *arr, const char *path, int idim, int islice);
00383 /*----------------------------------------------------------------------------*/
00394 int ra_writeslice(RARR *arr, FILE* stream, int idim, int islice);
00395 /*----------------------------------------------------------------------------*/
00406 int ra_fwriteslice(RARR *arr, const char *path, int idim, int islice);
00407 /*----------------------------------------------------------------------------*/
00408 /* 
00409 Get/set value. 
00410 If index is out of bounds, these functions:
00411   1) Do not perform get/set operation.
00412   2) Write error info into stderr.
00413 */
00414 /*----------------------------------------------------------------------------*/
00423 ireal ra_get(const RARR *arr, IPNT li);
00424 /*----------------------------------------------------------------------------*/
00432 ireal ra_gget(const RARR *arr, IPNT gi);
00433 /*----------------------------------------------------------------------------*/
00442 void ra_set(RARR *arr, IPNT li, ireal r);
00443 /*----------------------------------------------------------------------------*/
00451 void ra_gset(RARR *arr, IPNT gi, ireal r);
00452 /*----------------------------------------------------------------------------*/
00460 int ra_size(const RARR *arr, IPNT n);
00461 /*----------------------------------------------------------------------------*/
00469 int ra_datasize(const RARR *arr, size_t * n);
00470 /*----------------------------------------------------------------------------*/
00479 int ra_a_size(const RARR *arr, IPNT n);
00480 /*----------------------------------------------------------------------------*/
00489 int ra_a_datasize(const RARR *arr, size_t * n);
00490 /*----------------------------------------------------------------------------*/
00499 int ra_gse(const RARR *arr, IPNT gs, IPNT ge);
00500 /*** function over-loading *** what the f**k kind of documentation is that?*/
00501 int ra_gse(const RARR *arr1, const RARR *arr2, IPNT gs, IPNT ge);
00502 /*----------------------------------------------------------------------------*/
00521 int ra_se(const RARR *arr, IPNT s, IPNT e);
00522 /*----------------------------------------------------------------------------*/
00531 int ra_a_gse(const RARR *arr, IPNT gs, IPNT ge);
00532 /*----------------------------------------------------------------------------*/
00554 int ra_ds(const RARR *tgt, const RARR * src, IPNT ds);
00555 /*----------------------------------------------------------------------------*/
00564 int ra_checkbound(const RARR *arr, int idim, int li);
00565 /*----------------------------------------------------------------------------*/
00574 int ra_gcheckbound(const RARR *arr, int idim, int gi);
00575 /*----------------------------------------------------------------------------*/
00583 int ra_ndim(const RARR *arr, int *ndim);
00584 /*----------------------------------------------------------------------------*/
00592 int ra_empty(RARR *arr, int *empty);
00593 /*----------------------------------------------------------------------------*/
00599 int ra_setempty(RARR *arr);
00600 /*----------------------------------------------------------------------------*/
00609 int ra_setexchangeinfo(RARR *arr, EXCHANGEINFO *einfo);
00610 /*----------------------------------------------------------------------------*/
00619 int ra_overlap(RARR *arr1, RARR *arr2, int *overlap);
00620 /*----------------------------------------------------------------------------*/
00629 int ra_setoverlap(RARR *arr1, RARR *arr2);
00630 /*----------------------------------------------------------------------------*/
00636 int ra_zero(RARR *arr);
00637 /*----------------------------------------------------------------------------*/
00643 int ra_a_zero(RARR *arr);
00644 /*----------------------------------------------------------------------------*/
00652 int ra_ghost_zero(RARR *arr);
00653 /*----------------------------------------------------------------------------*/
00664 int ra_deepcopy(RARR const * src, RARR *tgt);
00665 /*----------------------------------------------------------------------------*/
00675 int ra_copy(RARR *arr_des, RARR *arr_src);
00676 /*----------------------------------------------------------------------------*/
00686 int ra_a_copy(RARR *arr_des, RARR *arr_src);
00687 /*----------------------------------------------------------------------------*/
00694 int ra_a_scale(RARR * tgt, ireal fac);
00695 /*----------------------------------------------------------------------------*/
00707 int ra_a_inner(RARR const * arr1, RARR const * arr2, ireal * ip);
00708 /*----------------------------------------------------------------------------*/
00719 int ra_axpy(RARR * arry, RARR const * arrx, ireal a);
00720 /*-----------------------------------------------------------------------------*/
00726 int ra_compare_meta(const RARR * a, const RARR * b); 
00727 /*-----------------------------------------------------------------------------*/
00728 
00729 #endif /*__RARRAY_H_*/

Generated on 5 Jan 2017 for IWAVEGRID by  doxygen 1.4.7