| 31 | using namespace Eigen; |
| 32 | |
| 33 | static 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 | |
| 55 | static void create_directory(const char* dir, int verbose) { |
no test coverage detected