PANOC-ALM  quadratic-penalty
Nonconvex constrained optimization
vec.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Eigen/Core>
4 
5 namespace pa {
6 
8 using real_t = double; // TODO: make template?
10 using realvec = Eigen::Matrix<real_t, Eigen::Dynamic, 1>;
12 using realmat = Eigen::Matrix<real_t, Eigen::Dynamic, Eigen::Dynamic>;
14 using vec = realvec;
16 using rvec = Eigen::Ref<vec>;
18 using crvec = Eigen::Ref<const vec>;
20 using mat = realmat;
22 using rmat = Eigen::Ref<mat>;
24 using crmat = Eigen::Ref<const mat>;
26 constexpr real_t inf = std::numeric_limits<real_t>::infinity();
28 constexpr real_t NaN = std::numeric_limits<real_t>::quiet_NaN();
29 
30 namespace vec_util {
31 
34 template <class V, class M>
35 auto norm_squared_weighted(V &&v, M &&Σ) {
36  return v.dot(Σ.asDiagonal() * v);
37 }
38 
41 template <class Vec>
42 real_t norm_inf(const Vec &v) {
43  return v.template lpNorm<Eigen::Infinity>();
44 }
45 
46 } // namespace vec_util
47 
48 } // namespace pa
pa::rvec
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
Definition: vec.hpp:16
pa::NaN
constexpr real_t NaN
Not a number.
Definition: vec.hpp:28
pa::vec
realvec vec
Default type for vectors.
Definition: vec.hpp:14
pa::rmat
Eigen::Ref< mat > rmat
Default type for mutable references to matrices.
Definition: vec.hpp:22
panocpy.test.v
v
Definition: test.py:42
pa
Definition: alm.hpp:10
pa::realmat
Eigen::Matrix< real_t, Eigen::Dynamic, Eigen::Dynamic > realmat
Default type for floating point matrices.
Definition: vec.hpp:12
pa::crmat
Eigen::Ref< const mat > crmat
Default type for immutable references to matrices.
Definition: vec.hpp:24
pa::inf
constexpr real_t inf
Definition: vec.hpp:26
pa::crvec
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
Definition: vec.hpp:18
pa::realvec
Eigen::Matrix< real_t, Eigen::Dynamic, 1 > realvec
Default type for floating point vectors.
Definition: vec.hpp:10
pa::vec_util::norm_squared_weighted
auto norm_squared_weighted(V &&v, M &&Σ)
Get the Σ norm squared of a given vector, with Σ a diagonal matrix.
Definition: vec.hpp:35
panocpy.test.Σ
int Σ
Definition: test.py:70
pa::mat
realmat mat
Default type for matrices.
Definition: vec.hpp:20
pa::vec_util::norm_inf
real_t norm_inf(const Vec &v)
Get the maximum or infinity-norm of the given vector.
Definition: vec.hpp:42
pa::real_t
double real_t
Default floating point type.
Definition: vec.hpp:8