Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hschreiber committed Apr 4, 2024
1 parent 6f54642 commit 353929a
Show file tree
Hide file tree
Showing 11 changed files with 3,890 additions and 2,954 deletions.
3 changes: 2 additions & 1 deletion src/Persistence_matrix/concept/FieldOperators.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ namespace persistence_matrix {
* Implementations of this concept are @ref Zp_field_operators, @ref Z2_field_operators,
* @ref Multi_field_operators and @ref Multi_field_small_operators.
*/
struct FieldOperators {
class FieldOperators
{
public:
using element_type = unspecified; /**< Type for the elements in the field. */
using characteristic_type = unspecified; /**< Type for the field characteristic. */
Expand Down
452 changes: 452 additions & 0 deletions src/Persistence_matrix/concept/PersistenceMatrixColumn.h

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/Persistence_matrix/concept/PersistenceMatrixOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ namespace persistence_matrix {
* If you want to provide your own, it is recommended that you derive from it and override some parts instead of
* writing a class from scratch.
*/
struct PersistenceMatrixOptions {
struct PersistenceMatrixOptions
{
/**
* @brief Field operators. Has to follow the @ref [TODO: concept] concept.
* The type will not be used if @ref is_z2 is set to true, so it can be set to anything.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,125 @@
* - YYYY/MM Author: Description of the modification
*/

/**
* @file cell_constructors.h
* @author Hannah Schreiber
* @brief Contains the @ref New_cell_constructor and @ref Pool_cell_constructor structures.
*/

#ifndef PM_COLUMN_CELL_CONSTRUCTORS_H
#define PM_COLUMN_CELL_CONSTRUCTORS_H

#include <utility> //std::swap
#include <utility> //std::swap

#include <gudhi/Simple_object_pool.h>

namespace Gudhi {
namespace persistence_matrix {

template<class Cell>
struct New_cell_constructor{
New_cell_constructor() {}

template<class...U>
Cell* construct(U&&...u) const { return new Cell(std::forward<U>(u)...); }

void destroy(Cell* cell) const { delete cell; }

friend void swap(New_cell_constructor& col1, New_cell_constructor& col2){}
/**
* @brief @ref Cell factory. Constructs and destroyes cell pointers with new and delete.
*
* @tparam Cell @ref Cell with the right templates.
*/
template <class Cell>
struct New_cell_constructor
{
/**
* @brief Default constructor.
*/
New_cell_constructor() {}

/**
* @brief Constructs a cell with the given cell arguments.
*
* @param u Arguments forwarded to the @ref Cell constructor.
* @return @ref Cell pointer.
*/
template <class... U>
Cell* construct(U&&... u) const {
return new Cell(std::forward<U>(u)...);
}

/**
* @brief Destroyes the given cell.
*
* @param cell @ref Cell pointer.
*/
void destroy(Cell* cell) const { delete cell; }

/**
* @brief Swap operator.
*/
friend void swap(New_cell_constructor& col1, New_cell_constructor& col2) {}
};

template<class Cell>
struct Pool_cell_constructor{
public:
Pool_cell_constructor() : cellPool_() {}
Pool_cell_constructor(const Pool_cell_constructor& col) : cellPool_(col.cellPool_) {}
Pool_cell_constructor(Pool_cell_constructor&& col) : cellPool_(std::move(col.cellPool_)) {}

template<class...U>
Cell* construct(U&&...u) {
return cellPool_.construct(std::forward<U>(u)...);
}

void destroy(Cell* cell) {
cellPool_.destroy(cell);
}

Pool_cell_constructor& operator=(const Pool_cell_constructor& other){
cellPool_ = other.cellPool_;
return *this;
}

friend void swap(Pool_cell_constructor& col1, Pool_cell_constructor& col2){
std::swap(col1.cellPool_, col2.cellPool_);
}

private:
Simple_object_pool<Cell> cellPool_;
/**
* @brief @ref Cell factory. Uses @ref Simple_object_pool to construct and destroy cell pointer.
*
* @tparam Cell @ref Cell with the right templates.
*/
template <class Cell>
struct Pool_cell_constructor
{
public:
/**
* @brief Default constructor.
*
*/
Pool_cell_constructor() : cellPool_() {}
//TODO: what does happen when the pool is copied?
/**
* @brief Copy constructor.
*
* @param col Factory to copy.
*/
Pool_cell_constructor(const Pool_cell_constructor& col) : cellPool_(col.cellPool_) {}
/**
* @brief Move constructor.
*
* @param col Factory to move.
*/
Pool_cell_constructor(Pool_cell_constructor&& col) : cellPool_(std::move(col.cellPool_)) {}

/**
* @brief Constructs a cell with the given cell arguments.
*
* @param u Arguments forwarded to the @ref Cell constructor.
* @return @ref Cell pointer.
*/
template <class... U>
Cell* construct(U&&... u) {
return cellPool_.construct(std::forward<U>(u)...);
}

/**
* @brief Destroyes the given cell.
*
* @param cell @ref Cell pointer.
*/
void destroy(Cell* cell) { cellPool_.destroy(cell); }

//TODO: Again, what does it mean to copy the pool?
/**
* @brief Assign operator.
*/
Pool_cell_constructor& operator=(const Pool_cell_constructor& other) {
cellPool_ = other.cellPool_;
return *this;
}
/**
* @brief Swap operator.
*/
friend void swap(Pool_cell_constructor& col1, Pool_cell_constructor& col2) {
std::swap(col1.cellPool_, col2.cellPool_);
}

private:
Simple_object_pool<Cell> cellPool_; /**< Cell pool. */
};

} //namespace persistence_matrix
} //namespace Gudhi
} // namespace persistence_matrix
} // namespace Gudhi

#endif // PM_COLUMN_CELL_CONSTRUCTORS_H
#endif // PM_COLUMN_CELL_CONSTRUCTORS_H
Loading

0 comments on commit 353929a

Please sign in to comment.