36 #include <feel/feelcore/feel.hpp>
69 Block( uint16_type __ic = 0, uint16_type __jc = 0,
size_type __gic = 0,
size_type __gjc = 0 )
76 Block( Block
const & __b )
112 uint16_type localRow()
const
116 uint16_type localColumn()
const
136 void setLocalRow( uint16_type __lr )
140 void setLocalColumn( uint16_type __lc )
149 void setGlobalColumnStart(
size_type __c )
172 typedef std::list<Block> list_block_type;
176 operator<<( std::ostream& __os, Block
const& __b )
179 << __b.localRow() <<
","
180 << __b.localColumn() <<
","
181 << __b.globalRowStart() <<
","
182 << __b.globalColumnStart() <<
"]";
189 template <
typename T>
192 typedef T block_type;
202 BlocksBase( uint16_type nr,uint16_type nc )
210 BlocksBase( uint16_type nr,uint16_type nc,block_type
const& a )
218 BlocksBase( BlocksBase<T>
const& b )
223 M_cptToBuild( b.M_cptToBuild )
227 operator<<( block_type
const& m )
const
229 BlocksBase<T> newBlock( *
this );
230 newBlock.M_vec[M_cptToBuild]=m;
231 ++( newBlock.M_cptToBuild );
236 push_back( block_type
const& m )
238 M_vec[M_cptToBuild]=m;
243 operator<<( block_type
const& m )
245 M_vec[M_cptToBuild]=m;
252 operator()( uint16_type c1,uint16_type c2 )
254 return M_vec[c1*M_nCol+c2];
258 operator()( uint16_type c1,uint16_type c2 )
const
260 return M_vec[c1*M_nCol+c2];
263 std::vector<block_type>
const&
264 getSetOfBlocks()
const
269 uint16_type nRow()
const
273 uint16_type nCol()
const
282 M_vec.resize( this->nRow()*this->nCol() );
285 void merge( uint16_type c1,uint16_type c2,BlocksBase<T>
const& b )
287 const uint16_type nRb = b.nRow(), nCb = b.nCol();
288 for ( uint16_type i=0; i<nRb; ++i )
289 for ( uint16_type j=0; j<nCb; ++j )
290 this->
operator()( c1+i,c2+j ) = b( i,j );
293 BlocksBase<T> subBlock(uint16_type x1r,uint16_type x1c,uint16_type x2r,uint16_type x2c)
const
295 const uint16_type nrow = x2r-x1r+1;
296 const uint16_type ncol = x2c-x1c+1;
297 BlocksBase<T> res(nrow,ncol);
298 for (uint16_type kr=0;kr<nrow;++kr)
299 for (uint16_type kc=0;kc<ncol;++kc)
300 res(kr,kc)=this->operator()(x1r+kr,x1c+kc);
304 BlocksBase<T> transpose()
const
306 BlocksBase<T> res(this->nCol(),this->nRow());
307 for (uint16_type i=0;i<res.nRow();++i)
308 for (uint16_type j=0;j<res.nCol();++j)
309 res(i,j) = this->operator()(j,i);
314 uint16_type M_nRow,M_nCol;
315 std::vector<block_type> M_vec;
316 uint16_type M_cptToBuild;
321 template <
int NR,
int NC,
typename T>
322 struct Blocks :
public BlocksBase<T>
324 static const uint16_type NBLOCKROWS = NR;
325 static const uint16_type NBLOCKCOLS = NC;
327 typedef BlocksBase<T> super_type;
328 typedef T block_type;
335 Blocks( block_type
const& a )
337 super_type( NR,NC, a )
340 Blocks( super_type
const& a )
346 operator<<( block_type
const& m )
const
348 Blocks<NR,NC,T> newBlock = super_type::operator<<( m ) ;
353 push_back( block_type
const& m )
355 super_type::push_back( m );
360 operator<<( block_type
const& m )
362 super_type::operator<<( m );
370 class BlocksStencilPattern :
public vf::BlocksBase<size_type>
372 typedef vf::BlocksBase<size_type> super_type;
373 typedef BlocksStencilPattern self_type;
376 BlocksStencilPattern(uint16_type nr,uint16_type nc)
381 BlocksStencilPattern(uint16_type nr,uint16_type nc,
size_type pat)
383 super_type(nr,nc,pat)
386 BlocksStencilPattern(super_type
const & b)
394 return super_type::operator<<( m );