Skip to content

Commit

Permalink
Update fastcpd 0.14.4
Browse files Browse the repository at this point in the history
*   Simplify code.
*   Expose `fastcpd_impl` API for use in other packages.
  • Loading branch information
doccstat committed Apr 27, 2024
1 parent 19925f4 commit 7cdb2f7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: fastcpd
Title: Fast Change Point Detection via Sequential Gradient Descent
Version: 0.14.3
Version: 0.14.4
Authors@R: c(
person("Xingchi", "Li", , "[email protected]",
role = c("aut", "cre", "cph"),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# fastcpd 0.14.4

* Simplify code.
* Expose `fastcpd_impl` API for use in other packages.

# fastcpd 0.14.3

* Skip certain tests on CRAN.
Expand Down
11 changes: 4 additions & 7 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
## Updates since last CRAN release (0.14.1)
## Updates since last CRAN release (0.14.3)

# fastcpd 0.14.3
### fastcpd 0.14.4

* Skip certain tests on CRAN.

### fastcpd 0.14.2

* Fix CRAN noSuggests error.
* Simplify code.
* Expose `fastcpd_impl` API for use in other packages.
12 changes: 5 additions & 7 deletions src/fastcpd_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ using ::Rcpp::as;
using ::Rcpp::checkUserInterrupt;
using ::Rcpp::Named;
using ::Rcpp::wrap;
using ::std::make_unique;

using ::arma::vec;
using ::Rcpp::Environment;
Expand Down Expand Up @@ -90,6 +91,7 @@ Fastcpd::Fastcpd(
pruning_coef(pruning_coef),
r_clock(r_clock),
r_progress(r_progress),
rProgress(make_unique<RProgress::RProgress>(kRProgress, data_n_rows)),
segment_count(segment_count),
segment_indices(round(linspace(0, data_n_rows, segment_count + 1))),
segment_theta_hat(mat(segment_count, p)),
Expand All @@ -102,10 +104,6 @@ Fastcpd::Fastcpd(
variance_estimate(variance_estimate),
warm_start(warm_start),
zero_data(join_cols(zeros<rowvec>(data_n_cols), data)) {
rProgress = std::make_unique<RProgress::RProgress>(
"[:bar] :current/:total in :elapsed", data_n_rows
);

if (k.isNotNull()) {
this->k = std::make_unique<Function>(k);
}
Expand Down Expand Up @@ -149,10 +147,10 @@ Fastcpd::Fastcpd(
} else if (family == "variance") {
get_nll_pelt = &Fastcpd::get_nll_pelt_variance;
} else {
this->cost = std::make_unique<Function>(cost);
this->cost = make_unique<Function>(cost);
if (cost_gradient.isNotNull() || cost_hessian.isNotNull()) {
this->cost_gradient = std::make_unique<Function>(cost_gradient);
this->cost_hessian = std::make_unique<Function>(cost_hessian);
this->cost_gradient = make_unique<Function>(cost_gradient);
this->cost_hessian = make_unique<Function>(cost_hessian);
}
get_gradient = &Fastcpd::get_gradient_custom;
get_hessian = &Fastcpd::get_hessian_custom;
Expand Down
14 changes: 9 additions & 5 deletions src/fastcpd_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ using ::arma::ucolvec;
using ::Rcpp::Function;
using ::Rcpp::List;
using ::std::string;
using ::std::string_view;
using ::std::unique_ptr;

using ::fastcpd::test::FastcpdTest;

constexpr char kRProgress[] = "[:bar] :current/:total in :elapsed";

namespace fastcpd::classes {

class Fastcpd {
Expand Down Expand Up @@ -58,16 +62,16 @@ class Fastcpd {
double beta;

// `cost` is the cost function to be used.
std::unique_ptr<Function> cost;
unique_ptr<Function> cost;

// Adjustment to the cost function.
const string cost_adjustment;

// `cost_gradient` is the gradient of the cost function to be used.
std::unique_ptr<Function> cost_gradient;
unique_ptr<Function> cost_gradient;

// `cost_hessian` is the Hessian of the cost function to be used.
std::unique_ptr<Function> cost_hessian;
unique_ptr<Function> cost_hessian;

const bool cp_only;

Expand Down Expand Up @@ -137,7 +141,7 @@ class Fastcpd {
// `hessian` stores the Hessian matrix up to the current data point.
cube hessian;

std::unique_ptr<Function> k;
unique_ptr<Function> k;

colvec line_search;

Expand All @@ -163,7 +167,7 @@ class Fastcpd {
const bool r_progress;

Rcpp::Clock rClock;
std::unique_ptr<RProgress::RProgress> rProgress;
unique_ptr<RProgress::RProgress> rProgress;

// `segment_count` is the number of segments for initial guess.
const int segment_count;
Expand Down

0 comments on commit 7cdb2f7

Please sign in to comment.