/usr/include/trilinos/AbstractLinAlgPack_VectorMutableBlocked.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | // @HEADER
// ***********************************************************************
//
// Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
// Copyright (2003) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
// Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
//
// ***********************************************************************
// @HEADER
#ifndef VECTOR_WITH_OP_MUTABLE_BLOCK_STD_H
#define VECTOR_WITH_OP_MUTABLE_BLOCK_STD_H
#include <vector>
#include "AbstractLinAlgPack_VectorMutable.hpp"
#include "AbstractLinAlgPack_VectorSpaceBlocked.hpp"
namespace AbstractLinAlgPack {
/** \brief Concrete subclass for a blocked vector.
*
* This is a near optimal implementation for a block vector in many
* circumstances.
*
* A blocked vector is simply the concatonation of two or more vectors to form a larger
* vector. Suppose that we are given a list of pointers to vector objects <tt>v[0],v[1],,,v[p]</tt>.
* Then <tt>this</tt> vector object would be represented as:
\verbatim
[ *v[0] ]
[ *v[1] ]
this = [ . ]
[ *v[p] ]
\endverbatim
* This vector subclass trys to implement all of the vector methods as efficiently as
* possble. For example, if a client requests a sub-view that corresponds to a whole constituent
* sub-vector, then it will return the unadorned vector such as <tt>this->sub_view(1,v[0]->dim()).get() == v[0]</tt>.
* However, if some sub-view is requested that overlaps two or more constitient vectors, then there is
* no choice but to return a <tt>%VectorMutableBlocked</tt> object from \c sub_view().
*
* There are some situations where this vector subclass will be inefficient. For example, suppose that
* the constituent vectors <tt>v[0],v[1],,,v[p]</tt> are parallel vectors with elements owned by unique processes
* such that an reduction/transformation operator could be applied in parallel to all the constituent vectors in the
* same time (wall clock) that it takes to apply an operator to one constituent vector. In this case, this vector
* subclass could not take advantage of this parallelism and therefore, a more specialized "parallel" block vector
* class should be created (using threads for instance). Alternatively, the implementation of this vector
* subclass could be modified to take advantage of threads if they are available.
*/
class VectorMutableBlocked : virtual public VectorMutable
{
public:
/** \brief . */
typedef Teuchos::RCP<const VectorSpaceBlocked> vec_space_comp_ptr_t;
/** \brief Calls <tt>this->initialize()</tt>.
*/
VectorMutableBlocked(
VectorMutable::vec_mut_ptr_t* vecs
,const vec_space_comp_ptr_t& vec_space
);
/** \brief Initialize given a list of constituent vectors.
*
* Preconditions:<ul>
* <li> <tt>vec_space.get() != NULL</tt> (throw <tt>std::logic_error</tt>).
* <li> <tt>vecs[k]->space().is_compatible(*vec_spaces->vector_spaces()[k]) == true</tt>,
* for <tt>k = 0...vec_space->num_vector_spaces()</tt>.
* </ul>
*
* Postconditions:<ul>
* <li> ToDo: Spell out for carefully!
* </ul>
*
* @param vecs [in] Array (size <tt>vec_space->num_vector_spaces()</tt>) of smart reference
* counted pointers to the constituent vectors.
* @param vec_space [in] Block vector space object containing constituent vector spaces.
*/
void initialize(
VectorMutable::vec_mut_ptr_t* vecs
,const vec_space_comp_ptr_t& vec_space
);
/** \brief Return the underlying block vector space.
*/
const VectorSpaceBlocked& block_space() const;
/** \brief Get the kth (zero based) constituent vector.
*/
const Vector& get_vector(int k) const;
/** \brief Get the kth (zero based) constituent vector.
*/
VectorMutable& get_vector(int k);
//@}
/** @name Overridden form Vector */
//@{
/** \brief . */
index_type dim() const;
/** \brief . */
const VectorSpace& space() const;
/** \brief . */
void apply_op(
const RTOpPack::RTOp& op
,const size_t num_vecs, const Vector* vecs[]
,const size_t num_targ_vecs, VectorMutable* targ_vecs[]
,RTOpPack::ReductTarget *reduct_obj
,const index_type first_ele, const index_type sub_dim, const index_type global_offset
) const;
/** \brief . */
index_type nz() const;
/** \brief . */
std::ostream& output(
std::ostream& out, bool print_dim, bool newline
,index_type global_offset
) const;
/** \brief . */
value_type get_ele(index_type i) const;
/** \brief . */
value_type norm_1() const;
/** \brief . */
value_type norm_inf() const;
/** \brief . */
value_type inner_product( const Vector& ) const;
/** \brief . */
void get_sub_vector( const Range1D& rng, RTOpPack::SubVector* sub_vec ) const;
/** \brief . */
void free_sub_vector( RTOpPack::SubVector* sub_vec ) const;
//@}
/** @name Overridden from VectorMutable */
//@{
/** \brief . */
vec_mut_ptr_t sub_view( const Range1D& rng );
/** \brief . */
void axpy( value_type alpha, const Vector& x );
/** \brief . */
VectorMutable& operator=(value_type);
/** \brief . */
VectorMutable& operator=(const Vector&);
/** \brief . */
void set_ele( index_type i, value_type val );
/** \brief . */
void set_sub_vector( const RTOpPack::SparseSubVector& sub_vec );
//@}
protected:
/** @name Overridden form Vector */
//@{
/** \brief . */
void has_changed() const;
//@}
private:
// ////////////////////////////////////
// Private types
typedef std::vector<VectorMutable::vec_mut_ptr_t> vecs_t; ///< Type for list of constituent vectors
// ////////////////////////////////////
// Private data members
#ifdef DOXYGEN_COMPILE
VectorMutable *vectors;
VectorSpaceBlocked *block_vector_space;
#else
vecs_t vecs_; ///< List of all the vector members.
vec_space_comp_ptr_t vec_space_; ///< overall block vector space.
#endif
mutable index_type nz_; ///< > dim() not initalized, < dim() already initialized!
mutable value_type norm_1_, norm_inf_; ///< < 0, not initialized, > 0 already calculated
// ////////////////////////////////////
// Private member functions
/** \brief . */
void assert_in_range(int k) const;
/** \brief . */
void assert_initialized() const;
// not defined and not to be called!
VectorMutableBlocked();
VectorMutableBlocked(const VectorMutableBlocked&);
VectorMutableBlocked& operator=(const VectorMutableBlocked&);
}; // end class VectorMutableBlocked
// ////////////////////////////////////
// Inline members
inline
const VectorSpaceBlocked&
VectorMutableBlocked::block_space() const
{
assert_initialized();
return *vec_space_;
}
inline
const Vector&
VectorMutableBlocked::get_vector(int k) const
{
assert_in_range(k);
return *vecs_[k];
}
inline
VectorMutable&
VectorMutableBlocked::get_vector(int k)
{
assert_in_range(k);
return *vecs_[k];
}
} // end namespace AbstractLinAlgPack
#endif // VECTOR_WITH_OP_MUTABLE_BLOCK_STD_H
|