Changeset 9730 for trunk/psLib
- Timestamp:
- Oct 24, 2006, 12:55:05 PM (20 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 28 edited
-
astro/psCoord.c (modified) (2 diffs)
-
db/psDB.c (modified) (8 diffs)
-
fits/psFitsImage.c (modified) (3 diffs)
-
fits/psFitsTable.c (modified) (7 diffs)
-
imageops/psImageBackground.c (modified) (1 diff)
-
imageops/psImageConvolve.c (modified) (5 diffs)
-
imageops/psImageGeomManip.c (modified) (4 diffs)
-
imageops/psImagePixelExtract.c (modified) (5 diffs)
-
imageops/psImageStats.c (modified) (6 diffs)
-
jpeg/psImageJpeg.c (modified) (1 diff)
-
math/psMinimizeLMM.c (modified) (6 diffs)
-
math/psMinimizePolyFit.c (modified) (12 diffs)
-
math/psMinimizePowell.c (modified) (2 diffs)
-
math/psPolynomial.c (modified) (31 diffs)
-
math/psPolynomial.h (modified) (2 diffs)
-
math/psSparse.c (modified) (3 diffs)
-
math/psSpline.c (modified) (4 diffs)
-
math/psStats.c (modified) (11 diffs)
-
mathtypes/psVector.c (modified) (3 diffs)
-
mathtypes/psVector.h (modified) (3 diffs)
-
sys/psError.c (modified) (2 diffs)
-
types/psArray.c (modified) (3 diffs)
-
types/psArray.h (modified) (3 diffs)
-
types/psHash.c (modified) (2 diffs)
-
types/psList.c (modified) (4 diffs)
-
types/psLookupTable.c (modified) (5 diffs)
-
types/psMetadataConfig.c (modified) (8 diffs)
-
types/psMetadataConfig.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psCoord.c
r9540 r9730 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.12 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-10- 13 22:04:58$12 * @version $Revision: 1.126 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-10-24 22:52:55 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 795 795 psVector *xOut = psVectorAlloc(numCoords, PS_TYPE_F64); 796 796 psVector *yOut = psVectorAlloc(numCoords, PS_TYPE_F64); 797 for ( psS32g = 0; g < numCoords; g++) {797 for (int g = 0; g < numCoords; g++) { 798 798 xIn->data.F64[g] = ((psPlane *) source->data[g])->x; 799 xIn->n++;800 799 yIn->data.F64[g] = ((psPlane *) source->data[g])->y; 801 yIn->n++;802 800 xOut->data.F64[g] = ((psPlane *) dest->data[g])->x; 803 xOut->n++;804 801 yOut->data.F64[g] = ((psPlane *) dest->data[g])->y; 805 yOut->n++;806 802 } 807 803 -
trunk/psLib/src/db/psDB.c
r9690 r9730 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.10 6$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-10-2 1 01:09:37$14 * @version $Revision: 1.107 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-10-24 22:52:55 $ 16 16 * 17 17 * Copyright (C) 2005-2006 Joshua Hoblitt, University of Hawaii … … 395 395 // then reset n to 0 so elements are added from the beginning of 396 396 // the array 397 column = psArrayAlloc(rowCount); 398 column->n = 0; 397 column = psArrayAllocEmpty(rowCount); 399 398 400 399 // Fetch each result … … 459 458 460 459 psVector *column = psVectorAlloc(stringColumn->n, type); 461 // column->n = column->nalloc;462 460 463 461 // conversion functions are a portability issue 464 462 switch (type) { 465 463 case PS_TYPE_S8: 466 column->n = column->nalloc;467 464 PS_STR_ARRAY_TO_PTYPE(column->data.S8, stringColumn, atoi, psS8, PS_TYPE_S8); 468 465 break; 469 466 case PS_TYPE_S16: 470 column->n = column->nalloc;471 467 PS_STR_ARRAY_TO_PTYPE(column->data.S16, stringColumn, atoi, psS16, PS_TYPE_S16); 472 468 break; 473 469 case PS_TYPE_S32: 474 column->n = column->nalloc;475 470 PS_STR_ARRAY_TO_PTYPE(column->data.S32, stringColumn, atoi, psS32, PS_TYPE_S32); 476 471 break; 477 472 case PS_TYPE_S64: 478 column->n = column->nalloc;479 473 PS_STR_ARRAY_TO_PTYPE(column->data.S64, stringColumn, atoll, psS64, PS_TYPE_S64); 480 474 break; 481 475 case PS_TYPE_U8: 482 column->n = column->nalloc;483 476 PS_STR_ARRAY_TO_PTYPE(column->data.U8, stringColumn, atoi, psU8, PS_TYPE_U8); 484 477 break; 485 478 case PS_TYPE_U16: 486 column->n = column->nalloc;487 479 PS_STR_ARRAY_TO_PTYPE(column->data.U16, stringColumn, atoi, psU16, PS_TYPE_U16); 488 480 break; 489 481 case PS_TYPE_U32: 490 column->n = column->nalloc;491 482 PS_STR_ARRAY_TO_PTYPE(column->data.U32, stringColumn, atoi, psU32, PS_TYPE_U32); 492 483 break; 493 484 case PS_TYPE_U64: 494 column->n = column->nalloc;495 485 PS_STR_ARRAY_TO_PTYPE(column->data.U64, stringColumn, atoll, psU64, PS_TYPE_U64); 496 486 break; 497 487 case PS_TYPE_F32: 498 column->n = column->nalloc;499 488 PS_STR_ARRAY_TO_PTYPE(column->data.F32, stringColumn, atof, psF32, PS_TYPE_F32); 500 489 break; 501 490 case PS_TYPE_F64: 502 column->n = column->nalloc;503 491 PS_STR_ARRAY_TO_PTYPE(column->data.F64, stringColumn, atof, psF64, PS_TYPE_F64); 504 492 break; 505 493 case PS_TYPE_C32: 506 494 // this is a bogus SQL type 507 column->n = column->nalloc;508 495 PS_STR_ARRAY_TO_PTYPE(column->data.C32, stringColumn, atof, psC32, PS_TYPE_C32); 509 496 break; … … 514 501 case PS_TYPE_BOOL: 515 502 // valid for psVector? 516 column->n = column->nalloc;517 503 PS_STR_ARRAY_TO_PTYPE(column->data.U8, stringColumn, atoi, psU8, PS_TYPE_U8); 518 504 break; … … 567 553 568 554 // Create array to store single row 569 psArray *rowSet = psArrayAlloc(1); 570 rowSet->n = 0; 555 psArray *rowSet = psArrayAllocEmpty(1); 571 556 psArrayAdd(rowSet, 0, (psPtr)row); 572 557 … … 697 682 } 698 683 699 psArray *rowData = psArrayAlloc (1);684 psArray *rowData = psArrayAllocEmpty(1); 700 685 psArrayAdd(rowData, 0, values); 701 686 long rowsAffected = p_psDBRunQueryPrepared(dbh, rowData, query); … … 966 951 // then reset n to 0 so elements are added from the beginning of 967 952 // the array 968 resultSet = psArrayAlloc (rowCount);953 resultSet = psArrayAllocEmpty(rowCount); 969 954 970 955 field = mysql_fetch_fields(result); … … 1304 1289 // Reset iterator to head of list 1305 1290 psListIteratorSet(cursor, 0); 1306 psArray *pKeys = psArrayAlloc (1);1291 psArray *pKeys = psArrayAllocEmpty(1); 1307 1292 while ((item = psListGetAndIncrement(cursor))) { 1308 1293 if (strstr(item->comment, "Primary Key")) { -
trunk/psLib/src/fits/psFitsImage.c
r9538 r9730 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-10- 13 21:13:47$9 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-10-24 22:52:55 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 519 519 if (nAxis == 2) { 520 520 psArray *images = psArrayAlloc(1); // Single image plane 521 images->n = 1;522 521 images->data[0] = psFitsReadImage(fits, region, 0); 523 522 return images; … … 533 532 534 533 psArray *images = psArrayAlloc(nAxes[2]); // Array of image planes 535 images->n = nAxes[2];536 534 for (int i = 0; i < nAxes[2]; i++) { 537 535 images->data[i] = psFitsReadImage(fits, region, i); -
trunk/psLib/src/fits/psFitsTable.c
r8627 r9730 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2006- 08-26 04:34:28$9 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-10-24 22:52:55 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 237 237 result->data[row] = psAlloc((width+1)*sizeof(char)); 238 238 } 239 result->n = numRows;240 239 241 240 fits_read_col_str(fits->fd, … … 319 318 320 319 psVector* result = psVectorAlloc(numRows, p_psFitsTypeFromCfitsio(typecode)); 321 result->n = numRows;322 320 323 321 fits_read_col(fits->fd, … … 389 387 psTrace("psLib.fits",5,"Reading row %i of %li\n",row, numRows); 390 388 table->data[row] = psFitsReadTableRow(fits,row); 391 table->n++;392 389 } 393 390 … … 564 561 psArray *columnNames = psArrayAlloc(numColumns); // Array of column names, for cfitsio 565 562 psArray *columnTypes = psArrayAlloc(numColumns); // Array of column types, for cfitsio 566 columnNames->n = numColumns;567 columnTypes->n = numColumns;568 563 psMetadataIterator *colSpecsIter = psMetadataIteratorAlloc(colSpecs, PS_LIST_HEAD, NULL); // Iterator 569 564 psMetadataItem *colSpecItem; // Column specification item, from iteration … … 644 639 size_t dataSize = PSELEMTYPE_SIZEOF(spec->type); // Size (in bytes) of this type 645 640 psVector *columnData = psVectorAlloc(table->n, spec->type); // The raw row data, to be written 646 columnData->n = table->n;647 641 psVectorInit(columnData, 0); 648 642 for (long i = 0; i < table->n; i++) { … … 667 661 case PS_DATA_STRING: { 668 662 psArray *strings = psArrayAlloc(table->n); // Array of strings 669 strings->n = table->n;670 663 for (long i = 0; i < table->n; i++) { 671 664 psMetadata *row = table->data[i]; // The row of interest -
trunk/psLib/src/imageops/psImageBackground.c
r8978 r9730 36 36 int Npixels = nx*ny; // Total number of pixels 37 37 38 psVector *values = psVectorAlloc (Nsubset, PS_TYPE_F32); // Vector containing subsample38 psVector *values = psVectorAllocEmpty(Nsubset, PS_TYPE_F32); // Vector containing subsample 39 39 40 40 // Minimum and maximum values -
trunk/psLib/src/imageops/psImageConvolve.c
r9538 r9730 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-10- 13 21:13:48$7 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-10-24 22:52:55 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 505 505 /* generate normalized gaussian */ \ 506 506 psVector *gaussnorm = psVectorAlloc(Npixel, PS_TYPE_##TYPE); \ 507 gaussnorm->n = gaussnorm->nalloc; \508 507 { \ 509 508 double sum = 0.0; \ … … 522 521 { \ 523 522 psVector *calculation = psVectorAlloc(Nx, PS_TYPE_##TYPE); \ 524 calculation->n = calculation->nalloc; \525 523 for (int j = 0; j < Ny; j++) { \ 526 524 ps##TYPE *vi = image->data.TYPE[j]; \ … … 573 571 /* Smooth in Y direction */ \ 574 572 psArray *rows = psArrayAlloc(Nrange); \ 575 rows->n = Nrange; \576 573 /* Smooth the first Nrange pixels, with renorm */ \ 577 574 int yMax = PS_MIN(Nrange, Ny); \ … … 579 576 for (int j = 0; j < yMax; j++) { \ 580 577 psVector *calculation = psVectorAlloc(Nx, PS_TYPE_##TYPE); \ 581 calculation->n = calculation->nalloc; \582 578 /* Zero the output row */ \ 583 579 memset(calculation->data.TYPE, 0, Nx*sizeof(ps##TYPE)); \ -
trunk/psLib/src/imageops/psImageGeomManip.c
r8232 r9730 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2006- 08-08 23:32:23$12 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-10-24 22:52:55 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 80 80 } 81 81 82 vec = psVectorAlloc (scale * scale, in->type.type);82 vec = psVectorAllocEmpty(scale * scale, in->type.type); 83 83 84 84 if (mask != NULL) { … … 93 93 return NULL; 94 94 } 95 maskVec = psVectorAlloc(scale * scale, PS_TYPE_MASK); 96 maskVec->n = maskVec->nalloc; 95 maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_MASK); 97 96 maskData = maskVec->data.PS_TYPE_MASK_DATA; 98 97 } … … 134 133 } \ 135 134 vec->n = n; \ 135 maskVec->n = n; \ 136 136 myStats = psVectorStats(myStats, vec, NULL, maskVec, maskVal); \ 137 137 outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \ -
trunk/psLib/src/imageops/psImagePixelExtract.c
r8627 r9730 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.2 7$ $Name: not supported by cvs2svn $11 * @date $Date: 2006- 08-26 04:34:28$10 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-10-24 22:52:55 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 18 18 19 19 #include "psMemory.h" 20 #include "psVector.h" 20 21 #include "psImagePixelExtract.h" 21 22 #include "psError.h" … … 392 393 if (direction == PS_CUT_X_POS || direction == PS_CUT_X_NEG) { 393 394 psVector* imgVec = psVectorAlloc(numRows, type); 394 imgVec->n = imgVec->nalloc;395 395 psVector* maskVec = NULL; 396 396 psMaskType* maskData = NULL; … … 417 417 if (mask != NULL) { 418 418 maskVec = psVectorAlloc(numRows, mask->type.type); 419 maskVec->n = maskVec->nalloc;420 419 } 421 420 #define PSIMAGE_CUT_VERTICAL(TYPE) \ … … 855 854 // n.b. alloc enough for the data by making the vectors slightly larger 856 855 // than the area of the region of interest. 857 buffer[lcv] = psVectorAlloc(1+4*(rSq[lcv+1]-rSq[lcv]), 858 input->type.type); 859 buffer[lcv]->n = 0; 856 buffer[lcv] = psVectorAllocEmpty(1+4*(rSq[lcv+1]-rSq[lcv]), 857 input->type.type); 860 858 861 859 bufferMask[lcv] = NULL; 862 860 if (mask != NULL) { 863 bufferMask[lcv] = psVectorAlloc(1+4*(rSq[lcv+1]-rSq[lcv]), 864 PS_TYPE_MASK); 865 bufferMask[lcv]->n = 0; 861 bufferMask[lcv] = psVectorAllocEmpty(1+4*(rSq[lcv+1]-rSq[lcv]), 862 PS_TYPE_MASK); 866 863 } 867 864 } -
trunk/psLib/src/imageops/psImageStats.c
r8627 r9730 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.10 0$ $Name: not supported by cvs2svn $12 * @date $Date: 2006- 08-26 04:34:28$11 * @version $Revision: 1.101 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-10-24 22:52:55 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 76 76 77 77 junkData = psVectorAlloc(numRows*numCols, in->type.type); 78 junkData->n = junkData->nalloc;79 78 80 79 psU8* data = junkData->data.U8; … … 100 99 101 100 junkMask = psVectorAlloc(numRows*numCols, mask->type.type); 102 junkMask->n = junkMask->nalloc;103 101 104 102 psU8* data = junkMask->data.U8; … … 149 147 150 148 junkData = psVectorAlloc(numRows*numCols, in->type.type); 151 junkData->n = junkData->nalloc;152 149 153 150 psU8* data = junkData->data.U8; … … 173 170 174 171 junkMask = psVectorAlloc(numRows*numCols, mask->type.type); 175 junkMask->n = junkMask->nalloc;176 172 177 173 psU8* data = junkMask->data.U8; … … 592 588 return -1; 593 589 }/* else if (col0 == col1 && row0 == row1) { 594 psError(PS_ERR_BAD_PARAMETER_VALUE, true,595 "Invalid psRegion specified. Region contains only 1 pixel.\n");596 return -1;597 }598 */590 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 591 "Invalid psRegion specified. Region contains only 1 pixel.\n"); 592 return -1; 593 } 594 */ 599 595 x0 = col0; 600 596 x1 = col1; -
trunk/psLib/src/jpeg/psImageJpeg.c
r8977 r9730 33 33 map->blue = psVectorAlloc(256, PS_TYPE_U8); 34 34 map->green = psVectorAlloc(256, PS_TYPE_U8); 35 36 map->red->n = 256;37 map->blue->n = 256;38 map->green->n = 256;39 35 40 36 return map; -
trunk/psLib/src/math/psMinimizeLMM.c
r9556 r9730 10 10 * @author EAM, IfA 11 11 * 12 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-10- 14 00:15:47$12 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-10-24 22:52:56 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 163 163 psImage *Alpha = psImageAlloc (params->n, params->n, PS_TYPE_F64); 164 164 psVector *beta = psVectorAlloc(params->n, PS_TYPE_F64); 165 beta->n = beta->nalloc;166 165 psVector *Params = psVectorAlloc(params->n, PS_TYPE_F64); 167 Params->n = Params->nalloc;168 166 psVector *dy = NULL; 169 167 psBool rc = true; … … 175 173 } else { 176 174 dy = psVectorAlloc(y->n, PS_TYPE_F32); 177 dy->n = dy->nalloc;178 175 psVectorInit(dy, 1.0); 179 176 } … … 246 243 psF64 ymodel; 247 244 psVector *deriv = psVectorAlloc(params->n, PS_TYPE_F32); 248 deriv->n = deriv->nalloc;249 245 250 246 // zero alpha and beta for summing below … … 380 376 psImage *Alpha = psImageAlloc(params->n, params->n, PS_TYPE_F64); 381 377 psVector *beta = psVectorAlloc(params->n, PS_TYPE_F64); 382 beta->n = beta->nalloc;383 378 psVector *Beta = psVectorAlloc(params->n, PS_TYPE_F64); 384 beta->n = beta->nalloc;385 379 psVector *Params = psVectorAlloc(params->n, PS_TYPE_F32); 386 Params->n = Params->nalloc;387 380 psVector *dy = NULL; 388 381 psF64 Chisq = 0.0; … … 398 391 } else { 399 392 dy = psVectorAlloc(y->n, PS_TYPE_F32); 400 dy->n = dy->nalloc;401 393 psVectorInit(dy, 1.0); 402 394 } -
trunk/psLib/src/math/psMinimizePolyFit.c
r9640 r9730 10 10 * @author EAM, IfA 11 11 * 12 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-10- 19 02:57:18$12 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-10-24 22:52:56 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 46 46 #define PS_VECTOR_GEN_CHEBY_INDEX(VEC, SIZE, TYPE) \ 47 47 VEC = psVectorAlloc(SIZE, TYPE); \ 48 VEC->n = VEC->nalloc; \49 48 if (TYPE == PS_TYPE_F64) { \ 50 49 for (psS32 i = 0 ; i < SIZE ; i++) { \ … … 93 92 if (sums == NULL) { 94 93 sums = psVectorAlloc(nSum, PS_TYPE_F64); 95 sums->n = sums->nalloc;96 94 } else if (nSum > sums->n) { 97 95 sums = psVectorRealloc(sums, nSum); 98 sums->n = sums->nalloc;96 sums->n = nSum; 99 97 } 100 98 … … 333 331 psImage *A = psImageAlloc(numTerms, numTerms, PS_TYPE_F64); // Least-squares matrix 334 332 psVector *B = psVectorAlloc(numTerms, PS_TYPE_F64); // Least-squares vector 335 B->n = numTerms;336 333 psImageInit(A, 0.0); 337 334 psVectorInit(B, 0.0); … … 509 506 psImage *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix 510 507 psVector *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector 511 B->n = B->nalloc;512 508 513 509 // Initialize data structures. … … 805 801 psVector *fit = NULL; 806 802 psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64); 807 resid->n = resid->nalloc;808 803 809 804 // eventual expansion: user supplies one of various stats option pairs, … … 976 971 psImage *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix 977 972 psVector *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector 978 B->n = B->nalloc;979 973 980 974 // Initialize data structures. … … 1256 1250 } 1257 1251 psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64); 1258 resid->n = resid->nalloc;1259 1252 1260 1253 // eventual expansion: user supplies one of various stats option pairs, … … 1434 1427 psImage *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix 1435 1428 psVector *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector 1436 B->n = B->nalloc;1437 1429 1438 1430 // Initialize data structures. … … 1790 1782 psVector *fit = NULL; 1791 1783 psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64); 1792 resid->n = resid->nalloc;1793 1784 1794 1785 // eventual expansion: user supplies one of various stats option pairs, … … 1967 1958 psImage *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix 1968 1959 psVector *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector 1969 B->n = B->nalloc;1970 1960 1971 1961 // Initialize data structures. … … 2368 2358 psVector *fit = NULL; 2369 2359 psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64); 2370 resid->n = resid->nalloc;2371 2360 2372 2361 // eventual expansion: user supplies one of various stats option pairs, -
trunk/psLib/src/math/psMinimizePowell.c
r9540 r9730 11 11 * NOTE: XXX: The SDR is silent about data types. F32 is implemented here. 12 12 * 13 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2006-10- 13 22:04:58$13 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-10-24 22:52:56 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 549 549 ((psVector *) (v->data[i]))->data.F32[j] = 0.0; 550 550 } 551 ((psVector *)(v->data[i]))->n++; 552 } 553 v->n++; 551 } 554 552 } 555 553 -
trunk/psLib/src/math/psPolynomial.c
r9540 r9730 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.15 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-10- 13 22:04:58$9 * @version $Revision: 1.152 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-10-24 22:52:56 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 266 266 // General case where the Chebyshev poly has 2 or more terms. 267 267 d = psVectorAlloc(nTerms, PS_TYPE_F64); 268 d->n = d->nalloc;269 268 if(poly->mask[nTerms-1] == 0) { 270 269 d->data.F64[nTerms-1] = poly->coeff[nTerms-1]; … … 571 570 psTrace("psLib.math", 4, "---- %s() end ----\n", __func__); 572 571 return(tmp * exp(-((x - mean) * (x - mean)) / (2.0 * sigma * sigma))); 573 }574 575 /*****************************************************************************576 p_psGaussianDev()577 This private routine (formerly a psLib API routine) creates a psVector of the578 specified size and type F32 and fills it with a random Gaussian distribution579 of numbers with the specified mean and sigma.580 581 XXX: It's possible to have a different seed everytime. However, for now,582 for testability, we use a common seed.583 *****************************************************************************/584 #define PS_XXX_GAUSSIAN_SEED 1995585 psVector* p_psGaussianDev(psF32 mean,586 psF32 sigma,587 unsigned int Npts)588 {589 PS_ASSERT_INT_NONNEGATIVE(Npts, NULL);590 591 // psRandom *r = psRandomAlloc(PS_RANDOM_TAUS, p_psRandomGetSystemSeed());592 psRandom *r = psRandomAlloc(PS_RANDOM_TAUS, PS_XXX_GAUSSIAN_SEED);593 psVector* gauss = psVectorAlloc(Npts, PS_TYPE_F32);594 for (unsigned int i = 0; i < Npts; i++) {595 gauss->data.F32[i] = mean + p_psRandomGaussian(r, sigma);596 gauss->n++;597 }598 psFree(r);599 600 return(gauss);601 572 } 602 573 … … 808 779 for (unsigned int i=0;i<x->n;i++) { 809 780 tmp->data.F64[i] = psPolynomial1DEval(poly, x->data.F64[i]); 810 tmp->n++;811 781 } 812 782 break; … … 815 785 for (unsigned int i=0;i<x->n;i++) { 816 786 tmp->data.F32[i] = psPolynomial1DEval(poly, x->data.F32[i]); 817 tmp->n++;818 787 } 819 788 break; … … 877 846 for (unsigned int i=0; i<vecLen; i++) { 878 847 tmp->data.F32[i] = psPolynomial2DEval(poly,x->data.F32[i],y->data.F32[i]); 879 tmp->n++;880 848 } 881 849 break; … … 892 860 for (unsigned int i=0; i<vecLen; i++) { 893 861 tmp->data.F64[i] = psPolynomial2DEval(poly,x->data.F64[i],y->data.F64[i]); 894 tmp->n++;895 862 } 896 863 break; … … 959 926 tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i], 960 927 y->data.F32[i], z->data.F32[i]); 961 tmp->n++;962 928 } 963 929 } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32) … … 966 932 tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i], 967 933 y->data.F32[i], z->data.F64[i]); 968 tmp->n++;969 934 } 970 935 } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64) … … 973 938 tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i], 974 939 y->data.F64[i], z->data.F32[i]); 975 tmp->n++;976 940 } 977 941 } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64) … … 980 944 tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i], 981 945 y->data.F64[i], z->data.F64[i]); 982 tmp->n++;983 946 } 984 947 } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32) … … 987 950 tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i], 988 951 y->data.F32[i], z->data.F32[i]); 989 tmp->n++;990 952 } 991 953 } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32) … … 994 956 tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i], 995 957 y->data.F32[i], z->data.F64[i]); 996 tmp->n++;997 958 } 998 959 } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64) … … 1001 962 tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i], 1002 963 y->data.F64[i], z->data.F32[i]); 1003 tmp->n++;1004 964 } 1005 965 } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64) … … 1008 968 tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i], 1009 969 y->data.F64[i], z->data.F64[i]); 1010 tmp->n++;1011 970 } 1012 971 } … … 1079 1038 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i], 1080 1039 y->data.F32[i], z->data.F32[i], t->data.F32[i]); 1081 tmp->n++;1082 1040 } 1083 1041 } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32) … … 1086 1044 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i], 1087 1045 y->data.F32[i], z->data.F32[i], t->data.F64[i]); 1088 tmp->n++;1089 1046 } 1090 1047 } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32) … … 1093 1050 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i], 1094 1051 y->data.F32[i], z->data.F64[i], t->data.F32[i]); 1095 tmp->n++;1096 1052 } 1097 1053 } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32) … … 1100 1056 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i], 1101 1057 y->data.F32[i], z->data.F64[i], t->data.F64[i]); 1102 tmp->n++;1103 1058 } 1104 1059 } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64) … … 1107 1062 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i], 1108 1063 y->data.F64[i], z->data.F32[i], t->data.F32[i]); 1109 tmp->n++;1110 1064 } 1111 1065 } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64) … … 1114 1068 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i], 1115 1069 y->data.F64[i], z->data.F32[i], t->data.F64[i]); 1116 tmp->n++;1117 1070 } 1118 1071 } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64) … … 1121 1074 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i], 1122 1075 y->data.F64[i], z->data.F64[i], t->data.F32[i]); 1123 tmp->n++;1124 1076 } 1125 1077 } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64) … … 1128 1080 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i], 1129 1081 y->data.F64[i], z->data.F64[i], t->data.F64[i]); 1130 tmp->n++;1131 1082 } 1132 1083 } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32) … … 1135 1086 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i], 1136 1087 y->data.F32[i], z->data.F32[i], t->data.F32[i]); 1137 tmp->n++;1138 1088 } 1139 1089 } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32) … … 1142 1092 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i], 1143 1093 y->data.F32[i], z->data.F32[i], t->data.F64[i]); 1144 tmp->n++;1145 1094 } 1146 1095 } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32) … … 1149 1098 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i], 1150 1099 y->data.F32[i], z->data.F64[i], t->data.F32[i]); 1151 tmp->n++;1152 1100 } 1153 1101 } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32) … … 1156 1104 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i], 1157 1105 y->data.F32[i], z->data.F64[i], t->data.F64[i]); 1158 tmp->n++;1159 1106 } 1160 1107 } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64) … … 1163 1110 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i], 1164 1111 y->data.F64[i], z->data.F32[i], t->data.F32[i]); 1165 tmp->n++;1166 1112 } 1167 1113 } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64) … … 1170 1116 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i], 1171 1117 y->data.F64[i], z->data.F32[i], t->data.F64[i]); 1172 tmp->n++;1173 1118 } 1174 1119 } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64) … … 1177 1122 tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i], 1178 1123 y->data.F64[i], z->data.F64[i], t->data.F32[i]); 1179 tmp->n++;1180 1124 } 1181 1125 } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64) … … 1185 1129 y->data.F64[i], z->data.F64[i], 1186 1130 t->data.F64[i]); 1187 tmp->n++;1188 1131 } 1189 1132 } -
trunk/psLib/src/math/psPolynomial.h
r7766 r9730 11 11 * @author GLG, MHPCC 12 12 * 13 * @version $Revision: 1.6 3$ $Name: not supported by cvs2svn $14 * @date $Date: 2006- 06-30 02:20:06 $13 * @version $Revision: 1.64 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-10-24 22:52:56 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 45 45 float sigma, ///< Standard deviation for the Gaussian 46 46 bool normal ///< Indicates whether result should be normalized 47 );48 49 /** Produce a vector of random numbers from a Gaussian distribution with50 * the specified mean and sigma51 *52 * @return psVector* vector of random numbers53 *54 */55 psVector* p_psGaussianDev(56 psF32 mean, ///< The mean of the Gaussian57 psF32 sigma, ///< The sigma of the Gaussian58 unsigned int Npts ///< The size of the vector59 47 ); 60 48 -
trunk/psLib/src/math/psSparse.c
r8627 r9730 35 35 psMemSetDeallocator(sparse, (psFreeFunc)sparseFree); 36 36 37 sparse->Aij = psVectorAlloc(Nelem, PS_DATA_F32); 38 sparse->Si = psVectorAlloc(Nelem, PS_DATA_S32); 39 sparse->Sj = psVectorAlloc(Nelem, PS_DATA_S32); 40 41 sparse->Aij->n = 0; 42 sparse->Si->n = 0; 43 sparse->Sj->n = 0; 37 sparse->Aij = psVectorAllocEmpty(Nelem, PS_DATA_F32); 38 sparse->Si = psVectorAllocEmpty(Nelem, PS_DATA_S32); 39 sparse->Sj = psVectorAllocEmpty(Nelem, PS_DATA_S32); 40 44 41 sparse->Nelem = 0; 45 42 46 43 sparse->Bfj = psVectorAlloc(Nrows, PS_DATA_F32); 47 44 sparse->Qii = psVectorAlloc(Nrows, PS_DATA_F32); 48 sparse->Bfj->n = Nrows;49 sparse->Qii->n = Nrows;50 45 51 46 sparse->Nrows = Nrows; … … 157 152 // temporary storage for intermediate results 158 153 psVector *dQ = psVectorAlloc(output->n, PS_DATA_F32); 159 dQ->n = output->n;160 154 161 155 for (int j = 0; j < Niter; j++) { … … 197 191 psVector *tSi = psVectorAlloc(Nelem, PS_DATA_S32); 198 192 psVector *tSj = psVectorAlloc(Nelem, PS_DATA_S32); 199 tAij->n = tSi->n = tSj->n = Nelem;200 193 201 194 for (int i = 0; i < Nelem; i++) { -
trunk/psLib/src/math/psSpline.c
r9540 r9730 6 6 * This file contains the routines that allocate, free, and evaluate splines. 7 7 * 8 * @version $Revision: 1.15 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-10- 13 22:04:58$8 * @version $Revision: 1.156 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-10-24 22:52:56 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 239 239 for (psS32 i = 0 ; i < x->n ; i++) { 240 240 spline->knots->data.F32[i] = x->data.F32[i]; 241 spline->knots->n++;242 241 } 243 242 } else if (x->type.type == PS_TYPE_F64) { 244 243 for (psS32 i = 0 ; i < x->n ; i++) { 245 244 spline->knots->data.F32[i] = (psF32) x->data.F64[i]; 246 spline->knots->n++;247 245 } 248 246 } … … 250 248 for (psS32 i = 0 ; i < y->n ; i++) { 251 249 spline->knots->data.F32[i] = (psF32) i; 252 spline->knots->n++;253 250 } 254 251 } … … 415 412 for (psS32 i=0;i<x->n;i++) { 416 413 tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]); 417 tmpVector->n++;418 414 } 419 415 } else if (x->type.type == PS_TYPE_F64) { 420 416 for (psS32 i=0;i<x->n;i++) { 421 417 tmpVector->data.F32[i] = psSpline1DEval(spline, (psF32) x->data.F64[i]); 422 tmpVector->n++;423 418 } 424 419 } -
trunk/psLib/src/math/psStats.c
r9540 r9730 16 16 * use ->min and ->max (PS_STAT_USE_RANGE) 17 17 * 18 * @version $Revision: 1.18 7$ $Name: not supported by cvs2svn $19 * @date $Date: 2006-10- 13 22:04:58$18 * @version $Revision: 1.188 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2006-10-24 22:52:56 $ 20 20 * 21 21 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 388 388 389 389 // Allocate temporary vectors for the data. 390 psVector* vector = psVectorAlloc (myVector->n, PS_TYPE_F32); // Vector containing the unmasked values390 psVector* vector = psVectorAllocEmpty(myVector->n, PS_TYPE_F32); // Vector containing the unmasked values 391 391 long count = 0; // Number of valid entries 392 392 … … 486 486 long numBins = histogram->nums->n; // Number of histogram bins 487 487 psVector *smooth = psVectorAlloc(numBins, PS_TYPE_F32); // Smoothed version of histogram bins 488 smooth->n = smooth->nalloc;489 488 const psVector *bounds = histogram->bounds; // The bounds for the histogram bins 490 489 … … 723 722 // We copy the mask vector, to preserve the original 724 723 psVector *tmpMask = psVectorAlloc(myVector->n, PS_TYPE_U8); 725 tmpMask->n = tmpMask->nalloc;726 724 psVectorInit(tmpMask, 0); 727 725 if (maskVector) { … … 901 899 psVector *x = psVectorAlloc(3, PS_TYPE_F64); 902 900 psVector *y = psVectorAlloc(3, PS_TYPE_F64); 903 x->n = 3;904 y->n = 3;905 901 psF32 tmpFloat = 0.0f; 906 902 … … 1066 1062 1067 1063 psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_MASK); // The actual mask we will use 1068 mask->n = myVector->n;1069 1064 psVectorInit(mask, 0); 1070 1065 if (maskVector) { … … 1487 1482 psVector *y = psVectorAlloc((1 + (binMax - binMin)), PS_TYPE_F32); // Vector of coordinates 1488 1483 psArray *x = psArrayAlloc((1 + (binMax - binMin))); // Array of ordinates 1489 y->n = y->nalloc;1490 x->n = x->nalloc;1491 1484 for (long i = binMin, j = 0; i <= binMax ; i++, j++) { 1492 1485 y->data.F32[j] = smoothed->data.F32[i]; 1493 1486 psVector *ordinate = psVectorAlloc(1, PS_TYPE_F32); // The ordinate value 1494 ordinate->n = 1;1495 1487 ordinate->data.F32[0] = PS_BIN_MIDPOINT(histogram, i); 1496 1488 x->data[j] = ordinate; … … 1521 1513 psMinimization *minimizer = psMinimizationAlloc(100, 0.01); // The minimizer information 1522 1514 psVector *params = psVectorAlloc(2, PS_TYPE_F32); // Parameters for the Gaussian 1523 params->n = params->nalloc;1524 1515 // Initial guess for the mean (index 0) and standard dev (index 1). 1525 1516 params->data.F32[0] = stats->robustMedian; … … 1654 1645 psVector* newBounds = psVectorAlloc(n + 1, PS_TYPE_F32); 1655 1646 newHist->bounds = newBounds; 1656 newBounds->n = newHist->bounds->nalloc;1657 1647 1658 1648 // Calculate the bounds for each bin. … … 1666 1656 // Allocate the bins, and initialize them to zero. 1667 1657 newHist->nums = psVectorAlloc(n, PS_TYPE_F32); 1668 for (long i = 0; i < newHist->nums->nalloc; i++) { 1669 newHist->nums->data.F32[i] = 0.0; 1670 newHist->nums->n++; 1671 } 1658 psVectorInit(newHist->nums, 0.0); 1672 1659 1673 1660 // Initialize the other members. … … 1699 1686 psHistogram *newHist = (psHistogram* ) psAlloc(sizeof(psHistogram)); // The new histogram structure 1700 1687 psMemSetDeallocator(newHist, (psFreeFunc) histogramFree); 1701 psVector* newBounds = psVector Alloc(bounds->n, PS_TYPE_F32);1688 psVector* newBounds = psVectorCopy(NULL, bounds, PS_TYPE_F32); 1702 1689 newHist->bounds = newBounds; 1703 newBounds->n = newHist->bounds->nalloc;1704 for (long i = 0; i < bounds->n; i++) {1705 newBounds->data.F32[i] = bounds->data.F32[i];1706 }1707 1690 1708 1691 // Allocate the bins, and initialize them to zero. If there are N bounds, 1709 1692 // then there are N-1 bins. 1710 1693 newHist->nums = psVectorAlloc((bounds->n) - 1, PS_TYPE_F32); 1711 for (long i = 0; i < newHist->nums->nalloc; i++) { 1712 newHist->nums->data.F32[i] = 0.0; 1713 newHist->nums->n++; 1714 } 1694 psVectorInit(newHist->nums, 0.0); 1715 1695 1716 1696 // Initialize the other members. -
trunk/psLib/src/mathtypes/psVector.c
r9554 r9730 9 9 * @author Robert DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.8 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-10- 14 00:12:39$11 * @version $Revision: 1.87 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-10-24 22:52:56 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 68 68 69 69 70 psVector* psVectorAlloc(long nalloc, 71 psElemType type) 72 { 73 psVector* psVec = NULL; 74 psS32 elementSize = 0; 75 76 elementSize = PSELEMTYPE_SIZEOF(type); 70 // Allocate a psVector; does not set vector->n (left to the caller) 71 static psVector *vectorAlloc(long nalloc, // Number of elements to allocate 72 psElemType type // Type of elements 73 ) 74 { 75 int elementSize = PSELEMTYPE_SIZEOF(type); // Size, in bytes, of element 77 76 if (elementSize < 1) { 78 77 psError(PS_ERR_BAD_PARAMETER_TYPE, true, … … 81 80 } 82 81 83 84 82 // Create vector struct 85 psVec = (psVector* ) psAlloc(sizeof(psVector)); 86 psMemSetDeallocator(psVec, (psFreeFunc) vectorFree); 87 88 psVec->type.dimen = PS_DIMEN_VECTOR; 89 psVec->type.type = type; 90 P_PSVECTOR_SET_NALLOC(psVec,nalloc); 91 // psVec->n = nalloc; 92 psVec->n = 0; 83 psVector *vector = (psVector*) psAlloc(sizeof(psVector)); 84 psMemSetDeallocator(vector, (psFreeFunc) vectorFree); 85 86 vector->type.dimen = PS_DIMEN_VECTOR; 87 vector->type.type = type; 88 P_PSVECTOR_SET_NALLOC(vector, nalloc); 93 89 94 90 // Create vector data array 95 psVec->data.U8 = psAlloc(nalloc * elementSize); 96 97 return psVec; 91 vector->data.U8 = psAlloc(nalloc * elementSize); 92 93 return vector; 94 } 95 96 psVector* psVectorAlloc(long nalloc, 97 psElemType type) 98 { 99 psVector *vector = vectorAlloc(nalloc, type); 100 if (!vector) { 101 return NULL; 102 } 103 vector->n = nalloc; 104 return vector; 105 } 106 107 psVector* psVectorAllocEmpty(long nalloc, 108 psElemType type) 109 { 110 psVector *vector = vectorAlloc(nalloc, type); 111 if (!vector) { 112 return NULL; 113 } 114 vector->n = 0; 115 return vector; 98 116 } 99 117 -
trunk/psLib/src/mathtypes/psVector.h
r9553 r9730 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.5 8$ $Name: not supported by cvs2svn $14 * @date $Date: 2006-10- 14 00:07:13$13 * @version $Revision: 1.59 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-10-24 22:52:56 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 74 74 ; 75 75 76 /** Allocate a vector .76 /** Allocate a vector, with length set to number allocated 77 77 * 78 78 * Uses psLib memory allocation functions to create a vector collection of … … 82 82 */ 83 83 psVector* psVectorAlloc( 84 long nalloc, ///< Total number of elements to make available. 85 psElemType type ///< Type of data to be held by vector. 86 ); 87 88 /** Allocate a vector, with length set to zero 89 * 90 * Uses psLib memory allocation functions to create a vector collection of 91 * data as defined by the psType type. 92 * 93 * @return psVector* Pointer to psVector. 94 */ 95 psVector* psVectorAllocEmpty( 84 96 long nalloc, ///< Total number of elements to make available. 85 97 psElemType type ///< Type of data to be held by vector. -
trunk/psLib/src/sys/psError.c
r9623 r9730 11 11 * @author Eric Van Alst, MHPCC 12 12 * 13 * @version $Revision: 1.4 0$ $Name: not supported by cvs2svn $14 * @date $Date: 2006-10- 18 15:26:33$13 * @version $Revision: 1.41 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-10-24 22:52:56 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 84 84 if ((errorStack = pthread_getspecific(errorStack_key)) == NULL) { 85 85 // allocate the error stack 86 errorStack = psArrayAlloc (MAX_ERROR_STACK_SIZE);86 errorStack = psArrayAllocEmpty(MAX_ERROR_STACK_SIZE); 87 87 p_psMemSetPersistent(errorStack, true); 88 88 p_psMemSetPersistent(errorStack->data, true); -
trunk/psLib/src/types/psArray.c
r9543 r9730 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.5 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-10- 13 22:24:29$11 * @version $Revision: 1.57 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-10-24 22:52:56 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 49 49 } 50 50 51 // Allocate an array, deliberately leave size unset. 52 static psArray *arrayAlloc(long nalloc) 53 { 54 if (nalloc < 0) { 55 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 56 "Can't allocate a psArray of negative size."); 57 return NULL; 58 } 59 60 // Create vector struct 61 psArray *array = (psArray*)psAlloc(sizeof(psArray)); 62 psMemSetDeallocator(array, (psFreeFunc)arrayFree); 63 64 P_PSARRAY_SET_NALLOC(array, nalloc); 65 // Create vector data array 66 array->data = psAlloc(nalloc * sizeof(psPtr)); 67 memset(array->data, 0, sizeof(void*) * nalloc); //set the initial values of data to NULL 68 69 return array; 70 } 51 71 52 72 /***************************************************************************** … … 55 75 psArray* psArrayAlloc(long nalloc) 56 76 { 57 if (nalloc < 0) { 58 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 59 "Can't allocate a psArray of negative size."); 60 return NULL; 61 } 62 psArray* psArr = NULL; 63 64 // Create vector struct 65 psArr = (psArray* ) psAlloc(sizeof(psArray)); 66 psMemSetDeallocator(psArr, (psFreeFunc) arrayFree); 67 68 P_PSARRAY_SET_NALLOC(psArr,nalloc); 69 psArr->n = 0; //set the initial number of elements in use to 0 70 // Create vector data array 71 psArr->data = psAlloc(nalloc * sizeof(psPtr)); 72 memset(psArr->data, 0, sizeof(void*) * nalloc); //set the initial values of data to NULL 73 74 return psArr; 77 psArray *array = arrayAlloc(nalloc); 78 if (!array) { 79 return NULL; 80 } 81 array->n = nalloc; 82 return array; 83 } 84 85 psArray* psArrayAllocEmpty(long nalloc) 86 { 87 psArray *array = arrayAlloc(nalloc); 88 if (!array) { 89 return NULL; 90 } 91 array->n = 0; 92 return array; 75 93 } 76 94 -
trunk/psLib/src/types/psArray.h
r9543 r9730 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.4 2$ $Name: not supported by cvs2svn $14 * @date $Date: 2006-10- 13 22:24:29$13 * @version $Revision: 1.43 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-10-24 22:52:56 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 60 60 61 61 62 /** Allocate an array .62 /** Allocate an array, set the length to the number of allocated elements 63 63 * 64 64 * Uses psLib memory allocation functions to create an array collection of … … 69 69 */ 70 70 psArray* psArrayAlloc( 71 long nalloc ///< Total number of elements to make available. 72 ); 73 74 /** Allocate an array, set the length to zero. 75 * 76 * Uses psLib memory allocation functions to create an array collection of 77 * data 78 * 79 * @return psArray* : Pointer to psArray. 80 * 81 */ 82 psArray* psArrayAllocEmpty( 71 83 long nalloc ///< Total number of elements to make available. 72 84 ); -
trunk/psLib/src/types/psHash.c
r9538 r9730 12 12 * @author GLG, MHPCC 13 13 * 14 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-10- 13 21:13:48$14 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-10-24 22:52:56 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 433 433 434 434 psArray* result = psArrayAlloc(nElements); 435 result->n = nElements;436 435 437 436 // now fill in the array with the hash hash's data -
trunk/psLib/src/types/psList.c
r9538 r9730 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.5 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-10- 13 21:13:48$8 * @version $Revision: 1.56 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-10-24 22:52:56 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 25 25 #define ITER_INIT_HEAD ((psPtr )1) // next iteration should return head 26 26 #define ITER_INIT_TAIL ((psPtr )2) // next iteration should return tail 27 28 #define INITIAL_NUM_ITERATORS 16 // Initial number of iterators to create 27 29 28 30 // private functions. … … 125 127 list->n = 0; 126 128 list->head = list->tail = NULL; 127 list->iterators = psArrayAlloc(16); 128 list->iterators->n = 0; 129 list->iterators = psArrayAllocEmpty(INITIAL_NUM_ITERATORS); 129 130 130 131 // create a default iterator … … 564 565 psArray* psListToArray(const psList* list) 565 566 { 566 psListElem* ptr; 567 psU32 n; 568 psArray* arr; 569 570 if (list == NULL) { 571 return NULL; 572 } 573 574 //XXX: Following is unnecessary as a list->n = 0 should do ArrayAlloc(0) I believe. 575 /* if (list->n > 0) { 576 arr = psArrayAlloc(list->n); 577 } else { 578 arr = psArrayAlloc(1); 579 } 580 */ 581 arr = psArrayAlloc(list->n); 582 arr->n = list->n; 583 584 ptr = list->head; 585 n = list->n; 567 PS_ASSERT_PTR_NON_NULL(list, NULL); 568 569 long n = list->n; 570 psArray *arr = psArrayAlloc(n); 571 572 psListElem *ptr = list->head; 586 573 for (psS32 i = 0; i < n; i++) { 587 574 arr->data[i] = psMemIncrRefCounter(ptr->data); -
trunk/psLib/src/types/psLookupTable.c
r9715 r9730 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1.4 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-10-2 2 00:51:05$9 * @version $Revision: 1.43 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-10-24 22:52:56 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii … … 36 36 #define MAX_STRING_LENGTH 256 37 37 #define ARRAY_STRIDE 16 38 38 #define INITIAL_NUM 10 // Initial number of elements 39 39 /******************************************************************************/ 40 40 /* TYPE DEFINITIONS */ … … 449 449 450 450 // Create output array and set array elements to zero 451 outputArray = psArrayAlloc(10); 452 outputArray->n = 0; 451 outputArray = psArrayAllocEmpty(INITIAL_NUM); 453 452 454 453 // Parse the format string to determine how many vectors … … 629 628 // Check if array is sorted on the index column 630 629 psVector* sortedIndex = psVectorAlloc(numRows,PS_TYPE_U32); 631 sortedIndex->n = numRows;632 630 sortedIndex = psVectorSortIndex(sortedIndex,indexColumnVector); 633 631 for(psS32 i = 0; i < numRows; i++ ) { … … 645 643 psS32 type = ((psVector*)(vectors->data[j]))->type.type; 646 644 newValueArray->data[j] = psVectorAlloc(numRows,type); 647 ((psVector*)(newValueArray->data[j]))->n = numRows;648 newValueArray->n++;649 645 } 650 646 -
trunk/psLib/src/types/psMetadataConfig.c
r9720 r9730 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.9 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-10-24 01:15:47$12 * @version $Revision: 1.96 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-10-24 22:52:56 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 47 47 /** Maximum size of a string */ 48 48 #define MAX_STRING_LENGTH 1024 49 #define INITIAL_LENGTH 10 // Initial length for arrays 49 50 50 51 /******************************************************************************/ … … 73 74 static psMetadata* setMetadataItem(psMetadata* template, char* linePtr) 74 75 ; 75 static void parseLevelInfoFree(p_psParseLevelInfo* info); 76 static psBool parseLine(psS32* level, psArray* levelArray, char* linePtr, psS32 lineCount, psBool overwrite); 77 static psBool parseMetadataItem(char* keyName, psS32* level, psArray* levelArray, char* linePtr, psS32 lineCount, psMetadataFlags flags); 76 static psBool parseLine(psS32* level, psArray* levelArray, char* linePtr, 77 psS32 lineCount, psBool overwrite); 78 static psBool parseMetadataItem(char* keyName, psS32* level, psArray* levelArray, 79 char* linePtr, psS32 lineCount, psMetadataFlags flags); 78 80 static psString formatMetadataItem(psMetadataItem *item); 79 81 static psArray *p_psMetadataKeyArray(psMetadata *md); 82 83 84 // A metadata data structure used in parsing arrays. 85 // Contains array information and the metadata storage location. 86 typedef struct 87 { 88 psArray* nonUniqueKeyArray; ///< non-unique key names 89 psArray* typeArray; ///< array of user defined types 90 psArray* templateArray; ///< array of user type templates 91 psMetadata* metadata; ///< metadata container 92 char* name; ///< name of key 93 } 94 p_psParseLevelInfo; 95 80 96 static void parseLevelInfoFree(p_psParseLevelInfo* info) 81 97 { … … 85 101 psFree(info->name); 86 102 psFree(info->metadata); 103 } 104 105 static p_psParseLevelInfo* p_psParseLevelInfoAlloc(void) 106 { 107 // Allocate memory for parse level info 108 p_psParseLevelInfo *info = (p_psParseLevelInfo*)psAlloc(sizeof(p_psParseLevelInfo)); 109 psMemSetDeallocator(info,(psFreeFunc)parseLevelInfoFree); 110 111 info->nonUniqueKeyArray = psArrayAllocEmpty(INITIAL_LENGTH); 112 info->typeArray = psArrayAllocEmpty(INITIAL_LENGTH); 113 info->templateArray = psArrayAllocEmpty(INITIAL_LENGTH); 114 info->metadata = NULL; 115 info->name = NULL; 116 117 return info; 87 118 } 88 119 … … 350 381 inString = saveValue; 351 382 end = NULL; 352 vec = psVectorAlloc (numValues, elemType);383 vec = psVectorAllocEmpty(numValues, elemType); 353 384 354 385 while(*inString!='\0') { … … 406 437 } 407 438 439 408 440 /*****************************************************************************/ 409 441 /* FUNCTION IMPLEMENTATION - PUBLIC */ 410 442 /*****************************************************************************/ 411 412 p_psParseLevelInfo* p_psParseLevelInfoAlloc(void)413 {414 415 p_psParseLevelInfo* info = NULL;416 417 // Allocate memory for parse level info418 info = (p_psParseLevelInfo*)psAlloc(sizeof(p_psParseLevelInfo));419 420 // If allocation successful then initialize members421 if(info != NULL) {422 423 info->nonUniqueKeyArray = psArrayAlloc(10);424 425 info->typeArray = psArrayAlloc(10);426 427 info->templateArray = psArrayAlloc(10);428 429 info->metadata = NULL;430 info->name = NULL;431 432 // Set memory deallocator433 psMemSetDeallocator(info,(psFreeFunc)parseLevelInfoFree);434 }435 return info;436 }437 443 438 444 bool psMetadataItemPrint(FILE * fd, … … 1220 1226 1221 1227 // Allocate array to store parse level information 1222 parseLevelInfoArray = psArrayAlloc (10);1228 parseLevelInfoArray = psArrayAllocEmpty(INITIAL_LENGTH); 1223 1229 1224 1230 // Set parse level info for the top level … … 1522 1528 PS_ASSERT_PTR_NON_NULL(md, NULL); 1523 1529 1524 psArray *keys = psArrayAlloc (psListLength(md->list));1530 psArray *keys = psArrayAllocEmpty(psListLength(md->list)); 1525 1531 1526 1532 // since we want to preserve the order of the keys in the metadata we can't -
trunk/psLib/src/types/psMetadataConfig.h
r9720 r9730 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-10-24 01:15:47$12 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-10-24 22:52:56 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 22 22 /// @addtogroup Metadata 23 23 /// @{ 24 25 /** A metadata data structure used in parsing arrays.26 *27 * Contains array information and the metadata storage location.28 */29 typedef struct30 {31 psArray* nonUniqueKeyArray; ///< non-unique key names32 psArray* typeArray; ///< array of user defined types33 psArray* templateArray; ///< array of user type templates34 psMetadata* metadata; ///< metadata container35 char* name; ///< name of key36 }37 p_psParseLevelInfo;38 39 /** Allocates a p_psParseLevelInfo structure40 *41 * @return p_psParseLevelInfo* : new p_psParseLevelInfo struct42 */43 p_psParseLevelInfo* p_psParseLevelInfoAlloc(void);44 24 45 25 /** Print metadata item to file.
Note:
See TracChangeset
for help on using the changeset viewer.
