Debian Codegraph @

packages/rol/example/l1-penalty/compressed_sensing.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 #pragma once
11 #ifndef COMPRESSED_SENSING_HPP
12 #define COMPRESSED_SENSING_HPP
13
14 #include "ROL_LinearConstraint.hpp"
15 #include "ROL_NonlinearLeastSquaresObjective.hpp"
16 #include "random_matrix.hpp"
17 #include "l1_penalty_optimization_problem.hpp"
18
19 template<typename Ordinal, typename Real>
20 class CompressedSensingConstraint : public ROL::LinearConstraint<Real> {
21 public:
22 CompressedSensingConstraint( Ordinal rows, Ordinal cols )
23 : ROL::LinearConstraint<Real>(create_random_operator<Ordinal,Real>(rows,cols),
24 create_random_vector<Ordinal,Real>(rows)) {}
25 };
26
27 template<typename Ordinal, typename Real>
28 ROL::Ptr<ROL::Objective<Real>>
29 make_CompressedSensingObjective( Ordinal rows, Ordinal cols ) {
30 using ROL::Ptr;
31 using ROL::makePtr;
32 Ptr<ROL::Constraint<Real>> con = makePtr<CompressedSensingConstraint<Ordinal,Real>>(rows,cols);
33 auto x = ROL::TeuchosVector<Ordinal,Real>(cols);
34 auto c = ROL::TeuchosVector<Ordinal,Real>(rows);
35 Ptr<ROL::Objective<Real>> obj = makePtr<ROL::NonlinearLeastSquaresObjective<Real>>(con,x,c);
36 return obj;
37 }
38
39
40 #endif // COMPRESSED_SENSING_HPP
41