3个版本
0.1.5 | 2023年5月23日 |
---|---|
0.1.4 | 2023年5月17日 |
0.1.0 | 2023年5月15日 |
#1357 in 数学
每月 44 次下载
50KB
1K SLoC
Mathrs
数学库
目前仅实现了矩阵计算器。
你可以做什么
- 计算矩阵的和、减法和乘法。
- 使用高斯消元法计算简化的矩阵。
- 使用高斯消元法和LU分解计算行列式矩阵。
- 使用高斯-若尔当法计算矩阵的逆。
Rust中的用法
每个矩阵都可以使用一个宏来创建,该宏将以以下方式解析表示矩阵的字符串: {{a11, a12, a13, ...}. {a21, a22, a23, ...}, ...}
. 因为每个矩阵都可以包含不同类型的数字,所以你必须指定你将得到哪种类型的数字: matrix_<number_type>!("{{a11, a12, ...}, {a21, a22, ...}, ...}")
.
示例
调用
let matrix = matrix_f32!("{{1.1, 2.2}, {2.1, 3.2}}");
println!("{matrix}")
将打印
+1.1000000 +2.2000000
+2.1000000 +3.2000000
JavaScript或TypeScript中的用法
const performSum = async () => {
await init();
result.value = RMatrixF32.checked_sum(
RMatrixF32.from_string(matA.value, 1e-6),
RMatrixF32.from_string(matB.value, 1e-6)
).to_string();
};
const performSub = async () => {
await init();
result.value = RMatrixF32.checked_sub(
RMatrixF32.from_string(matA.value, 1e-6),
RMatrixF32.from_string(matB.value, 1e-6)
).to_string();
};
const performMul = async () => {
await init();
result.value = RMatrixF32.checked_mul(
RMatrixF32.from_string(matA.value, 1e-6),
RMatrixF32.from_string(matB.value, 1e-6)
).to_string();
};
const mat = ref("");
const result2 = ref("Nothing yet...");
const preformGaussReduction = async () => {
await init();
result2.value = RMatrixF32.from_string(mat.value, 1e-6)
.gaussian_triangulation()
.to_string();
};
const performGaussJordanDeterminant = async () => {
await init();
result2.value = RMatrixF32.from_string(mat.value, 1e-6)
.determinant_using_gauss()
.toString();
};
const performGaussJordanInverse = async () => {
await init();
result2.value = RMatrixF32.from_string(mat.value, 1e-6)
.inverse_gauss_jordan()
.to_string();
};
依赖项
~2.2–3MB
~53K SLoC