CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
outputHelpers.hpp
1#pragma once
2
3#include <iostream>
4
5template<typename Vec>
6void printVector(std::string const& name, Vec const& v, size_t length, size_t offset) {
7 std::cout << "Vector " << name << ": {";
8 for(size_t i = 0; i < length; i += 1) {
9 if(i != 0) {
10 std::cout << ", ";
11 }
12 std::cout << v[offset + i];
13 }
14 std::cout << "}" << std::endl;
15}
16
17template<typename Vec>
18void printVectorDim(std::string const& name, Vec const& v, size_t length, size_t offset, size_t dim) {
19 std::cout << "Vector " << name << ": {";
20 for(size_t i = 0; i < length; i += 1) {
21 if(i != 0) {
22 std::cout << ", ";
23 }
24 std::cout << v[offset + i][dim];
25 }
26 std::cout << "}" << std::endl;
27}
28
29
30template<typename Jac>
31void printJacCol(std::string const& text, Jac const &jac, size_t col) {
32 std::cout << text <<": {";
33 for(size_t j = 0; j < jac.getN(); j += 1) {
34 if(j != 0) {
35 std::cout << ", ";
36 }
37 std::cout << jac(col, j);
38 }
39 std::cout << "}" << std::endl;
40}
41
42template<typename Hes>
43void printHesForOutput(std::string const& text, Hes const &hes, size_t output) {
44 std::cout << text <<": {\n";
45 for(size_t j = 0; j < hes.getN(); j += 1) {
46 std::cout << " ";
47 for(size_t k = 0; k < hes.getN(); k += 1) {
48 if(k != 0) {
49 std::cout << ", ";
50 }
51 std::cout << hes(output, j, k);
52 }
53 std::cout << "\n";
54 }
55 std::cout << "}" << std::endl;
56}
size_t constexpr dim()
Number of dimensions this gradient value has.
Definition gradientTraits.hpp:96