42 #ifndef MATRIX_SYM_POS_DEF_CHOL_FACTOR_H
43 #define MATRIX_SYM_POS_DEF_CHOL_FACTOR_H
45 #include "AbstractLinAlgPack_Types.hpp"
46 #include "AbstractLinAlgPack_MatrixExtractInvCholFactor.hpp"
47 #include "AbstractLinAlgPack_MatrixSymAddDelUpdateable.hpp"
48 #include "AbstractLinAlgPack_MatrixSymOpNonsingSerial.hpp"
49 #include "AbstractLinAlgPack_MatrixSymDenseInitialize.hpp"
50 #include "AbstractLinAlgPack_MatrixSymOpGetGMSSymMutable.hpp"
51 #include "AbstractLinAlgPack_MatrixSymSecant.hpp"
52 #include "DenseLinAlgPack_DMatrixClass.hpp"
53 #include "DenseLinAlgPack_DMatrixAsTriSym.hpp"
54 #include "SerializationPack_Serializable.hpp"
56 #include "ReleaseResource.hpp"
58 namespace AbstractLinAlgPack {
119 class MatrixSymPosDefCholFactor
123 ,
virtual public MatrixExtractInvCholFactor
124 ,
virtual public MatrixSymSecant
125 ,
virtual public MatrixSymAddDelUpdateable
143 bool maintain_original =
true
144 ,
bool maintain_factor =
false
145 ,
bool allow_factor =
true
147 :maintain_original_(maintain_original)
148 ,maintain_factor_(maintain_factor)
149 ,allow_factor_(allow_factor)
152 void initialize(MatrixSymPosDefCholFactor* p)
const
156 ,maintain_original_,maintain_factor_,allow_factor_
160 bool maintain_original_;
161 bool maintain_factor_;
176 MatrixSymPosDefCholFactor();
182 MatrixSymPosDefCholFactor(
183 DMatrixSlice *MU_store
184 ,
const release_resource_ptr_t& release_resource_ptr = Teuchos::null
186 ,
bool maintain_original =
true
187 ,
bool maintain_factor =
false
188 ,
bool allow_factor =
true
189 ,
bool set_full_view =
true
190 ,value_type scale = 1.0
247 DMatrixSlice *MU_store
248 ,
const release_resource_ptr_t& release_resource_ptr = Teuchos::null
250 ,
bool maintain_original =
true
251 ,
bool maintain_factor =
false
252 ,
bool allow_factor =
true
253 ,
bool set_full_view =
true
254 ,value_type scale = 1.0
302 ,
bool maintain_original
305 ,
bool maintain_factor
311 void pivot_tols( PivotTolerances pivot_tols );
313 PivotTolerances pivot_tols()
const;
325 ,
bool *maintain_original
328 ,
bool *maintain_factor
334 bool allocates_storage()
const;
338 DMatrixSlice& MU_store();
340 const DMatrixSlice& MU_store()
const;
345 const DMatrixSliceTri U()
const;
350 const DMatrixSliceSym M()
const;
368 std::ostream& output(std::ostream& out)
const;
371 MatrixOp* m_lhs, value_type alpha
380 const MatrixOp &mwo_rhs
393 ,
const DVectorSlice& vs_rhs2, value_type beta)
const;
396 ,
const SpVectorSlice& vs_rhs2, value_type beta)
const;
398 void Vp_StPtMtV(DVectorSlice* vs_lhs, value_type alpha
401 ,
const DVectorSlice& vs_rhs3, value_type beta)
const;
403 void Vp_StPtMtV(DVectorSlice* vs_lhs, value_type alpha
406 ,
const SpVectorSlice& sv_rhs3, value_type beta)
const;
413 void Mp_StPtMtP( DMatrixSliceSym* sym_lhs, value_type alpha
414 , EMatRhsPlaceHolder dummy_place_holder
416 , value_type beta )
const;
425 ,
const DVectorSlice& vs_rhs2)
const;
428 ,
const SpVectorSlice& sv_rhs2)
const;
437 DMatrixSliceSym* sym_gms_lhs, value_type alpha
447 void initialize(
const DMatrixSliceSym& M );
475 void extract_inv_chol( DMatrixSliceTriEle* InvChol )
const;
483 void init_identity(
const VectorSpace& space_diag, value_type alpha );
485 void init_diagonal(
const Vector& diag );
487 void secant_update(VectorMutable* s, VectorMutable* y, VectorMutable* Bs);
501 const DMatrixSliceSym &A
503 ,
bool force_factorization
505 ,PivotTolerances pivot_tols
510 Inertia inertia()
const;
512 void set_uninitialized();
515 const DVectorSlice *t
517 ,
bool force_refactorization
518 ,EEigenValType add_eigen_val
519 ,PivotTolerances pivot_tols
524 ,
bool force_refactorization
525 ,EEigenValType drop_eigen_val
526 ,PivotTolerances pivot_tols
536 void serialize( std::ostream &out )
const;
538 void unserialize( std::istream &in );
547 bool maintain_original_;
548 bool maintain_factor_;
549 bool factor_is_updated_;
550 bool allocates_storage_;
551 release_resource_ptr_t release_resource_ptr_;
552 DMatrixSlice MU_store_;
561 PivotTolerances pivot_tols_;
567 void assert_storage()
const;
568 void allocate_storage(
size_type max_size)
const;
569 void assert_initialized()
const;
570 void resize_and_zero_off_diagonal(
size_type n, value_type scale);
571 void update_factorization()
const;
572 std::string build_serialization_string()
const;
573 static void write_matrix(
const DMatrixSlice &Q,
BLAS_Cpp::Uplo Q_uplo, std::ostream &out );
574 static void read_matrix( std::istream &in,
BLAS_Cpp::Uplo Q_uplo, DMatrixSlice *Q );
582 bool MatrixSymPosDefCholFactor::allocates_storage()
const
584 return allocates_storage_;
588 DMatrixSlice& MatrixSymPosDefCholFactor::MU_store()
594 const DMatrixSlice& MatrixSymPosDefCholFactor::MU_store()
const
600 void MatrixSymPosDefCholFactor::get_view_setup(
603 ,
bool *maintain_original
606 ,
bool *maintain_factor
613 *maintain_original = maintain_original_;
614 *M_l_r = maintain_original_ ? M_l_r_ : 0;
615 *M_l_c = maintain_original_ ? M_l_c_ : 0;
616 *maintain_factor = maintain_factor_;
617 *U_l_r = maintain_factor_ ? U_l_r_ : 0;
618 *U_l_c = maintain_factor_ ? U_l_c_ : 0;
622 DMatrixSliceTri MatrixSymPosDefCholFactor::U()
624 return DenseLinAlgPack::nonconst_tri(
625 MU_store_(U_l_r_,U_l_r_+M_size_-1,U_l_c_+1,U_l_c_+M_size_)
626 , BLAS_Cpp::upper, BLAS_Cpp::nonunit
631 const DMatrixSliceTri MatrixSymPosDefCholFactor::U()
const
633 return DenseLinAlgPack::tri(
634 MU_store_(U_l_r_,U_l_r_+M_size_-1,U_l_c_+1,U_l_c_+M_size_)
635 , BLAS_Cpp::upper, BLAS_Cpp::nonunit
640 DMatrixSliceSym MatrixSymPosDefCholFactor::M()
642 return DenseLinAlgPack::nonconst_sym(
643 MU_store_(M_l_r_+1,M_l_r_+M_size_,M_l_c_,M_l_c_+M_size_-1)
649 const DMatrixSliceSym MatrixSymPosDefCholFactor::M()
const
651 return DenseLinAlgPack::sym(
652 MU_store_(M_l_r_+1,M_l_r_+M_size_,M_l_c_,M_l_c_+M_size_-1)
659 #endif // MATRIX_SYM_POS_DEF_CHOL_FACTOR_H
void Vp_StPtMtV(VectorMutable *v_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, const MatrixOp &M_rhs2, BLAS_Cpp::Transp M_rhs2_trans, const Vector &v_rhs3, value_type beta=1.0)
v_lhs = alpha * op(P_rhs1) * op(M_rhs2) * v_rhs3 + beta * v_rhs
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Abstract interface that allows the extraction of a non-const DenseLinAlgPack::DMatrixSliceSym view of...
Abstract base class for all serial polymorphic symmetric nonsingular matrices that can be used to com...
void Mp_StPtMtP(MatrixOp *mwo_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs, const GenPermMatrixSlice &P_rhs2, BLAS_Cpp::Transp P_rhs2_trans)
mwo_lhs += alpha * op(P_rhs1) * op(M_rhs) * op(P_rhs2).
void syrk(const MatrixOp &mwo_rhs, BLAS_Cpp::Transp M_trans, value_type alpha, value_type beta, MatrixSymOp *sym_lhs)
Perform a rank-k update of a symmetric matrix of the form:
void V_InvMtV(VectorMutable *v_lhs, const MatrixNonsing &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2)
v_lhs = inv(op(M_rhs1)) * v_rhs2
void Mp_StM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta=1.0)
v_lhs = alpha * op(M_rhs1) * v_rhs2 + beta * v_lhs (BLAS xGEMV)
void M_StMtInvMtM(MatrixSymOp *sym_gms_lhs, value_type alpha, const MatrixOp &mwo, BLAS_Cpp::Transp mwo_trans, const MatrixSymNonsing &mswof, MatrixSymNonsing::EMatrixDummyArg mwo_rhs)
sym_gms_lhs = alpha * op(mwo) * inv(mswof) * op(mwo)'
Mix-in Interface for initializing a matrix with a dense symmetric matrix.