Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant comments, defaulted constructors, and defaulted operator= #237

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions include/sleipnir/Pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,9 @@ class PoolResource {
*/
PoolResource() { AddChunk(); }

/**
* Copy constructor.
*/
PoolResource(const PoolResource&) = delete;

/**
* Copy-assignment operator.
*/
PoolResource& operator=(const PoolResource&) = delete;

/**
* Move constructor.
*/
PoolResource(PoolResource&&) = default;

/**
* Move-assignment operator.
*/
PoolResource& operator=(PoolResource&&) = default;

/**
Expand Down
22 changes: 1 addition & 21 deletions include/sleipnir/autodiff/Expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,30 +130,10 @@ struct SLEIPNIR_DLLEXPORT Expression {
uint32_t refCount = 0;

/**
* Default constructor.
* Constructs a constant expression with a value of zero.
*/
Expression() = default;

/**
* Copy constructor.
*/
Expression(const Expression&) = default;

/**
* Copy-assignment operator.
*/
Expression& operator=(const Expression&) = default;

/**
* Move constructor.
*/
Expression(Expression&&) = default;

/**
* Move-assignment operator.
*/
Expression& operator=(Expression&&) = default;

/**
* Constructs a nullary expression (an operator with no arguments).
*
Expand Down
24 changes: 2 additions & 22 deletions include/sleipnir/autodiff/Variable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,9 @@ class SLEIPNIR_DLLEXPORT Variable {
detail::ExpressionPtr expr = detail::Zero();

/**
* Constructs an uninitialized Variable.
* Constructs a Variable initialized to zero.
*/
constexpr Variable() = default;

/**
* Copy constructor.
*/
Variable(const Variable&) = default;

/**
* Copy assignment operator.
*/
Variable& operator=(const Variable&) = default;

/**
* Move constructor.
*/
Variable(Variable&&) = default;

/**
* Move assignment operator.
*/
Variable& operator=(Variable&&) = default;
Variable() = default;

/**
* Constructs a Variable from a double.
Expand Down
81 changes: 42 additions & 39 deletions include/sleipnir/autodiff/VariableBlock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,48 @@ namespace sleipnir {
template <typename Mat>
class VariableBlock {
public:
/**
* Copy constructs a VariableBlock to the block.
*/
VariableBlock(const VariableBlock<Mat>& values) {
m_mat = values.m_mat;
m_rowOffset = values.m_rowOffset;
m_colOffset = values.m_colOffset;
m_blockRows = values.m_blockRows;
m_blockCols = values.m_blockCols;
}

/**
* Assigns a VariableBlock to the block.
*/
VariableBlock<Mat>& operator=(VariableBlock<Mat>& values) {
if (this == &values) {
return *this;
}

if (m_mat == nullptr) {
m_mat = values.m_mat;
m_rowOffset = values.m_rowOffset;
m_colOffset = values.m_colOffset;
m_blockRows = values.m_blockRows;
m_blockCols = values.m_blockCols;
} else {
assert(Rows() == values.Rows());
assert(Cols() == values.Cols());

for (int row = 0; row < Rows(); ++row) {
for (int col = 0; col < Cols(); ++col) {
(*this)(row, col) = values(row, col);
}
}
}

return *this;
}

VariableBlock(VariableBlock<Mat>&&) = default;
VariableBlock<Mat>& operator=(VariableBlock<Mat>&&) = default;

/**
* Constructs a Variable block pointing to all of the given matrix.
*
Expand Down Expand Up @@ -73,45 +115,6 @@ class VariableBlock {
return *this;
}

/**
* Copy constructs a VariableBlock to the block.
*/
VariableBlock(const VariableBlock<Mat>& values) {
m_mat = values.m_mat;
m_rowOffset = values.m_rowOffset;
m_colOffset = values.m_colOffset;
m_blockRows = values.m_blockRows;
m_blockCols = values.m_blockCols;
}

/**
* Assigns a VariableBlock to the block.
*/
VariableBlock<Mat>& operator=(VariableBlock<Mat>& values) {
if (this == &values) {
return *this;
}

if (m_mat == nullptr) {
m_mat = values.m_mat;
m_rowOffset = values.m_rowOffset;
m_colOffset = values.m_colOffset;
m_blockRows = values.m_blockRows;
m_blockCols = values.m_blockCols;
} else {
assert(Rows() == values.Rows());
assert(Cols() == values.Cols());

for (int row = 0; row < Rows(); ++row) {
for (int col = 0; col < Cols(); ++col) {
(*this)(row, col) = values(row, col);
}
}
}

return *this;
}

/**
* Assigns an Eigen matrix to the block.
*/
Expand Down
Loading