MCPcopy Create free account
hub / github.com/TinyMPC/TinyMPC / print_matrix

Function print_matrix

src/tinympc/codegen.cpp:33–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31using namespace Eigen;
32
33static void print_matrix(FILE *f, MatrixXd mat, int num_elements)
34{
35 // Check if matrix is uninitialized or too small
36 if (mat.size() == 0 || mat.size() < num_elements) {
37 // Print zeros for all elements
38 for (int i = 0; i < num_elements; i++) {
39 fprintf(f, "(tinytype)0.0000000000000000");
40 if (i < num_elements - 1)
41 fprintf(f, ",");
42 }
43 return;
44 }
45
46 // Matrix is properly initialized and has enough elements
47 for (int i = 0; i < num_elements; i++) {
48 fprintf(f, "(tinytype)%.16f", mat.reshaped<RowMajor>()[i]);
49 if (i < num_elements - 1)
50 fprintf(f, ",");
51 }
52}
53
54
55static void create_directory(const char* dir, int verbose) {

Callers 3

codegen_data_sourceFunction · 0.85
WithFormatClass · 0.85
IO.hFile · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected