-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathutils.h
More file actions
39 lines (34 loc) · 807 Bytes
/
utils.h
File metadata and controls
39 lines (34 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef UTILS_H
#define UTILS_H
#include <clarabel.hpp>
#include <cstddef>
#include <cstdio>
namespace utils
{
template<typename T>
void print_array(Eigen::Map<Eigen::VectorX<T>> &vec)
{
printf("[");
size_t n = vec.size();
for (size_t i = 0; i < n; i++)
{
printf("%.10f", vec.data()[i]);
if (i < n - 1)
{
printf(", ");
}
}
printf("]\n");
}
template<typename T>
void print_solution(clarabel::DefaultSolution<T> &solution)
{
printf("Solution (x)\t = ");
print_array(solution.x);
printf("Multipliers (z)\t = ");
print_array(solution.z);
printf("Slacks (s)\t = ");
print_array(solution.s);
}
}
#endif /* UTILS_H */