132{
133 if (is_a<Interval>(*o)) {
134 const Interval &other = down_cast<const Interval &>(*o);
135 RCP<const Number> start,
end;
136 bool left_open, right_open;
137 RCP<const Basic> start_end, end_start;
138 start_end =
min({this->start_, other.end_});
139 end_start =
min({this->end_, other.start_});
140
141 if (
eq(*this->start_, *start_end) and
eq(*other.start_, *end_start)) {
142 RCP<const Basic> start_start, end_end;
143 start_start =
min({this->start_, other.start_});
144 end_end =
min({this->end_, other.end_});
145 if (
neq(*this->start_, *other.start_)) {
146 if (
eq(*this->start_, *start_start)) {
147 start = other.start_;
148 left_open = other.left_open_;
149 } else {
150 start = this->start_;
151 left_open = this->left_open_;
152 }
153 } else {
154 start = this->start_;
155 left_open = this->left_open_ or other.left_open_;
156 }
157
158 if (
neq(*this->end_, *other.end_)) {
159 if (
eq(*this->end_, *end_end)) {
161 right_open = this->right_open_;
162 } else {
164 right_open = other.right_open_;
165 }
166 } else {
168 right_open = this->right_open_ or other.right_open_;
169 }
170 return interval(start, end, left_open, right_open);
171 } else {
173 }
174 }
175 if (is_a<Integers>(*o) or is_a<Naturals>(*o) or is_a<Naturals0>(*o)) {
179 if (is_a<Naturals>(*o)
180 and not down_cast<const Integer &>(*first).is_positive()) {
182 } else if (is_a<Naturals0>(*o)
183 and down_cast<const Integer &>(*first).is_negative()) {
185 }
186 if (
eq(*first, *start_) and left_open_) {
188 }
189 if (
eq(*last, *end_) and right_open_) {
191 }
192 if (
eq(*
Lt(last, first), *boolTrue)) {
194 }
195 set_basic container;
196 while (
eq(*
Ge(last, first), *boolTrue)) {
199 }
201 } else {
202 return SymEngine::set_intersection(
203 {rcp_from_this_cast<const Set>(), o});
204 }
205 }
206 if (is_a<UniversalSet>(*o) or is_a<EmptySet>(*o) or is_a<FiniteSet>(*o)
207 or is_a<Union>(*o) or is_a<Rationals>(*o) or is_a<Reals>(*o)
208 or is_a<Complexes>(*o)) {
209 return (*o).set_intersection(rcp_from_this_cast<const Set>());
210 }
211 return make_set_intersection({rcp_from_this_cast<const Set>(), o});
212}
RCP< const Boolean > Ge(const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
Convenience function returning LessThan object.
RCP< const EmptySet > emptyset()
RCP< const Set > finiteset(const set_basic &container)
RCP< const Boolean > Lt(const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
Returns the canonicalized StrictLessThan object from the arguments.
RCP< const Basic > ceiling(const RCP< const Basic > &arg)
Canonicalize Ceiling:
RCP< const Basic > floor(const RCP< const Basic > &arg)
Canonicalize Floor:
RCP< const Basic > add(const RCP< const Basic > &a, const RCP< const Basic > &b)
Adds two objects (safely).
bool neq(const Basic &a, const Basic &b)
Checks inequality for a and b
std::enable_if< std::is_integral< T >::value, RCP< constInteger > >::type integer(T i)