⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrix_triangpacked.cxx

📁 Multivac 的Level set包
💻 CXX
📖 第 1 页 / 共 3 页
字号:
    FileStream.write(reinterpret_cast<char*>(this->data_),		     this->GetDataSize() * sizeof(value_type));#ifdef SELDON_CHECK_IO    // Checks if data was written.    if (!FileStream.good())      throw IOError("Matrix_TriangPacked::Write(ofstream& FileStream)",                    string("Output operation failed.")		    + string(" The output file may have been removed")		    + " or there is no space left on device.");#endif  }  //! Writes the matrix in a file.  /*!    Stores the matrix in a file in text format.    Only matrix elements are written (not dimensions).    Each row is written on a single line and elements of    a row are delimited by tabulations.    \param FileName output file name.  */  template <class T, class Prop, class Storage, class Allocator>  void Matrix_TriangPacked<T, Prop, Storage, Allocator>  ::WriteText(string FileName) const  {    ofstream FileStream;    FileStream.open(FileName.c_str());#ifdef SELDON_CHECK_IO    // Checks if the file was opened.    if (!FileStream.is_open())      throw IOError("Matrix_TriangPacked::WriteText(string FileName)",		    string("Unable to open file \"") + FileName + "\".");#endif    this->WriteText(FileStream);    FileStream.close();  }  //! Writes the matrix to an output stream.  /*!    Writes the matrix to an output stream in text format.    Only matrix elements are written (not dimensions).    Each row is written on a single line and elements of    a row are delimited by tabulations.    \param FileStream output stream.  */  template <class T, class Prop, class Storage, class Allocator>  void Matrix_TriangPacked<T, Prop, Storage, Allocator>  ::WriteText(ofstream& FileStream) const  {#ifdef SELDON_CHECK_IO    // Checks if the stream is ready.    if (!FileStream.good())      throw IOError("Matrix_TriangPacked::WriteText(ofstream& FileStream)",                    "Stream is not ready.");#endif    int i, j;    for (i = 0; i < this->GetM(); i++)      {	for (j = 0; j < this->GetN(); j++)	  FileStream << (*this)(i, j) << '\t';	FileStream << endl;      }#ifdef SELDON_CHECK_IO    // Checks if data was written.    if (!FileStream.good())      throw IOError("Matrix_TriangPacked::WriteText(ofstream& FileStream)",                    string("Output operation failed.")		    + string(" The output file may have been removed")		    + " or there is no space left on device.");#endif  }  //! Reads the matrix from a file.  /*!    Reads a matrix stored in binary format in a file.    The number of rows (integer) and the number of columns (integer)    are read, and matrix elements are then read in the same order    as it should be in memory (e.g. row-major storage).    \param FileName input file name.  */  template <class T, class Prop, class Storage, class Allocator>  void Matrix_TriangPacked<T, Prop, Storage, Allocator>::Read(string FileName)  {    ifstream FileStream;    FileStream.open(FileName.c_str());#ifdef SELDON_CHECK_IO    // Checks if the file was opened.    if (!FileStream.good())      throw IOError("Matrix_TriangPacked::Read(string FileName)",		    string("Unable to open file \"") + FileName + "\".");#endif    this->Read(FileStream);    FileStream.close();  }   //! Reads the matrix from an input stream.  /*!    Reads a matrix in binary format from an input stream.    The number of rows (integer) and the number of columns (integer)    are read, and matrix elements are then read in the same order    as it should be in memory (e.g. row-major storage).    \param FileStream input stream.  */  template <class T, class Prop, class Storage, class Allocator>  void Matrix_TriangPacked<T, Prop, Storage, Allocator>  ::Read(ifstream& FileStream)  {#ifdef SELDON_CHECK_IO    // Checks if the stream is ready.    if (!FileStream.good())      throw IOError("Matrix_TriangPacked::Read(ifstream& FileStream)",                    "Stream is not ready.");#endif    int new_m, new_n;    FileStream.read(reinterpret_cast<char*>(&new_m), sizeof(int));    FileStream.read(reinterpret_cast<char*>(&new_n), sizeof(int));    this->Reallocate(new_m, new_n);    FileStream.read(reinterpret_cast<char*>(this->data_),		    this->GetDataSize() * sizeof(value_type));#ifdef SELDON_CHECK_IO    // Checks if data was read.    if (!FileStream.good())      throw IOError("Matrix_TriangPacked::Read(ifstream& FileStream)",                    string("Output operation failed.")		    + string(" The intput file may have been removed")		    + " or may not contain enough data.");#endif      }  ///////////////////////////////  // MATRIX<COLUPTRIANGPACKED> //  ///////////////////////////////  /****************   * CONSTRUCTORS *   ****************/  //! Default constructor.  /*!    On exit, the matrix is an empty 0x0 matrix.  */  template <class T, class Prop, class Allocator>  inline Matrix<T, Prop, ColUpTriangPacked, Allocator>::Matrix():    Matrix_TriangPacked<T, Prop, ColUpTriangPacked, Allocator>()  {  }  //! Main constructor.  /*! Builds a i x j column-major upper triangular matrix in packed form.    \param i number of rows.    \param j number of columns.    \note 'j' is assumed to be equal to 'i' and is therefore discarded.  */  template <class T, class Prop, class Allocator>  inline Matrix<T, Prop, ColUpTriangPacked, Allocator>::Matrix(int i, int j):    Matrix_TriangPacked<T, Prop, ColUpTriangPacked, Allocator>(i, i)  {  }  /*****************   * OTHER METHODS *   *****************/  //! Fills the matrix with a given value.  /*!    \param x value to fill the matrix with.  */  template <class T, class Prop, class Allocator>  template <class T0>  Matrix<T, Prop, ColUpTriangPacked, Allocator>&  Matrix<T, Prop, ColUpTriangPacked, Allocator>::operator= (const T0& x)  {    this->Fill(x);    return *this;  }  ///////////////////////////////  // MATRIX<COLLOTRIANGPACKED> //  ///////////////////////////////  /****************   * CONSTRUCTORS *   ****************/  //! Default constructor.  /*!    On exit, the matrix is an empty 0x0 matrix.  */  template <class T, class Prop, class Allocator>  inline Matrix<T, Prop, ColLoTriangPacked, Allocator>::Matrix():    Matrix_TriangPacked<T, Prop, ColLoTriangPacked, Allocator>()  {  }  //! Main constructor.  /*! Builds a i x j column-major lower triangular matrix in packed form.    \param i number of rows.    \param j number of columns.    \note 'j' is assumed to be equal to 'i' and is therefore discarded.  */  template <class T, class Prop, class Allocator>  inline Matrix<T, Prop, ColLoTriangPacked, Allocator>::Matrix(int i, int j):    Matrix_TriangPacked<T, Prop, ColLoTriangPacked, Allocator>(i, i)  {  }  /*****************   * OTHER METHODS *   *****************/  //! Fills the matrix with a given value.  /*!    \param x value to fill the matrix with.  */  template <class T, class Prop, class Allocator>  template <class T0>  Matrix<T, Prop, ColLoTriangPacked, Allocator>&  Matrix<T, Prop, ColLoTriangPacked, Allocator>::operator= (const T0& x)  {    this->Fill(x);    return *this;  }  ///////////////////////////////  // MATRIX<ROWUPTRIANGPACKED> //  ///////////////////////////////  /****************   * CONSTRUCTORS *   ****************/  //! Default constructor.  /*!    On exit, the matrix is an empty 0x0 matrix.  */  template <class T, class Prop, class Allocator>  inline Matrix<T, Prop, RowUpTriangPacked, Allocator>::Matrix():    Matrix_TriangPacked<T, Prop, RowUpTriangPacked, Allocator>()  {  }  //! Main constructor.  /*! Builds a i x j row-major upper triangular matrix in packed form.    \param i number of rows.    \param j number of columns.    \note 'j' is assumed to be equal to 'i' and is therefore discarded.  */  template <class T, class Prop, class Allocator>  inline Matrix<T, Prop, RowUpTriangPacked, Allocator>::Matrix(int i, int j):    Matrix_TriangPacked<T, Prop, RowUpTriangPacked, Allocator>(i, i)  {  }  /*****************   * OTHER METHODS *   *****************/  //! Fills the matrix with a given value.  /*!    \param x value to fill the matrix with.  */  template <class T, class Prop, class Allocator>  template <class T0>  Matrix<T, Prop, RowUpTriangPacked, Allocator>&  Matrix<T, Prop, RowUpTriangPacked, Allocator>::operator= (const T0& x)  {    this->Fill(x);    return *this;  }  ///////////////////////////////  // MATRIX<ROWLOTRIANGPACKED> //  ///////////////////////////////  /****************   * CONSTRUCTORS *   ****************/  //! Default constructor.  /*!    On exit, the matrix is an empty 0x0 matrix.  */  template <class T, class Prop, class Allocator>  inline Matrix<T, Prop, RowLoTriangPacked, Allocator>::Matrix():    Matrix_TriangPacked<T, Prop, RowLoTriangPacked, Allocator>()  {  }  //! Main constructor.  /*! Builds a i x j row-major lower triangular matrix in packed form.    \param i number of rows.    \param j number of columns.    \note 'j' is assumed to be equal to 'i' and is therefore discarded.  */  template <class T, class Prop, class Allocator>  inline Matrix<T, Prop, RowLoTriangPacked, Allocator>::Matrix(int i, int j):    Matrix_TriangPacked<T, Prop, RowLoTriangPacked, Allocator>(i, i)  {  }  /*****************   * OTHER METHODS *   *****************/  //! Fills the matrix with a given value.  /*!    \param x value to fill the matrix with.  */  template <class T, class Prop, class Allocator>  template <class T0>  Matrix<T, Prop, RowLoTriangPacked, Allocator>&  Matrix<T, Prop, RowLoTriangPacked, Allocator>::operator= (const T0& x)  {    this->Fill(x);    return *this;  }} // namespace Seldon.#define SELDON_FILE_MATRIX_TRIANGPACKED_CXX#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -