A library for working with phylogenetic and population genetic data.
v0.32.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-2022 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 
54 Bitvector bitwise_and( Bitvector const& lhs, Bitvector const& rhs, bool use_larger = false );
55 
61 Bitvector bitwise_or( Bitvector const& lhs, Bitvector const& rhs, bool use_larger = false );
62 
68 Bitvector bitwise_xor( Bitvector const& lhs, Bitvector const& rhs, bool use_larger = false );
69 
70 Bitvector set_minus (Bitvector const& lhs, Bitvector const& rhs);
71 Bitvector symmetric_difference( Bitvector const& lhs, Bitvector const& rhs );
72 
76 bool is_strict_subset( Bitvector const& sub, Bitvector const& super );
77 
81 bool is_strict_superset( Bitvector const& super, Bitvector const& sub );
82 
86 bool is_subset( Bitvector const& sub, Bitvector const& super );
87 
91 bool is_superset( Bitvector const& super, Bitvector const& sub );
92 
93 // /* *
94 // * @brief Return whether @p lhs is lexicographically less than @p rhs.
95 // *
96 // * This function consideres the bits ordered with most significant bits towards the left, so that
97 // * `0001 < 1000` for example. Both Bitvector%s have to have the same length (this could be
98 // * implemented for Bitvectors of different size, but that is not needed as of now, so it isn't).
99 // */
100 // bool is_lexicographically_less( Bitvector const& lhs, Bitvector const& rhs );
101 //
102 // /* *
103 // * @brief Return whether @p lhs is lexicographically less than @p rhs, or equal to it.
104 // *
105 // * @copydetails is_lexicographically_less()
106 // */
107 // bool is_lexicographically_less_or_equal( Bitvector const& lhs, Bitvector const& rhs );
108 //
109 // /* *
110 // * @brief Return whether @p lhs is lexicographically greater than @p rhs.
111 // *
112 // * @copydetails is_lexicographically_less()
113 // */
114 // bool is_lexicographically_greater( Bitvector const& lhs, Bitvector const& rhs );
115 //
116 // /* *
117 // * @brief Return whether @p lhs is lexicographically greater than @p rhs, or equal to it.
118 // *
119 // * @copydetails is_lexicographically_less()
120 // */
121 // bool is_lexicographically_greater_or_equal( Bitvector const& lhs, Bitvector const& rhs );
122 
126 std::ostream& operator << ( std::ostream& out, Bitvector const& bv );
127 
132 std::istream& operator >> ( std::istream& in, Bitvector& bv );
133 
134 } // namespace utils
135 } // namespace genesis
136 
137 #endif // include guard
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::operator<<
std::ostream & operator<<(std::ostream &os, Color const &color)
Write a textual representation of the Color the a stream, in the format "(r, g, b,...
Definition: utils/color/functions.cpp:129
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
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_or
Bitvector bitwise_or(Bitvector const &lhs, Bitvector const &rhs, bool use_larger)
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::bitwise_and
Bitvector bitwise_and(Bitvector const &lhs, Bitvector const &rhs, bool use_larger)
Take the bitwise and of two Bitvectors of potentially different size.
Definition: utils/math/bitvector/operators.cpp:45
genesis::utils::is_strict_superset
bool is_strict_superset(Bitvector const &super, Bitvector const &sub)
Strict superset.
Definition: utils/math/bitvector/operators.cpp:102
genesis::utils::bitwise_xor
Bitvector bitwise_xor(Bitvector const &lhs, Bitvector const &rhs, bool use_larger)
Take the bitwise xor of two Bitvectors of potentially different size.
Definition: utils/math/bitvector/operators.cpp:71