11 #ifndef ROL_VECTORWORKSPACE_HPP
12 #define ROL_VECTORWORKSPACE_HPP
63 template<
typename Real>
85 ss <<
"VectorKey(" << std::hex << key.
hash_code <<
","
119 for(
auto v :
vectors_ ) count += ( getCount(v) > 3 );
130 "VectorWorkspace::VectorStack tried to clone a std::vector of type " <<
131 std::hex <<
key_.
hash_code <<
", but it can only clone std::vectors of type " <<
135 "VectorWorkspace::VectorStack tried to clone a std::vector of dimension " <<
136 std::hex <<
key_.
dimension <<
", but it can only clone std::vectors of dimension " <<
140 if( getCount(e) <= 2 ) {
146 vectors_.push_back( v );
152 std::vector<size_type> counts;
153 for(
auto e:
vectors_ ) counts.push_back( getCount(e) );
167 Ptr<VectorStack> vstack{nullPtr};
169 for(
auto e :
workspace_ ) key_count += (key == e.first);
171 if( key_count == 0 ) {
172 vstack = makePtr<VectorStack>(x);
173 workspace_.insert( std::make_pair(key,vstack) );
175 else vstack = workspace_[key];
177 return vstack->clone(x);
189 Ptr<V>
copy(
const Ptr<const V>& x ) {
return copy(*x); }
192 os <<
"\n\n" << std::string(80,
'-') << std::endl;
193 os <<
"VectorWorkspace contains the following VectorStack(hash_code,dim) entries:\n\n";
195 os <<
" VectorStack(" << std::hex << entry.first.hash_code <<
","
196 << std::dec << entry.first.dimension <<
")";
197 os <<
"\n Reference Counts per element" << std::endl;
198 for(
auto e : entry.second->vectors_ ) {
199 os <<
" " << getCount( e ) << std::endl;
202 os << std::string(80,
'-') << std::endl;
typename PV< Real >::size_type size_type
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
bool operator==(const VectorKey &x) const
Ptr< V > clone(const V &x)
Ptr< V > copy(const Ptr< const V > &x)
void status(std::ostream &os) const
std::vector< Ptr< V > > vectors_
Defines the linear algebra or vector space interface.
const VectorKey & getKey() const
Provides a "smart" cloning manager to be used a member variable in a class and called in the member f...
Ptr< V > copy(const V &x)
std::map< VectorKey, Ptr< VectorStack > > workspace_
VectorKey(const Ptr< V > &x)
Ptr< V > clone(const Ptr< const V > &x)
size_type number_assigned() const
Ptr< V > clone(const V &x)
typename std::vector< Real >::size_type size_type
std::vector< size_type > getRefCounts(void) const
bool operator<(const VectorKey &x) const
static std::string to_string(const VectorKey &key)