1 /* ZV.h */ 2 3 #include "../DV.h" 4 5 /*--------------------------------------------------------------------*/ 6 /* 7 --------------------------------------------------------- 8 ZV -- double complex vector object 9 10 size -- size of the vector 11 maxsize -- maximum size of the vector 12 owned -- owner flag 13 when == 1, storage pointed to by entries 14 has been allocated here and can be free'd. 15 when == 0, storage pointed to by entries 16 has not been allocated here and cannot be free'd. 17 vec -- pointer to base address 18 --------------------------------------------------------- 19 */ 20 typedef struct _ZV ZV ; 21 struct _ZV { 22 int size ; 23 int maxsize ; 24 int owned ; 25 double *vec ; 26 } ; 27 /*--------------------------------------------------------------------*/ 28 /* 29 ------------------------------------------------------------------------ 30 ----- methods found in basics.c ---------------------------------------- 31 ------------------------------------------------------------------------ 32 */ 33 /* 34 ----------------------- 35 constructor method 36 37 created -- 98jan22, cca 38 ----------------------- 39 */ 40 ZV * 41 ZV_new ( 42 void 43 ) ; 44 /* 45 ----------------------- 46 set the default fields 47 48 created -- 98jan22, cca 49 ----------------------- 50 */ 51 void 52 ZV_setDefaultFields ( 53 ZV *zv 54 ) ; 55 /* 56 ----------------------- 57 clear the data fields 58 59 created -- 98jan22, cca 60 ----------------------- 61 */ 62 void 63 ZV_clearData ( 64 ZV *zv 65 ) ; 66 /* 67 ----------------------- 68 destructor 69 70 created -- 98jan22, cca 71 ----------------------- 72 */ 73 void 74 ZV_free ( 75 ZV *zv 76 ) ; 77 /*--------------------------------------------------------------------*/ 78 /* 79 ------------------------------------------------------------------------ 80 ----- methods found in init.c ------------------------------------------ 81 ------------------------------------------------------------------------ 82 */ 83 /* 84 --------------------------------------------- 85 simplest initialization method 86 87 data is cleared 88 if entries != NULL 89 the object does not own the entries, 90 it just points to the entries base address 91 else if size > 0 92 the object will own the entries, 93 it allocates a vector of 2*size doubles's. 94 else 95 nothing happens 96 endif 97 98 created -- 98jan22, cca 99 --------------------------------------------- 100 */ 101 void 102 ZV_init ( 103 ZV *zv, 104 int size, 105 double *entries 106 ) ; 107 /* 108 ------------------------- 109 basic initializion method 110 111 created -- 98jan22, cca 112 ------------------------- 113 */ 114 void 115 ZV_init1 ( 116 ZV *zv, 117 int size 118 ) ; 119 /* 120 ------------------------- 121 total initializion method 122 123 created -- 98jan22, cca 124 ------------------------- 125 */ 126 void 127 ZV_init2 ( 128 ZV *zv, 129 int size, 130 int maxsize, 131 int owned, 132 double *vec 133 ) ; 134 /* 135 ---------------------------------- 136 set the maximum size of the vector 137 138 created -- 98jan22, cca 139 ---------------------------------- 140 */ 141 void 142 ZV_setMaxsize ( 143 ZV *zv, 144 int newmaxsize 145 ) ; 146 /* 147 -------------------------- 148 set the size of the vector 149 150 created -- 98jan22, cca 151 -------------------------- 152 */ 153 void 154 ZV_setSize ( 155 ZV *zv, 156 int newsize 157 ) ; 158 /*--------------------------------------------------------------------*/ 159 /* 160 ------------------------------------------------------------------------ 161 ----- methods found in instance.c -------------------------------------- 162 ------------------------------------------------------------------------ 163 */ 164 /* 165 ----------------------------------------------- 166 return 1 if the entries are owned by the object 167 return 0 otherwise 168 169 created -- 98jan22, cca 170 ----------------------------------------------- 171 */ 172 int 173 ZV_owned ( 174 ZV *dv 175 ) ; 176 /* 177 ----------------------- 178 return the vector size 179 180 created -- 98jan22, cca 181 ----------------------- 182 */ 183 int 184 ZV_maxsize ( 185 ZV *dv 186 ) ; 187 /* 188 ----------------------- 189 return the vector size 190 191 created -- 98jan22, cca 192 ----------------------- 193 */ 194 int 195 ZV_size ( 196 ZV *dv 197 ) ; 198 /* 199 ------------------------------------------------- 200 return the loc'th entry of a vector. 201 202 created -- 98jan22, cca 203 ------------------------------------------------- 204 */ 205 void 206 ZV_entry ( 207 ZV *dv, 208 int loc, 209 double *pReal, 210 double *pImag 211 ) ; 212 /* 213 ------------------------------------------------- 214 return pointers to the loc'th entry of a vector. 215 216 created -- 98jan22, cca 217 ------------------------------------------------- 218 */ 219 void 220 ZV_pointersToEntry ( 221 ZV *dv, 222 int loc, 223 double **ppReal, 224 double **ppImag 225 ) ; 226 /* 227 ---------------------------------------------- 228 return a pointer to the object's entries array 229 230 created -- 98jan22, cca 231 ---------------------------------------------- 232 */ 233 double * 234 ZV_entries ( 235 ZV *dv 236 ) ; 237 /* 238 -------------------------------------------- 239 fill *psize with the vector's size 240 and *pentries with the address of the vector 241 242 created -- 98jan22, cca 243 -------------------------------------------- 244 */ 245 void 246 ZV_sizeAndEntries ( 247 ZV *dv, 248 int *psize, 249 double **pentries 250 ) ; 251 /* 252 --------------------------- 253 set and entry in the vector 254 255 created -- 98jan22, cca 256 --------------------------- 257 */ 258 void 259 ZV_setEntry ( 260 ZV *dv, 261 int loc, 262 double real, 263 double imag 264 ) ; 265 /*--------------------------------------------------------------------*/ 266 /* 267 ------------------------------------------------------------------------ 268 ----- methods found in util.c ------------------------------------------ 269 ------------------------------------------------------------------------ 270 */ 271 /* 272 ----------------------------------------------------------- 273 shift the base of the entries and adjust the dimensions 274 note: this is a dangerous operation because the zv->vec 275 does not point to the base of the entries any longer, 276 and thus if the object owns its entries and it is called 277 to resize them or to free them, malloc and free will choke. 278 279 USE WITH CAUTION! 280 281 created -- 98jan22, cca 282 ----------------------------------------------------------- 283 */ 284 void 285 ZV_shiftBase ( 286 ZV *zv, 287 int offset 288 ) ; 289 /* 290 -------------------------------------- 291 push an entry onto the list 292 293 created -- 95oct06, cca 294 -------------------------------------- 295 */ 296 void 297 ZV_push ( 298 ZV *zv, 299 double real, 300 double imag 301 ) ; 302 /* 303 --------------------------- 304 minimum and maximum entries 305 306 created -- 95oct06, cca 307 --------------------------- 308 */ 309 double 310 ZV_minabs ( 311 ZV *zv 312 ) ; 313 /* 314 ---------------------------------------------- 315 return the number of bytes taken by the object 316 317 created -- 95oct06, cca 318 ---------------------------------------------- 319 */ 320 int 321 ZV_sizeOf ( 322 ZV *zv 323 ) ; 324 /* 325 -------------------------- 326 fill a vector with a value 327 328 created -- 96jun22, cca 329 -------------------------- 330 */ 331 void 332 ZV_fill ( 333 ZV *zv, 334 double real, 335 double imag 336 ) ; 337 /* 338 ------------------------ 339 fill a vector with zeros 340 341 created -- 98jun02, cca 342 ------------------------ 343 */ 344 void 345 ZV_zero ( 346 ZV *zv 347 ) ; 348 /* 349 -------------------------------------- 350 copy entries from zv2 into zv1. 351 note: this is a "mapped" copy, 352 zv1 and zv2 need not be the same size. 353 354 created -- 96aug31, cca 355 -------------------------------------- 356 */ 357 void 358 ZV_copy ( 359 ZV *zv1, 360 ZV *zv2 361 ) ; 362 /*--------------------------------------------------------------------*/ 363 /* 364 ------------------------------------------------------------------------ 365 ----- methods found in profile.c --------------------------------------- 366 ------------------------------------------------------------------------ 367 */ 368 /* 369 ------------------------------------------------------------------ 370 to fill xDV and yDV with a log10 profile of the magnitudes of 371 the entries in the ZV object. tausmall and tau big provide 372 cutoffs within which to examine the entries. pnzero, pnsmall 373 and pnbig are addresses to hold the number of entries zero, 374 smaller than tausmall and larger than taubig, respectively. 375 376 created -- 97feb14, cca 377 ------------------------------------------------------------------ 378 */ 379 void 380 ZV_log10profile ( 381 ZV *zv, 382 int npts, 383 DV *xDV, 384 DV *yDV, 385 double tausmall, 386 double taubig, 387 int *pnzero, 388 int *pnsmall, 389 int *pnbig 390 ) ; 391 /*--------------------------------------------------------------------*/ 392 /* 393 ------------------------------------------------------------------------ 394 ----- methods found in IO.c -------------------------------------------- 395 ------------------------------------------------------------------------ 396 */ 397 /* 398 ---------------------------------------------- 399 purpose -- to read in an ZV object from a file 400 401 input -- 402 403 fn -- filename, must be *.zvb or *.zvf 404 405 return value -- 1 if success, 0 if failure 406 407 created -- 98jan22, cca 408 ---------------------------------------------- 409 */ 410 int 411 ZV_readFromFile ( 412 ZV *zv, 413 char *fn 414 ) ; 415 /* 416 ----------------------------------------------------- 417 purpose -- to read an ZV object from a formatted file 418 419 return value -- 1 if success, 0 if failure 420 421 created -- 98jan22, cca 422 ----------------------------------------------------- 423 */ 424 int 425 ZV_readFromFormattedFile ( 426 ZV *zv, 427 FILE *fp 428 ) ; 429 /* 430 --------------------------------------------------- 431 purpose -- to read an ZV object from a binary file 432 433 return value -- 1 if success, 0 if failure 434 435 created -- 98jan22, cca 436 --------------------------------------------------- 437 */ 438 int 439 ZV_readFromBinaryFile ( 440 ZV *zv, 441 FILE *fp 442 ) ; 443 /* 444 ------------------------------------------- 445 purpose -- to write an ZV object to a file 446 447 input -- 448 449 fn -- filename 450 *.zvb -- binary 451 *.zvf -- formatted 452 anything else -- for human eye 453 454 return value -- 1 if success, 0 otherwise 455 456 created -- 98jan22, cca 457 ------------------------------------------- 458 */ 459 int 460 ZV_writeToFile ( 461 ZV *zv, 462 char *fn 463 ) ; 464 /* 465 ----------------------------------------------------- 466 purpose -- to write an ZV object to a formatted file 467 468 return value -- 1 if success, 0 otherwise 469 470 created -- 98jan22, cca 471 ----------------------------------------------------- 472 */ 473 int 474 ZV_writeToFormattedFile ( 475 ZV *zv, 476 FILE *fp 477 ) ; 478 /* 479 -------------------------------------------------- 480 purpose -- to write an ZV object to a binary file 481 482 return value -- 1 if success, 0 otherwise 483 484 created -- 98jan22, cca 485 -------------------------------------------------- 486 */ 487 int 488 ZV_writeToBinaryFile ( 489 ZV *zv, 490 FILE *fp 491 ) ; 492 /* 493 ------------------------------------------------- 494 purpose -- to write an ZV object for a human eye 495 496 return value -- 1 if success, 0 otherwise 497 498 created -- 98jan22, cca 499 ------------------------------------------------- 500 */ 501 int 502 ZV_writeForHumanEye ( 503 ZV *zv, 504 FILE *fp 505 ) ; 506 /* 507 --------------------------------------------------------- 508 purpose -- to write out the statistics for the ZV object 509 510 return value -- 1 if success, 0 otherwise 511 512 created -- 98jan22, cca 513 --------------------------------------------------------- 514 */ 515 int 516 ZV_writeStats ( 517 ZV *zv, 518 FILE *fp 519 ) ; 520 /* 521 -------------------------------------------------- 522 purpose -- write the vector entries out for matlab 523 524 created -- 98apr15, cca 525 -------------------------------------------------- 526 */ 527 void 528 ZV_writeForMatlab ( 529 ZV *zv, 530 char *vecname, 531 FILE *fp 532 ) ; 533 /*--------------------------------------------------------------------*/ 534