31 void gsWriteCsv(std::string
const & filename,
const gsMatrix<T> & matrix,
const std::vector<std::string> & headers = std::vector<std::string>() )
34 const static gsEigen::IOFormat CSVFormat(gsEigen::FullPrecision, gsEigen::Aligned,
", ",
"\n");
36 std::ofstream csv_file;
37 csv_file.open(filename);
38 GISMO_ASSERT( (headers.empty() || headers.size() == matrix.cols()),
"The column headers should be as many as the columns of the matrix provided." );
41 if (! headers.empty())
43 for (
index_t j=0 ; j < headers.size() ; j++)
45 csv_file << headers[j];
46 if (headers.size()-1 == j)
47 csv_file << CSVFormat.rowSeparator;
49 csv_file << CSVFormat.coeffSeparator ;
53 csv_file << matrix.format(CSVFormat);
#define index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
void gsWriteCsv(std::string const &filename, const gsMatrix< T > &matrix, const std::vector< std::string > &headers=std::vector< std::string >())
Export a gsMatrix to a .csv (comma separated values) file.
Definition: gsCsv.h:31
Provides forward declarations of types and structs.