.. include:: ../../toolkit-substitutions

.. oe:namespace:: OEMath

.. meta::
   :keywords: OEMatrix


.. _OEMath_OEMatrix:

.. oe:class:: OEMatrix

   .. oe:api::

      class OEMatrix

   :ref:`OEMatrix <OEMath_OEMatrix>` class represents a Matrix.

   The :ref:`OEMatrix <OEMath_OEMatrix>` class defines the following public methods:
    * :oe:meth:`AddRow<OEMath::OEMatrix::AddRow>`
    * :oe:meth:`Clear<OEMath::OEMatrix::Clear>`
    * :oe:meth:`GetData<OEMath::OEMatrix::GetData>`
    * :oe:meth:`GetNumColumns<OEMath::OEMatrix::GetNumColumns>`
    * :oe:meth:`GetNumRows<OEMath::OEMatrix::GetNumRows>`
    * :oe:meth:`Resize<OEMath::OEMatrix::Resize>`
    * :oe:meth:`SetRowData<OEMath::OEMatrix::SetRowData>`
    * :oe:meth:`Transpose<OEMath::OEMatrix::Transpose>`


   .. oe:method:: Constructors

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEMatrix()
            OEMatrix(const unsigned numRow, const unsigned numCol,
                     const double initialValue = 0.0)
            OEMatrix(const OEMatrix&)

      .. oe:language:: python

         .. oe:api:: python

            OEMatrix() -> OEMatrix
            OEMatrix(arg2: OEMatrix) -> OEMatrix
            OEMatrix(numRow: int, numCol: int, initialValue: float = 0.0) -> OEMatrix

      Default and copy constructors.

      The default constructor creates an empty matrix. The second overload creates a matrix
      with *numRows* rows and *numCols* columns, with all the values set to zero.  The
      third overload creates a matrix with *numRows* rows and *numCols* columns, with all the 
      values set to *initialValue*.

   .. oe:method:: operator=
      :language: c++
  
      .. oe:api::

         OEMatrix& operator=(const OEMatrix& rhs)

      Assignment operator for :ref:`OEMatrix <OEMath_OEMatrix>`.

      Assignment operator.


   .. oe:method:: AddRow
        
      .. oe:language:: c++ java csharp

         .. oe:api::

            void AddRow(const double initialValue = 0.0)

      .. oe:language:: python

         .. oe:api:: python

            AddRow(initialValue: float = 0.0) -> None

      Add a new row to the matrix.  The new row is initialized with *zero*, unless
      *initialValue* is provided.

   .. oe:method:: Clear
        
      .. oe:language:: c++ java csharp

         .. oe:api::

            void Clear()

      .. oe:language:: python

         .. oe:api:: python

            Clear() -> None

      Clear the matrix.

   .. oe:method:: GetData
        
      .. oe:language:: c++ java csharp

         .. oe:api::

            const std::vector<double>& GetData() const

      .. oe:language:: python

         .. oe:api:: python

            GetData() -> OEDoubleVector

      Get the contents of the matrix. The data is organized sequentially from the first row
      to the last.

   .. oe:method:: GetNumColumns
        
      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned GetNumColumns() const

      .. oe:language:: python

         .. oe:api:: python

            GetNumColumns() -> int

      Returns the number of columns in the matrix.

   .. oe:method:: GetNumRows
        
      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned GetNumRows() const

      .. oe:language:: python

         .. oe:api:: python

            GetNumRows() -> int

      Returns the number of rows in the matrix.

   .. oe:method:: Resize
        
      .. oe:language:: c++ java csharp

         .. oe:api::

            void Resize(const unsigned numRow, const unsigned numCol,
                        const double initialValue = 0.0)

      .. oe:language:: python

         .. oe:api:: python

            Resize(numRow: int, numCol: int, initialValue: float = 0.0) -> None

      Resize the matrix to *numRows* rows and *numCols* columns.  The matrix is initialized 
      with *zero*, unless *initialValue* is provided.

   .. oe:method:: SetRowData
        
      .. oe:language:: c++ java csharp

         .. oe:api::

            void SetRowData(const unsigned iRow,
                            const std::vector<double>& vecValues)

      .. oe:language:: python

         .. oe:api:: python

            SetRowData(iRow: int, vecValues: OEDoubleVector) -> None

      Set *vecValues* as content of the *iRow*-th row.

   .. oe:method:: Transpose
        
      .. oe:language:: c++ java csharp

         .. oe:api::

            OEMatrix Transpose() const

      .. oe:language:: python

         .. oe:api:: python

            Transpose() -> OEMatrix

      Returns the transpose of the matrix.
