IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7579


Ignore:
Timestamp:
Jun 14, 2006, 4:29:12 PM (20 years ago)
Author:
drobbin
Message:

removed 'const' from ImageSet/VectorSet and worked on indice problem ([row][col] or [y][x])

Location:
trunk/psLib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/mathtypes/psImage.c

    r7533 r7579  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-06-13 19:53:54 $
     11 *  @version $Revision: 1.107 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-06-15 02:29:12 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    363363    #define IMAGE_SET_CASE(TYPE) \
    364364case PS_TYPE_##TYPE: \
    365     image->data.TYPE[y][x] = value; \
     365    image->data.TYPE[y][x] = (ps##TYPE)value; \
    366366    break;
    367367
     
    400400                "Invalid x-position %d.  Position out of range (%d-%d)\n",
    401401                x, image->col0, image->numCols+image->col0-1 );
    402         return false;
     402        return NAN;
    403403    } else if ( y >= (image->row0 + image->numRows) ) {
    404404        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
    405405                "Invalid y-position %d.  Position out of range (%d-%d)\n",
    406406                y, image->row0, image->numRows+image->row0-1 );
    407         return false;
     407        return NAN;
    408408    } else if (x < image->col0 && x >= 0) {
    409409        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
    410410                "Invalid x-position %d.  Position out of range (%d-%d)\n",
    411411                x, image->col0, image->numCols+image->col0-1 );
    412         return false;
     412        return NAN;
    413413    } else if (y < image->row0 && y >= 0) {
    414414        psError(PS_ERR_BAD_PARAMETER_SIZE, true,
    415415                "Invalid y-position %d.  Position out of range (%d-%d)\n",
    416416                y, image->row0, image->numRows+image->row0-1 );
    417         return false;
     417        return NAN;
    418418    } else if (x < 0 || y < 0) {
    419419        if (x < 0) {
     
    424424                    "Invalid x-position %d.  Position out of range (%d-%d)\n",
    425425                    (x+image->col0), image->col0, image->numCols+image->col0-1 );
    426             return false;
     426            return NAN;
    427427        }
    428428        if (y < 0) {
     
    433433                    "Invalid y-position %d.  Position out of range (%d-%d)\n",
    434434                    (y+image->row0), image->row0, image->numRows+image->row0-1 );
    435             return false;
     435            return NAN;
    436436        }
    437437    } else {
  • trunk/psLib/src/mathtypes/psImage.h

    r7553 r7579  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.78 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-06-14 01:29:16 $
     13 *  @version $Revision: 1.79 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-06-15 02:29:12 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    9393 */
    9494psImage* psImageAlloc(
    95     int numCols,                       ///< Number of rows in image.
    96     int numRows,                       ///< Number of columns in image.
     95    int numCols,                       ///< Number of columns in image.
     96    int numRows,                       ///< Number of rows in image.
    9797    psElemType type                    ///< Type of data for image.
    9898)
  • trunk/psLib/src/mathtypes/psVector.c

    r7255 r7579  
    99*  @author Robert DeSonia, MHPCC
    1010*
    11 *  @version $Revision: 1.75 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2006-06-01 01:00:03 $
     11*  @version $Revision: 1.76 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2006-06-15 02:29:12 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    873873}
    874874
    875 bool psVectorSet(const psVector *input,
     875bool psVectorSet(psVector *input,
    876876                 long position,
    877877                 double complex value)
     
    904904    switch (input->type.type) {
    905905    case PS_TYPE_U8:
    906         *(psU8*)&input->data.U8[position] = value;
     906        input->data.U8[position] = (psU8)value;
    907907        break;
    908908    case PS_TYPE_U16:
    909         *(psU16*)&input->data.U16[position] = value;
     909        input->data.U16[position] = (psU16)value;
    910910        break;
    911911    case PS_TYPE_U32:
    912         *(psU32*)&input->data.U32[position] = value;
     912        input->data.U32[position] = (psU32)value;
    913913        break;
    914914    case PS_TYPE_U64:
    915         *(psU64*)&input->data.U64[position] = value;
     915        input->data.U64[position] = (psU64)value;
    916916        break;
    917917    case PS_TYPE_S8:
    918         *(psS8*)&input->data.S8[position] = value;
     918        input->data.S8[position] = (psS8)value;
    919919        break;
    920920    case PS_TYPE_S16:
    921         *(psS16*)&input->data.S16[position] = value;
     921        input->data.S16[position] = (psS16)value;
    922922        break;
    923923    case PS_TYPE_S32:
    924         *(psS32*)&input->data.S32[position] = value;
     924        input->data.S32[position] = (psS32)value;
    925925        break;
    926926    case PS_TYPE_S64:
    927         *(psS64*)&input->data.S64[position] = value;
     927        input->data.S64[position] = (psS64)value;
    928928        break;
    929929    case PS_TYPE_F32:
    930         *(psF32*)&input->data.F32[position] = value;
     930        input->data.F32[position] = (psF32)value;
    931931        break;
    932932    case PS_TYPE_F64:
    933         *(psF64*)&input->data.F64[position] = value;
     933        input->data.F64[position] = (psF64)value;
    934934        break;
    935935    case PS_TYPE_C32:
    936         *(psC32*)&input->data.C32[position] = value;
     936        input->data.C32[position] = (psC32)value;
    937937        break;
    938938    case PS_TYPE_C64:
    939         *(psC64*)&input->data.C64[position] = value;
     939        input->data.C64[position] = (psC64)value;
    940940        break;
    941941    default:
  • trunk/psLib/src/mathtypes/psVector.h

    r6500 r7579  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-02-28 02:53:03 $
     13 *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-06-15 02:29:12 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    233233 */
    234234bool psVectorSet(
    235     const psVector *input,             ///< Input vector to set
     235    psVector *input,                   ///< Input vector to set
    236236    long position,                     ///< vector position
    237237    double complex value               ///< value to set
  • trunk/psLib/test/mathtypes/tst_psImage.c

    r6578 r7579  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2006-03-14 03:25:48 $
     8 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2006-06-15 02:29:12 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    361361{
    362362    psImage *image = NULL;
    363     image = psImageAlloc(5, 5, PS_TYPE_S32);
     363    image = psImageAlloc(5, 4, PS_TYPE_S32);
    364364
    365365    //Set the position of the subimage relative to the parent.
    366366    image->col0 = 10;
    367367    image->row0 = 10;
    368     for (int i = 0; i < 5; i++) {
     368    for (int i = 0; i < 4; i++) {
    369369        for (int j = 0; j < 5; j++) {
    370370            image->data.S32[i][j] = i+j;
     
    419419
    420420    //Try to set a position inside of the subimage.
    421     if ( !psImageSet(image, 13, 14, 666) ) {
     421    if ( !psImageSet(image, 14, 12, 666) ) {
    422422        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    423423                "psImageSet failed to return true when passed valid parameters.\n");
    424424        return 6;
    425     } else if (image->data.S32[3][4] != 666) {
    426         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    427                 "psImageSet failed to set the data values correctly.\n");
     425    }
     426    if (image->data.S32[2][4] != 666) {
     427        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     428                "psImageSet failed to set the data values correctly. value=%d\n", image->data.S32[2][4]);
    428429        return 7;
    429430    }
     
    433434                "psImageSet failed to return true when passed valid parameters.\n");
    434435        return 8;
    435     } else if  (image->data.S32[4][4] != 666) {
     436    } else if  (image->data.S32[3][4] != 666) {
    436437        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    437438                "psImageSet failed to set (from the tail) the data values correctly.\n");
    438         printf("\n value at 14,14 is %d\n", image->data.S32[4][4]);
     439        printf("\n value at 14,14 is %d\n", image->data.S32[3][4]);
    439440        return 9;
    440441    }
     
    477478{
    478479    psImage *image = NULL;
    479     image = psImageAlloc(5, 5, PS_TYPE_S32);
     480    image = psImageAlloc(5, 3, PS_TYPE_S32);
    480481
    481482    //Set the position of the subimage relative to the parent.
    482483    image->col0 = 10;
    483484    image->row0 = 10;
    484     for (int i = 0; i < 5; i++) {
     485    for (int i = 0; i < 3; i++) {
    485486        for (int j = 0; j < 5; j++) {
    486487            image->data.S32[i][j] = i+j;
     
    535536
    536537    //Try to get a position inside of the subimage.
    537     if ( psImageGet(image, 13, 14) != 7 ) {
     538    if ( psImageGet(image, 14, 12) != 6 ) {
    538539        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    539540                "psImageGet failed to return the correct value.\n");
     
    541542    }
    542543    //Try to get a position inside of the subimage from the tail.
    543     if ( psImageGet(image, -1, -1) != 8 ) {
     544    if ( psImageGet(image, -1, -1) != 6 ) {
    544545        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    545546                "psImageGet failed to return the correct value.\n");
     
    549550    //Try to get a position outside of the subimage but inside of the parent image.
    550551    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    551     if ( isnan( psImageGet(image, 1, 1) ) ) {
     552    if ( !isnan( psImageGet(image, 1, 1) ) ) {
    552553        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    553554                "psImageGet failed to return NAN when passed an invalid location.\n");
     
    555556    }
    556557    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    557     if ( isnan( psImageGet(image, 9, 10) ) ) {
     558    if ( !isnan( psImageGet(image, 9, 10) ) ) {
    558559        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    559560                "psImageGet failed to return NAN when passed an invalid location.\n");
     
    563564    //Try to set a position outside of the subimage.
    564565    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    565     if ( isnan( psImageGet(image, 15, 14) ) ) {
     566    if ( !isnan( psImageGet(image, 15, 14) ) ) {
    566567        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    567568                "psImageGet failed to return NAN when passed an invalid location.\n");
     
    570571    //Try to set a position outside of the subimage, indexing from the tail.
    571572    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    572     if ( isnan( psImageGet(image, -6, -1) ) ) {
     573    if ( !isnan( psImageGet(image, -6, -1) ) ) {
    573574        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    574575                "psImageGet failed to return NAN when passed an invalid location.\n");
Note: See TracChangeset for help on using the changeset viewer.