Changeset 2441 for branches/newmole

Show
Ignore:
Timestamp:
11/04/08 14:35:50 (2 months ago)
Author:
rjrw
Message:

Remove get_const_address -- switch throughout mole_solve.cpp to the
more general get_ptr shim.

Location:
branches/newmole/source
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/newmole/source/cddefines.h

    r2440 r2441  
    15611561/**get_ptr attribute shim to get raw pointer to contained data with 
    15621562 * correct type */ 
     1563template<class T> inline T* get_ptr(T *v) 
     1564{ 
     1565        return v; 
     1566} 
    15631567template<class T> inline T* get_ptr(valarray<T> &v) 
    15641568{ 
     
    15771581  return const_cast<const T*>(&const_cast<vector<T>&>(v)[0]); 
    15781582} 
    1579  
    15801583 
    15811584/************************************************************************** 
  • branches/newmole/source/mole.h

    r2430 r2441  
    192192extern struct chem_element_s *element_list[LIMELM]; 
    193193 
    194 template<class T> inline const T* get_const_address(const valarray<T> &v) 
    195 { 
    196         return const_cast<const T*>(&const_cast<valarray<T>&>(v)[0]); 
    197 } 
    198 template<class T> inline const T* get_const_address(const vector<T> &v) 
    199 { 
    200         return const_cast<const T*>(&const_cast<vector<T>&>(v)[0]); 
    201 } 
    202  
    203194#endif /* _MOLE_H_ */ 
  • branches/newmole/source/mole_solve.cpp

    r2426 r2441  
    105105                nPrevBad = nBad; 
    106106 
    107                 MoleMap.setup(&oldmols[0]); 
    108  
    109                 grouped_elems(&oldmols[0],molElems); 
     107                MoleMap.setup(get_ptr(oldmols)); 
     108 
     109                grouped_elems(get_ptr(oldmols),molElems); 
    110110                 
    111111                long j; 
     
    117117                        if (0) 
    118118                        { 
    119                                 grouped_elems(&newmols[0],molElemsNew); 
     119                                grouped_elems(get_ptr(newmols),molElemsNew); 
    120120                                for (long nelem=0; nelem <LIMELM; nelem++) 
    121121                                { 
     
    358358                 (c[][], first iteration) from reaction list */ 
    359359         
    360         mole_eval_dynamic_balance(mole.num_total,&b[0],lgJac,c);         
     360        mole_eval_dynamic_balance(mole.num_total,get_ptr(b),lgJac,c);    
    361361         
    362362        /*------------------------------------------------------------------ */ 
     
    518518                        double molnow[LIMELM]; 
    519519 
    520                         grouped_elems(get_const_address(b2vec), molnow); 
     520                        grouped_elems(get_ptr(b2vec), molnow); 
    521521 
    522522                        iamax = 0; 
     
    742742        if (0)  
    743743        { 
    744                 grouped_elems(&ervals[0],molElemsNew); 
     744                grouped_elems(get_ptr(ervals),molElemsNew); 
    745745                for ( long nelem=0; nelem<LIMELM; nelem++) 
    746746                {