alpaqa
1.0.0a15
Nonconvex constrained optimization
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
i
j
l
m
n
o
p
r
s
t
u
v
w
Functions
a
b
c
d
e
f
g
i
j
l
m
n
o
p
r
s
t
u
w
Variables
Typedefs
a
c
d
f
i
l
m
p
r
s
t
u
v
Enumerations
Concepts
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
û
ŷ
α
γ
δ
ε
λ
ρ
σ
τ
φ
ψ
ϵ
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
û
α
ρ
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
ŷ
α
γ
δ
ε
λ
ρ
σ
τ
φ
ψ
ϵ
Typedefs
a
b
c
d
e
f
h
i
l
m
n
o
p
r
s
t
v
w
Enumerations
Enumerator
a
f
i
s
u
Related Symbols
Files
File List
File Members
All
a
c
d
e
f
g
l
m
p
r
s
t
u
w
Functions
a
c
d
e
f
g
l
m
p
r
s
t
w
Variables
Typedefs
Enumerations
Enumerator
Macros
a
c
e
p
u
Examples
Sphinx
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
src
alpaqa
include
alpaqa
util
check-dim.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
alpaqa/config/config.hpp
>
4
#include <optional>
5
#include <stdexcept>
6
#include <string>
7
8
namespace
alpaqa::util
{
9
10
template
<
class
V>
11
void
check_dim_msg
(
const
V
&
v
,
auto
sz
, std::string
msg
) {
12
if
(
v
.size() !=
sz
) {
13
msg
+=
"\n(should be "
;
14
msg
+= std::to_string(
sz
);
15
msg
+=
", got "
;
16
msg
+= std::to_string(
v
.size());
17
msg
+=
")"
;
18
throw
std::invalid_argument(
msg
);
19
}
20
}
11
void
check_dim_msg
(
const
V
&
v
,
auto
sz
, std::string
msg
) {
…
}
21
22
template
<
class
V>
23
void
check_dim_msg
(std::optional<V> &
v
,
auto
sz
, std::string
msg
) {
24
if
(!
v
) {
25
v
= V::Zero(
sz
);
26
}
else
if
(
v
->size() !=
sz
) {
27
msg
+=
"\n(should be "
;
28
msg
+= std::to_string(
sz
);
29
msg
+=
", got "
;
30
msg
+= std::to_string(
v
->size());
31
msg
+=
")"
;
32
throw
std::invalid_argument(
msg
);
33
}
34
}
23
void
check_dim_msg
(std::optional<V> &
v
,
auto
sz
, std::string
msg
) {
…
}
35
36
template
<
class
V>
37
void
check_dim
(std::string name,
V
&&
v
,
auto
sz
) {
38
name +=
": dimension mismatch"
;
39
check_dim_msg
(std::forward<V>(
v
),
sz
, name);
40
}
37
void
check_dim
(std::string name,
V
&&
v
,
auto
sz
) {
…
}
41
42
template
<
class
M>
43
void
check_dim_msg
(
const
M
&m,
auto
rows,
auto
cols, std::string
msg
) {
44
if
(m.cols() != cols || m.rows() != rows) {
45
msg
+=
"\n(should be "
;
46
msg
+= std::to_string(rows);
47
msg
+=
"×"
;
48
msg
+= std::to_string(cols);
49
msg
+=
", got "
;
50
msg
+= std::to_string(m.rows());
51
msg
+=
"×"
;
52
msg
+= std::to_string(m.cols());
53
msg
+=
")"
;
54
throw
std::invalid_argument(
msg
);
55
}
56
}
43
void
check_dim_msg
(
const
M
&m,
auto
rows,
auto
cols, std::string
msg
) {
…
}
57
58
template
<
class
M>
59
void
check_dim
(std::string name,
M
&&m,
auto
rows,
auto
cols) {
60
name +=
": dimension mismatch"
;
61
check_dim_msg
(std::forward<M>(m), rows, cols, name);
62
}
59
void
check_dim
(std::string name,
M
&&m,
auto
rows,
auto
cols) {
…
}
63
64
}
// namespace alpaqa::util
8
namespace
alpaqa::util
{
…
}
config.hpp
alpaqa::util
Definition
check-dim.hpp:8
alpaqa::util::check_dim
void check_dim(std::string name, V &&v, auto sz)
Definition
check-dim.hpp:37
alpaqa::util::check_dim_msg
void check_dim_msg(const V &v, auto sz, std::string msg)
Definition
check-dim.hpp:11
alpaqa::inf
constexpr const auto inf
Definition
config.hpp:85
Generated on Wed Nov 22 2023 for alpaqa by
1.9.8