Skip to content

Commit

Permalink
Scalar is now an associated type of FitModel
Browse files Browse the repository at this point in the history
(that's a massive rewrite!)
This change might seem random, but it, in fact, simplifies usage A LOT.
Now, `Scalar` type is **determined** by model, which is what should
happen in the first place.
  • Loading branch information
Dzuchun committed Nov 24, 2024
1 parent 68641ac commit 9d4c06a
Show file tree
Hide file tree
Showing 21 changed files with 774 additions and 567 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ struct CustomModel {
peaks: [Gaussian<f64>; 3],
}

impl FitModel<f64> for CustomModel {
impl FitModel for CustomModel {
type Scalar = f64;
type ParamCount = typenum::U13; // oh, and you also need to manually compute total parameter count

fn evaluate(&self, x: &f64) -> f64 {
Expand Down Expand Up @@ -205,13 +206,14 @@ Good news is - there's a macro for that!
# use static_assertions::assert_impl_all;
#
#[derive(FitModelSum)]
#[scalar_type(f64)]
struct ConstExponent {
linear: Constant<f64>,
exponent: Exponent<f64>,
peaks: [Gaussian<f64>; 3],
}
#
# assert_impl_all!(ConstExponent: FitModel<f64>);
# assert_impl_all!(ConstExponent: FitModel<Scalar = f64>);
```

And it does exactly all of the above, except you can do a bunch of stuff that would be hard to implement manually.
Expand Down
Loading

0 comments on commit 9d4c06a

Please sign in to comment.