34 gsXmlNode *
makeNode(
const std::string & name,
38 return data.allocate_node(rapidxml::node_element ,
39 data.allocate_string(name.c_str() ),
47 std::ostringstream oss;
49 oss << std::setprecision(data.getFloatPrecision()) <<
"\n";
53 for (
index_t j = 0; j< value.cols(); ++j)
55 for (
index_t i = 0; i< value.rows(); ++i)
56 oss << value(i,j) <<
" ";
60 for (
index_t i = 0; i< value.rows(); ++i)
62 for (
index_t j = 0; j< value.cols(); ++j)
63 oss << value(i,j) <<
" ";
67 return data.allocate_string( oss.str().c_str() );
73 const std::string& base_type_flag) {
75 std::string base_type_flag_;
76 base_type_flag_.reserve(base_type_flag.size());
77 std::transform(base_type_flag.cbegin(), base_type_flag.cend(),
78 std::back_inserter(base_type_flag_),
79 [](
unsigned char c) {
return std::tolower(c); });
80 if (base_type_flag_ ==
"ascii") {
81 std::istringstream str;
82 str.str(node->value());
83 result.resize(rows, cols);
84 for (
unsigned i = 0; i < rows; ++i)
85 for (
unsigned j = 0; j < cols; ++j)
87 if (!gsGetValue(str, result(i, j))) {
88 gsWarn <<
"XML Warning: Reading matrix of size " << rows
89 <<
"x" << cols <<
" failed.\n";
90 gsWarn <<
"Tag: " << node->name() <<
", Matrix entry: ("
91 << i <<
", " << j <<
").\n";
97 result.resize(rows, cols);
112 gsXmlTree & data, std::string name)
116 std::ostringstream str;
117 str << std::setprecision(data.getFloatPrecision());
118 const index_t nCol = mat.cols();
120 for (
index_t j=0; j != nCol; ++j)
121 for ( cIter it(mat,j); it; ++it )
124 str <<it.index() <<
" "<<j<<
" " << it.value() <<
"\n";
138 std::istringstream str;
139 str.str( node->value() );
144 while( (str >> r) && (str >> c) && ( gsGetValue(str,val)) )
Class that provides a container for triplets (i,j,value) to be filled in a sparse matrix...
Definition: gsSparseMatrix.h:33
static void DecodeIntoGsType(const std::string &base64_string, const std::string &base_type_flag_, gsMatrix< ScalarType > &result)
Decode a string and copy into requested gismo Type.
Definition: gsBase64.h:355
#define index_t
Definition: gsConfig.h:32
Input and output Utilities.
#define gsWarn
Definition: gsDebug.h:50
gsXmlNode * putSparseMatrixToXml(gsSparseMatrix< T > const &mat, gsXmlTree &data, std::string name="SparseMatrix")
Helper to insert sparse matrices into XML.
Definition: gsXml.hpp:111
gsXmlNode * makeNode(const std::string &name, gsXmlTree &data)
Helper to allocate XML node.
Definition: gsXml.cpp:54
char * makeValue(const std::string &value, gsXmlTree &data)
Helper to allocate XML value.
Definition: gsXml.cpp:32
gsXmlNode * putMatrixToXml(gsMatrix< T > const &mat, gsXmlTree &data, std::string name="Matrix")
Helper to insert matrices into XML.
Definition: gsXml.hpp:103
This is the main header file that collects wrappers of Eigen for linear algebra.
void getSparseEntriesFromXml(gsXmlNode *node, gsSparseEntries< T > &result)
Helper to fetch sparse entries.
Definition: gsXml.hpp:133
void getMatrixFromXml(gsXmlNode *node, unsigned const &rows, unsigned const &cols, gsMatrix< T > &result, const std::string &base_type_flag="ascii")
Helper to fetch matrices.
Definition: gsXml.hpp:71