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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
//! # Yufmath - 计算机代数系统
//!
//! Yufmath 是一个基于 Rust 编写的高性能计算机代数系统(CAS)库,
//! 提供符号数学计算、精确算术运算和多种接口支持。
//!
//! ## 主要特性
//!
//! - **精确计算**:支持任意精度整数、有理数和复数运算
//! - **符号计算**:代数表达式的符号操作和简化
//! - **微积分**:符号求导和积分
//! - **多接口支持**:Rust API、C++ 绑定、命令行工具
//! - **高性能**:优化的算法和缓存机制
//! - **进度监控**:支持长时间计算的进度跟踪和取消
//! - **批量处理**:支持批量计算和并行处理
//!
//! ## 快速开始
//!
//! ### 基本使用
//!
//! ```rust,ignore
//! use yufmath::Yufmath;
//!
//! // 创建 Yufmath 实例
//! let yuf = Yufmath::new();
//!
//! // 基本计算
//! let result = yuf.compute("2 + 3 * 4").unwrap();
//! println!("计算结果: {}", result); // 输出: 14
//!
//! // 符号计算
//! let result = yuf.compute("x + x").unwrap();
//! println!("简化结果: {}", result); // 输出: 2*x
//!
//! // 求导
//! let expr = yuf.parse("x^2 + 2*x + 1").unwrap();
//! let derivative = yuf.diff(&expr, "x").unwrap();
//! println!("导数: {:?}", derivative);
//!
//! // 积分
//! let integral = yuf.integrate(&expr, "x").unwrap();
//! println!("积分: {:?}", integral);
//! ```
//!
//! ### 配置使用
//!
//! ```rust,ignore
//! use yufmath::{Yufmath, ComputeConfig, PrecisionConfig};
//! use std::time::Duration;
//!
//! // 创建自定义配置
//! let precision_config = PrecisionConfig::new()
//! .with_force_exact(true)
//! .with_max_precision(1000);
//!
//! let config = ComputeConfig::new()
//! .with_progress(true)
//! .with_max_compute_time(Duration::from_secs(60))
//! .with_precision(precision_config);
//!
//! // 使用配置创建实例
//! let yuf = Yufmath::with_config(config);
//! ```
//!
//! ### 进度监控
//!
//! ```rust,ignore
//! use yufmath::Yufmath;
//!
//! let mut yuf = Yufmath::new();
//!
//! // 设置进度回调
//! yuf.set_progress_callback(Box::new(|progress| {
//! println!("进度: {:.1}% - {}",
//! progress.progress * 100.0,
//! progress.current_step);
//! true // 返回 true 继续计算,false 取消计算
//! }));
//!
//! // 带进度的计算
//! let result = yuf.compute_with_progress("integrate(sin(x^2), x)").unwrap();
//! ```
//!
//! ### 批量计算
//!
//! ```rust,ignore
//! use yufmath::Yufmath;
//!
//! let yuf = Yufmath::new();
//!
//! // 批量计算
//! let expressions = vec!["2 + 3", "x^2 + 1", "sin(pi/2)"];
//! let results = yuf.batch_compute(&expressions);
//!
//! for (expr, result) in expressions.iter().zip(results.iter()) {
//! match result {
//! Ok(value) => println!("{} = {}", expr, value),
//! Err(e) => println!("{} -> 错误: {}", expr, e),
//! }
//! }
//! ```
//!
//! ### 高级数学功能
//!
//! ```rust,ignore
//! use yufmath::Yufmath;
//!
//! let yuf = Yufmath::new();
//!
//! // 多项式运算
//! let poly = yuf.parse("(x + 1)^3").unwrap();
//! let expanded = yuf.expand(&poly).unwrap();
//! println!("展开: {:?}", expanded);
//!
//! // 方程求解
//! let equation = yuf.parse("x^2 - 4").unwrap();
//! let solutions = yuf.solve(&equation, "x").unwrap();
//! println!("解: {:?}", solutions);
//!
//! // 数论函数
//! let gcd_result = yuf.gcd(&yuf.parse("48").unwrap(), &yuf.parse("18").unwrap()).unwrap();
//! println!("最大公约数: {:?}", gcd_result);
//!
//! // 矩阵运算
//! let matrix_a = yuf.parse("[[1,2],[3,4]]").unwrap();
//! let matrix_b = yuf.parse("[[5,6],[7,8]]").unwrap();
//! let product = yuf.matrix_multiply(&matrix_a, &matrix_b).unwrap();
//! println!("矩阵乘积: {:?}", product);
//! ```
//!
//! ## 错误处理
//!
//! Yufmath 提供了完善的错误处理机制:
//!
//! ```rust,ignore
//! use yufmath::{Yufmath, YufmathError};
//!
//! let yuf = Yufmath::new();
//!
//! match yuf.compute("2 + + 3") {
//! Ok(result) => println!("结果: {}", result),
//! Err(e) => {
//! println!("错误: {}", e.user_friendly_message());
//! println!("建议: {:?}", e.suggestions());
//!
//! // 生成完整的错误报告
//! println!("{}", e.format_error_report(Some("2 + + 3")));
//! }
//! }
//! ```
//!
//! ## 性能监控
//!
//! ```rust,ignore
//! use yufmath::Yufmath;
//!
//! let mut yuf = Yufmath::new();
//!
//! // 执行一些计算
//! yuf.compute("x^2 + 2*x + 1").unwrap();
//! yuf.compute("integrate(sin(x), x)").unwrap();
//!
//! // 获取性能统计
//! if let Some(stats) = yuf.get_performance_stats() {
//! println!("总计算次数: {}", stats.total_computations);
//! println!("成功率: {:.2}%", stats.success_rate() * 100.0);
//! println!("平均计算时间: {:?}", stats.avg_compute_time);
//! println!("精确计算比例: {:.2}%", stats.exact_computation_ratio * 100.0);
//! }
//! ```
// 重新导出主要的公共接口
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// 库的版本信息
pub const VERSION: &str = env!;
/// 库的名称
pub const NAME: &str = env!;
/// 库的描述
pub const DESCRIPTION: &str = env!;