/usr/include/trilinos/Thyra_EpetraLinearOp.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 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | // @HEADER
// ***********************************************************************
//
// Thyra: Trilinos Solver Framework Core
// Copyright (2004) 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 Michael A. Heroux (maherou@sandia.gov)
//
// ***********************************************************************
// @HEADER
#ifndef THYRA_EPETRA_LINEAR_OP_HPP
#define THYRA_EPETRA_LINEAR_OP_HPP
#include "Thyra_LinearOpBase.hpp"
#include "Thyra_EpetraLinearOpBase.hpp"
#include "Thyra_SpmdVectorSpaceBase.hpp"
namespace Thyra {
/** \brief Concrete <tt>LinearOpBase</tt> adapter subclass for
* <tt>Epetra_Operator</tt> object.
*
* This subclass can be used to represent the non-transposed operator or
* transposed operator defined by an <tt>Epetra_Operator</tt> object. This
* class can implement <tt>apply()</tt> using either
* <tt>Epetra_Operator::Apply()</tt> or
* <tt>Epetra_Operator::ApplyInverse()</tt>. In addition, the user can
* specify whether adjoints are supported or not.
*
* <b>Partial Automatic Change Propagation:</b> This class shall maintain no
* state with respect to the <em>values</em> of the internally stored
* <tt>Epetra_Operator</tt> object. Therefore, as long as the domain and
* range maps do not change, the the <tt>Epetra_Operator</tt> can be changed
* and this will automatically update <tt>*this</tt> object. This simplifies
* some types of update operations. Since this is a simple concrete class,
* this is harmless. However, if the range and domain maps change, then one
* must call the <tt>this->initialize()</tt> function.
*
* \ingroup Epetra_Thyra_Op_Vec_adapters_grp
*/
class EpetraLinearOp
: virtual public LinearOpBase<double>,
virtual public EpetraLinearOpBase
{
public:
/** \name Constructors / initializers / accessors */
//@{
/** \brief Construct to uninitialized.
*
* See the postconditions for <tt>uninitialize()</tt>
*/
EpetraLinearOp();
/** \brief Fully initialize.
*
* \param op [in] The <tt>Epetra_Operator</tt> this <tt>*this</tt> will
* wrap.
*
* \param opTrans [in] If <tt>opTrans==NOTRANS</tt> then <tt>op</tt> will be
* viewed as <tt>op</tt> and if <tt>opTrans==TRANS</tt> then <tt>op</tt>
* will be viewed as its transpose <tt>op'</tt> for the behavior of
* <tt>apply()</tt>.
*
* \param applyAs [in] If <tt>applyAs==APPLY_APPLY</tt> then
* <tt>op->Apply()</tt> will be used and if
* <tt>applyAs==APPLY_APPLY_INVERSE</tt> then <tt>op->ApplyInverse()</tt> is
* used instead.
*
* \param adjointSupport [in] Determines if it is to be assumed that
* adjoints are supported on the underlying <tt>Epetra_Operator</tt> object
* <tt>op</tt>. If <tt>adjointSupport==EPETRA_OP_ADJOINT_SUPPORTED</tt>
* then <tt>this->opSupported(TRANS)</tt> will return <tt>true</tt>. If
* <tt>adjointSupport==EPETRA_OP_ADJOINT_UNSUPPORTED</tt> then
* <tt>this->opSupported(TRANS)</tt> will return <tt>false</tt>.
*
* \param range [in] Smart pointer to the range space for the
* <tt>Epetra_Operator</tt>. The default value is <tt>Teuchos::null</tt> in
* which case <tt>*this</tt> will allocate a new <tt>SpmdVectorSpace</tt>
* given range map from <tt>op</tt>. A client may only bother to specify
* this space if one wants to override the defintion of the scalar product.
*
* \param domain [in] Smart pointer to the domain space for the
* <tt>Epetra_Operator</tt>. The default value is <tt>Teuchos::null</tt> in
* which case <tt>*this</tt> will allocate a new
* <tt>DefaultSpmdVectorSpace</tt> given map from <tt>op</tt>. A client may
* only bother to specify this space if one wants to override the defintion
* of the scalar product.
*
* Preconditions:<ul>
* <li> <tt>!is_null(op)</tt>
* </ul>
*
* Postconditions:<ul>
* <li> <tt>this->epetra_op().get() == op.get()</tt>
* <li> [<tt>range.get() != NULL</tt>] <tt>this->range().get() == range.get()</tt>
* <li> [<tt>domain.get() != NULL</tt>] <tt>this->domain().get() == domain.get()</tt>
* <li> [<tt>range.get() == NULL</tt>] <tt>this->range().get() != NULL</tt>
* <li> [<tt>domain.get() == NULL</tt>] <tt>this->domain().get() != NULL</tt>
* <li> <tt>this->opSupported(NOTRANS) == true</tt>
* <li> <tt>this->opSupported(TRNAS) == adjointSupport==EPETRA_OP_ADJOINT_SUPPORTED</tt>
* </ul>
*
* After this function is called, <tt>this</tt> will be fully initialized
* and ready to go.
*/
void initialize(
const RCP<Epetra_Operator> &op,
EOpTransp opTrans = NOTRANS,
EApplyEpetraOpAs applyAs = EPETRA_OP_APPLY_APPLY,
EAdjointEpetraOp adjointSupport = EPETRA_OP_ADJOINT_SUPPORTED,
const RCP<const VectorSpaceBase<double> > &range = Teuchos::null,
const RCP<const VectorSpaceBase<double> > &domain = Teuchos::null
);
/** \brief Partially initialize.
*
* \param range [in] Smart pointer to the range space for the
* <tt>Epetra_Operator</tt>.
*
* \param domain [in] Smart pointer to the domain space for the
* <tt>Epetra_Operator</tt>.
*
* \param op [in] The <tt>Epetra_Operator</tt> this <tt>*this</tt> will
* wrap. This object is assumed to not be fully unitialized.
*
* \param opTrans [in] If <tt>opTrans==NOTRANS</tt> then <tt>op</tt> will be
* viewed as <tt>op</tt> and if <tt>opTrans==TRANS</tt> then <tt>op</tt>
* will be viewed as its transpose <tt>op'</tt> for the behavior of
* <tt>apply()</tt>.
*
* \param applyAs [in] If <tt>applyAs==APPLY_APPLY</tt> then
* <tt>op->Apply()</tt> will be used and if
* <tt>applyAs==APPLY_APPLY_INVERSE</tt> then <tt>op->ApplyInverse()</tt> is
* used instead.
*
* \param adjointSupport [in] Determines if it is to be assumed that
* adjoints are supported on the underlying <tt>Epetra_Operator</tt> object
* <tt>op</tt>. If <tt>adjointSupport==EPETRA_OP_ADJOINT_SUPPORTED</tt>
* then <tt>this->opSupported(TRANS)</tt> will return <tt>true</tt>. If
* <tt>adjointSupport==EPETRA_OP_ADJOINT_UNSUPPORTED</tt> then
* <tt>this->opSupported(TRANS)</tt> will return <tt>false</tt>.
*
* Preconditions:<ul>
* <li> <tt>!is_null(range)</tt>
* <li> <tt>!is_null(domain)</tt>
* <li> <tt>!is_null(op)</tt>
* </ul>
*
* Postconditions:<ul>
* <li> <tt>this->epetra_op().get() == op.get()</tt>
* <li> [<tt>range.get() != NULL</tt>] <tt>this->range().get() == range.get()</tt>
* <li> [<tt>domain.get() != NULL</tt>] <tt>this->domain().get() == domain.get()</tt>
* <li> [<tt>range.get() == NULL</tt>] <tt>this->range().get() != NULL</tt>
* <li> [<tt>domain.get() == NULL</tt>] <tt>this->domain().get() != NULL</tt>
* <li> <tt>this->opSupported(NOTRANS) == true</tt>
* <li> <tt>this->opSupported(TRNAS) == adjointSupport==EPETRA_OP_ADJOINT_SUPPORTED</tt>
* </ul>
*
* After this function is called, only the range and domain spaces will be
* supported and this must be followed up by a call to
* <tt>setFullyInitialized()</tt>.
*/
void partiallyInitialize(
const RCP<const VectorSpaceBase<double> > &range,
const RCP<const VectorSpaceBase<double> > &domain,
const RCP<Epetra_Operator> &op,
EOpTransp opTrans = NOTRANS,
EApplyEpetraOpAs applyAs = EPETRA_OP_APPLY_APPLY,
EAdjointEpetraOp adjointSupport = EPETRA_OP_ADJOINT_SUPPORTED
);
/** \brief Set to fully initialized.
*
* In debug mode, asserts will be performed to ensure that everything
* matches up as it should.
*
* The functions <tt>initailize()</tt> ore <tt>partiallyInitialize()</tt>
* must have been called prior to calling this function.
*/
void setFullyInitialized(bool isFullyInitialized = true);
/** \brief Set to uninitialized and optionally return the current state.
*
* Postconditions:<ul>
* <li> <tt>this->domain().get() == NULL</tt>
* <li> <tt>this->range().get() == NULL</tt>
* </ul>
*/
void uninitialize(
RCP<Epetra_Operator> *op= NULL,
EOpTransp *opTrans = NULL,
EApplyEpetraOpAs *applyAs = NULL,
EAdjointEpetraOp *adjointSupport = NULL,
RCP<const VectorSpaceBase<double> > *range = NULL,
RCP<const VectorSpaceBase<double> > *domain = NULL
);
/** \brief Return a smart pointer to the SpmdVectorSpaceBase object for the
* range.
*
* Postconditions:<ul>
* <li> [<tt>this->range().get() != NULL</tt>] <tt>return.get() != NULL</tt>
* <li> [<tt>this->range().get() == NULL</tt>] <tt>return.get() == NULL</tt>
* </ul>
*/
RCP<const SpmdVectorSpaceBase<double> > spmdRange() const;
/** \brief Return a smart pointer to the SpmdVectorSpaceBase object for the
* domain.
*
* Postconditions:<ul>
* <li> [<tt>this->domain().get() != NULL</tt>] <tt>return.get() != NULL</tt>
* <li> [<tt>this->domain().get() == NULL</tt>] <tt>return.get() == NULL</tt>
* </ul>
*/
RCP<const SpmdVectorSpaceBase<double> > spmdDomain() const;
/** \brief . */
RCP<Epetra_Operator> epetra_op();
/** \brief . */
RCP<const Epetra_Operator> epetra_op() const;
//@}
/** \name Overridden from EpetraLinearOpBase */
//@{
/** \brief . */
void getNonconstEpetraOpView(
const Ptr<RCP<Epetra_Operator> > &epetraOp,
const Ptr<EOpTransp> &epetraOpTransp,
const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport
);
/** \brief . */
void getEpetraOpView(
const Ptr<RCP<const Epetra_Operator> > &epetraOp,
const Ptr<EOpTransp> &epetraOpTransp,
const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport
) const;
//@}
/** \name Overridden from LinearOpBase */
//@{
/** \brief . */
RCP<const VectorSpaceBase<double> > range() const;
/** \brief . */
RCP<const VectorSpaceBase<double> > domain() const;
/** \brief . */
RCP<const LinearOpBase<double> > clone() const;
//@}
/** \name Overridden from Teuchos::Describable */
//@{
/** \brief . */
std::string description() const;
/** \brief . */
void describe(
FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel
) const;
//@}
protected:
/** \name Protected member functions overridden from LinearOpBase. */
//@{
/** \brief . */
bool opSupportedImpl(EOpTransp M_trans) const;
/** \brief . */
void applyImpl(
const EOpTransp M_trans,
const MultiVectorBase<double> &X,
const Ptr<MultiVectorBase<double> > &Y,
const double alpha,
const double beta
) const;
//@}
/** \name Allocators for domain and range spaces */
//@{
/** \brief Allocate the domain space of the operator.
*
* Purpose: In TSFExtended, both EpetraLinearOp and
* EpetraVectorSpace are extended from the Thyra versions by
* inheritance, and the TSFExtended operator subclasses expect to
* work with an extended vector space subclass. Thus, it is
* necessary for the base operator class to never directly allocate
* vector space objects, and allocation is delegated to a virtual
* allocator function.
*/
virtual RCP< const SpmdVectorSpaceBase<double> >
allocateDomain(
const RCP<Epetra_Operator> &op,
EOpTransp op_trans
) const;
/** \brief Allocate the range space of the operator.
*
* Purpose: In TSFExtended, both EpetraLinearOp and
* EpetraVectorSpace are extended from the Thyra versions by
* inheritance, and the TSFExtended operator subclasses expect to
* work with an extended vector space subclass. Thus, it is
* necessary for the base operator class to never directly allocate
* vector space objects, and allocation is delegated to a virtual
* allocator function.
*/
virtual RCP< const SpmdVectorSpaceBase<double> >
allocateRange(
const RCP<Epetra_Operator> &op,
EOpTransp op_trans
) const;
//@}
private:
// ////////////////////////////////////
// Private data members
bool isFullyInitialized_;
RCP<Epetra_Operator> op_;
EOpTransp opTrans_;
EApplyEpetraOpAs applyAs_;
EAdjointEpetraOp adjointSupport_;
RCP<const SpmdVectorSpaceBase<double> > range_;
RCP<const SpmdVectorSpaceBase<double> > domain_;
// ////////////////////////////////////
// Private member functions
const Epetra_Map& getRangeMap() const;
const Epetra_Map& getDomainMap() const;
}; // end class EpetraLinearOp
/** \brief Default nonmember constructor.
*
* \relates EpetraLinearOp
*/
RCP<EpetraLinearOp> nonconstEpetraLinearOp();
/** \brief Partially initialized EpetraLinearOp
*
* \relates EpetraLinearOp
*/
RCP<EpetraLinearOp>
partialNonconstEpetraLinearOp(
const RCP<const VectorSpaceBase<double> > &range,
const RCP<const VectorSpaceBase<double> > &domain,
const RCP<Epetra_Operator> &op,
EOpTransp opTrans = NOTRANS,
EApplyEpetraOpAs applyAs = EPETRA_OP_APPLY_APPLY,
EAdjointEpetraOp adjointSupport = EPETRA_OP_ADJOINT_SUPPORTED
);
/** \brief Dynamically allocate an const EpetraLinearOp to wrap a const
* Epetra_Operator object.
*
* \relates EpetraLinearOp
*/
RCP<EpetraLinearOp>
nonconstEpetraLinearOp(
const RCP<Epetra_Operator> &op,
EOpTransp opTrans = NOTRANS,
EApplyEpetraOpAs applyAs = EPETRA_OP_APPLY_APPLY,
EAdjointEpetraOp adjointSupport = EPETRA_OP_ADJOINT_SUPPORTED,
const RCP< const VectorSpaceBase<double> > &range = Teuchos::null,
const RCP< const VectorSpaceBase<double> > &domain = Teuchos::null
);
/** \brief Dynamically allocate a nonconst EpetraLinearOp to wrap a const
* Epetra_Operator object.
*
* \relates EpetraLinearOp
*/
RCP<const EpetraLinearOp>
epetraLinearOp(
const RCP<const Epetra_Operator> &op,
EOpTransp opTrans = NOTRANS,
EApplyEpetraOpAs applyAs = EPETRA_OP_APPLY_APPLY,
EAdjointEpetraOp adjointSupport = EPETRA_OP_ADJOINT_SUPPORTED,
const RCP<const VectorSpaceBase<double> > &range = Teuchos::null,
const RCP<const VectorSpaceBase<double> > &domain = Teuchos::null
);
/** \brief Dynamically allocate an const EpetraLinearOp to wrap a const
* Epetra_Operator object and give it a string label.
*
* \relates EpetraLinearOp
*/
RCP<EpetraLinearOp>
nonconstEpetraLinearOp(
const RCP<Epetra_Operator> &op,
const std::string &label,
EOpTransp opTrans = NOTRANS,
EApplyEpetraOpAs applyAs = EPETRA_OP_APPLY_APPLY,
EAdjointEpetraOp adjointSupport = EPETRA_OP_ADJOINT_SUPPORTED,
const RCP<const VectorSpaceBase<double> > &range = Teuchos::null,
const RCP<const VectorSpaceBase<double> > &domain = Teuchos::null
);
/** \brief Dynamically allocate a nonconst EpetraLinearOp to wrap a const
* Epetra_Operator object.
*
* \relates EpetraLinearOp
*/
RCP<const EpetraLinearOp>
epetraLinearOp(
const RCP<const Epetra_Operator> &op,
const std::string &label,
EOpTransp opTrans = NOTRANS,
EApplyEpetraOpAs applyAs = EPETRA_OP_APPLY_APPLY,
EAdjointEpetraOp adjointSupport = EPETRA_OP_ADJOINT_SUPPORTED,
const RCP< const SpmdVectorSpaceBase<double> > &range = Teuchos::null,
const RCP< const SpmdVectorSpaceBase<double> > &domain = Teuchos::null
);
} // end namespace Thyra
#endif // THYRA_EPETRA_LINEAR_OP_HPP
|