Skip to content

Commit b99d257

Browse files
committed
Allow for having names different from the ones in the backend
1 parent f28c0c2 commit b99d257

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

src/elliptic.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
macro_rules! declare_method {
2-
($(#[$attribute:meta])* $name:ident $($argument:ident)*) => {
2+
($(#[$attribute:meta])* $name:ident($($argument:ident),*)) => {
33
$(#[$attribute])*
44
fn $name(self, $($argument: Self,)*) -> Self;
55
};
@@ -10,30 +10,30 @@ macro_rules! declare_method {
1010
// With @kc_x, define_method expect x as the first and self as the second argument.
1111
// With @first, define_method expect self as the first argument.
1212
macro_rules! define_method {
13-
(@kc $name:ident $($argument:ident)*) => {
13+
(@kc $name:ident -> $backend:ident($($argument:ident),*)) => {
1414
fn $name(self, $($argument: Self,)*) -> Self {
1515
debug_assert!(self > 0.0, concat!("m (self) cannot be less than 1"));
1616
ellip::$name((1.0 - self).sqrt(), $($argument,)*).unwrap()
1717
}
1818
};
19-
(@kc_x $name:ident $x:ident) => {
19+
(@kc_x $name:ident -> $backend:ident($x:ident)) => {
2020
fn $name(self, $x: Self) -> Self {
2121
debug_assert!(self > 0.0, concat!("m (self) cannot be less than 1"));
2222
ellip::$name($x, (1.0 - self).sqrt()).unwrap()
2323
}
2424
};
25-
(@kc_x $name:ident $x:ident $($argument:ident)+) => {
25+
(@kc_x $name:ident -> $backend:ident($x:ident, $($argument:ident),+)) => {
2626
fn $name(self, $x: Self, $($argument: Self,)*) -> Self {
2727
debug_assert!(self > 0.0, concat!("m (self) cannot be less than 1"));
2828
ellip::$name($x, (1.0 - self).sqrt(), $($argument,)*).unwrap()
2929
}
3030
};
31-
(@first $name:ident $($argument:ident)*) => {
31+
(@first $name:ident -> $backend:ident($($argument:ident),*)) => {
3232
fn $name(self, $($argument: Self,)*) -> Self {
3333
ellip::$name(self, $($argument,)*).unwrap()
3434
}
3535
};
36-
($name:ident $($argument:ident)*) => {
36+
($name:ident -> $backend:ident($($argument:ident),*)) => {
3737
fn $name(self, $($argument: Self,)*) -> Self {
3838
ellip::$name($($argument,)* self).unwrap()
3939
}
@@ -43,19 +43,19 @@ macro_rules! define_method {
4343
macro_rules! implement {
4444
($(
4545
$(#[$attribute:meta])*
46-
$(@$flag:ident)? $name:ident $([$($order:tt)*])? $($argument:ident)*,
46+
$(@$flag:ident)? $name:ident -> $backend:ident($($argument:tt)*),
4747
)*) => {
4848
/// Elliptic integrals.
4949
pub trait Elliptic: Sized {
50-
$(declare_method!($(#[$attribute])* $name $($argument)*);)*
50+
$(declare_method!($(#[$attribute])* $name($($argument)*));)*
5151
}
5252

5353
impl Elliptic for f32 {
54-
$(define_method!($(@$flag)? $name $($argument)*);)*
54+
$(define_method!($(@$flag)? $name -> $backend($($argument)*));)*
5555
}
5656

5757
impl Elliptic for f64 {
58-
$(define_method!($(@$flag)? $name $($argument)*);)*
58+
$(define_method!($(@$flag)? $name -> $backend($($argument)*));)*
5959
}
6060
};
6161
}
@@ -83,7 +83,7 @@ implement!(
8383
/// The function panics if m > 1.
8484
///
8585
/// [1]: https://crates.io/crates/ellip
86-
ellipk,
86+
ellipk -> ellipk(),
8787

8888
/// Compute the complete elliptic integral of the second kind (E).
8989
///
@@ -107,7 +107,7 @@ implement!(
107107
/// The function panics if m > 1.
108108
///
109109
/// [1]: https://crates.io/crates/ellip
110-
ellipe,
110+
ellipe -> ellipe(),
111111

112112
/// Compute the complete elliptic integral of the third kind (Π).
113113
///
@@ -133,7 +133,7 @@ implement!(
133133
/// The function panics if m > 1.
134134
///
135135
/// [1]: https://crates.io/crates/ellip
136-
ellippi n,
136+
ellippi -> ellippi(n),
137137

138138
/// Compute the complete elliptic integral of Legendre's type (D).
139139
///
@@ -157,7 +157,7 @@ implement!(
157157
/// The function panics if m > 1.
158158
///
159159
/// [1]: https://crates.io/crates/ellip
160-
ellipd,
160+
ellipd -> ellipd(),
161161

162162
// <--- Incomplete Legendre's Integrals --->
163163

@@ -185,7 +185,7 @@ implement!(
185185
/// The function panics if m sin²φ > 1.
186186
///
187187
/// [1]: https://crates.io/crates/ellip
188-
ellipf phi,
188+
ellipf -> ellipf(phi),
189189

190190
/// Compute the incomplete elliptic integral of the second kind (E).
191191
///
@@ -211,7 +211,7 @@ implement!(
211211
/// The function panics if m sin²φ > 1.
212212
///
213213
/// [1]: https://crates.io/crates/ellip
214-
ellipeinc phi,
214+
ellipeinc -> ellipeinc(phi),
215215

216216
/// Compute the incomplete elliptic integral of the third kind (Π).
217217
///
@@ -239,7 +239,7 @@ implement!(
239239
/// The function panics if m sin²φ > 1, n sin²φ = 1, or m ≥ 1 and φ is not a multiple of π/2.
240240
///
241241
/// [1]: https://crates.io/crates/ellip
242-
ellippiinc phi n,
242+
ellippiinc -> ellippiinc(phi, n),
243243

244244
/// Compute the incomplete elliptic integral of the third kind (Π) using Bulirsch's method.
245245
///
@@ -267,7 +267,7 @@ implement!(
267267
/// The function panics if m sin²φ > 1, n sin²φ = 1, or m ≥ 1 and φ is not a multiple of π/2.
268268
///
269269
/// [1]: https://crates.io/crates/ellip
270-
ellippiinc_bulirsch phi n,
270+
ellippiinc_bulirsch -> ellippiinc_bulirsch(phi, n),
271271

272272
/// Compute the incomplete elliptic integral of Legendre's type (D).
273273
///
@@ -293,7 +293,7 @@ implement!(
293293
/// The function panics if m sin²φ > 1.
294294
///
295295
/// [1]: https://crates.io/crates/ellip
296-
ellipdinc phi,
296+
ellipdinc -> ellipdinc(phi),
297297

298298
// <--- Bulirsch's Integrals --->
299299

@@ -326,7 +326,7 @@ implement!(
326326
/// The function panics if m = 1, p = 0, or more than one arguments are infinite.
327327
///
328328
/// [1]: https://crates.io/crates/ellip
329-
@kc cel p a b,
329+
@kc cel -> cel(p, a, b),
330330

331331
/// Compute Bulirsch's complete elliptic integral.
332332
///
@@ -352,7 +352,7 @@ implement!(
352352
/// The function panics if m = 1.
353353
///
354354
/// [1]: https://crates.io/crates/ellip
355-
@kc cel1,
355+
@kc cel1 -> cel1(),
356356

357357
/// Compute Bulirsch's complete elliptic integral.
358358
///
@@ -381,7 +381,7 @@ implement!(
381381
/// The function panics if m = 1 or more than one arguments are infinite.
382382
///
383383
/// [1]: https://crates.io/crates/ellip
384-
@kc cel2 a b,
384+
@kc cel2 -> cel2(a, b),
385385

386386
/// Compute Bulirsch's incomplete elliptic integral.
387387
///
@@ -409,7 +409,7 @@ implement!(
409409
/// The function panics if m = 1.
410410
///
411411
/// [1]: https://crates.io/crates/ellip
412-
@kc_x el1 x,
412+
@kc_x el1 -> el1(x),
413413

414414
/// Compute Bulirsch's incomplete elliptic integral.
415415
///
@@ -440,7 +440,7 @@ implement!(
440440
/// The function panics if m = 1.
441441
///
442442
/// [1]: https://crates.io/crates/ellip
443-
@kc_x el2 x a b,
443+
@kc_x el2 -> el2(x, a, b),
444444

445445
/// Compute Bulirsch's incomplete elliptic integral.
446446
///
@@ -470,7 +470,7 @@ implement!(
470470
/// The function panics if m = 1, 1 + px² = 0, or m < 0 for p < 0.
471471
///
472472
/// [1]: https://crates.io/crates/ellip
473-
@kc_x el3 x p,
473+
@kc_x el3 -> el3(x, p),
474474

475475
// <--- Carlson's Symmetric Integrals --->
476476

@@ -499,7 +499,7 @@ implement!(
499499
/// The function panics if any of x, y, or z is negative, or more than one of them are zero.
500500
///
501501
/// [1]: https://crates.io/crates/ellip
502-
elliprf y z,
502+
elliprf -> elliprf(y, z),
503503

504504
/// Compute Carlson's symmetric elliptic integral of the second kind (RG).
505505
///
@@ -526,7 +526,7 @@ implement!(
526526
/// The function panics if any of x, y, or z is negative or infinite.
527527
///
528528
/// [1]: https://crates.io/crates/ellip
529-
elliprg y z,
529+
elliprg -> elliprg(y, z),
530530

531531
/// Compute Carlson's symmetric elliptic integral of the third kind (RJ).
532532
///
@@ -555,7 +555,7 @@ implement!(
555555
/// The function panics if p = 0, any of x, y, or z is negative, or more than one of them are zero.
556556
///
557557
/// [1]: https://crates.io/crates/ellip
558-
@first elliprj y z p,
558+
@first elliprj -> elliprj(y, z, p),
559559

560560
/// Compute Carlson's degenerate symmetric elliptic integral (RC).
561561
///
@@ -581,7 +581,7 @@ implement!(
581581
/// The function panics if x < 0, y = 0, or y < 0.
582582
///
583583
/// [1]: https://crates.io/crates/ellip
584-
@first elliprc y,
584+
@first elliprc -> elliprc(y),
585585

586586
/// Compute Carlson's symmetric elliptic integral of the second kind (RD).
587587
///
@@ -608,7 +608,7 @@ implement!(
608608
/// The function panics if x < 0, y < 0, z ≤ 0 or when both x and y are zero.
609609
///
610610
/// [1]: https://crates.io/crates/ellip
611-
@first elliprd y z,
611+
@first elliprd -> elliprd(y, z),
612612

613613
// <--- Miscellaneous Functions --->
614614

@@ -637,7 +637,7 @@ implement!(
637637
/// The function panics if m > 1, phi is infinite, or m is infinite.
638638
///
639639
/// [1]: https://crates.io/crates/ellip
640-
jacobi_zeta phi,
640+
jacobi_zeta -> jacobi_zeta(phi),
641641

642642
/// Compute Heuman's Lambda function.
643643
///
@@ -664,5 +664,5 @@ implement!(
664664
/// The function panics if m < 0, m ≥ 1, or phi is infinite.
665665
///
666666
/// [1]: https://crates.io/crates/ellip
667-
heuman_lambda phi,
667+
heuman_lambda -> heuman_lambda(phi),
668668
);

0 commit comments

Comments
 (0)