IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 9, 2004, 11:00:39 AM (22 years ago)
Author:
harman
Message:

Added F32 types

File:
1 edited

Legend:

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

    r2392 r2674  
    66*     A)  Create input and output images
    77*     B)  Transpose input image into output image
    8 *     C)  Transpose input image into auto allocated NULL output image 
     8*     C)  Transpose input image into auto allocated NULL output image
    99*     D)  Free images and check for leaks
    1010*
    1111*  @author  Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
    14 *  @date  $Date: 2004-11-22 21:00:21 $
     13*  @version $Revision: 1.9 $  $Name: not supported by cvs2svn $
     14*  @date  $Date: 2004-12-09 21:00:39 $
    1515*
    1616*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2222
    2323#define PRINT_MATRIX(IMAGE)                         \
    24 for(psS32 i=IMAGE->numRows-1; i>-1; i--) {        \
    25     for(psS32 j=0; j<IMAGE->numCols; j++) {       \
    26         printf("%f ", IMAGE->data.F64[i][j]);   \
    27     }                                          \
    28     printf("\n");                              \
    29 }
     24for(psS32 i=0; i<IMAGE->numRows; i++) {             \
     25    for(psS32 j=0; j<IMAGE->numCols; j++) {         \
     26        if(IMAGE->type.type == PS_TYPE_F64) {       \
     27            printf("%lf ", IMAGE->data.F64[i][j]);  \
     28        } else {                                    \
     29            printf("%f ", IMAGE->data.F32[i][j]);   \
     30        }                                           \
     31    }                                               \
     32    printf("\n");                                   \
     33}                                                   \
     34printf("\n")
    3035
    31 psS32 main( psS32 argc,
    32             char* argv[] )
     36psS32 main( psS32 argc, char* argv[] )
    3337{
    3438    psImage * tempImage = NULL;
     
    3640
    3741    // Test A - Create input and output images
    38     printPositiveTestHeader( stdout, "psMatrix", "Create input and output images" );
    39     psImage *inImage = ( psImage* ) psImageAlloc( 3, 3, PS_TYPE_F64 );
    40     psImage *outImage = ( psImage* ) psImageAlloc( 3, 3, PS_TYPE_F64 );
    41     inImage->data.F64[ 0 ][ 0 ] = 1;
    42     inImage->data.F64[ 0 ][ 1 ] = 2;
    43     inImage->data.F64[ 0 ][ 2 ] = 3;
    44     inImage->data.F64[ 1 ][ 0 ] = 4;
    45     inImage->data.F64[ 1 ][ 1 ] = 5;
    46     inImage->data.F64[ 1 ][ 2 ] = 6;
    47     inImage->data.F64[ 2 ][ 0 ] = 7;
    48     inImage->data.F64[ 2 ][ 1 ] = 8;
    49     inImage->data.F64[ 2 ][ 2 ] = 9;
    50     PRINT_MATRIX( inImage );
    51     printFooter( stdout, "psMatrix", "Create input and output images", true );
     42    printPositiveTestHeader(stdout, "psMatrix", "Create input and output images");
     43    psImage *inImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
     44    psImage *outImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
     45    inImage->data.F64[0][0] = 1;
     46    inImage->data.F64[0][1] = 2;
     47    inImage->data.F64[0][2] = 3;
     48    inImage->data.F64[1][0] = 4;
     49    inImage->data.F64[1][1] = 5;
     50    inImage->data.F64[1][2] = 6;
     51    inImage->data.F64[2][0] = 7;
     52    inImage->data.F64[2][1] = 8;
     53    inImage->data.F64[2][2] = 9;
     54    psImage *inImageF32 = (psImage*)psImageAlloc(3, 3, PS_TYPE_F32);
     55    psImage *outImageF32 = (psImage*)psImageAlloc(3, 3, PS_TYPE_F32);
     56    inImageF32->data.F32[0][0] = 1;
     57    inImageF32->data.F32[0][1] = 2;
     58    inImageF32->data.F32[0][2] = 3;
     59    inImageF32->data.F32[1][0] = 4;
     60    inImageF32->data.F32[1][1] = 5;
     61    inImageF32->data.F32[1][2] = 6;
     62    inImageF32->data.F32[2][0] = 7;
     63    inImageF32->data.F32[2][1] = 8;
     64    inImageF32->data.F32[2][2] = 9;
     65    PRINT_MATRIX(inImage);
     66    PRINT_MATRIX(inImageF32);
     67    printFooter(stdout, "psMatrix", "Create input and output images", true);
    5268
    5369
    5470    // Test B - Transpose input image into output image
    55     printPositiveTestHeader( stdout, "psMatrix", "Transpose input image into output image" );
     71    printPositiveTestHeader(stdout, "psMatrix", "Transpose input image into output image");
    5672    tempImage = outImage;
    57     outImage = psMatrixTranspose( outImage, inImage );
    58     PRINT_MATRIX( outImage );
    59     if ( outImage->type.dimen != PS_DIMEN_IMAGE ) {
    60         printf( "Error: Resulting image is not PS_DIMEN_IMAGE\n" );
    61     } else
    62         if ( outImage != tempImage ) {
    63             printf( "Error: Return pointer not equal to output argument pointer\n" );
    64         }
    65     printFooter( stdout, "psMatrix", "Transpose input image into output image", true );
     73    outImage = psMatrixTranspose(outImage, inImage);
     74    PRINT_MATRIX(outImage);
     75    if (outImage->type.dimen != PS_DIMEN_IMAGE) {
     76        printf( "Error: Resulting image is not PS_DIMEN_IMAGE\n");
     77    } else if (outImage != tempImage) {
     78        printf("Error: Return pointer not equal to output argument pointer\n");
     79    }
     80
     81    tempImage = outImageF32;
     82    outImageF32 = psMatrixTranspose(outImageF32, inImageF32);
     83    PRINT_MATRIX(outImageF32);
     84    if (outImageF32->type.dimen != PS_DIMEN_IMAGE) {
     85        printf("Error: Resulting image is not PS_DIMEN_IMAGE\n");
     86    } else if (outImageF32 != tempImage) {
     87        printf("Error: Return pointer not equal to output argument pointer\n");
     88    }
     89    printFooter(stdout, "psMatrix", "Transpose input image into output image", true);
    6690
    6791
    68     // Test C -  Transpose input image into auto allocated NULL output image
    69     printPositiveTestHeader( stdout, "psMatrix", "ranspose input image into auto allocated NULL output image" );
     92    // Test C - Transpose input image into auto allocated NULL output image
     93    printPositiveTestHeader(stdout, "psMatrix", "Transpose input image into auto allocated NULL output image");
    7094    psImage *outImageNull = NULL;
    71     outImageNull = psMatrixTranspose( outImageNull, inImage );
    72     PRINT_MATRIX( outImageNull );
    73     printFooter( stdout, "psMatrix", "ranspose input image into auto allocated NULL output image", true );
     95    outImageNull = psMatrixTranspose(outImageNull, inImage);
     96    PRINT_MATRIX(outImageNull);
     97
     98    psImage *outImageNullF32 = NULL;
     99    outImageNullF32 = psMatrixTranspose(outImageNullF32, inImageF32);
     100    PRINT_MATRIX(outImageNullF32);
     101    printFooter(stdout, "psMatrix", "Transpose input image into auto allocated NULL output image", true);
    74102
    75103
    76104    // Test D - Free images and check for leaks
    77     printPositiveTestHeader( stdout, "psMatrix", "Free images and check for leaks" );
    78     psFree( inImage );
    79     psFree( outImage );
    80     psFree( outImageNull );
    81     psS32 nLeaks = psMemCheckLeaks( 0, NULL, stdout, false );
    82     if ( nLeaks != 0 ) {
    83         printf( "ERROR: Found %d memory leaks\n", nLeaks );
     105    printPositiveTestHeader(stdout, "psMatrix", "Free images and check for leaks");
     106    psFree(inImage);
     107    psFree(outImage);
     108    psFree(outImageNull);
     109    psFree(inImageF32);
     110    psFree(outImageF32);
     111    psFree(outImageNullF32);
     112    psS32 nLeaks = psMemCheckLeaks(0, NULL, stdout, false);
     113    if (nLeaks != 0) {
     114        printf("ERROR: Found %d memory leaks\n", nLeaks);
    84115    }
    85     psS32 nBad = psMemCheckCorruption( 0 );
    86     if ( nBad ) {
    87         printf( "ERROR: Found %d bad memory blocks\n", nBad );
     116    psS32 nBad = psMemCheckCorruption(0);
     117    if (nBad) {
     118        printf("ERROR: Found %d bad memory blocks\n", nBad);
    88119    }
    89     printFooter( stdout, "psMatrix" , "Free images and check for leaks", true );
     120    printFooter(stdout, "psMatrix" , "Free images and check for leaks", true);
    90121
    91122    return 0;
Note: See TracChangeset for help on using the changeset viewer.