cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
boolbv_complex.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
#include "
boolbv.h
"
10
11
#include <
util/invariant.h
>
12
13
bvt
boolbvt::convert_complex
(
const
complex_exprt
&expr)
14
{
15
std::size_t width=
boolbv_width
(expr.
type
());
16
17
DATA_INVARIANT
(
18
expr.
type
().
id
() == ID_complex,
19
"complex expression shall have complex type"
);
20
21
bvt
bv;
22
bv.reserve(width);
23
24
const
exprt::operandst
&operands = expr.
operands
();
25
std::size_t op_width = width / operands.size();
26
27
for
(
const
auto
&op : operands)
28
{
29
const
bvt
&tmp =
convert_bv
(op, op_width);
30
31
bv.insert(bv.end(), tmp.begin(), tmp.end());
32
}
33
34
return
bv;
35
}
36
37
bvt
boolbvt::convert_complex_real
(
const
complex_real_exprt
&expr)
38
{
39
std::size_t width=
boolbv_width
(expr.
type
());
40
41
bvt
bv =
convert_bv
(expr.
op
(), width * 2);
42
43
bv.resize(width);
// chop
44
45
return
bv;
46
}
47
48
bvt
boolbvt::convert_complex_imag
(
const
complex_imag_exprt
&expr)
49
{
50
std::size_t width=
boolbv_width
(expr.
type
());
51
52
bvt
bv =
convert_bv
(expr.
op
(), width * 2);
53
54
bv.erase(bv.begin(), bv.begin()+width);
55
56
return
bv;
57
}
boolbv.h
boolbvt::convert_bv
virtual const bvt & convert_bv(const exprt &expr, const std::optional< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
Definition
boolbv.cpp:40
boolbvt::convert_complex_imag
virtual bvt convert_complex_imag(const complex_imag_exprt &expr)
Definition
boolbv_complex.cpp:48
boolbvt::convert_complex_real
virtual bvt convert_complex_real(const complex_real_exprt &expr)
Definition
boolbv_complex.cpp:37
boolbvt::convert_complex
virtual bvt convert_complex(const complex_exprt &expr)
Definition
boolbv_complex.cpp:13
boolbvt::boolbv_width
virtual std::size_t boolbv_width(const typet &type) const
Definition
boolbv.h:106
complex_exprt
Complex constructor from a pair of numbers.
Definition
std_expr.h:1849
complex_imag_exprt
Imaginary part of the expression describing a complex number.
Definition
std_expr.h:1947
complex_real_exprt
Real part of the expression describing a complex number.
Definition
std_expr.h:1910
exprt::operandst
std::vector< exprt > operandst
Definition
expr.h:59
exprt::type
typet & type()
Return the type of the expression.
Definition
expr.h:85
exprt::operands
operandst & operands()
Definition
expr.h:95
irept::id
const irep_idt & id() const
Definition
irep.h:388
unary_exprt::op
const exprt & op() const
Definition
std_expr.h:384
bvt
std::vector< literalt > bvt
Definition
literal.h:201
invariant.h
DATA_INVARIANT
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition
invariant.h:534
solvers
flattening
boolbv_complex.cpp
Generated by
1.17.0