IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2688


Ignore:
Timestamp:
Dec 10, 2004, 10:54:34 AM (22 years ago)
Author:
harman
Message:

Added support for psF32 types

File:
1 edited

Legend:

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

    r2392 r2688  
    1010*  @author  Ross Harman, MHPCC
    1111*
    12 *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
    13 *  @date  $Date: 2004-11-22 21:00:21 $
     12*  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
     13*  @date  $Date: 2004-12-10 20:54:34 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2020#include "psTest.h"
    2121
    22 #define PRINT_MATRIX(IMAGE)                         \
    23 for(psS32 i=0; i<IMAGE->numRows; i++) {           \
    24     for(psS32 j=0; j<IMAGE->numCols; j++) {       \
    25         printf("%f ", IMAGE->data.F64[i][j]);   \
    26     }                                          \
    27     printf("\n");                              \
     22#define TOLERANCE 0.000001
     23
     24#define CHECK_MATRIX(IMAGE)                                                                                  \
     25for(psU32 i=0; i<IMAGE->numRows; i++) {                                                                  \
     26    for(psU32 j=0; j<IMAGE->numCols; j++) {                                                              \
     27        if(IMAGE->type.type == PS_TYPE_F64) {                                                            \
     28            if(fabs(IMAGE->data.F64[i][j]-truthMatrix[i][j]) > TOLERANCE) {                              \
     29                printf("Matrix values at element %d, %d don't agree %lf vs %lf\n", i, j,                 \
     30                       IMAGE->data.F64[i][j], truthMatrix[i][j]);                                        \
     31            }                                                                                            \
     32        } else if(IMAGE->type.type == PS_TYPE_F32){                                                      \
     33            if(fabs(IMAGE->data.F32[i][j]-truthMatrix[i][j]) > TOLERANCE) {                              \
     34                printf("Matrix values at element %d, %d don't agree %f vs %lf\n", i, j,                  \
     35                       IMAGE->data.F32[i][j], truthMatrix[i][j]);                                        \
     36            }                                                                                            \
     37        }                                                                                                \
     38    }                                                                                                    \
    2839}
    2940
     
    3546    psImage *inImage1 = NULL;
    3647    psImage *inImage2 = NULL;
     48    psImage * outImage32 = NULL;
     49    psImage *inImage132 = NULL;
     50    psImage *inImage232 = NULL;
     51
     52    double truthMatrix[3][3] = {{ 8.000000, 20.000000},
     53                                {-4.000000, 11.000000}};
     54
     55
    3756
    3857
    3958    // Test A - Create input and output images
    40     printPositiveTestHeader( stdout, "psMatrix", "Create input and output images" );
    41     outImage = ( psImage* ) psImageAlloc( 2, 2, PS_TYPE_F64 );
    42     inImage1 = ( psImage* ) psImageAlloc( 2, 2, PS_TYPE_F64 );
    43     inImage2 = ( psImage* ) psImageAlloc( 2, 2, PS_TYPE_F64 );
    44     inImage1->data.F64[ 0 ][ 0 ] = 2;
    45     inImage1->data.F64[ 0 ][ 1 ] = 3;
    46     inImage1->data.F64[ 1 ][ 0 ] = -1;
    47     inImage1->data.F64[ 1 ][ 1 ] = 2;
    48     inImage2->data.F64[ 0 ][ 0 ] = 4;
    49     inImage2->data.F64[ 0 ][ 1 ] = 1;
    50     inImage2->data.F64[ 1 ][ 0 ] = 0;
    51     inImage2->data.F64[ 1 ][ 1 ] = 6;
    52     PRINT_MATRIX( inImage1 );
    53     printf( "\n" );
    54     PRINT_MATRIX( inImage2 );
     59    printPositiveTestHeader(stdout, "psMatrix", "Create input and output images");
     60    outImage = (psImage*) psImageAlloc(2, 2, PS_TYPE_F64);
     61    inImage1 = (psImage*) psImageAlloc(2, 2, PS_TYPE_F64);
     62    inImage2 = (psImage*) psImageAlloc(2, 2, PS_TYPE_F64);
     63    inImage1->data.F64[0][0] = 2;
     64    inImage1->data.F64[0][1] = 3;
     65    inImage1->data.F64[1][0] = -1;
     66    inImage1->data.F64[1][1] = 2;
     67    inImage2->data.F64[0][0] = 4;
     68    inImage2->data.F64[0][1] = 1;
     69    inImage2->data.F64[1][0] = 0;
     70    inImage2->data.F64[1][1] = 6;
     71    outImage32 = (psImage*)psImageAlloc(2, 2, PS_TYPE_F32);
     72    inImage132 = (psImage*)psImageAlloc(2, 2, PS_TYPE_F32);
     73    inImage232 = (psImage*)psImageAlloc(2, 2, PS_TYPE_F32);
     74    inImage132->data.F32[0][0] = 2;
     75    inImage132->data.F32[0][1] = 3;
     76    inImage132->data.F32[1][0] = -1;
     77    inImage132->data.F32[1][1] = 2;
     78    inImage232->data.F32[0][0] = 4;
     79    inImage232->data.F32[0][1] = 1;
     80    inImage232->data.F32[1][0] = 0;
     81    inImage232->data.F32[1][1] = 6;
    5582    printFooter( stdout, "psMatrix", "Create input and output images", true );
    5683
    5784
    5885    // Test B - Multiply images
    59     printPositiveTestHeader( stdout, "psMatrix", "Multiply images" );
    60     psMatrixMultiply( outImage, inImage1, inImage2 );
    61     PRINT_MATRIX( outImage );
    62     printFooter( stdout, "psMatrix", "Multiply images", true );
     86    printPositiveTestHeader(stdout, "psMatrix", "Multiply images");
     87    psMatrixMultiply(outImage, inImage1, inImage2);
     88    CHECK_MATRIX(outImage);
     89    psMatrixMultiply(outImage32, inImage132, inImage232);
     90    CHECK_MATRIX(outImage32);
     91    printFooter(stdout, "psMatrix", "Multiply images", true);
    6392
    6493
    6594    // Test C - Free input and output images
    6695    printPositiveTestHeader( stdout, "psMatrix", "Free input and output images" );
    67     psFree( outImage );
    68     psFree( inImage1 );
    69     psFree( inImage2 );
     96    psFree(outImage);
     97    psFree(inImage1);
     98    psFree(inImage2);
     99    psFree(outImage32);
     100    psFree(inImage132);
     101    psFree(inImage232);
    70102    psS32 nLeaks = psMemCheckLeaks( 0, NULL, stdout, false );
    71103    if ( nLeaks != 0 ) {
Note: See TracChangeset for help on using the changeset viewer.