LMCAS
Lamina Computer Algebra System
Toggle main menu visibility
载入中...
搜索中...
未找到
exact_root_id.hpp
浏览该文件的文档.
1
#pragma once
2
3
#include "
polynomial.hpp
"
4
#include <algorithm>
5
6
#include <cstddef>
7
8
namespace
LMCAS::detail
{
9
10
struct
ExactRootId
{
11
Polynomial<Rational>
polynomial
;
12
std::size_t
index
= 0;
13
14
std::size_t
hash
()
const
{
15
std::size_t seed =
index
;
16
for
(
const
auto
& coefficient :
polynomial
.
coeffs
) {
17
seed ^= coefficient.hash() + 0x9e3779b9U +
18
(seed << 6U) + (seed >> 2U);
19
}
20
return
seed;
21
}
22
23
int
compare
(
const
ExactRootId
& other)
const
{
24
const
auto
common = std::min(
25
polynomial
.
coeffs
.size(), other.
polynomial
.
coeffs
.size());
26
for
(std::size_t position = common; position-- > 0;) {
27
const
auto
& left =
polynomial
.
coeffs
[position];
28
const
auto
&
right
= other.
polynomial
.
coeffs
[position];
29
if
(left <
right
)
return
-1;
30
if
(
right
< left)
return
1;
31
}
32
if
(
polynomial
.
coeffs
.size() != other.
polynomial
.
coeffs
.size()) {
33
return
polynomial
.
coeffs
.size() < other.
polynomial
.
coeffs
.size()
34
? -1 : 1;
35
}
36
if
(
index
== other.
index
)
return
0;
37
return
index
< other.
index
? -1 : 1;
38
}
39
};
40
41
}
LMCAS::Polynomial
一元多项式模板类
定义
polynomial.hpp:52
LMCAS::Polynomial::coeffs
std::vector< CoeffType > coeffs
系数数组,coeffs[i] 为 x^i 的系数
定义
polynomial.hpp:55
LMCAS::detail
多元 Hensel 提升(单变量步)
定义
assumption_context.hpp:31
LMCAS::right
const ExprPtr & right
定义
residual_verification.hpp:50
polynomial.hpp
一元多项式模板类 Polynomial<T>,支持四则运算,GCD,求导,求值.
LMCAS::detail::ExactRootId
定义
exact_root_id.hpp:10
LMCAS::detail::ExactRootId::index
std::size_t index
定义
exact_root_id.hpp:12
LMCAS::detail::ExactRootId::polynomial
Polynomial< Rational > polynomial
定义
exact_root_id.hpp:11
LMCAS::detail::ExactRootId::hash
std::size_t hash() const
定义
exact_root_id.hpp:14
LMCAS::detail::ExactRootId::compare
int compare(const ExactRootId &other) const
定义
exact_root_id.hpp:23
src
internal
exact_root_id.hpp
生成于
, 为 LMCAS使用
1.18.0