diff options
author | Thomas White <taw@physics.org> | 2021-01-11 09:53:47 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-01-11 09:57:58 +0100 |
commit | 9d9e819bc535102ca52d6270b6a928e6e70539b6 (patch) | |
tree | 135655915dc6418356f72076b572fc1ed032159e /src | |
parent | 708590dd4bfac92bde90d9762f413c7496afbddf (diff) |
UnitCell: Store all representations once they're calculated
Previously, the "getter" functions would re-calculate the requested
representation every time they were called. This could mean doing a
matrix inversion in the middle of a tight loop, wasting loads of time.
Now, it stores the calculated values and returns them directly next
time. Setting the parameters invalidates the values for all
representations other than the one given.
The cost of doing this is that the cell can no longer be "const" in the
getter functions. This tracked through some other code, but nothing too
severe.
Diffstat (limited to 'src')
-rw-r--r-- | src/post-refinement.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/post-refinement.c b/src/post-refinement.c index 09438a82..89b468c4 100644 --- a/src/post-refinement.c +++ b/src/post-refinement.c @@ -56,7 +56,7 @@ struct rf_alteration struct rf_priv { - const Crystal *cr; /**< Original crystal (before any refinement) */ + Crystal *cr; /**< Original crystal (before any refinement) */ const RefList *full; int serial; int scaleflags; @@ -98,7 +98,7 @@ const char *str_prflag(enum prflag flag) } -static void rotate_cell_xy(const UnitCell *source, UnitCell *tgt, +static void rotate_cell_xy(UnitCell *source, UnitCell *tgt, double ang1, double ang2) { double asx, asy, asz; @@ -150,7 +150,7 @@ static void rotate_cell_xy(const UnitCell *source, UnitCell *tgt, } -static void apply_parameters(const Crystal *cr_orig, Crystal *cr_tgt, +static void apply_parameters(Crystal *cr_orig, Crystal *cr_tgt, struct rf_alteration alter) { double R, lambda; @@ -161,7 +161,7 @@ static void apply_parameters(const Crystal *cr_orig, Crystal *cr_tgt, R = crystal_get_profile_radius(cr_orig); lambda = crystal_get_image_const(cr_orig)->lambda; - rotate_cell_xy(crystal_get_cell_const(cr_orig), crystal_get_cell(cr_tgt), + rotate_cell_xy(crystal_get_cell(cr_orig), crystal_get_cell(cr_tgt), alter.rot_x, alter.rot_y); crystal_set_profile_radius(cr_tgt, R+alter.delta_R); image->lambda = lambda+alter.delta_wave; |