Skip to content

Commit

Permalink
Add sympy-compatible export option
Browse files Browse the repository at this point in the history
- Allow printing atoms in canonical form, independent
  of implementation details.
  • Loading branch information
benruijl committed Jul 23, 2024
1 parent cd91cf7 commit 48c5b99
Show file tree
Hide file tree
Showing 6 changed files with 317 additions and 169 deletions.
14 changes: 1 addition & 13 deletions examples/fuel_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,7 @@ fn main() {
.collect(),
);

let print_opt = PrintOptions {
terms_on_new_line: false,
color_top_level_sum: false,
color_builtin_symbols: false,
print_finite_field: false,
symmetric_representation_for_finite_field: false,
explicit_rational_polynomial: false,
number_thousands_separator: None,
multiplication_operator: '*',
square_brackets_for_function: false,
num_exp_as_superscript: false,
latex: false,
};
let print_opt = PrintOptions::file();

buffer.clear();
while let Ok(n) = stdin.read_line(&mut buffer) {
Expand Down
22 changes: 2 additions & 20 deletions src/api/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,8 @@ unsafe extern "C" fn simplify(
let token = Token::parse(cstr).unwrap();

let opts = PrintOptions {
terms_on_new_line: false,
color_top_level_sum: false,
color_builtin_symbols: false,
print_finite_field: false,
symmetric_representation_for_finite_field: false,
explicit_rational_polynomial,
number_thousands_separator: None,
multiplication_operator: '*',
square_brackets_for_function: false,
num_exp_as_superscript: false,
latex: false,
..PrintOptions::file()
};

macro_rules! to_rational {
Expand Down Expand Up @@ -299,17 +290,8 @@ unsafe extern "C" fn simplify_factorized(
let token = Token::parse(cstr).unwrap();

let opts = PrintOptions {
terms_on_new_line: false,
color_top_level_sum: false,
color_builtin_symbols: false,
print_finite_field: false,
symmetric_representation_for_finite_field: false,
explicit_rational_polynomial,
number_thousands_separator: None,
multiplication_operator: '*',
square_brackets_for_function: false,
num_exp_as_superscript: false,
latex: false,
..PrintOptions::file()
};

macro_rules! to_rational {
Expand Down
33 changes: 3 additions & 30 deletions src/api/mathematica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,8 @@ fn simplify(input: String, prime: i64, explicit_rational_polynomial: bool) -> St
RationalPolynomialPrinter {
poly: &r,
opts: PrintOptions {
terms_on_new_line: false,
color_top_level_sum: false,
color_builtin_symbols: false,
print_finite_field: false,
explicit_rational_polynomial,
symmetric_representation_for_finite_field: false,
number_thousands_separator: None,
multiplication_operator: '*',
square_brackets_for_function: false,
num_exp_as_superscript: false,
latex: false,
..PrintOptions::mathematica()
},
add_parentheses: false
}
Expand All @@ -114,17 +105,8 @@ fn simplify(input: String, prime: i64, explicit_rational_polynomial: bool) -> St
RationalPolynomialPrinter {
poly: &rf,
opts: PrintOptions {
terms_on_new_line: false,
color_top_level_sum: false,
color_builtin_symbols: false,
print_finite_field: false,
explicit_rational_polynomial,
symmetric_representation_for_finite_field: false,
number_thousands_separator: None,
multiplication_operator: '*',
square_brackets_for_function: false,
num_exp_as_superscript: false,
latex: false,
..PrintOptions::mathematica()
},
add_parentheses: false
}
Expand All @@ -146,17 +128,8 @@ fn simplify(input: String, prime: i64, explicit_rational_polynomial: bool) -> St
RationalPolynomialPrinter {
poly: &rf,
opts: PrintOptions {
terms_on_new_line: false,
color_top_level_sum: false,
color_builtin_symbols: false,
print_finite_field: false,
explicit_rational_polynomial,
symmetric_representation_for_finite_field: false,
number_thousands_separator: None,
multiplication_operator: '*',
square_brackets_for_function: false,
num_exp_as_superscript: false,
latex: false,
..PrintOptions::mathematica()
},
add_parentheses: false
}
Expand Down
Loading

0 comments on commit 48c5b99

Please sign in to comment.