| 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 L1_UTILITIES_HPP |
| 12 |
#define L1_UTILITIES_HPP |
| 13 |
|
| 14 |
#include <tuple> |
| 15 |
//#include "ROL_BoundConstraint.hpp" |
| 16 |
//#include "ROL_Constraint.hpp" |
| 17 |
//#include "ROL_Objective.hpp" |
| 18 |
#include "ROL_PartitionedVector.hpp" |
| 19 |
//#include "ROL_Ptr.hpp" |
| 20 |
|
| 21 |
namespace ROL { |
| 22 |
|
| 23 |
//template<typename> class L1PenaltyObjective; |
| 24 |
//template<typename> class L1PenaltyConstraint; |
| 25 |
|
| 26 |
namespace detail { |
| 27 |
|
| 28 |
template<typename Real> |
| 29 |
inline auto pv_cast( const Vector<Real>& x ) { |
| 30 |
return static_cast<const PartitionedVector<Real>&>(x); |
| 31 |
} |
| 32 |
|
| 33 |
template<typename Real> |
| 34 |
inline auto pv_cast( Vector<Real>& x ) { |
| 35 |
return static_cast<PartitionedVector<Real>&>(x); |
| 36 |
} |
| 37 |
|
| 38 |
//template<template<typename> class Derived, typename Real> |
| 39 |
//struct Base {}; |
| 40 |
// |
| 41 |
//template<typename Real> |
| 42 |
//struct Base<PartitionedVector,Real> { using type = Vector<Real>; }; |
| 43 |
// |
| 44 |
//template<typename Real> |
| 45 |
//struct Base<BoundConstraint_Partitioned,Real> { using type = BoundConstraint<Real>; }; |
| 46 |
// |
| 47 |
//template<typename Real> |
| 48 |
//struct Base<L1PenaltyConstraint,Real> { using type = Constraint<Real>; }; |
| 49 |
// |
| 50 |
//template<typename Real> |
| 51 |
//struct Base<L1PenaltyObjective,Real> { using type = Objective<Real>; }; |
| 52 |
|
| 53 |
|
| 54 |
} // namespace detail |
| 55 |
|
| 56 |
auto&& pv_cast = []( auto&&...args ) { return std::make_tuple(detail::pv_cast(args)...); }; |
| 57 |
|
| 58 |
//template<typename Real> |
| 59 |
//inline auto up_cast( const Ptr<const PartitionedVector<Real>>& x ) { |
| 60 |
// return staticPtrCast<const Vector<Real>>(x); |
| 61 |
//} |
| 62 |
// |
| 63 |
//template<typename Real> |
| 64 |
//inline auto up_cast( const Ptr<PartitionedVector<Real>>& x ) { |
| 65 |
// return staticPtrCast<Vector<Real>>(x); |
| 66 |
//} |
| 67 |
// |
| 68 |
//template<template<typename> class C, typename T> |
| 69 |
//using base_t = typename detail::Base<C,T>::type; |
| 70 |
// |
| 71 |
//template<template<typename> class Derived, typename Real> |
| 72 |
//inline auto up_cast( const Ptr<const Derived<Real>>& x ) { |
| 73 |
// return staticPtrCast<const base_t<Derived,Real>>(x); |
| 74 |
//} |
| 75 |
// |
| 76 |
//template<template<typename> class Derived, typename Real> |
| 77 |
//inline auto up_cast( const Ptr<Derived<Real>>& x ) { |
| 78 |
// return staticPtrCast<base_t<Derived,Real>>(x); |
| 79 |
//} |
| 80 |
|
| 81 |
|
| 82 |
//template<typename Real> |
| 83 |
//inline auto up_cast( const Ptr<const PartitionedVector<Real>>& x ) { |
| 84 |
// return staticPtrCast<const Vector<Real>>(x); |
| 85 |
//} |
| 86 |
// |
| 87 |
//template<typename Real> |
| 88 |
//inline auto up_cast( const Ptr<PartitionedVector<Real>>& x ) { |
| 89 |
// return staticPtrCast<Vector<Real>>(x); |
| 90 |
//} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
} // namespace ROL |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
#endif //L1_UTILITIES_HPP |
| 99 |
|