Skip to content

Commit

Permalink
Merge pull request #1154 from hschreiber/matrix_vine_opt
Browse files Browse the repository at this point in the history
[Persistence Matrix] Addition of small vectors as a column type
  • Loading branch information
VincentRouvreau authored Feb 5, 2025
2 parents 9b26cab + 5b4b9e2 commit 529281f
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 122 deletions.
9 changes: 7 additions & 2 deletions src/Persistence_matrix/include/gudhi/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ class Matrix {
using Matrix_heap_column = Heap_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_list_column = List_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_vector_column = Vector_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_naive_vector_column = Naive_vector_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_naive_vector_column = Naive_std_vector_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_small_vector_column = Naive_small_vector_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_set_column = Set_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_unordered_set_column = Unordered_set_column<Matrix<PersistenceMatrixOptions> >;
using Matrix_intrusive_list_column = Intrusive_list_column<Matrix<PersistenceMatrixOptions> >;
Expand Down Expand Up @@ -353,7 +354,11 @@ class Matrix {
typename std::conditional<
PersistenceMatrixOptions::column_type == Column_types::NAIVE_VECTOR,
Matrix_naive_vector_column,
Matrix_intrusive_set_column
typename std::conditional<
PersistenceMatrixOptions::column_type == Column_types::SMALL_VECTOR,
Matrix_small_vector_column,
Matrix_intrusive_set_column
>::type
>::type
>::type
>::type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ namespace persistence_matrix {
* row index. Additionally, the given entry range added into the heap does not need to be somehow ordered.
*
* @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
* @tparam Entry_constructor Factory of @ref Entry classes.
*/
template <class Master_matrix>
class Heap_column : public Master_matrix::Column_dimension_option, public Master_matrix::Chain_column_option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ namespace persistence_matrix {
* are stored uniquely in the underlying container.
*
* @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
* @tparam Entry_constructor Factory of @ref Entry classes.
*/
template <class Master_matrix>
class Intrusive_list_column : public Master_matrix::Row_access_option,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ namespace persistence_matrix {
* are stored uniquely in the underlying container.
*
* @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
* @tparam Entry_constructor Factory of @ref Entry classes.
*/
template <class Master_matrix>
class Intrusive_set_column : public Master_matrix::Row_access_option,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ namespace persistence_matrix {
* are stored uniquely in the underlying container.
*
* @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
* @tparam Entry_constructor Factory of @ref Entry classes.
*/
template <class Master_matrix>
class List_column : public Master_matrix::Row_access_option,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ namespace persistence_matrix {
* are stored uniquely in the underlying container.
*
* @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
* @tparam Entry_constructor Factory of @ref Entry classes.
*/
template <class Master_matrix>
class Set_column : public Master_matrix::Row_access_option,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ struct EntryPointerEq {
* also does not need to be ordered (contrary to most other column types).
*
* @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
* @tparam Entry_constructor Factory of @ref Entry classes.
*/
template <class Master_matrix>
class Unordered_set_column : public Master_matrix::Row_access_option,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ namespace persistence_matrix {
* On the other hand, two entries will never have the same row index.
*
* @tparam Master_matrix An instantiation of @ref Matrix from which all types and options are deduced.
* @tparam Entry_constructor Factory of @ref Entry classes.
*/
template <class Master_matrix>
class Vector_column : public Master_matrix::Row_access_option,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ enum class Column_types {
VECTOR, /**< @ref Vector_column "": Underlying container is a std::vector<@ref Entry*>
with a lazy removal method. */
NAIVE_VECTOR, /**< @ref Naive_vector_column "": Underlying container is a std::vector<@ref Entry*>. */
SMALL_VECTOR, /**< @ref Naive_vector_column "": Underlying container is a
boost::container::small_vector<@ref Entry*, 8>. */
UNORDERED_SET, /**< @ref Unordered_set_column "": Underlying container is a std::unordered_set<@ref Entry*>. */
INTRUSIVE_LIST, /**< @ref Intrusive_list_column "": Underlying container is a boost::intrusive::list<@ref Entry>. */
INTRUSIVE_SET /**< @ref Intrusive_set_column "": Underlying container is a boost::intrusive::set<@ref Entry>. */
Expand Down
16 changes: 10 additions & 6 deletions src/Persistence_matrix/test/pm_column_tests_boost_type_lists.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ using Gudhi::persistence_matrix::Heap_column;
using Gudhi::persistence_matrix::Intrusive_list_column;
using Gudhi::persistence_matrix::Intrusive_set_column;
using Gudhi::persistence_matrix::List_column;
using Gudhi::persistence_matrix::Naive_vector_column;
using Gudhi::persistence_matrix::Naive_std_vector_column;
using Gudhi::persistence_matrix::Naive_small_vector_column;
using Gudhi::persistence_matrix::Set_column;
using Gudhi::persistence_matrix::Unordered_set_column;
using Gudhi::persistence_matrix::Vector_column;
Expand Down Expand Up @@ -65,7 +66,9 @@ class column_non_validity {
} else if constexpr (col_type::Master::Option_list::column_type == Column_types::UNORDERED_SET) {
return !std::is_same_v<col_type, Unordered_set_column<typename col_type::Master> >;
} else if constexpr (col_type::Master::Option_list::column_type == Column_types::NAIVE_VECTOR) {
return !std::is_same_v<col_type, Naive_vector_column<typename col_type::Master> >;
return !std::is_same_v<col_type, Naive_std_vector_column<typename col_type::Master> >;
} else if constexpr (col_type::Master::Option_list::column_type == Column_types::SMALL_VECTOR) {
return !std::is_same_v<col_type, Naive_small_vector_column<typename col_type::Master> >;
} else if constexpr (col_type::Master::Option_list::column_type == Column_types::VECTOR) {
return !std::is_same_v<col_type, Vector_column<typename col_type::Master> >;
} else if constexpr (col_type::Master::Option_list::column_type == Column_types::HEAP) {
Expand All @@ -81,12 +84,13 @@ class column_non_validity {

// if a new column type is implemented, create a `ct_*` structure for it and add it to this list...
using col_type_list = boost::mp11::mp_list<ct_intrusive_list, ct_intrusive_set, ct_list, ct_set, ct_heap,
ct_unordered_set, ct_vector, ct_naive_vector>;
ct_unordered_set, ct_vector, ct_naive_vector, ct_small_vector>;
using row_col_type_list = boost::mp11::mp_list<ct_intrusive_list, ct_intrusive_set, ct_list, ct_set, ct_unordered_set,
ct_vector, ct_naive_vector>;
ct_vector, ct_naive_vector, ct_small_vector>;
//...and add the column name here.
using column_list = mp_list_q<Intrusive_list_column, Intrusive_set_column, List_column, Set_column,
Unordered_set_column, Naive_vector_column, Vector_column, Heap_column>;
using column_list =
mp_list_q<Intrusive_list_column, Intrusive_set_column, List_column, Set_column, Unordered_set_column,
Naive_std_vector_column, Naive_small_vector_column, Vector_column, Heap_column>;
using c_matrix_type_list = mp_list_q<Column_mini_matrix>;

template <typename option_name_list, typename bool_is_z2, typename col_t, typename bool_has_row, typename bool_rem_row,
Expand Down
4 changes: 4 additions & 0 deletions src/Persistence_matrix/test/pm_common_boost_type_lists.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ struct ct_naive_vector {
static constexpr const Column_types t = Column_types::NAIVE_VECTOR;
};

struct ct_small_vector {
static constexpr const Column_types t = Column_types::SMALL_VECTOR;
};

struct true_value {
static constexpr const bool t = true;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class matrix_non_validity {
// users. But in case real changes were made to this module, it would be better to test at least once with all column
// types as below:
// using col_type_list = boost::mp11::mp_list<ct_intrusive_list, ct_intrusive_set, ct_list, ct_set, ct_heap,
// ct_unordered_set, ct_vector, ct_naive_vector>;
// ct_unordered_set, ct_vector, ct_naive_vector, ct_small_vector>;
#ifdef PM_TEST_INTR_LIST
using col_type_list = boost::mp11::mp_list<ct_intrusive_list>;
#else
Expand All @@ -162,6 +162,9 @@ using col_type_list = boost::mp11::mp_list<ct_unordered_set>;
#ifdef PM_TEST_NAIVE_VECTOR
using col_type_list = boost::mp11::mp_list<ct_naive_vector>;
#else
#ifdef PM_TEST_SMALL_VECTOR
using col_type_list = boost::mp11::mp_list<ct_small_vector>;
#else
using col_type_list = boost::mp11::mp_list<ct_vector>;
#endif
#endif
Expand All @@ -170,6 +173,7 @@ using col_type_list = boost::mp11::mp_list<ct_vector>;
#endif
#endif
#endif
#endif

using matrix_type_list = mp_list_q<Matrix>;

Expand Down

0 comments on commit 529281f

Please sign in to comment.