Skip to content
Snippets Groups Projects
Commit a132286f authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add output for subviews

parent 7dd81c7b
No related branches found
No related tags found
1 merge request!161Improve connectivity construction's performances
...@@ -24,6 +24,18 @@ class [[nodiscard]] Array ...@@ -24,6 +24,18 @@ class [[nodiscard]] Array
const size_t m_size; const size_t m_size;
public: public:
friend std::ostream&
operator<<(std::ostream& os, const UnsafeArrayView& x)
{
if (x.size() > 0) {
os << 0 << ':' << NaNHelper(x[0]);
}
for (size_t i = 1; i < x.size(); ++i) {
os << ' ' << i << ':' << NaNHelper(x[i]);
}
return os;
}
[[nodiscard]] PUGS_INLINE size_t [[nodiscard]] PUGS_INLINE size_t
size() const size() const
{ {
......
...@@ -63,6 +63,19 @@ class [[nodiscard]] Table ...@@ -63,6 +63,19 @@ class [[nodiscard]] Table
Assert(row < table.numberOfRows(), "required row view is not contained in the Table"); Assert(row < table.numberOfRows(), "required row view is not contained in the Table");
} }
friend std::ostream&
operator<<(std::ostream& os, const UnsafeRowView& x)
{
if (x.size() > 0) {
os << 0 << ':' << NaNHelper(x[0]);
}
for (size_t i = 1; i < x.size(); ++i) {
os << ' ' << i << ':' << NaNHelper(x[i]);
}
return os;
}
// To try to keep these views close to the initial array one // To try to keep these views close to the initial array one
// forbids copy constructor and take benefits of C++-17 copy // forbids copy constructor and take benefits of C++-17 copy
// elisions. // elisions.
...@@ -113,6 +126,19 @@ class [[nodiscard]] Table ...@@ -113,6 +126,19 @@ class [[nodiscard]] Table
} }
} }
friend std::ostream&
operator<<(std::ostream& os, const RowView& x)
{
if (x.size() > 0) {
os << 0 << ':' << NaNHelper(x[0]);
}
for (size_t i = 1; i < x.size(); ++i) {
os << ' ' << i << ':' << NaNHelper(x[i]);
}
return os;
}
RowView(const UnsafeTableView& table_view, index_type row) : m_table_view{table_view}, m_row{row} RowView(const UnsafeTableView& table_view, index_type row) : m_table_view{table_view}, m_row{row}
{ {
Assert(row < m_table_view.numberOfRows(), "required row view is not contained in the Table view"); Assert(row < m_table_view.numberOfRows(), "required row view is not contained in the Table view");
...@@ -155,6 +181,19 @@ class [[nodiscard]] Table ...@@ -155,6 +181,19 @@ class [[nodiscard]] Table
return m_table(m_row_begin + i, m_column_begin + j); return m_table(m_row_begin + i, m_column_begin + j);
} }
friend std::ostream&
operator<<(std::ostream& os, const UnsafeTableView& t)
{
for (size_t i = 0; i < t.numberOfRows(); ++i) {
os << i << '|';
for (size_t j = 0; j < t.numberOfColumns(); ++j) {
os << ' ' << j << ':' << NaNHelper(t(i, j));
}
os << '\n';
}
return os;
}
PUGS_INLINE void PUGS_INLINE void
fill(const DataType& data) const fill(const DataType& data) const
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment