Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
110 lines (98 loc) · 3.01 KB

File metadata and controls

110 lines (98 loc) · 3.01 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <symengine/printers.h>
#include <symengine/subs.h>
#if HAVE_SYMENGINE_RTTI
#include <symengine/serialize-cereal.h>
#endif
#include <array>
namespace SymEngine
{
std::string type_code_name(TypeID id)
{
#define STRINGIFY0(x) #x
#define STRINGIFY(x) STRINGIFY0(x)
const static std::array<std::string,
static_cast<int>(TypeID::TypeID_Count) + 1>
type_names{{
#define SYMENGINE_INCLUDE_ALL
#define SYMENGINE_ENUM(type, Class) STRINGIFY(Class),
#include "symengine/type_codes.inc"
#undef SYMENGINE_ENUM
"TypeID_Count"}};
#undef SYMENGINE_INCLUDE_ALL
#undef STRINGIFY0
#undef STRINGIFY
if ((id < 0) || (id > TypeID::TypeID_Count)) {
throw std::runtime_error("type_id out of range");
}
return type_names[id];
}
int Basic::__cmp__(const Basic &o) const
{
auto a = this->get_type_code();
auto b = o.get_type_code();
if (a == b) {
return this->compare(o);
} else {
// We return the order given by the numerical value of the TypeID enum
// type.
// The types don't need to be ordered in any given way, they just need
// to be ordered.
return a < b ? -1 : 1;
}
}
std::string Basic::__str__() const
{
return str(*this);
}
std::string Basic::dumps() const
{
#if HAVE_SYMENGINE_RTTI
std::ostringstream oss;
unsigned short major = SYMENGINE_MAJOR_VERSION;
unsigned short minor = SYMENGINE_MINOR_VERSION;
RCPBasicAwareOutputArchive<cereal::PortableBinaryOutputArchive>{oss}(
major, minor, this->rcp_from_this());
return oss.str();
#else
throw NotImplementedError("Serialization not implemented in no-rtti mode");
#endif
}
RCP<const Basic> Basic::loads(const std::string &serialized)
{
#if HAVE_SYMENGINE_RTTI
unsigned short major, minor;
RCP<const Basic> obj;
std::istringstream iss(serialized);
RCPBasicAwareInputArchive<cereal::PortableBinaryInputArchive> iarchive{iss};
iarchive(major, minor);
if (major != SYMENGINE_MAJOR_VERSION or minor != SYMENGINE_MINOR_VERSION) {
throw SerializationError(StreamFmt()
<< "SymEngine-" << SYMENGINE_MAJOR_VERSION
<< "." << SYMENGINE_MINOR_VERSION
<< " was asked to deserialize an object "
<< "created using SymEngine-" << major << "."
<< minor << ".");
}
iarchive(obj);
return obj;
#else
throw NotImplementedError("Serialization not implemented in no-rtti mode");
#endif
}
RCP<const Basic> Basic::subs(const map_basic_basic &subs_dict) const
{
return SymEngine::subs(this->rcp_from_this(), subs_dict);
}
RCP<const Basic> Basic::xreplace(const map_basic_basic &xreplace_dict) const
{
return SymEngine::xreplace(this->rcp_from_this(), xreplace_dict);
}
const char *get_version()
{
return SYMENGINE_VERSION;
}
bool is_a_Atom(const Basic &b)
{
return is_a_Number(b) or is_a<Symbol>(b) or is_a<Constant>(b);
}
} // namespace SymEngine
Morty Proxy This is a proxified and sanitized view of the page, visit original site.