30 #ifndef OOMPH_MAP_MATRIX_HEADER 31 #define OOMPH_MAP_MATRIX_HEADER 36 #include <oomph-lib-config.h> 113 template<
class KEY_TYPE_ROW,
class KEY_TYPE_COL,
class VALUE_TYPE>
138 typedef std::map<KEY_TYPE_ROW,std::map<KEY_TYPE_COL,VALUE_TYPE>*>
150 KEY_TYPE_COL,VALUE_TYPE>& map_mat)
153 for (ConstOuterMixedIt it=map_mat.Row_pt.begin(); it!=map_mat.Row_pt.end();
161 InnerMapMixed inner_map=*(it->second);
164 for (ConstInnerMixedIt it2=inner_map.begin(); it2!=inner_map.end();
172 (*this)(it->first,it2->first)=it2->second;
183 std::map<KEY_TYPE_ROW,VALUE_TYPE> &copied_map)
186 for(OuterMixedIt it=
Row_pt.begin(); it!=
Row_pt.end(); it++)
192 InnerMapMixed inner_map=*(it->second);
194 if(inner_map[j] != 0)
198 copied_map[it->first] = inner_map[j];
209 for (OuterMixedIt it=
Row_pt.begin(); it!=
Row_pt.end(); it++)
224 for (OuterMixedIt it=
Row_pt.begin(); it!=
Row_pt.end(); it++)
239 VALUE_TYPE&
operator()(
const KEY_TYPE_ROW&
i,
const KEY_TYPE_COL& j)
248 VALUE_TYPE
get(
const KEY_TYPE_ROW&
i,
const KEY_TYPE_COL& j)
const 253 InnerMapMixed* inner_map_mixed_pt =
Row_pt.find(i)->second;
254 if(inner_map_mixed_pt->count(j) > 0)
256 return inner_map_mixed_pt->find(j)->second;
260 return VALUE_TYPE(0);
266 return VALUE_TYPE(0);
282 for (OuterMixedIt it=
Row_pt.begin(); it!=
Row_pt.end(); it++)
288 InnerMapMixed inner_map=*(it->second);
291 for (InnerMixedIt it2=inner_map.begin(); it2!=inner_map.end(); it2++)
297 outfile << it->first <<
" " << it2->first <<
" " 298 << it2->second << std::endl;
309 unsigned long count=0;
312 for (OuterMixedIt it=
Row_pt.begin(); it!=
Row_pt.end(); it++)
318 InnerMapMixed inner_map=*(it->second);
321 for (InnerMixedIt it2=inner_map.begin(); it2!=inner_map.end(); it2++)
338 unsigned long count=0;
341 for (ConstOuterMixedIt it=
Row_pt.begin(); it!=
Row_pt.end(); it++)
347 InnerMapMixed inner_map=*(it->second);
350 for (ConstInnerMixedIt it2=inner_map.begin(); it2!=inner_map.end(); it2++)
370 unsigned long count=0;
373 for (OuterMixedIt it=
Row_pt.begin(); it!=
Row_pt.end(); it++)
379 InnerMapMixed inner_map=*(it->second);
382 for (InnerMixedIt it2=inner_map.begin(); it2!=inner_map.end(); it2++)
395 unsigned long count=0;
398 for (ConstOuterMixedIt it=
Row_pt.begin(); it!=
Row_pt.end(); it++)
404 InnerMapMixed inner_map=*(it->second);
407 for (ConstInnerMixedIt it2=inner_map.begin(); it2!=inner_map.end(); it2++)
420 VALUE_TYPE*
entry_pt(
const KEY_TYPE_ROW& i,
const KEY_TYPE_COL& j)
426 Row_pt[
i]=
new std::map<KEY_TYPE_COL, VALUE_TYPE>;
440 std::map<KEY_TYPE_ROW, std::map<KEY_TYPE_COL, VALUE_TYPE>* >
Row_pt;
519 template<
class KEY_TYPE,
class VALUE_TYPE>
529 typedef std::map<KEY_TYPE,VALUE_TYPE>
InnerMap;
538 typedef std::map<KEY_TYPE,std::map<KEY_TYPE,VALUE_TYPE>*>
OuterMap;
550 for (ConstOuterIt it=map_mat.
Row_pt.begin(); it!=map_mat.
Row_pt.end(); it++)
556 InnerMap inner_map=*(it->second);
559 for (ConstInnerIt it2=inner_map.begin(); it2!=inner_map.end(); it2++)
564 (*this)(it->first,it2->first)=it2->second;
VALUE_TYPE & operator()(const KEY_TYPE_ROW &i, const KEY_TYPE_COL &j)
Return (reference to) entry. Careful: If the entry does not exist then it is created and set to zero...
virtual ~MapMatrixMixed()
Destructor.
InnerMap::const_iterator ConstInnerIt
Typedef to keep the code more readable.
unsigned long nnz()
Work out number of non-`zero' entries.
InnerMapMixed::const_iterator ConstInnerMixedIt
Typedef to keep the code more readable const version.
OuterMap::iterator OuterIt
Typedef to keep the code more readable.
InnerMap::iterator InnerIt
Typedef to keep the code more readable.
void clear()
Wipe all entries.
void operator=(const MapMatrixMixed &)
Broken assignment operator.
void operator=(const MapMatrix &)
Broken assignment operator.
std::map< KEY_TYPE, std::map< KEY_TYPE, VALUE_TYPE > * > OuterMap
Typedef to keep the code more readable.
MapMatrix(const MapMatrix< KEY_TYPE, VALUE_TYPE > &map_mat)
Copy constructor.
std::map< unsigned, oomph::CRDoubleMatrix * > InnerMap
Typedef to keep the code more readable.
OuterMapMixed::const_iterator ConstOuterMixedIt
Typedef to keep the code more readable const version.
OuterMap::const_iterator ConstOuterIt
Typedef to keep the code more readable.
InnerMapMixed::iterator InnerMixedIt
Typedef to keep the code more readable.
std::map< KEY_TYPE_ROW, std::map< KEY_TYPE_COL, VALUE_TYPE > *> Row_pt
MapMatrixMixed()
Default (empty) constructor.
void copy_column(const KEY_TYPE_COL &j, std::map< KEY_TYPE_ROW, VALUE_TYPE > &copied_map)
Copy a single column into its own map.
MapMatrix()
Default (empty) constructor.
VALUE_TYPE * entry_pt(const KEY_TYPE_ROW &i, const KEY_TYPE_COL &j)
Return pointer to entry.
unsigned long size() const
Work out total number of entries const version.
std::map< KEY_TYPE_COL, VALUE_TYPE > InnerMapMixed
Typedef to keep the code more readable.
unsigned long size()
Work out total number of entries.
std::map< KEY_TYPE_ROW, std::map< KEY_TYPE_COL, VALUE_TYPE > * > OuterMapMixed
Typedef to keep the code more readable.
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
unsigned long nnz() const
Work out number of non-`zero' entries, const version.
OuterMapMixed::iterator OuterMixedIt
Typedef to keep the code more readable.
MapMatrixMixed(const MapMatrixMixed< KEY_TYPE_ROW, KEY_TYPE_COL, VALUE_TYPE > &map_mat)
Copy constructor.
void output(std::ostream &outfile)
Dump all non-`zero' entries to file. Output is in the format `i', `j', `entry[i][j]'.