LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
LMCAS::anonymous_namespace{symbolic_algebra_adapter.cpp} 命名空间参考

类型定义

using ResultantMatrix = std::vector<std::vector<Rational>>

函数

void eliminate_resultant_column (ResultantMatrix &matrix, int pivot, const Rational &previous)
Rational resultant_determinant (ResultantMatrix &matrix)
ResultantMatrix sylvester_matrix (const Polynomial< Rational > &left, const Polynomial< Rational > &right)

类型定义说明

◆ ResultantMatrix

using LMCAS::anonymous_namespace{symbolic_algebra_adapter.cpp}::ResultantMatrix = std::vector<std::vector<Rational>>

在文件 symbolic_algebra_adapter.cpp 第 7 行定义.

函数说明

◆ eliminate_resultant_column()

void LMCAS::anonymous_namespace{symbolic_algebra_adapter.cpp}::eliminate_resultant_column ( ResultantMatrix & matrix,
int pivot,
const Rational & previous )

在文件 symbolic_algebra_adapter.cpp 第 29 行定义.

30 {
31 const int size = static_cast<int>(matrix.size());
32 for (int row = pivot + 1; row < size; ++row) {
33 for (int column = pivot + 1; column < size; ++column) {
34 matrix[row][column] =
35 (matrix[row][column] * matrix[pivot][pivot] -
36 matrix[row][pivot] * matrix[pivot][column]) / previous;
37 }
38 matrix[row][pivot] = Rational(0);
39 }
40}

引用了 eliminate_resultant_column().

被这些函数引用 eliminate_resultant_column() , 以及 resultant_determinant().

函数调用图:
这是这个函数的调用关系图:

◆ resultant_determinant()

Rational LMCAS::anonymous_namespace{symbolic_algebra_adapter.cpp}::resultant_determinant ( ResultantMatrix & matrix)

在文件 symbolic_algebra_adapter.cpp 第 42 行定义.

42 {
43 Rational previous(1);
44 int sign = 1;
45 const int size = static_cast<int>(matrix.size());
46 for (int pivot = 0; pivot < size; ++pivot) {
47 if (matrix[pivot][pivot] == Rational(0)) {
48 int replacement = pivot + 1;
49 while (replacement < size &&
50 matrix[replacement][pivot] == Rational(0)) {
51 ++replacement;
52 }
53 if (replacement == size) { return Rational(0); }
54 std::swap(matrix[pivot], matrix[replacement]);
55 sign = -sign;
56 }
57 eliminate_resultant_column(matrix, pivot, previous);
58 previous = matrix[pivot][pivot];
59 }
60 auto determinant = matrix.back().back();
61 if (sign < 0) { determinant = Rational(0) - determinant; }
62 return determinant;
63}
void eliminate_resultant_column(ResultantMatrix &matrix, int pivot, const Rational &previous)
@ Rational
Rational numbers

引用了 eliminate_resultant_column() , 以及 resultant_determinant().

被这些函数引用 resultant_determinant().

函数调用图:
这是这个函数的调用关系图:

◆ sylvester_matrix()

ResultantMatrix LMCAS::anonymous_namespace{symbolic_algebra_adapter.cpp}::sylvester_matrix ( const Polynomial< Rational > & left,
const Polynomial< Rational > & right )

在文件 symbolic_algebra_adapter.cpp 第 9 行定义.

10 {
11 const int left_degree = left.degree();
12 const int right_degree = right.degree();
13 const int size = left_degree + right_degree;
14 ResultantMatrix matrix(size, std::vector<Rational>(size, Rational(0)));
15 for (int row = 0; row < right_degree; ++row) {
16 for (int column = 0; column <= left_degree; ++column) {
17 matrix[row][row + column] = left.coeffs[left_degree - column];
18 }
19 }
20 for (int row = 0; row < left_degree; ++row) {
21 for (int column = 0; column <= right_degree; ++column) {
22 matrix[right_degree + row][row + column] =
23 right.coeffs[right_degree - column];
24 }
25 }
26 return matrix;
27}
std::vector< CoeffType > coeffs
系数数组,coeffs[i] 为 x^i 的系数
int degree() const
获取多项式的次数
const ExprPtr & right

引用了 LMCAS::Polynomial< CoeffType >::coeffs, LMCAS::Polynomial< CoeffType >::degree(), LMCAS::right , 以及 sylvester_matrix().

被这些函数引用 sylvester_matrix().

函数调用图:
这是这个函数的调用关系图: