The print_sparse function in RandBLAS 1.1 is very messy. A minimal improvement (should have the same behavior as the current function) is
template <typename SparseSkOp>
void print_sparse(const SparseSkOp &S0) {
using std::cout;
constexpr auto tab = '\t';
cout << "SparseSkOp information\n";
cout << tab << (S0.dist.major_axis == Axis::Short
? "SASO: short-axis-sparse operator"
: "LASO: long-axis-sparse operator") << '\n';
cout << tab << "n_rows = " << S0.dist.n_rows << '\n';
cout << tab << "n_cols = " << S0.dist.n_cols << '\n';
int64_t nnz = S0.dist.full_nnz;
auto print_array = [&](const char* label, auto* ptr) {
cout << tab << label;
if (ptr != nullptr) {
cout << "\n" << tab << tab;
std::copy(ptr, ptr + nnz, std::ostream_iterator<decltype(*ptr)>(cout, ", "));
// ^ That prints a comma separated sequence to cout.
} else {
cout << " is the null pointer.";
}
cout << '\n';
};
print_array("vector of row indices", S0.rows);
print_array("vector of column indices", S0.cols);
print_array("vector of values", S0.vals);
}
It would be better if we used RandBLAS' utility functions for array printing, and allowed Matlab / Python formatting strings.
The print_sparse function in RandBLAS 1.1 is very messy. A minimal improvement (should have the same behavior as the current function) is
It would be better if we used RandBLAS' utility functions for array printing, and allowed Matlab / Python formatting strings.