Changeset 610

Show
Ignore:
Timestamp:
09/13/09 23:14:24 (15 years ago)
Author:
smidl
Message:

rv returns name of a scalar at prespecified position

Location:
library
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/bdmbase.h

    r609 r610  
    181181                return NAMES ( ids ( at ) ); 
    182182        } 
     183        //! returns name of a scalar at position scalat, i.e. it can be in the middle of vector name, in that case it adds "_%d" to it 
     184        std::string scalarname ( int scalat ) const { 
     185                bdm_assert_debug(scalat<dsize,"Wrong input index"); 
     186                int id=0; 
     187                int scalid=0; 
     188                while (scalid+SIZES(ids(id))<=scalat)  { scalid+=SIZES(ids(id)); id++;}; 
     189                //now id is the id of variable of interest 
     190                if (size(id)==1) 
     191                        return  NAMES ( ids ( id ) ); 
     192                else 
     193                        return  NAMES ( ids ( id ) )+ "_" + num2str(scalat-scalid); 
     194 
     195        } 
    183196        void set_time ( int at, int time0 ) { 
    184197                times ( at ) = time0; 
  • library/tests/rv_test.cpp

    r604 r610  
    150150         
    151151        CHECK_EQUAL(uniq1.id(0), uniq2.id(0)); 
     152         
     153        // check scalarname 
     154        CHECK_EQUAL("a_in_test_rv_2", abc.scalarname(2)); 
     155        CHECK_EQUAL("b_in_test_rv_0", abc.scalarname(3)); 
    152156}