Skip to content

Commit

Permalink
Deprecate begin/end methods of matrix classes
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Aug 8, 2023
1 parent 609c09b commit ef99b25
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 deletions.
24 changes: 12 additions & 12 deletions include/cantera/base/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ class Array2D
//! types.
/*!
* This is just equal to vector<double>::iterator.
* @deprecated Unused. To be removed after %Cantera 3.0.
*/
typedef vector<double>::iterator iterator;

//! Type definition for the const_iterator class that is can be used by
//! Array2D types.
/*!
* This is just equal to vector<double>::const_iterator.
* @deprecated Unused. To be removed after %Cantera 3.0.
*/
typedef vector<double>::const_iterator const_iterator;

Expand Down Expand Up @@ -197,24 +199,20 @@ class Array2D
}

//! Return an iterator pointing to the first element
iterator begin() {
return m_data.begin();
}
//! @deprecated Unused. To be removed after %Cantera 3.0.
iterator begin();

//! Return an iterator pointing past the last element
iterator end() {
return m_data.end();
}
//! @deprecated Unused. To be removed after %Cantera 3.0.
iterator end();

//! Return a const iterator pointing to the first element
const_iterator begin() const {
return m_data.begin();
}
//! @deprecated Unused. To be removed after %Cantera 3.0.
const_iterator begin() const;

//! Return a const iterator pointing to past the last element
const_iterator end() const {
return m_data.end();
}
//! @deprecated Unused. To be removed after %Cantera 3.0.
const_iterator end() const;

//! Return a reference to the data vector
vector<double>& data() {
Expand All @@ -226,6 +224,8 @@ class Array2D
return m_data;
}

void operator*=(double a);

//! Return a pointer to the top of column j, columns are contiguous
//! in memory
/*!
Expand Down
4 changes: 4 additions & 0 deletions include/cantera/numerics/BandMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,28 @@ class BandMatrix : public GeneralMatrix
//! Returns an iterator for the start of the band storage data
/*!
* Iterator points to the beginning of the data, and it is changeable.
* @deprecated Unused. To be removed after %Cantera 3.0.
*/
virtual vector<double>::iterator begin();

//! Returns an iterator for the end of the band storage data
/*!
* Iterator points to the end of the data, and it is changeable.
* @deprecated Unused. To be removed after %Cantera 3.0.
*/
vector<double>::iterator end();

//! Returns a const iterator for the start of the band storage data
/*!
* Iterator points to the beginning of the data, and it is not changeable.
* @deprecated Unused. To be removed after %Cantera 3.0.
*/
vector<double>::const_iterator begin() const;

//! Returns a const iterator for the end of the band storage data
/*!
* Iterator points to the end of the data, and it is not changeable.
* @deprecated Unused. To be removed after %Cantera 3.0.
*/
vector<double>::const_iterator end() const;

Expand Down
4 changes: 2 additions & 2 deletions include/cantera/numerics/GeneralMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ class GeneralMatrix

//! Return an iterator pointing to the first element
/*!
* We might drop this later
* @deprecated Unused. To be removed after %Cantera 3.0.
*/
virtual vector<double>::iterator begin() = 0;

//! Return a const iterator pointing to the first element
/*!
* We might drop this later
* @deprecated Unused. To be removed after %Cantera 3.0.
*/
virtual vector<double>::const_iterator begin() const = 0;

Expand Down
20 changes: 20 additions & 0 deletions src/base/Array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "cantera/base/Array.h"
#include "cantera/base/utilities.h"
#include "cantera/base/global.h"

namespace Cantera
{
Expand Down Expand Up @@ -96,6 +97,25 @@ void Array2D::getColumn(size_t m, double* const col)
}
}

Array2D::iterator Array2D::begin() {

Check warning on line 100 in src/base/Array.cpp

View check run for this annotation

Codecov / codecov/patch

src/base/Array.cpp#L100

Added line #L100 was not covered by tests
warn_deprecated("Array2D::begin", "To be removed after Cantera 3.0.");
return m_data.begin();

Check warning on line 102 in src/base/Array.cpp

View check run for this annotation

Codecov / codecov/patch

src/base/Array.cpp#L102

Added line #L102 was not covered by tests
}

Array2D::iterator Array2D::end() {

Check warning on line 105 in src/base/Array.cpp

View check run for this annotation

Codecov / codecov/patch

src/base/Array.cpp#L105

Added line #L105 was not covered by tests
warn_deprecated("Array2D::end", "To be removed after Cantera 3.0.");
return m_data.end();

Check warning on line 107 in src/base/Array.cpp

View check run for this annotation

Codecov / codecov/patch

src/base/Array.cpp#L107

Added line #L107 was not covered by tests
}

Array2D::const_iterator Array2D::begin() const {

Check warning on line 110 in src/base/Array.cpp

View check run for this annotation

Codecov / codecov/patch

src/base/Array.cpp#L110

Added line #L110 was not covered by tests
warn_deprecated("Array2D::begin", "To be removed after Cantera 3.0.");
return m_data.begin();

Check warning on line 112 in src/base/Array.cpp

View check run for this annotation

Codecov / codecov/patch

src/base/Array.cpp#L112

Added line #L112 was not covered by tests
}

Array2D::const_iterator Array2D::end() const {

Check warning on line 115 in src/base/Array.cpp

View check run for this annotation

Codecov / codecov/patch

src/base/Array.cpp#L115

Added line #L115 was not covered by tests
warn_deprecated("Array2D::end", "To be removed after Cantera 3.0.");
return m_data.end();

Check warning on line 117 in src/base/Array.cpp

View check run for this annotation

Codecov / codecov/patch

src/base/Array.cpp#L117

Added line #L117 was not covered by tests
}

std::ostream& operator<<(std::ostream& s, const Array2D& m)
{
Expand Down
4 changes: 4 additions & 0 deletions src/numerics/BandMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,23 +292,27 @@ int BandMatrix::solve(double* b, size_t nrhs, size_t ldb)

vector<double>::iterator BandMatrix::begin()
{
warn_deprecated("BandMatrix::begin", "To be removed after Cantera 3.0.");
m_factored = false;
return data.begin();
}

vector<double>::iterator BandMatrix::end()
{
warn_deprecated("BandMatrix::end", "To be removed after Cantera 3.0.");
m_factored = false;
return data.end();
}

vector<double>::const_iterator BandMatrix::begin() const
{
warn_deprecated("BandMatrix::begin", "To be removed after Cantera 3.0.");
return data.begin();
}

vector<double>::const_iterator BandMatrix::end() const
{
warn_deprecated("BandMatrix::end", "To be removed after Cantera 3.0.");
return data.end();
}

Expand Down

0 comments on commit ef99b25

Please sign in to comment.