Skip to content

Commit

Permalink
Use .resize_mut() rather than view().into() to avoid reallocating int…
Browse files Browse the repository at this point in the history
…ernal matrices
  • Loading branch information
sd2k committed May 30, 2024
1 parent d89593b commit c3d215f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions changepoint/src/gp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,11 @@ where
self.mrc = self.run_length_pr.len();

// Adjust other variables
self.u = self.u.view((0, 0), (self.mrc - 1, self.mrc - 1)).into();
self.u.resize_mut(self.mrc - 1, self.mrc - 1, 0.0);
self.last_nlml = self.last_nlml.rows_range(0..(self.mrc - 1)).into();
self.alpha = self.alpha.view((0, 0), (self.mrc - 1, 1)).into();
self.alpha_t = self.alpha_t.view((0, 0), (self.mrc - 1, 1)).into();
self.beta_t = self.beta_t.view((0, 0), (self.mrc - 1, 1)).into();
self.alpha.resize_mut(self.mrc - 1, 1, 0.0);
self.alpha_t.resize_mut(self.mrc - 1, 1, 0.0);
self.beta_t.resize_mut(self.mrc - 1, 1, 0.0);

&self.run_length_pr
}
Expand Down

0 comments on commit c3d215f

Please sign in to comment.