IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 7, 2004, 4:48:01 PM (22 years ago)
Author:
desonia
Message:

fixed psBinaryOp/psUnaryOp to handle the out parameter in a manner like
other functions. Also expanded the types supported to all numeric types.

File:
1 edited

Legend:

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

    r1648 r2021  
    1515 *  @author  Ross Harman, MHPCC
    1616 *
    17  *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
    18  *  @date  $Date: 2004-08-27 23:31:35 $
     17 *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
     18 *  @date  $Date: 2004-10-08 02:48:01 $
    1919 *
    2020 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8686    printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Check for NULL arguments",
    8787                            "Null XXX argument", 0);
    88     psBinaryOp(NULL, image1, "+", image2);
    89     psBinaryOp(image2, NULL, "+", image2);
    90     psBinaryOp(image2, image1, "+", NULL);
    91     psBinaryOp(image2, image1, NULL, image2);
    92     psUnaryOp(NULL, image1, "sin");
    93     psUnaryOp(image2, NULL, "sin");
    94     psUnaryOp(image2, image1, NULL);
    95     printFooter(stdout, "psBitSet", "Check for NULL arguments", true);
    96 
     88    psImage* image6 = (psImage*)psBinaryOp(NULL, image1, "+", image2);
     89    if (image6 == NULL) {
     90        psLogMsg(__func__,PS_LOG_ERROR,"psBinaryOp failed to make an image given no output to recycle.");
     91        return 1;
     92    }
     93
     94    image6 = (psImage*)psBinaryOp(image6, NULL, "+", image2);
     95    if (image6 != NULL) {
     96        psLogMsg(__func__,PS_LOG_ERROR,"psBinaryOp returned a result given a NULL first operand.");
     97        return 2;
     98    }
     99
     100    image6 = (psImage*)psBinaryOp(image6, image1, "+", NULL);
     101    if (image6 != NULL) {
     102        psLogMsg(__func__,PS_LOG_ERROR,"psBinaryOp returned a result given a NULL second operand.");
     103        return 3;
     104    }
     105    image6 = (psImage*)psBinaryOp(image6, image1, NULL, image2);
     106    if (image6 != NULL) {
     107        psLogMsg(__func__,PS_LOG_ERROR,"psBinaryOp returned a result given a NULL operator.");
     108        return 4;
     109    }
     110
     111    image6 = (psImage*)psUnaryOp(NULL, image1, "sin");
     112    if (image6 == NULL) {
     113        psLogMsg(__func__,PS_LOG_ERROR,"psUnaryOp failed to make an image given no output to recycle.");
     114        return 5;
     115    }
     116
     117    image6 = (psImage*)psUnaryOp(image6, NULL, "sin");
     118    if (image6 != NULL) {
     119        psLogMsg(__func__,PS_LOG_ERROR,"psUnaryOp returned a result given a NULL operand.");
     120        return 6;
     121    }
     122
     123    image6 = (psImage*)psUnaryOp(image6, image1, NULL);
     124    if (image6 != NULL) {
     125        psLogMsg(__func__,PS_LOG_ERROR,"psUnaryOp returned a result given a NULL operator.");
     126        return 7;
     127    }
     128
     129    printFooter(stdout, "psMatrixVectorArithmetic", "Check for NULL arguments", true);
    97130
    98131    // Inconsistent element types
    99132    printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Inconsistent element types",
    100133                            "Element types for arguments inconsistent", 0);
    101     psBinaryOp(image2, image3, "+", image2);
    102     psUnaryOp(image2, image3, "sin");
    103     printFooter(stdout, "psBitSet", "Inconsistent element types", true);
     134    image6 = (psImage*)psBinaryOp(image6, image3, "+", image2);
     135    if (image6 != NULL) {
     136        psLogMsg(__func__,PS_LOG_ERROR,"psBinaryOp returned a result given operands of different types.");
     137        return 8;
     138    }
     139
     140    image6 = psImageCopy(image6,image2,PS_TYPE_F64);
     141    image6 = (psImage*)psUnaryOp(image6, image3, "sin");
     142    if (image6 == NULL || image6->type.type != PS_TYPE_F32) {
     143        psLogMsg(__func__,PS_LOG_ERROR,"psUnaryOp failed to convert the type of the output.");
     144        return 9;
     145    }
     146
     147    printFooter(stdout, "psMatrixVectorArithmetic", "Inconsistent element types", true);
    104148
    105149
     
    107151    printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Inconsistent element count",
    108152                            "Inconsistent element count", 0);
    109     psBinaryOp(image2, image4, "+", image2);
    110     psUnaryOp(image2, image4, "sin");
    111     psBinaryOp(image2, vector1, "+", image2);
     153    image6 = (psImage*)psBinaryOp(image6, image4, "+", image2);
     154    if (image6 != NULL) {
     155        psLogMsg(__func__,PS_LOG_ERROR,"psBinaryOp returned a result given operands of different sizes.");
     156        return 10;
     157    }
     158
     159    image6 = psImageCopy(image6,image2,PS_TYPE_F64);
     160    image6 = (psImage*)psUnaryOp(image6, image4, "sin");
     161    if (image6 == NULL ||
     162            image6->numCols != image6->numCols ||
     163            image6->numRows != image6->numRows) {
     164        psLogMsg(__func__,PS_LOG_ERROR,"psUnaryOp failed to resize the output.");
     165        return 11;
     166    }
     167
     168    image6 = (psImage*)psBinaryOp(image6, vector1, "+", image2);
     169    if (image6 != NULL) {
     170        psLogMsg(__func__,PS_LOG_ERROR,"psBinaryOp returned a result given operands of different sizes.");
     171        return 12;
     172    }
     173
    112174    vector1->type.dimen = PS_DIMEN_TRANSV;
    113     psBinaryOp(image2, vector1, "+", image2);
    114     printFooter(stdout, "psBitSet", "Inconsistent element count", true);
     175    image6 = (psImage*)psBinaryOp(image6, vector1, "+", image2);
     176    if (image6 != NULL) {
     177        psLogMsg(__func__,PS_LOG_ERROR,"psBinaryOp returned a result given operands of different sizes.");
     178        return 13;
     179    }
     180    printFooter(stdout, "psMatrixVectorArithmetic", "Inconsistent element count", true);
    115181
    116182
     
    118184    printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Inconsistent dimensionality",
    119185                            "Dimensionality for arguments inconsistent", 0);
    120     psUnaryOp(image2, vector2, "sin");
    121     printFooter(stdout, "psBitSet", "Inconsistent dimensionality", true);
    122 
    123 
    124     // Division by zero
    125     printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Divide by zero",
    126                             "Divide by zero", 0);
    127     psBinaryOp(image1, image1, "/", image2);
    128     printFooter(stdout, "psBitSet", "Division by zero", true);
    129 
     186    image6 = psImageCopy(image6,image2,PS_TYPE_F64);
     187    image6 = (psImage*)psUnaryOp(image6, vector2, "sin");
     188    if (image6 != NULL) {
     189        psLogMsg(__func__,PS_LOG_ERROR,"psUnaryOp returned result given wrong type out parameter.");
     190        return 14;
     191    }
     192
     193    printFooter(stdout, "psMatrixVectorArithmetic", "Inconsistent dimensionality", true);
    130194
    131195    // Attempt to use min with complex numbers
    132196    printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Use min with complex numbers",
    133197                            "Minimum operation not supported for complex numbers", 0);
    134     psBinaryOp(image5, image5, "min", image5);
    135     printFooter(stdout, "psBitSet", "Use min with complex numbers", true);
     198    image6 = (psImage*)psBinaryOp(image6, image5, "min", image5);
     199    printFooter(stdout, "psMatrixVectorArithmetic", "Use min with complex numbers", true);
    136200
    137201
     
    139203    printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Use max with complex numbers",
    140204                            "Maximum operation not supported for complex numbers", 0);
    141     psBinaryOp(image5, image5, "max", image5);
    142     printFooter(stdout, "psBitSet", "Use max with complex numbers", true);
     205    image6 = (psImage*)psBinaryOp(image6, image5, "max", image5);
     206    printFooter(stdout, "psMatrixVectorArithmetic", "Use max with complex numbers", true);
    143207
    144208
     
    146210    printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Invalid operation",
    147211                            "Invalid operation", 0);
    148     psBinaryOp(image1, image1, "yarg", image2);
    149     psUnaryOp(image2, image1, "yarg");
    150     printFooter(stdout, "psBitSet", "Invalid operation", true);
     212    image6 = (psImage*)psBinaryOp(image6, image1, "yarg", image2);
     213    image6 = (psImage*)psUnaryOp(image6, image1, "yarg");
     214    printFooter(stdout, "psMatrixVectorArithmetic", "Invalid operation", true);
    151215
    152216    return 0;
Note: See TracChangeset for help on using the changeset viewer.