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