A library for working with phylogenetic and population genetic data.
v0.27.0
utils/math/bitvector/operators.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_UTILS_MATH_BITVECTOR_OPERATORS_H_
2 #define GENESIS_UTILS_MATH_BITVECTOR_OPERATORS_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2021 Lucas Czech
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lczech@carnegiescience.edu>
23  Department of Plant Biology, Carnegie Institution For Science
24  260 Panama Street, Stanford, CA 94305, USA
25 */
26 
35 
36 #include <iosfwd>
37 
38 namespace genesis {
39 namespace utils {
40 
41 // =================================================================================================
42 // Bitvector Operators
43 // =================================================================================================
44 
52 Bitvector bitwise_and (Bitvector const& lhs, Bitvector const& rhs);
53 
61 Bitvector bitwise_or (Bitvector const& lhs, Bitvector const& rhs);
62 
70 Bitvector bitwise_xor (Bitvector const& lhs, Bitvector const& rhs);
71 
72 Bitvector set_minus (Bitvector const& lhs, Bitvector const& rhs);
73 Bitvector symmetric_difference (Bitvector const& lhs, Bitvector const& rhs);
74 
78 bool is_strict_subset( Bitvector const& sub, Bitvector const& super );
79 
83 bool is_strict_superset( Bitvector const& super, Bitvector const& sub );
84 
88 bool is_subset( Bitvector const& sub, Bitvector const& super );
89 
93 bool is_superset( Bitvector const& super, Bitvector const& sub );
94 
95 // /* *
96 // * @brief Return whether @p lhs is lexicographically less than @p rhs.
97 // *
98 // * This function consideres the bits ordered with most significant bits towards the left, so that
99 // * `0001 < 1000` for example. Both Bitvector%s have to have the same length (this could be
100 // * implemented for Bitvectors of different size, but that is not needed as of now, so it isn't).
101 // */
102 // bool is_lexicographically_less( Bitvector const& lhs, Bitvector const& rhs );
103 //
104 // /* *
105 // * @brief Return whether @p lhs is lexicographically less than @p rhs, or equal to it.
106 // *
107 // * @copydetails is_lexicographically_less()
108 // */
109 // bool is_lexicographically_less_or_equal( Bitvector const& lhs, Bitvector const& rhs );
110 //
111 // /* *
112 // * @brief Return whether @p lhs is lexicographically greater than @p rhs.
113 // *
114 // * @copydetails is_lexicographically_less()
115 // */
116 // bool is_lexicographically_greater( Bitvector const& lhs, Bitvector const& rhs );
117 //
118 // /* *
119 // * @brief Return whether @p lhs is lexicographically greater than @p rhs, or equal to it.
120 // *
121 // * @copydetails is_lexicographically_less()
122 // */
123 // bool is_lexicographically_greater_or_equal( Bitvector const& lhs, Bitvector const& rhs );
124 
128 std::ostream& operator << ( std::ostream& out, Bitvector const& bv );
129 
134 std::istream& operator >> ( std::istream& in, Bitvector& bv );
135 
136 } // namespace utils
137 } // namespace genesis
138 
139 #endif // include guard
genesis::utils::operator<<
std::ostream & operator<<(std::ostream &os, const Matrix< signed char > &matrix)
Template specialization for signed char, in order to print nicely.
Definition: utils/containers/matrix/operators.cpp:89
genesis::utils::operator>>
std::istream & operator>>(std::istream &in, Bitvector &bv)
Extraction operator that inputs a Bitvector from a string of '0's and '1's, and stops at the first ch...
Definition: utils/math/bitvector/operators.cpp:169
genesis::utils::is_superset
bool is_superset(Bitvector const &super, Bitvector const &sub)
Superset or equal.
Definition: utils/math/bitvector/operators.cpp:112
genesis::utils::is_strict_subset
bool is_strict_subset(Bitvector const &sub, Bitvector const &super)
Strict subset.
Definition: utils/math/bitvector/operators.cpp:94
genesis::utils::bitwise_xor
Bitvector bitwise_xor(Bitvector const &lhs, Bitvector const &rhs)
Take the bitwise xor of two Bitvectors of potentially different size.
Definition: utils/math/bitvector/operators.cpp:71
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
genesis::utils::set_minus
Bitvector set_minus(Bitvector const &lhs, Bitvector const &rhs)
Definition: utils/math/bitvector/operators.cpp:84
genesis::utils::bitwise_and
Bitvector bitwise_and(Bitvector const &lhs, Bitvector const &rhs)
Take the bitwise and of two Bitvectors of potentially different size.
Definition: utils/math/bitvector/operators.cpp:45
genesis::utils::bitwise_or
Bitvector bitwise_or(Bitvector const &lhs, Bitvector const &rhs)
Take the bitwise or of two Bitvectors of potentially different size.
Definition: utils/math/bitvector/operators.cpp:58
genesis::utils::is_subset
bool is_subset(Bitvector const &sub, Bitvector const &super)
Subset or equal.
Definition: utils/math/bitvector/operators.cpp:107
genesis::utils::symmetric_difference
Bitvector symmetric_difference(Bitvector const &lhs, Bitvector const &rhs)
Definition: utils/math/bitvector/operators.cpp:89
bitvector.hpp
genesis::utils::is_strict_superset
bool is_strict_superset(Bitvector const &super, Bitvector const &sub)
Strict superset.
Definition: utils/math/bitvector/operators.cpp:102