Skip to content

Commit 06cde9a

Browse files
committed
Merge branch 'pr/9'
2 parents db84b2a + 67db8e2 commit 06cde9a

5 files changed

Lines changed: 832 additions & 35 deletions

File tree

benches/scalar_micro.rs

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,54 @@ const SCALAR_MICRO_GROUPS: &[BenchGroupDoc] = &[
412412
name: "atanh_sqrt_two_error",
413413
description: "Rejects atanh(sqrt(2)) through exact structural domain checks.",
414414
},
415+
BenchDoc {
416+
name: "sinh_ln_two",
417+
description: "Folds sinh(ln(2)) to the exact rational 3/4 via the integer-log-collapse shortcut.",
418+
},
419+
BenchDoc {
420+
name: "cosh_ln_two",
421+
description: "Folds cosh(ln(2)) to the exact rational 5/4 via the integer-log-collapse shortcut.",
422+
},
423+
BenchDoc {
424+
name: "tanh_ln_two",
425+
description: "Folds tanh(ln(2)) to the exact rational 3/5 via the integer-log-collapse shortcut.",
426+
},
427+
BenchDoc {
428+
name: "sinh_rational_one",
429+
description: "Builds sinh(1) through the generic (exp(x) - exp(-x))/2 identity path.",
430+
},
431+
BenchDoc {
432+
name: "cosh_rational_one",
433+
description: "Builds cosh(1) through the generic (exp(x) + exp(-x))/2 identity path.",
434+
},
435+
BenchDoc {
436+
name: "tanh_rational_one",
437+
description: "Builds tanh(1) through the generic (exp(x) - exp(-x))/(exp(x) + exp(-x)) identity path.",
438+
},
439+
BenchDoc {
440+
name: "atan2_origin",
441+
description: "Hits the origin (0, 0) short-circuit returning exact zero.",
442+
},
443+
BenchDoc {
444+
name: "atan2_axis_positive_y",
445+
description: "Hits the positive-y axis short-circuit returning exact pi/2.",
446+
},
447+
BenchDoc {
448+
name: "atan2_axis_negative_x",
449+
description: "Hits the negative-x axis short-circuit returning exact pi.",
450+
},
451+
BenchDoc {
452+
name: "atan2_quadrant_one_unit_diagonal",
453+
description: "Quadrant I unit diagonal reduces to atan(1) = pi/4 exact special form.",
454+
},
455+
BenchDoc {
456+
name: "atan2_quadrant_two_pi_correction",
457+
description: "Quadrant II (1, -2) exercises atan(small ratio) + pi correction.",
458+
},
459+
BenchDoc {
460+
name: "atan2_quadrant_three_negative_pi",
461+
description: "Quadrant III (-1, -2) exercises atan(small ratio) - pi correction.",
462+
},
415463
BenchDoc {
416464
name: "log2_power_of_two",
417465
description: "Folds log2(1024) to the exact rational 10 via the integer-log-detection shortcut.",
@@ -1075,6 +1123,100 @@ fn bench_exact_transcendental_special_forms(c: &mut Criterion) {
10751123
)
10761124
});
10771125

1126+
let ln_two = Real::new(Rational::new(2)).ln().unwrap();
1127+
let rational_one = Real::one();
1128+
1129+
group.bench_function("sinh_ln_two", |b| {
1130+
b.iter_batched(
1131+
|| ln_two.clone(),
1132+
|value| black_box(value.sinh().unwrap()),
1133+
BatchSize::SmallInput,
1134+
)
1135+
});
1136+
group.bench_function("cosh_ln_two", |b| {
1137+
b.iter_batched(
1138+
|| ln_two.clone(),
1139+
|value| black_box(value.cosh().unwrap()),
1140+
BatchSize::SmallInput,
1141+
)
1142+
});
1143+
group.bench_function("tanh_ln_two", |b| {
1144+
b.iter_batched(
1145+
|| ln_two.clone(),
1146+
|value| black_box(value.tanh().unwrap()),
1147+
BatchSize::SmallInput,
1148+
)
1149+
});
1150+
group.bench_function("sinh_rational_one", |b| {
1151+
b.iter_batched(
1152+
|| rational_one.clone(),
1153+
|value| black_box(value.sinh().unwrap()),
1154+
BatchSize::SmallInput,
1155+
)
1156+
});
1157+
group.bench_function("cosh_rational_one", |b| {
1158+
b.iter_batched(
1159+
|| rational_one.clone(),
1160+
|value| black_box(value.cosh().unwrap()),
1161+
BatchSize::SmallInput,
1162+
)
1163+
});
1164+
group.bench_function("tanh_rational_one", |b| {
1165+
b.iter_batched(
1166+
|| rational_one.clone(),
1167+
|value| black_box(value.tanh().unwrap()),
1168+
BatchSize::SmallInput,
1169+
)
1170+
});
1171+
1172+
let zero = Real::zero();
1173+
let positive_one = Real::one();
1174+
let negative_one = -Real::one();
1175+
let negative_two = Real::from(-2_i32);
1176+
1177+
group.bench_function("atan2_origin", |b| {
1178+
b.iter_batched(
1179+
|| (zero.clone(), zero.clone()),
1180+
|(y, x)| black_box(y.atan2(x)),
1181+
BatchSize::SmallInput,
1182+
)
1183+
});
1184+
group.bench_function("atan2_axis_positive_y", |b| {
1185+
b.iter_batched(
1186+
|| (positive_one.clone(), zero.clone()),
1187+
|(y, x)| black_box(y.atan2(x)),
1188+
BatchSize::SmallInput,
1189+
)
1190+
});
1191+
group.bench_function("atan2_axis_negative_x", |b| {
1192+
b.iter_batched(
1193+
|| (zero.clone(), negative_one.clone()),
1194+
|(y, x)| black_box(y.atan2(x)),
1195+
BatchSize::SmallInput,
1196+
)
1197+
});
1198+
group.bench_function("atan2_quadrant_one_unit_diagonal", |b| {
1199+
b.iter_batched(
1200+
|| (positive_one.clone(), positive_one.clone()),
1201+
|(y, x)| black_box(y.atan2(x)),
1202+
BatchSize::SmallInput,
1203+
)
1204+
});
1205+
group.bench_function("atan2_quadrant_two_pi_correction", |b| {
1206+
b.iter_batched(
1207+
|| (positive_one.clone(), negative_two.clone()),
1208+
|(y, x)| black_box(y.atan2(x)),
1209+
BatchSize::SmallInput,
1210+
)
1211+
});
1212+
group.bench_function("atan2_quadrant_three_negative_pi", |b| {
1213+
b.iter_batched(
1214+
|| (negative_one.clone(), negative_two.clone()),
1215+
|(y, x)| black_box(y.atan2(x)),
1216+
BatchSize::SmallInput,
1217+
)
1218+
});
1219+
10781220
let log2_power = Real::new(Rational::new(1024));
10791221
let log2_three = Real::new(Rational::new(3));
10801222
let ln_five = Real::new(Rational::new(5)).ln().unwrap();

benchmarks.md

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -346,38 +346,62 @@ Construction-time shortcuts for exact rational multiples of pi and inverse compo
346346
| `exact_transcendental_special_forms/asin_sin_6pi_7` | not run | not run | Recognizes the principal branch of asin(sin(6pi/7)). |
347347
| `exact_transcendental_special_forms/acos_cos_9pi_7` | not run | not run | Recognizes the principal branch of acos(cos(9pi/7)). |
348348
| `exact_transcendental_special_forms/atan_tan_6pi_7` | not run | not run | Recognizes the principal branch of atan(tan(6pi/7)). |
349-
| `exact_transcendental_special_forms/asinh_large` | not run | not run | Builds a large inverse hyperbolic sine without exact intermediate Reals. |
350-
| `exact_transcendental_special_forms/atanh_sqrt_half` | 192.18 ns | 189.98 ns - 194.71 ns | Builds atanh(sqrt(2)/2) after exact structural domain checks. |
351-
| `exact_transcendental_special_forms/atanh_sqrt_two_error` | 199.45 ns | 121.09 ns - 355.20 ns | Rejects atanh(sqrt(2)) through exact structural domain checks. |
352-
| `exact_transcendental_special_forms/log2_power_of_two` | 173.46 ns | 171.28 ns - 175.58 ns | Folds log2(1024) to the exact rational 10 via the integer-log-detection shortcut. |
353-
| `exact_transcendental_special_forms/log2_rational_three` | 289.47 ns | 284.87 ns - 294.52 ns | Builds log2(3) as a lightweight Log2 symbolic certificate. |
354-
| `exact_transcendental_special_forms/log2_ln_quotient_fold` | 1.283 us | 1.228 us - 1.371 us | Folds ln(5) / ln(2) into a Log2 certificate via the divide-recognize shortcut. |
349+
| `exact_transcendental_special_forms/asinh_large` | 361.76 ns | 360.65 ns - 362.87 ns | Builds a large inverse hyperbolic sine without exact intermediate Reals. |
350+
| `exact_transcendental_special_forms/atanh_sqrt_half` | 636.03 ns | 633.97 ns - 638.10 ns | Builds atanh(sqrt(2)/2) after exact structural domain checks. |
351+
| `exact_transcendental_special_forms/atanh_sqrt_two_error` | 453.00 ns | 445.31 ns - 460.68 ns | Rejects atanh(sqrt(2)) through exact structural domain checks. |
352+
| `exact_transcendental_special_forms/sinh_ln_two` | 1.562 us | 1.519 us - 1.604 us | Folds sinh(ln(2)) to the exact rational 3/4 via the integer-log-collapse shortcut. |
353+
| `exact_transcendental_special_forms/cosh_ln_two` | 1.329 us | 1.312 us - 1.346 us | Folds cosh(ln(2)) to the exact rational 5/4 via the integer-log-collapse shortcut. |
354+
| `exact_transcendental_special_forms/tanh_ln_two` | 1.470 us | 1.436 us - 1.505 us | Folds tanh(ln(2)) to the exact rational 3/5 via the integer-log-collapse shortcut. |
355+
| `exact_transcendental_special_forms/sinh_rational_one` | 2.103 us | 2.091 us - 2.115 us | Builds sinh(1) through the generic (exp(x) - exp(-x))/2 identity path. |
356+
| `exact_transcendental_special_forms/cosh_rational_one` | 1.761 us | 1.745 us - 1.777 us | Builds cosh(1) through the generic (exp(x) + exp(-x))/2 identity path. |
357+
| `exact_transcendental_special_forms/tanh_rational_one` | 5.608 us | 5.595 us - 5.621 us | Builds tanh(1) through the generic (exp(x) - exp(-x))/(exp(x) + exp(-x)) identity path. |
358+
| `exact_transcendental_special_forms/atan2_origin` | 528.39 ns | 219.56 ns - 837.23 ns | Hits the origin (0, 0) short-circuit returning exact zero. |
359+
| `exact_transcendental_special_forms/atan2_axis_positive_y` | 289.65 ns | 285.15 ns - 294.15 ns | Hits the positive-y axis short-circuit returning exact pi/2. |
360+
| `exact_transcendental_special_forms/atan2_axis_negative_x` | 261.49 ns | 260.46 ns - 262.51 ns | Hits the negative-x axis short-circuit returning exact pi. |
361+
| `exact_transcendental_special_forms/atan2_quadrant_one_unit_diagonal` | 756.33 ns | 746.31 ns - 766.34 ns | Quadrant I unit diagonal reduces to atan(1) = pi/4 exact special form. |
362+
| `exact_transcendental_special_forms/atan2_quadrant_two_pi_correction` | 1.890 us | 1.872 us - 1.908 us | Quadrant II (1, -2) exercises atan(small ratio) + pi correction. |
363+
| `exact_transcendental_special_forms/atan2_quadrant_three_negative_pi` | 1.156 us | 1.140 us - 1.172 us | Quadrant III (-1, -2) exercises atan(small ratio) - pi correction. |
364+
| `exact_transcendental_special_forms/log2_power_of_two` | not run | not run | Folds log2(1024) to the exact rational 10 via the integer-log-detection shortcut. |
365+
| `exact_transcendental_special_forms/log2_rational_three` | not run | not run | Builds log2(3) as a lightweight Log2 symbolic certificate. |
366+
| `exact_transcendental_special_forms/log2_ln_quotient_fold` | not run | not run | Folds ln(5) / ln(2) into a Log2 certificate via the divide-recognize shortcut. |
355367

356368
### `symbolic_reductions`
357369

358370
Existing symbolic constant algebra cases considered for additional reductions.
359371

360372
| Benchmark output | Mean | 95% CI | What it measures |
361373
| --- | ---: | ---: | --- |
362-
| `symbolic_reductions/sqrt_pi_square` | 137.90 ns | 134.60 ns - 141.59 ns | Reduces sqrt(pi^2). |
363-
| `symbolic_reductions/sqrt_pi_e_square` | 174.66 ns | 173.75 ns - 175.54 ns | Reduces sqrt((pi * e)^2). |
364-
| `symbolic_reductions/ln_scaled_e` | 1.394 us | 1.382 us - 1.408 us | Reduces ln(2 * e). |
365-
| `symbolic_reductions/sub_pi_three` | 248.16 ns | 244.62 ns - 252.32 ns | Builds the certified pi - 3 constant-offset form. |
366-
| `symbolic_reductions/pi_minus_three_facts` | 36.67 ns | 36.34 ns - 37.03 ns | Reads structural facts for the cached pi - 3 offset form. |
367-
| `symbolic_reductions/div_exp_exp` | 566.66 ns | 562.95 ns - 570.95 ns | Reduces e^3 / e. |
368-
| `symbolic_reductions/div_pi_square_e` | 464.50 ns | 463.12 ns - 465.90 ns | Reduces pi^2 / e. |
369-
| `symbolic_reductions/div_const_products` | 855.78 ns | 852.01 ns - 860.32 ns | Reduces (pi^3 * e^5) / (pi * e^2). |
370-
| `symbolic_reductions/inverse_pi` | 89.50 ns | 89.20 ns - 89.85 ns | Builds the reciprocal of pi. |
371-
| `symbolic_reductions/div_one_pi` | 141.50 ns | 140.79 ns - 142.37 ns | Reduces 1 / pi. |
372-
| `symbolic_reductions/div_rational_exp` | 292.12 ns | 289.84 ns - 294.69 ns | Reduces 2 / e. |
373-
| `symbolic_reductions/div_e_pi` | 269.92 ns | 261.15 ns - 279.59 ns | Reduces e / pi. |
374-
| `symbolic_reductions/mul_pi_inverse_pi` | 247.62 ns | 246.97 ns - 248.30 ns | Multiplies pi by its reciprocal. |
375-
| `symbolic_reductions/mul_pi_e_sqrt_two` | 438.83 ns | 437.88 ns - 439.69 ns | Builds the factored pi * e * sqrt(2) form. |
376-
| `symbolic_reductions/mul_const_product_sqrt_sqrt` | 685.04 ns | 676.75 ns - 693.88 ns | Cancels sqrt(2) from (pi * e * sqrt(2)) * sqrt(2). |
377-
| `symbolic_reductions/div_const_product_sqrt_e` | 728.58 ns | 725.63 ns - 731.29 ns | Reduces (pi * e * sqrt(2)) / e. |
378-
| `symbolic_reductions/inverse_const_product_sqrt` | 478.56 ns | 475.73 ns - 482.08 ns | Builds a rationalized reciprocal of pi * e * sqrt(2). |
379-
| `symbolic_reductions/inverse_sqrt_two` | 101.33 ns | 100.92 ns - 101.81 ns | Builds the rationalized reciprocal of unit-scaled sqrt(2). |
380-
| `symbolic_reductions/div_sqrt_two_sqrt_three` | 842.52 ns | 838.35 ns - 847.63 ns | Rationalizes a quotient of two unit-scaled square roots. |
374+
| `symbolic_reductions/sqrt_pi_square` | not run | not run | Reduces sqrt(pi^2). |
375+
| `symbolic_reductions/sqrt_pi_e_square` | not run | not run | Reduces sqrt((pi * e)^2). |
376+
| `symbolic_reductions/ln_scaled_e` | not run | not run | Reduces ln(2 * e). |
377+
| `symbolic_reductions/sub_pi_three` | not run | not run | Builds the certified pi - 3 constant-offset form. |
378+
| `symbolic_reductions/pi_minus_three_facts` | not run | not run | Reads structural facts for the cached pi - 3 offset form. |
379+
| `symbolic_reductions/div_exp_exp` | not run | not run | Reduces e^3 / e. |
380+
| `symbolic_reductions/div_pi_square_e` | not run | not run | Reduces pi^2 / e. |
381+
| `symbolic_reductions/div_const_products` | not run | not run | Reduces (pi^3 * e^5) / (pi * e^2). |
382+
| `symbolic_reductions/inverse_pi` | not run | not run | Builds the reciprocal of pi. |
383+
| `symbolic_reductions/div_one_pi` | not run | not run | Reduces 1 / pi. |
384+
| `symbolic_reductions/div_rational_exp` | not run | not run | Reduces 2 / e. |
385+
| `symbolic_reductions/div_e_pi` | not run | not run | Reduces e / pi. |
386+
| `symbolic_reductions/mul_pi_inverse_pi` | not run | not run | Multiplies pi by its reciprocal. |
387+
| `symbolic_reductions/mul_pi_e_sqrt_two` | not run | not run | Builds the factored pi * e * sqrt(2) form. |
388+
| `symbolic_reductions/mul_const_product_sqrt_sqrt` | not run | not run | Cancels sqrt(2) from (pi * e * sqrt(2)) * sqrt(2). |
389+
| `symbolic_reductions/div_const_product_sqrt_e` | not run | not run | Reduces (pi * e * sqrt(2)) / e. |
390+
| `symbolic_reductions/inverse_const_product_sqrt` | not run | not run | Builds a rationalized reciprocal of pi * e * sqrt(2). |
391+
| `symbolic_reductions/inverse_sqrt_two` | not run | not run | Builds the rationalized reciprocal of unit-scaled sqrt(2). |
392+
| `symbolic_reductions/div_sqrt_two_sqrt_three` | not run | not run | Rationalizes a quotient of two unit-scaled square roots. |
393+
394+
### `exact_product_sums`
395+
396+
Fixed product-sum reducers used by determinant and cofactor kernels.
397+
398+
| Benchmark output | Mean | 95% CI | What it measures |
399+
| --- | ---: | ---: | --- |
400+
| `exact_product_sums/signed_product_sum_lcm_6x2` | not run | not run | Computes an exact rational six-term signed product sum with mixed denominators. |
401+
| `exact_product_sums/signed_product_sum_common_scale_6x2` | not run | not run | Computes an exact rational six-term signed product sum through the carried common-scale reducer. |
402+
| `exact_product_sums/signed_product_sum_sparse_single_6x2` | not run | not run | Computes a sparse exact rational six-term signed product sum with one active product. |
403+
| `exact_product_sums/real_signed_product_sum_rational_det3` | not run | not run | Computes a 3x3 determinant-shaped signed product sum through the public `Real` builder. |
404+
| `exact_product_sums/real_signed_product_sum_mixed_symbolic_det3` | not run | not run | Computes the same determinant-shaped builder with symbolic factors and rational scales. |
381405

382406
<!-- END scalar_micro -->
383407

0 commit comments

Comments
 (0)