Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00033 #include <acado/matrix_vector/acado_mat_file.hpp>
00034
00035 BEGIN_NAMESPACE_ACADO
00036
00037 template<typename T>
00038 void MatFile< T >::write( std::ostream& stream,
00039 const GenericMatrix< T >& mat,
00040 const char* name
00041 )
00042 {
00043 Fmatrix x;
00044 double tmp;
00045
00046 x.type = 0000;
00047 x.mrows = mat.getNumRows();
00048 x.ncols = mat.getNumCols();
00049 x.imagf = 0;
00050 x.namelen = 1+strlen(name);
00051
00052 stream.write( (char*) &x, sizeof(Fmatrix));
00053 stream.write(name, x.namelen);
00054
00055
00056 for (uint col = 0; col < mat.getNumCols(); ++col)
00057 {
00058 for (uint row = 0; row < mat.getNumRows(); ++row)
00059 {
00060 tmp = mat(row, col);
00061 stream.write((char*) &tmp, sizeof(double));
00062 }
00063 }
00064
00065
00066 }
00067
00068 template<typename T>
00069 void MatFile< T >::write( std::ostream& stream,
00070 const GenericVector< T >& vec,
00071 const char* name
00072 )
00073 {
00074 Fmatrix x;
00075 double tmp;
00076
00077 x.type = 0000;
00078 x.mrows = vec.getDim();
00079 x.ncols = 1;
00080 x.imagf = 0;
00081 x.namelen = 1+strlen(name);
00082
00083 stream.write( (char*) &x, sizeof(Fmatrix));
00084 stream.write(name, x.namelen);
00085
00086
00087 for (uint row=0; row<vec.getDim(); ++row)
00088 {
00089 tmp = vec( row );
00090 stream.write((char*) &tmp, sizeof(double));
00091 }
00092
00093
00094 }
00095
00096
00097
00098
00099 template class MatFile< double >;
00100 template class MatFile< int >;
00101 template class MatFile< bool >;
00102
00103 CLOSE_NAMESPACE_ACADO