Verified Commit 5fa47d72 authored by Tim Gymnich's avatar Tim Gymnich
Browse files

Improved printing of doubles

parent ee5705ec
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "global.h" #include "global.h"
#include <vector> #include <vector>
#include <type_traits>
using namespace std; using namespace std;
...@@ -379,10 +380,18 @@ llvm::raw_ostream& operator<<(llvm::raw_ostream& os, Matrix<T> const& matrix) { ...@@ -379,10 +380,18 @@ llvm::raw_ostream& operator<<(llvm::raw_ostream& os, Matrix<T> const& matrix) {
for (int row = 0; row < matrix.getHeight(); row++) { for (int row = 0; row < matrix.getHeight(); row++) {
os << "[ "; os << "[ ";
for (int column = 0; column < matrix.getWidth(); column++) { for (int column = 0; column < matrix.getWidth(); column++) {
if (column == matrix.getWidth() - 1) { if constexpr (std::is_floating_point_v<T>) {
os << llvm::format("%d", matrix.value(row,column)); if (column == matrix.getWidth() - 1) {
os << llvm::format("%f", matrix.value(row,column));
} else {
os << llvm::format("%-6.2f", matrix.value(row,column));
}
} else { } else {
os << llvm::format("%-6d", matrix.value(row,column)); if (column == matrix.getWidth() - 1) {
os << llvm::format("%d", matrix.value(row,column));
} else {
os << llvm::format("%-6d", matrix.value(row,column));
}
} }
} }
os << " ]\n"; os << " ]\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment