44 #include "AbstractLinAlgPack_BasisSystemComposite.hpp"
45 #include "AbstractLinAlgPack_MatrixOpNonsing.hpp"
46 #include "AbstractLinAlgPack_MatrixComposite.hpp"
47 #include "AbstractLinAlgPack_MultiVectorMutable.hpp"
48 #include "AbstractLinAlgPack_VectorSpaceBlocked.hpp"
49 #include "AbstractLinAlgPack_LinAlgOpPack.hpp"
50 #include "ReleaseResource_ref_count_ptr.hpp"
51 #include "Teuchos_AbstractFactoryStd.hpp"
52 #include "Teuchos_dyn_cast.hpp"
53 #include "Teuchos_Assert.hpp"
60 class AllocatorMultiVectorMutable {
62 AllocatorMultiVectorMutable(
64 ,AbstractLinAlgPack::size_type num_vecs
66 :vec_space_(vec_space)
71 ptr_t allocate()
const
73 return vec_space_->create_members(num_vecs_);
77 AbstractLinAlgPack::size_type num_vecs_;
82 namespace AbstractLinAlgPack {
94 namespace mmp = MemMngPack;
97 space_xD.
get() == NULL, std::invalid_argument
98 ,
"BasisSystemComposite::initialize_space_x(...): Error!" );
100 var_dep == NULL, std::invalid_argument
101 ,
"BasisSystemComposite::initialize_space_x(...): Error!" );
102 TEUCHOS_TEST_FOR_EXCEPTION(
103 space_xI.
get() != NULL && var_indep == NULL, std::invalid_argument
104 ,
"BasisSystemComposite::initialize_space_x(...): Error!" );
105 TEUCHOS_TEST_FOR_EXCEPTION(
106 space_x == NULL, std::invalid_argument
107 ,
"BasisSystemComposite::initialize_space_x(...): Error!" );
109 *var_dep =
Range1D(1,space_xD->dim());
114 vec_spaces[2] = { space_xD, space_xI };
125 namespace mmp = MemMngPack;
139 namespace mmp = MemMngPack;
143 space_x.
get() == NULL, std::invalid_argument
144 ,
"BasisSystemComposite::initialize_Gc(...): Error!" );
146 space_c.
get() == NULL, std::invalid_argument
147 ,
"BasisSystemComposite::initialize_Gc(...): Error!" );
152 var_dep_size = var_dep.
size();
155 C.
get() == NULL, std::invalid_argument
156 ,
"BasisSystemComposite::initialize_Gc(...): Error!" );
158 var_dep_size < n && N.
get() == NULL, std::invalid_argument
159 ,
"BasisSystemComposite::initialize_Gc(...): Error!" );
161 Gc == NULL, std::invalid_argument
162 ,
"BasisSystemComposite::initialize_Gc(...): Error!" );
176 C_rr_ptr_ptr =
Teuchos::rcp(
new mmp::ReleaseResource_ref_count_ptr<MatrixOpNonsing>(C));
180 ,C_rr_ptr_ptr->ptr.get()
188 N_rr_ptr_ptr =
Teuchos::rcp(
new mmp::ReleaseResource_ref_count_ptr<MatrixOp>(N));
192 ,N_rr_ptr_ptr->ptr.get()
210 Gc == NULL, std::invalid_argument
211 ,
"BasisSystemComposite::get_C_N(...): Error!" );
218 C == NULL, std::invalid_argument
219 ,
"BasisSystemComposite::get_C_N(...): Error!" );
221 n > m && N == NULL, std::invalid_argument
222 ,
"BasisSystemComposite::get_C_N(...): Error!" );
228 MatrixComposite::matrix_list_t::const_iterator
231 if( mat_itr != mat_end ) {
234 const_cast<MatrixOp&
>(*(mat_itr++)->A_) );
237 *N = &
const_cast<MatrixOp&
>(*(mat_itr++)->A_);
259 C == NULL, std::invalid_argument
260 ,
"BasisSystemComposite::get_C_N(...): Error!" );
262 n > m && N == NULL, std::invalid_argument
263 ,
"BasisSystemComposite::get_C_N(...): Error!" );
269 MatrixComposite::matrix_list_t::const_iterator
272 if( mat_itr != mat_end ) {
283 true, std::invalid_argument
284 ,
"BasisSystemComposite::get_C_N(...): Error, "
285 "The Gc matrix object has not been initialized with C and N!" );
304 namespace mmp = MemMngPack;
305 const size_type n = space_x->dim(), m = space_c->dim();
325 space_x,var_dep,var_indep,space_c,factory_C,factory_transDtD,factory_S
341 namespace mmp = MemMngPack;
344 space_x.
get() == NULL, std::invalid_argument
345 ,
"BasisSystemComposite::initialize(...): Error!" );
347 space_c.
get() == NULL, std::invalid_argument
348 ,
"BasisSystemComposite::initialize(...): Error!" );
350 const size_type n = space_x->dim(), m = space_c->dim();
353 var_dep.
size() + var_indep.
size() != space_x->dim(), std::invalid_argument
354 ,
"BasisSystemComposite::initialize(...): Error!" );
357 , std::invalid_argument
358 ,
"BasisSystemComposite::initialize(...): Error!" );
359 TEUCHOS_TEST_FOR_EXCEPTION(
361 , std::invalid_argument
362 ,
"BasisSystemComposite::initialize(...): Error!" );
363 TEUCHOS_TEST_FOR_EXCEPTION(
364 factory_C.
get() == NULL, std::invalid_argument
365 ,
"BasisSystemComposite::initialize(...): Error!" );
374 if( factory_D_.get() == NULL ) {
375 factory_D_ = Teuchos::abstractFactoryStd<MatrixOp,MultiVectorMutable>(
376 AllocatorMultiVectorMutable(space_x_->sub_space(var_dep),var_indep.
size() ) );
383 namespace mmp = MemMngPack;
385 space_x_ = Teuchos::null;
388 factory_C_ = Teuchos::null;
389 factory_D_ = Teuchos::null;
452 n = var_dep_.size() + var_indep_.size(),
455 n == 0, std::logic_error
456 ,
"BasisSystemComposite::update_basis(...): Error, this must be initialized first!" );
458 C == NULL && ( n > m ? D == NULL :
false ), std::logic_error
459 ,
"BasisSystemComposite::update_basis(...): Error, C or D must be non-NULL!" );
465 get_C_N( Gc, &C_aggr, &N_aggr );
472 update_D(*C_aggr,*N_aggr,D,mat_rel);
const mat_fcty_ptr_t factory_D() const
static void get_C_N(MatrixOp *Gc, MatrixOpNonsing **C, MatrixOp **N)
Get the non-const aggregate matrices C and N (or NULL pointers if not initialized).
Interface for the creation and maintainance of a basis matrix for a decomposition of linearlized cons...
matrix_list_t::iterator matrices_begin()
static void initialize_Gc(const VectorSpace::space_ptr_t &space_x, const Range1D &var_dep, const Range1D &var_indep, const VectorSpace::space_ptr_t &space_c, const C_ptr_t &C, const N_ptr_t &N, MatrixOp *Gc)
Initialize the Gc matrix object given created from space_Gc()->create().
const VectorSpace::space_ptr_t & space_x() const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void add_matrix(size_type row_offset, size_type col_offset, value_type alpha, const GenPermMatrixSlice *P, const release_resource_ptr_t &P_release, BLAS_Cpp::Transp P_trans, const MatrixOp *A, const release_resource_ptr_t &A_release, BLAS_Cpp::Transp A_trans, const GenPermMatrixSlice *Q, const release_resource_ptr_t &Q_release, BLAS_Cpp::Transp Q_trans)
Add a sub-matrix alpha*op(P)*op(A)*op(Q).
T_To & dyn_cast(T_From &from)
virtual void update_D(const MatrixOpNonsing &C, const MatrixOp &N, MatrixOp *D, EMatRelations mat_rel) const
Overridden by subclasses to update D if a specialized implementation is needed.
void update_basis(const MatrixOp &Gc, MatrixOpNonsing *C, MatrixOp *D, MatrixOp *GcUP, EMatRelations mat_rel, std::ostream *out) const
static void initialize_space_x(const VectorSpace::space_ptr_t &space_xD, const VectorSpace::space_ptr_t &space_xI, Range1D *var_dep, Range1D *var_indep, VectorSpace::space_ptr_t *space_x)
Initialize the composite vector space for x = [ xD; xI ] as well as var_dep and var_indep.
virtual void finish_construction(const VectorSpace::space_ptr_t &space_cols, const VectorSpace::space_ptr_t &space_rows)
Call to finish the construction process.
const VectorSpace::space_ptr_t & space_c() const
virtual size_type cols() const
Return the number of columns in the matrix.
virtual void initialize(const mat_sym_fcty_ptr_t &factory_transDtD, const mat_sym_nonsing_fcty_ptr_t &factory_S)
Initialize the factory objects for the special matrices for D'*D and S = I + D'*D.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
matrix_list_t::iterator matrices_end()
const mat_nonsing_fcty_ptr_t factory_C() const
VectorSpace subclass for the composite of one or more VectorSpace objects.
Base class for all matrices that support basic matrix operations.
static const Range1D Invalid
void reinitialize(size_type rows=0, size_type cols=0)
Initialize a sized (on unsized) zero matrix to start with.
Interface for a collection of mutable vectors (multi-vector, matrix).
virtual void set_uninitialized()
Set uninitialized.
virtual const mat_sym_nonsing_fcty_ptr_t factory_S() const
Returns a matrix factory for the result of S = I + D'*D
void initialize(const VectorSpace::space_ptr_t &space_x, const Range1D &var_dep, const Range1D &var_indep, const VectorSpace::space_ptr_t &space_c, const mat_nonsing_fcty_ptr_t &factory_C, const mat_sym_fcty_ptr_t &factory_transDtD, const mat_sym_nonsing_fcty_ptr_t &factory_S, const mat_fcty_ptr_t &factory_D=Teuchos::null)
Initialize.
virtual const mat_sym_fcty_ptr_t factory_transDtD() const
Returns a matrix factory for the result of J = D'*D
Abstract base class for all nonsingular polymorphic matrices that can be used to compute matrix-vecto...
void M_StInvMtM(MatrixOp *m_lhs, value_type alpha, const MatrixNonsing &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &mwo_rhs2, BLAS_Cpp::Transp trans_rhs2)
m_lhs = alpha * inv(op(mwo_rhs1)) * op(mwo_rhs2) (right)
virtual size_type rows() const
Return the number of rows in the matrix.
Range1D var_indep() const
Matrix class for matrices composed out of a set of other matrices and vectors.
static const fcty_Gc_ptr_t factory_Gc()
Return a matrix factory object for the composte Gc matrix object.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)