PlayaBlockVectorSpaceImpl.hpp
00001
00002
00003
00004
00005 #ifndef PLAYA_BLOCKEDVECTORSPACEBASEIMPL_HPP
00006 #define PLAYA_BLOCKEDVECTORSPACEBASEIMPL_HPP
00007
00008 #include "PlayaBlockVectorSpaceDecl.hpp"
00009 #include "PlayaVectorSpaceDecl.hpp"
00010
00011 namespace Playa
00012 {
00013 template <class Scalar> inline
00014 int BlockVectorSpaceBase<Scalar>::dim() const
00015 {
00016 int rtn = 0;
00017 for (int i=0; i<this->numBlocks(); i++)
00018 {
00019 rtn += this->getBlock(i).dim();
00020 }
00021 return rtn;
00022 }
00023
00024 template <class Scalar> inline
00025 int BlockVectorSpaceBase<Scalar>::numLocalElements() const
00026 {
00027 int rtn = 0;
00028 for (int i=0; i<this->numBlocks(); i++)
00029 {
00030 rtn += this->getBlock(i).numLocalElements();
00031 }
00032 return rtn;
00033 }
00034
00035 template <class Scalar> inline
00036 bool BlockVectorSpaceBase<Scalar>::isCompatible(const VectorSpaceBase<Scalar>* other) const
00037 {
00038 if (this->numBlocks() != other->numBlocks()) return false;
00039
00040 const BlockVectorSpaceBase<Scalar>* bs
00041 = dynamic_cast<const BlockVectorSpaceBase<Scalar>* >(other);
00042
00043 if (bs == 0) return false;
00044
00045 for (int i=0; i<this->numBlocks(); i++)
00046 {
00047 if (! (this->getBlock(i).isCompatible(bs->getBlock(i))))
00048 return false;
00049 }
00050 return true;
00051 }
00052
00053
00054 template <class Scalar> inline
00055 std::string BlockVectorSpaceBase<Scalar>::description() const
00056 {
00057 std::ostringstream rtn;
00058 rtn << "BlockVS[";
00059 for (int b=0; b<this->numBlocks(); b++)
00060 {
00061 if (b > 0) rtn << ", ";
00062 rtn << this->getBlock(b).description();
00063 }
00064 rtn << "]";
00065 return rtn.str();
00066 }
00067
00068
00069
00070
00071 }
00072
00073 #endif