Skip to content
Snippets Groups Projects
Commit 89832db1 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

C++11: convert MatrixForm to a class enum

parent 946d105c
No related branches found
No related tags found
No related merge requests found
......@@ -27,24 +27,24 @@ SigmaeStatement::SigmaeStatement(matrix_t matrix_arg) noexcept(false) :
{
}
SigmaeStatement::matrix_form_t
SigmaeStatement::MatrixForm
SigmaeStatement::determineMatrixForm(const matrix_t &matrix) noexcept(false)
{
size_t nbe;
int inc;
matrix_form_t type;
MatrixForm type;
// Checking if first or last row has one element.
if (matrix.front().size() == 1)
{
inc = 1;
nbe = 2;
type = eLower;
type = MatrixForm::lower;
}
else if (matrix.back().size() == 1)
{
inc = -1;
nbe = matrix.front().size()-1;
type = eUpper;
type = MatrixForm::upper;
}
else
throw MatrixFormException();
......@@ -70,17 +70,17 @@ SigmaeStatement::writeOutput(ostream &output, const string &basename, bool minim
{
for (ic = 0; ic < matrix.size(); ic++)
{
if (ic >= ir && matrix_form == eUpper)
if (ic >= ir && matrix_form == MatrixForm::upper)
{
ic1 = ic-ir;
ir1 = ir;
}
else if (ic < ir && matrix_form == eUpper)
else if (ic < ir && matrix_form == MatrixForm::upper)
{
ic1 = ir-ic;
ir1 = ic;
}
else if (ic > ir && matrix_form == eLower)
else if (ic > ir && matrix_form == MatrixForm::lower)
{
ic1 = ir;
ir1 = ic;
......
......@@ -31,10 +31,10 @@ class SigmaeStatement : public Statement
{
public:
//! Matrix form (lower or upper triangular) enum
enum matrix_form_t
enum class MatrixForm
{
eLower = 0, //!< Lower triangular matrix
eUpper = 1 //!< Upper triangular matrix
lower, //!< Lower triangular matrix
upper //!< Upper triangular matrix
};
//! Type of a matrix row
using row_t = vector<expr_t>;
......@@ -49,11 +49,11 @@ private:
//! The matrix
const matrix_t matrix;
//! Matrix form (lower or upper)
const matrix_form_t matrix_form;
const MatrixForm matrix_form;
//! Returns the type (upper or lower triangular) of a given matrix
/*! Throws an exception if it is neither upper triangular nor lower triangular */
static matrix_form_t determineMatrixForm(const matrix_t &matrix) noexcept(false);
static MatrixForm determineMatrixForm(const matrix_t &matrix) noexcept(false);
public:
SigmaeStatement(matrix_t matrix_arg) noexcept(false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment