FEI Version of the Day
fei_VectorTraits_CSVec.hpp
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 #ifndef _fei_VectorTraits_CSVec_hpp_
00010 #define _fei_VectorTraits_CSVec_hpp_
00011 
00012 #include <fei_VectorTraits.hpp>
00013 #include <fei_CSVec.hpp>
00014 
00015 namespace fei {
00016   template<>
00017   struct VectorTraits<CSVec> {
00018     static const char* typeName()
00019       { return("CSVec"); }
00020     
00021     static int setValues(CSVec* vec, int firstLocalOffset,
00022                          double scalar, bool isSolnVector=false)
00023       {
00024         set_values(*vec, scalar);
00025         return(0);
00026       }
00027 
00028     static int putValuesIn(CSVec* vec,
00029                      int firstLocalOffset,
00030                      int numValues, const int* indices, const double* values,
00031                      bool sum_into,
00032                      bool isSolnVector=false,
00033                      int vectorIndex=0)
00034       {
00035         if (sum_into) {
00036           for(int i=0; i<numValues; ++i) {
00037             if (indices[i] < 0) continue;
00038             add_entry(*vec, indices[i], values[i]);
00039           }
00040         }
00041         else {
00042           for(int i=0; i<numValues; ++i) {
00043             if (indices[i] < 0) continue;
00044             put_entry(*vec, indices[i], values[i]);
00045           }
00046         }
00047 
00048         return( 0 );
00049       }
00050 
00051     static int copyOut(CSVec* vec,
00052                        int firstLocalOffset,
00053                        int numValues, const int* indices, double* values,
00054                        bool isSolnVector=false,
00055                        int vectorIndex=0)
00056       {
00057         for(int i=0; i<numValues; ++i) {
00058           try {
00059             values[i] = get_entry(*vec, indices[i]);
00060           }
00061           catch(...) {}
00062         }
00063         return(0);
00064       }
00065 
00066     static int update(CSVec* vec,
00067                       double a,
00068                       const CSVec* x,
00069                       double b)
00070     { return(-1); }
00071 
00072   };
00073 }//namespace fei
00074 
00075 #endif // _fei_VectorTraits_CSVec_hpp_
00076 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends