2 #ifndef vnl_xio_matrix_hxx_ 3 #define vnl_xio_matrix_hxx_ 7 #include <vsl/vsl_basic_xml_element.h> 13 vsl_basic_xml_element element(name);
14 element.add_attribute(
"rows", (
int) M.
rows());
15 element.add_attribute(
"cols", (
int) M.
cols());
16 for (
unsigned int r=0; r<M.
rows(); ++r) {
17 for (
unsigned int c=0; c<M.
cols(); ++c)
18 element.append_cdata(M.
get(r,c));
27 vsl_basic_xml_element element(name);
28 element.add_attribute(
"rows", (
int) M.
rows());
29 element.add_attribute(
"cols", (
int) M.
cols());
30 for (
unsigned int r=0; r<M.
rows(); ++r) {
31 element.append_cdata(
"<row>");
32 for (
unsigned int c=0; c<M.
cols(); ++c) {
33 element.append_cdata(
"<cell>");
34 element.append_cdata(M.
get(r,c));
35 element.append_cdata(
"</cell>");
37 element.append_cdata(
"</row>");
42 #undef VNL_XIO_MATRIX_INSTANTIATE 43 #define VNL_XIO_MATRIX_INSTANTIATE(T) \ 44 template VNL_EXPORT void x_write(std::ostream &, vnl_matrix<T > const&, std::string); \ 45 template VNL_EXPORT void x_write_tree(std::ostream &, vnl_matrix<T > const&, std::string) 47 #endif // vnl_xio_matrix_hxx_ unsigned int cols() const
Return the number of columns.
XML write a vnl_matrix Two functions which write a valid XML fragment to an ostream.
An ordinary mathematical matrix.
void VNL_EXPORT x_write_tree(std::ostream &os, vnl_matrix< T > const &v, std::string name="vnl_matrix")
XML save vnl_matrix as a 3-level tree to stream.
T get(unsigned r, unsigned c) const
get element with boundary checks if error checking is on.
An ordinary mathematical matrix.
unsigned int rows() const
Return the number of rows.
void VNL_EXPORT x_write(std::ostream &os, vnl_matrix< T > const &v, std::string name="vnl_matrix")
XML save vnl_matrix to stream.