Debian Codegraph @

packages/rol/src/oed/factors/ROL_OED_StdMomentOperator.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef ROL_OED_STD_COVARIANCE_OPERATOR_HPP
11 #define ROL_OED_STD_COVARIANCE_OPERATOR_HPP
12
13 #include "ROL_OED_MomentOperator.hpp"
14 #include "ROL_LinearAlgebra.hpp"
15 #include "ROL_LAPACK.hpp"
16 #include "ROL_BLAS.hpp"
17
18 #include <algorithm>
19 #include <functional>
20 #include <sstream>
21
22 namespace ROL {
23 namespace OED {
24
25 template<typename Real>
26 class StdMomentOperator : public MomentOperator<Real> {
27 private:
28 const Ptr<LAPACK<int,Real>> lapack_;
29 const Ptr<BLAS<int,Real>> blas_;
30 LA::Matrix<Real> M_, Minv_, U_, V_, Xpred_, P_;
31 std::vector<Real> sval_, sfull_;
32 bool isBuilt_, isFactorized_, isSet_, isFullSet_, useSVD_, isPset_;
33 std::vector<LA::Matrix<Real>> Xdata_, Xfull_;
34 int nobs_;
35
36 void initialize(int nfactors);
37 void build(const Vector<Real> &p);
38 void factorize(const Vector<Real> &p);
39
40 protected:
41 /***************************************************************************/
42 /* Begin Accessor Functions */
43 /***************************************************************************/
44 virtual std::vector<Real>& getData(Vector<Real> &x) const;
45 virtual const std::vector<Real>& getConstData(const Vector<Real> &x) const;
46 /***************************************************************************/
47 /* End Accessor Functions */
48 /***************************************************************************/
49
50 using MomentOperator<Real>::get;
51 using MomentOperator<Real>::set;
52 using MomentOperator<Real>::getNoise;
53 using MomentOperator<Real>::getLocalDesign;
54 using MomentOperator<Real>::getConstLocalDesign;
55 using MomentOperator<Real>::sumAll;
56 using MomentOperator<Real>::applyPerturbation;
57 using ProfiledClass<Real,std::string>::startTimer;
58 using ProfiledClass<Real,std::string>::stopTimer;
59
60 public:
61 StdMomentOperator(RegressionType regType = LEASTSQUARES,
62 bool homNoise = true,
63 const Ptr<Noise<Real>> &noise = nullPtr);
64
65 Ptr<MomentOperator<Real>> clone() const;
66
67 void update(const Vector<Real> &p, UpdateType type, int iter = -1);
68
69 void applyInverse(Vector<Real> &Mx,
70 const Vector<Real> &x,
71 const Vector<Real> &p);
72
73 void apply(Vector<Real> &Mc,
74 const Vector<Real> &c,
75 const Vector<Real> &p);
76
77 void applyDeriv(Vector<Real> &Mc,
78 const Vector<Real> &c,
79 const Vector<Real> &p);
80
81 void applySampleMatrices(Vector<Real> &uXv, const Vector<Real> &u, const Vector<Real> &v);
82
83 void setFactors(const Ptr<Factors<Real>> &factors);
84
85 void setPerturbation(const Ptr<LinearOperator<Real>> &pOp);
86
87 Real logDeterminant(const Vector<Real> &z);
88
89 }; // class StdMomentOperator
90
91 } // End OED Namespace
92 } // End ROL Namespace
93
94 #include "ROL_OED_StdMomentOperator_Def.hpp"
95
96 #endif