Sacado_LFad_LogicalSparse.hpp

Go to the documentation of this file.
00001 // $Id$ 
00002 // $Source$ 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 //                           Sacado Package
00007 //                 Copyright (2006) Sandia Corporation
00008 // 
00009 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00010 // the U.S. Government retains certain rights in this software.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
00027 // (etphipp@sandia.gov).
00028 // 
00029 // ***********************************************************************
00030 // @HEADER
00031 
00032 #ifndef SACADO_LFAD_LOGICALSPARSE_HPP
00033 #define SACADO_LFAD_LOGICALSPARSE_HPP
00034 
00035 #include "Sacado_LFad_LogicalSparseTraits.hpp"
00036 #include "Sacado_LFad_ExpressionTraits.hpp"
00037 #include "Sacado_Fad_DynamicStorage.hpp"
00038 
00039 namespace Sacado {
00040 
00042   namespace LFad {
00043 
00045 
00049     template <typename ExprT> class Expr {};
00050 
00055     template <typename ValT, typename LogT>
00056     class LogicalSparseImp : 
00057       public Fad::DynamicStorage<ValT,LogT> {
00058 
00059       typedef Fad::DynamicStorage<ValT,LogT> Storage;
00060 
00061     public:
00062 
00064       typedef ValT value_type;
00065 
00067       typedef LogT logical_type;
00068 
00073 
00075       LogicalSparseImp() : Storage(value_type(0)) {}
00076 
00078 
00081       LogicalSparseImp(const value_type & x) : Storage(x) {}
00082 
00084 
00087       LogicalSparseImp(const int sz, const value_type & x) : Storage(sz, x) {}
00088 
00090 
00095       LogicalSparseImp(const int sz, const int i, const value_type & x) : 
00096   Storage(sz, x) { 
00097   this->fastAccessDx(i)=logical_type(1); 
00098       }
00099 
00101       LogicalSparseImp(const LogicalSparseImp& x) : 
00102   Storage(x) {}
00103 
00105       template <typename S> LogicalSparseImp(const Expr<S>& x);
00106 
00108       ~LogicalSparseImp() {}
00109 
00111 
00117       void diff(const int ith, const int n);
00118 
00120 
00125 
00127       bool hasFastAccess() const { return this->size()!=0;}
00128 
00130       bool isPassive() const { return this->size()!=0;}
00131       
00133       void setIsConstant(bool is_const) { 
00134   if (is_const && this->size()!=0)
00135     this->resize(0);
00136       }
00137     
00139 
00144 
00146       LogicalSparseImp& operator=(const value_type& val);
00147 
00149       LogicalSparseImp& 
00150       operator=(const LogicalSparseImp& x);
00151 
00153       template <typename S> 
00154       LogicalSparseImp& operator=(const Expr<S>& x); 
00155 
00157 
00162 
00164       LogicalSparseImp& operator += (const value_type& x);
00165 
00167       LogicalSparseImp& operator -= (const value_type& x);
00168 
00170       LogicalSparseImp& operator *= (const value_type& x);
00171 
00173       LogicalSparseImp& operator /= (const value_type& x);
00174 
00176       template <typename S> 
00177       LogicalSparseImp& operator += (const Expr<S>& x);
00178 
00180       template <typename S> 
00181       LogicalSparseImp& operator -= (const Expr<S>& x);
00182   
00184       template <typename S> 
00185       LogicalSparseImp& operator *= (const Expr<S>& x);
00186 
00188       template <typename S> 
00189       LogicalSparseImp& operator /= (const Expr<S>& x);
00190 
00192 
00193     }; // class LogicalSparseImp
00194 
00196     template <typename ValT, typename LogT> 
00197     class Expr< LogicalSparseImp<ValT,LogT> > : 
00198       public LogicalSparseImp<ValT,LogT> {
00199 
00200     public:
00201 
00203       Expr() : 
00204   LogicalSparseImp<ValT,LogT>() {}
00205 
00207 
00210       Expr(const ValT & x) : 
00211   LogicalSparseImp<ValT,LogT>(x) {}
00212 
00214 
00217       Expr(const int sz, const ValT & x) : 
00218   LogicalSparseImp<ValT,LogT>(sz,x) {}
00219 
00221 
00226       Expr(const int sz, const int i, const ValT & x) : 
00227   LogicalSparseImp<ValT,LogT>(sz,i,x) {}
00228 
00230       Expr(const Expr& x) : 
00231   LogicalSparseImp<ValT,LogT>(x) {}
00232 
00234       template <typename S> Expr(const Expr<S>& x) :
00235   LogicalSparseImp<ValT,LogT>(x) {}
00236 
00238       ~Expr() {}
00239 
00240     }; // class Expr<LogicalSparseImp>
00241 
00246     template <typename ValT, typename LogT >
00247     class LogicalSparse : public Expr< LogicalSparseImp<ValT,LogT > > {
00248 
00249     public:
00250 
00252       template <typename T, typename U = LogT> 
00253       struct apply {
00254   typedef LogicalSparse<T,U> type;
00255       };
00256 
00261 
00263 
00266       LogicalSparse() : 
00267   Expr< LogicalSparseImp< ValT,LogT > >() {}
00268 
00270 
00273       LogicalSparse(const ValT& x) : 
00274   Expr< LogicalSparseImp< ValT,LogT > >(x) {}
00275 
00277 
00280       LogicalSparse(const int sz, const ValT& x) : 
00281   Expr< LogicalSparseImp< ValT,LogT > >(sz,x) {}
00282 
00284 
00289       LogicalSparse(const int sz, const int i, const ValT & x) : 
00290   Expr< LogicalSparseImp< ValT,LogT > >(sz,i,x) {}
00291 
00293       LogicalSparse(const LogicalSparse& x) : 
00294   Expr< LogicalSparseImp< ValT,LogT > >(x) {}
00295 
00297       template <typename S> LogicalSparse(const Expr<S>& x) : 
00298   Expr< LogicalSparseImp< ValT,LogT > >(x) {}
00299 
00301 
00303       ~LogicalSparse() {}
00304 
00306       LogicalSparse& operator=(const ValT& v) {
00307   LogicalSparseImp< ValT,LogT >::operator=(v);
00308   return *this;
00309       }
00310 
00312       LogicalSparse& operator=(const LogicalSparse& x) {
00313   LogicalSparseImp< ValT,LogT >::operator=(static_cast<const LogicalSparseImp< ValT,LogT >&>(x));
00314   return *this;
00315       }
00316 
00318       template <typename S> LogicalSparse& operator=(const Expr<S>& x) 
00319       {
00320   LogicalSparseImp< ValT,LogT >::operator=(x);
00321   return *this;
00322       }
00323   
00324     }; // class LogicalSparse<ValT,LogT>
00325 
00326   } // namespace LFad
00327 
00328 } // namespace Sacado
00329 
00330 #include "Sacado_LFad_LogicalSparseImp.hpp"
00331 #include "Sacado_LFad_LogicalSparseOps.hpp"
00332 
00333 #endif // SACADO_LFAD_LOGICALSPARSE_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:19:33 2011 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.6.3