Changeset 2220 for trunk/psLib/src/math/psStats.c
- Timestamp:
- Oct 27, 2004, 11:55:09 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psStats.c
r2217 r2220 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.7 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10-27 21: 06:30$11 * @version $Revision: 1.75 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-27 21:55:09 $ 13 13 n * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 1437 1437 psHistogram* psHistogramAlloc(float lower, float upper, psS32 n) 1438 1438 { 1439 PS_INT_CHECK_POSITIVE(n, NULL); 1440 PS_FLOAT_COMPARE(lower, upper, NULL); 1441 1439 1442 psS32 i = 0; // Loop index variable 1440 1443 psHistogram* newHist = NULL; // The new histogram structure 1441 1444 float binSize = 0.0; // The histogram bin size 1442 1445 1443 // NOTE: Verify that this is the correct action.1444 if (n == 0) {1445 return (NULL);1446 }1447 if (n < 0) {1448 psAbort(__func__, "psHistogramAlloc() called with bin size %d.\n", n);1449 }1450 // NOTE: Verify that this is the correct action.1451 if (lower > upper) {1452 return (NULL);1453 }1454 1446 // Allocate memory for the new histogram structure. If there are N 1455 1447 // bins, then there are N+1 bounds to those bins. … … 1494 1486 psHistogram* psHistogramAllocGeneric(const psVector* restrict bounds) 1495 1487 { 1488 PS_VECTOR_CHECK_NULL(bounds, NULL); 1489 PS_VECTOR_CHECK_TYPE(bounds, PS_TYPE_F32, NULL); 1490 PS_INT_COMPARE(bounds->n, 2, NULL); 1491 1496 1492 psHistogram* newHist = NULL; // The new histogram structure 1497 1493 psS32 i; // Loop index variable 1498 1494 1499 // NOTE: Verify that this is the correct action.1500 if (bounds == NULL) {1501 // psAbort(__func__, "psHistogram requested with NULL bounds");1502 return (NULL);1503 }1504 // NOTE: Verify that this is the correct action.1505 if (bounds->n <= 1) {1506 // psAbort(__func__, "psHistogram requested with NULL bounds");1507 return (NULL);1508 }1509 1510 if (bounds->type.type != PS_TYPE_F32) {1511 // psAbort(__func__, "psHistogram request a bound which is not type F32");1512 return (NULL);1513 }1514 1495 // Allocate memory for the new histogram structure. 1515 1496 newHist = (psHistogram* ) psAlloc(sizeof(psHistogram)); … … 1562 1543 psU32 maskVal) 1563 1544 { 1545 PS_PTR_CHECK_NULL(out, NULL); 1546 PS_VECTOR_CHECK_TYPE(out->bounds, PS_TYPE_F32, NULL); 1547 PS_VECTOR_CHECK_TYPE(out->nums, PS_TYPE_U32, NULL); 1548 PS_VECTOR_CHECK_NULL(in, NULL); 1549 if (mask != NULL) { 1550 PS_VECTOR_CHECK_SIZE_EQUAL(in, mask, NULL); 1551 PS_VECTOR_CHECK_TYPE(mask, PS_TYPE_U8, NULL); 1552 } 1553 1564 1554 psS32 i = 0; // Loop index variable 1565 1555 float binSize = 0.0; // Histogram bin size … … 1571 1561 psVector* inF32; 1572 1562 psS32 mustFreeTmp = 1; 1573 1574 // NOTE: Verify that this is the correct action.1575 if (out == NULL) {1576 return (NULL);1577 }1578 // Check the specified output histogram for type psF321579 if (out->bounds->type.type != PS_TYPE_F32) {1580 psAbort(__func__, "Only data type PS_TYPE_F32 for the output.bounds member.");1581 }1582 1583 if (out->nums->type.type != PS_TYPE_U32) {1584 psAbort(__func__, "Only data type PS_TYPE_U32 for out->nums member.");1585 }1586 // NOTE: Verify that this is the correct action.1587 if (in == NULL) {1588 return (out);1589 }1590 1591 if (mask != NULL) {1592 if (in->n != mask->n) {1593 psError(__func__, "Vector data and vector mask are of different sizes.");1594 }1595 if (mask->type.type != PS_TYPE_U8) {1596 psError(__func__, "Vector mask must be type PS_TYPE_U8");1597 }1598 }1599 1600 1563 inF32 = p_psConvertToF32((psVector *) in); 1601 1564 if (inF32 == NULL) { … … 1721 1684 psU32 maskVal) 1722 1685 { 1686 PS_PTR_CHECK_NULL(stats, NULL); 1687 PS_VECTOR_CHECK_NULL(in, NULL); 1688 if (mask != NULL) { 1689 PS_VECTOR_CHECK_SIZE_EQUAL(mask, in, NULL); 1690 PS_VECTOR_CHECK_TYPE(mask, PS_TYPE_U8, NULL); 1691 } 1723 1692 psVector* inF32; 1724 1693 psS32 mustFreeTmp = 1; 1725 1726 if (in == NULL) {1727 psError(__func__, "in is NULL\n");1728 return(stats);1729 }1730 PS_PTR_CHECK_NULL(stats, NULL);1731 1694 1732 1695 inF32 = p_psConvertToF32((psVector *) in); … … 1735 1698 mustFreeTmp = 0; 1736 1699 } 1700 1737 1701 if ((stats->options & PS_STAT_USE_RANGE) && (stats->min >= stats->max)) { 1738 psError(__func__, "psVectorStats() called with range: %f to %f\n", stats->min, stats->max); 1739 return(stats); 1740 } 1741 1742 if (mask != NULL) { 1743 PS_VECTOR_CHECK_SIZE_EQUAL(mask, in, NULL); 1744 PS_VECTOR_CHECK_TYPE(mask, PS_TYPE_U8, NULL); 1745 } 1702 PS_FLOAT_COMPARE(stats->max, stats->min, stats); 1703 } 1704 1746 1705 // ************************************************************************ 1747 1706 if (stats->options & PS_STAT_SAMPLE_MEAN) {
Note:
See TracChangeset
for help on using the changeset viewer.
