fei_FillableVec.cpp

00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #include "fei_FillableVec.hpp"
00010 
00011 namespace fei {
00012 
00013 FillableVec::FillableVec()
00014  : vecdata_()
00015 {
00016 }
00017 
00018 FillableVec::~FillableVec()
00019 {
00020 }
00021 
00022 void
00023 FillableVec::addEntries(unsigned numEntries,
00024                   const double* coefs,
00025                   const int* indices)
00026 {
00027   for(unsigned i=0; i<numEntries; ++i) {
00028     addEntry(indices[i], coefs[i]);
00029   }
00030 }
00031 
00032 void
00033 FillableVec::putEntries(unsigned numEntries,
00034                   const double* coefs,
00035                   const int* indices)
00036 {
00037   for(unsigned i=0; i<numEntries; ++i) {
00038     putEntry(indices[i], coefs[i]);
00039   }
00040 }
00041 
00042 void
00043 FillableVec::setValues(double value)
00044 {
00045   if (size() > 0) {
00046     feipoolmap::iterator iter = vecdata_.begin(), iter_end = vecdata_.end();
00047     for(; iter != iter_end; ++iter) {
00048       iter->second = value;
00049     }
00050   }
00051 }
00052 
00053 void
00054 FillableVec::clear()
00055 {
00056   vecdata_.clear();
00057 }
00058 
00059 unsigned
00060 FillableVec::size() const
00061 {
00062   return vecdata_.size();
00063 }
00064 
00065 bool
00066 FillableVec::hasEntry(int index) const
00067 {
00068   feipoolmap::const_iterator iter = vecdata_.find(index);
00069   return iter != vecdata_.end();
00070 }
00071 
00072 double
00073 FillableVec::getEntry(int index) const
00074 {
00075   feipoolmap::const_iterator iter = vecdata_.find(index);
00076   if (iter == vecdata_.end()) {
00077     throw std::runtime_error("FillableVec::getEntry: index not found.");
00078   }
00079 
00080   return iter->second;
00081 }
00082 
00083 void
00084 FillableVec::removeEntry(int index)
00085 {
00086   feipoolmap::iterator iter = vecdata_.find(index);
00087   if (iter != vecdata_.end()) {
00088     vecdata_.erase(iter);
00089   }
00090 }
00091 
00092 }//namespace fei
00093 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:23 2011 for FEI by  doxygen 1.6.3