IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 29, 2004, 5:48:15 PM (22 years ago)
Author:
evanalst
Message:

Add check for memory leaks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/dataManip/tst_psMatrix06.c

    r1073 r1348  
    11/** @file  tst_psMatrix_06.c
    2  *
    3  *  @brief Test driver for psMatrix Eigenvectors function
    4  *
    5  *  This test driver contains the following tests for psMatrix test point 6:
    6  *     A)  Create input and output images
    7  *     B)  Calculate Eigenvectors
    8  *     C)  Free input and output images
    9  *
    10  *  @author  Ross Harman, MHPCC
    11  *
    12  *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
    13  *  @date  $Date: 2004-06-23 23:00:17 $
    14  *
    15  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    16  *
    17  */
     2*
     3*  @brief Test driver for psMatrix Eigenvectors function
     4*
     5*  This test driver contains the following tests for psMatrix test point 6:
     6*     A)  Create input and output images
     7*     B)  Calculate Eigenvectors
     8*     C)  Free input and output images
     9*
     10*  @author  Ross Harman, MHPCC
     11*
     12*  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
     13*  @date  $Date: 2004-07-30 03:48:15 $
     14*
     15*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     16*
     17*/
    1818
    1919#include "pslib.h"
     
    2222#define PRINT_MATRIX(IMAGE)                         \
    2323for(int i=0; i<IMAGE->numRows; i++) {           \
    24     for(int j=0; j<IMAGE->numCols; j++) {       \
    25         printf("%f ", IMAGE->data.F64[i][j]);   \
    26     }                                          \
    27     printf("\n");                              \
    28 }
    29 
    30 
    31 int main(int argc,
    32          char* argv[])
     24        for(int j=0; j<IMAGE->numCols; j++) {       \
     25                printf("%f ", IMAGE->data.F64[i][j]);   \
     26            }                                          \
     27        printf("\n");                              \
     28    }
     29   
     30   
     31int main( int argc,
     32          char* argv[] )
    3333{
    34     psImage *outImage = NULL;
     34    psImage * outImage = NULL;
    3535    psImage *inImage = NULL;
    36 
    37 
     36   
     37   
    3838    // Test A - Create input and output images
    39     printPositiveTestHeader(stdout, "psMatrix", "Create input and output images");
    40     outImage = (psImage*)psImageAlloc(4, 4, PS_TYPE_F64);
    41     inImage = (psImage*)psImageAlloc(4, 4, PS_TYPE_F64);
    42 
    43     inImage->data.F64[0][0] = 1./1.;
    44     inImage->data.F64[0][1] = 1./2.;
    45     inImage->data.F64[0][2] = 1./3.;
    46     inImage->data.F64[0][3] = 1./4.;
    47 
    48     inImage->data.F64[1][0] = 1./2.;
    49     inImage->data.F64[1][1] = 1./3.;
    50     inImage->data.F64[1][2] = 1./4.;
    51     inImage->data.F64[1][3] = 1./5.;
    52 
    53     inImage->data.F64[2][0] = 1./3.;
    54     inImage->data.F64[2][1] = 1./4.;
    55     inImage->data.F64[2][2] = 1./5.;
    56     inImage->data.F64[2][3] = 1./6.;
    57 
    58     inImage->data.F64[3][0] = 1./4.;
    59     inImage->data.F64[3][1] = 1./5.;
    60     inImage->data.F64[3][2] = 1./6.;
    61     inImage->data.F64[3][3] = 1./7.;
    62 
    63     PRINT_MATRIX(inImage);
    64     printFooter(stdout, "psMatrix", "Create input and output images", true);
    65 
    66 
     39    printPositiveTestHeader( stdout, "psMatrix", "Create input and output images" );
     40    outImage = ( psImage* ) psImageAlloc( 4, 4, PS_TYPE_F64 );
     41    inImage = ( psImage* ) psImageAlloc( 4, 4, PS_TYPE_F64 );
     42   
     43    inImage->data.F64[ 0 ][ 0 ] = 1. / 1.;
     44    inImage->data.F64[ 0 ][ 1 ] = 1. / 2.;
     45    inImage->data.F64[ 0 ][ 2 ] = 1. / 3.;
     46    inImage->data.F64[ 0 ][ 3 ] = 1. / 4.;
     47   
     48    inImage->data.F64[ 1 ][ 0 ] = 1. / 2.;
     49    inImage->data.F64[ 1 ][ 1 ] = 1. / 3.;
     50    inImage->data.F64[ 1 ][ 2 ] = 1. / 4.;
     51    inImage->data.F64[ 1 ][ 3 ] = 1. / 5.;
     52   
     53    inImage->data.F64[ 2 ][ 0 ] = 1. / 3.;
     54    inImage->data.F64[ 2 ][ 1 ] = 1. / 4.;
     55    inImage->data.F64[ 2 ][ 2 ] = 1. / 5.;
     56    inImage->data.F64[ 2 ][ 3 ] = 1. / 6.;
     57   
     58    inImage->data.F64[ 3 ][ 0 ] = 1. / 4.;
     59    inImage->data.F64[ 3 ][ 1 ] = 1. / 5.;
     60    inImage->data.F64[ 3 ][ 2 ] = 1. / 6.;
     61    inImage->data.F64[ 3 ][ 3 ] = 1. / 7.;
     62   
     63    PRINT_MATRIX( inImage );
     64    printFooter( stdout, "psMatrix", "Create input and output images", true );
     65   
     66   
    6767    // Test B - Calculate Eigenvectors
    68     printPositiveTestHeader(stdout, "psMatrix", "Calculate Eigenvectors");
    69     psMatrixEigenvectors(outImage, inImage);
    70     PRINT_MATRIX(outImage);
    71     printFooter(stdout, "psMatrix", "Calculate Eigenvectors", true);
    72 
    73 
     68    printPositiveTestHeader( stdout, "psMatrix", "Calculate Eigenvectors" );
     69    psMatrixEigenvectors( outImage, inImage );
     70    PRINT_MATRIX( outImage );
     71    printFooter( stdout, "psMatrix", "Calculate Eigenvectors", true );
     72   
     73   
    7474    // Test C - Free input and output images
    75     printPositiveTestHeader(stdout, "psMatrix", "Free input and output images");
    76     psFree(outImage);
    77     psFree(inImage);
    78     psMemCheckLeaks(0, NULL, stdout);
    79     int nBad = psMemCheckCorruption(0);
    80     if(nBad) {
    81         printf("ERROR: Found %d bad memory blocks\n", nBad);
    82     }
    83     printFooter(stdout, "psMatrix" ,"Free input and output images", true);
    84 
     75    printPositiveTestHeader( stdout, "psMatrix", "Free input and output images" );
     76    psFree( outImage );
     77    psFree( inImage );
     78    int nLeaks = psMemCheckLeaks( 0, NULL, stdout );
     79    if ( nLeaks != 0 ) {
     80            printf( "ERROR: Found %d memory leaks\n", nLeaks );
     81        }
     82    int nBad = psMemCheckCorruption( 0 );
     83    if ( nBad ) {
     84            printf( "ERROR: Found %d bad memory blocks\n", nBad );
     85        }
     86    printFooter( stdout, "psMatrix" , "Free input and output images", true );
     87   
    8588    return 0;
    8689}
Note: See TracChangeset for help on using the changeset viewer.