IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5656


Ignore:
Timestamp:
Dec 1, 2005, 2:51:48 PM (21 years ago)
Author:
mberning
Message:

Added Support for different data typesCVS: ----------------------------------------------------------------------

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/mathtypes/tst_psVector.c

    r5137 r5656  
    1414 *  @author  Ross Harman, MHPCC
    1515 *
    16  *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
    17  *  @date  $Date: 2005-09-26 22:35:54 $
     16 *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
     17 *  @date  $Date: 2005-12-02 00:51:48 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2929static psS32 testVectorInit(void);
    3030static psS32 testVectorCreate(void);
     31static psS32 testVectorCreateA(void);
     32static psS32 testVectorCreateB(void);
    3133static psS32 testVectorGetSet(void);
    3234static psS32 testVectorCountPixelMask(void);
     
    3840                              {testVectorInit,-4,"psVectorInit",0,false},
    3941                              {testVectorCreate,-5,"psVectorCreate",0,false},
    40                               {testVectorGetSet,-6,"psVectorGet/Set",0,false},
    41                               {testVectorCountPixelMask,-7,"psVectorCountPixelMask",0,false},
     42                              {testVectorCreateA,-6,"psVectorCreateA",0,false},
     43                              {testVectorCreateB,-7,"psVectorCreateB",0,false},
     44                              {testVectorGetSet,-8,"psVectorGet/Set",0,false},
     45                              {testVectorCountPixelMask,-9,"psVectorCountPixelMask",0,false},
    4246                              {NULL}
    4347                          };
     
    371375    psVector *test2 = NULL;
    372376    psVector *input = NULL;
    373     psVector *input2 = psVectorAlloc(5, PS_TYPE_F64);
     377    psVector *input2 = psVectorAlloc(5, PS_TYPE_F32);
    374378
    375379    test = psVectorCreate(input, 0.0, 10.0, 1.0, PS_TYPE_S32);
     
    392396    return 0;
    393397}
    394 
     398psS32 testVectorCreateA(void)
     399{
     400    //
     401    //  Test PS_TYPE_F64
     402    //       PS_TYPE_S64
     403    //
     404    psVector *test = NULL;
     405    psVector *test2 = NULL;
     406    psVector *input = NULL;
     407    psVector *input2 = psVectorAlloc(5, PS_TYPE_F64);
     408
     409    test = psVectorCreate(input, 0.0, 10.0, 1.0, PS_TYPE_S64);
     410    test2 = psVectorCreate(input2, 0.0, 5.0, 0.5, PS_TYPE_F64);
     411
     412    for (int i = 0; i < 10; i++) {
     413        if (test->data.S64[i] != i) {
     414            fprintf(stderr, "Vector data does not match. i = %d, data=%ld\n",
     415                    i, (long)test->data.S64[i]);
     416            return 1;
     417        }
     418        if (test2->data.F64[i] != i*0.5) {
     419            fprintf(stderr, "Vector data does not match. i = %d, data=%f\n",
     420                    i, test->data.F64[i]);
     421            return 1;
     422        }
     423    }
     424    psFree(test);
     425    psFree(test2);
     426    return 0;
     427}
     428psS32 testVectorCreateB(void)
     429{
     430    //
     431    //  Test PS_TYPE_U16
     432    //       PS_TYPE_S16
     433    //
     434    psVector *test = NULL;
     435    psVector *test2 = NULL;
     436    psVector *input = NULL;
     437    psVector *input2 = psVectorAlloc(5, PS_TYPE_U16);
     438
     439    test = psVectorCreate(input, 0.0, 10.0, 1.0, PS_TYPE_S16);
     440    test2 = psVectorCreate(input2, 0.0, 20.0, 2.0, PS_TYPE_U16);
     441
     442    for (int i = 0; i < 10; i++) {
     443        if (test->data.S16[i] != i) {
     444            fprintf(stderr, "Vector data does not match. i = %d, data=%d\n",
     445                    i, test->data.S16[i]);
     446            return 1;
     447        }
     448        if (test2->data.U16[i] != i*2.0) {
     449            fprintf(stderr, "Vector data does not match. i = %d, data=%d\n",
     450                    i, test->data.U16[i]);
     451            return 1;
     452        }
     453    }
     454    psFree(test);
     455    psFree(test2);
     456    return 0;
     457}
    395458psS32 testVectorGetSet(void)
    396459{
Note: See TracChangeset for help on using the changeset viewer.