So-Bogus
A c++ sparse block matrix library aimed at Second Order cone problems
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
PyramidLaw.hpp
1 /*
2  * This file is part of bogus, a C++ sparse block matrix library.
3  *
4  * Copyright 2016 Gilles Daviet <gdaviet@gmail.com>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
10 
11 #ifndef BOGUS_PYRAMIDLAW_HPP
12 #define BOGUS_PYRAMIDLAW_HPP
13 
14 #include <cmath>
15 
16 namespace bogus
17 {
18 
20 
29 template < DenseIndexType Dimension, typename Scalar, bool DeSaxceCOV >
31 {
32 public:
34  enum{ dimension = Dimension } ;
35 
37 
41  PyramidLaw( const unsigned n, const double * mu ) ;
42 
44  Scalar eval( const unsigned problemIndex,
45  const typename Traits::Vector &x,
46  const typename Traits::Vector &y ) const ;
47 
49  bool solveLocal(
50  const unsigned problemIndex,
51  const typename Traits::Matrix &A,
52  const typename Traits::Vector &b,
53  typename Traits::Vector &x,
54  const Scalar scaling
55  ) const ;
56 
58  void projectOnConstraint( const unsigned problemIndex, typename Traits::Vector &x ) const ;
59 
61 
64  template< typename Segment >
65  void dualityCOV( const unsigned problemIndex, const Segment& y,
66  typename Traits::Vector& s ) const
67  {
68  if( DeSaxceCOV ) {
69  Traits::np( s ) = m_mu[problemIndex] * Traits::tp(y).template lpNorm<1>() ;
70  Traits::tp( s ).setZero() ;
71  } else s.setZero() ;
72  }
73 
74 private:
75 
76  const double * m_mu ;
77  const unsigned m_n ;
78 
79 } ;
80 
81 
82 }
83 
84 #endif
Scalar eval(const unsigned problemIndex, const typename Traits::Vector &x, const typename Traits::Vector &y) const
PyramidLaw(const unsigned n, const double *mu)
Constructor.
void projectOnConstraint(const unsigned problemIndex, typename Traits::Vector &x) const
Projects x on .
bool solveLocal(const unsigned problemIndex, const typename Traits::Matrix &A, const typename Traits::Vector &b, typename Traits::Vector &x, const Scalar scaling) const
Solve for with y(x) = Ax + b.
void dualityCOV(const unsigned problemIndex, const Segment &y, typename Traits::Vector &s) const
Computes the change of variable s(y) so that (x, y+s(y)) obeys an associated law. ...
Definition: PyramidLaw.hpp:65
Definition: EigenProblemTraits.hpp:38
Experimental and incomplete pyramidal local solver that can be used within GaussSeidel and ProjectedG...
Definition: PyramidLaw.hpp:30