# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' Calculate Day-3 Method
#'
#' @description Takes a numeric vector of daily snow changes, as well as
#' a logical vector of possible indices to include in the Day-3 method,
#' and returns the vector of the Day-3 method.
#'
#' @param dx A numeric vector of daily snow changes.
#'
#' @param d3_cands A logical vector of indices associated with dx.
#' d3_cands(i) is TRUE if and only if dx(i) and dx(i + 2) are positive.
#'
#' @return A numeric vector of the Day-3 method. See details.
#'
#' @section Details:
#' An observation of the Day-3 method consists of the sum of three
#' consecutive elements of dx, the first and last of which must be
#' positive, and the sum of the three observations must be positive.
#' The d3_cands logical vector is TRUE when the first and third
#' observations are positive. At the indices where d3_cands is TRUE,
#' this function sums the dx(i), dx(i + 1), and dx(i + 2). If that sum
#' is positive, it is added as a value of the Day-3 method.
#' The function would then falsify d3_cands(i + 1) and d3_cands(i + 2)
#' as an index of dx can be used in a sum only once.
#'
#' @examples
#' dx <- c(1, -3, 3, 1, 2, 3, 1, -7, 2, -1, -2, 3)
#' d3_cands <- c(TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE,
#' FALSE)
#' rdailychange:::calc_d3_method(d3_cands, dx)
#'
calc_d3_method <- function(d3_cands, dx) {
.Call(`_rdailychange_calc_d3_method`, d3_cands, dx)
}
#' Calculate Day-4 Method
#'
#' @description Takes a numeric vector of daily snow changes, as well as
#' a logical vector of possible indices to include in the Day-4 method,
#' and returns the vector of the Day-4 method.
#'
#' @param dx A numeric vector of daily snow changes.
#'
#' @param d4_cands A logical vector of indices associated with dx.
#' d4_cands(i) is TRUE if and only if dx(i) and dx(i + 3) are positive,
#' and at most one of dx(i + 1) or dx(i + 2) are negative.
#'
#' @return A numeric vector of the Day-4 method. See details.
#'
#' @section Details:
#' An observation of the Day-4 method consists of the sum of four
#' consecutive elements of dx, the first and last of which must be
#' positive, only one negative observation in the middle,
#' and the sum of the four observations must be positive.
#' The d4_cands logical vector is TRUE when the first and fourth
#' observations are positive, and at most one of the second and third
#' observation is negative. At the indices where d4_cands is TRUE,
#' this function sums the dx(i), dx(i + 1), dx(i + 2), and dx(i + 3).
#' If that sum is positive, it is added as a value of the Day-4 method.
#' The function would then falsify d4_cands(i + 1), d4_cands(i + 2),
#' and d4_cands(i + 3) as an index of dx can be used in a sum only once.
#'
#' @examples
#' dx <- c(1, -3, 3, 1, 2, 3, 1, -7, 2, -1, -2, 3)
#' d4_cands <- c(TRUE, FALSE, TRUE, TRUE, FALSE,
#' TRUE, FALSE, FALSE, TRUE)
#' rdailychange:::calc_d4_method(d4_cands, dx)
#'
calc_d4_method <- function(d4_cands, dx) {
.Call(`_rdailychange_calc_d4_method`, d4_cands, dx)
}
#' Calculate Day-5 Method
#'
#' @description Takes a numeric vector of daily snow changes, as well as
#' a logical vector of possible indices to include in the Day-5 method,
#' and returns the vector of the Day-5 method.
#'
#' @param dx A numeric vector of daily snow changes.
#'
#' @param d5_cands A logical vector of indices associated with dx.
#' d4_cands(i) is TRUE if and only if dx(i) and dx(i + 4) are positive,
#' and at most one of dx(i + 1), dx(i + 2), or dx(i + 3) are negative.
#'
#' @return A numeric vector of the Day-5 method. See details.
#'
#' @section Details:
#' An observation of the Day-5 method consists of the sum of five
#' consecutive elements of dx, the first and last of which must be
#' positive, only one negative observation in the middle,
#' and the sum of the five observations must be positive.
#' The d5_cands logical vector is TRUE when the first and fifth
#' observations are positive, and at most one of the second, third,
#' and fourth observation is negative. At the indices where d5_cands is TRUE,
#' this function sums the dx(i), dx(i + 1), dx(i + 2), dx(i + 3), dx(i + 4).
#' If that sum is positive, it is added as a value of the Day-5 method.
#' The function would then falsify d5_cands(i + 1), d5_cands(i + 2),
#' d5_cands(i + 3), and d5_cands(i + 4) as an index of dx can
#' be used in a sum only once.
#'
#' @examples
#' dx <- c(1, -3, 3, 1, 2, 3, 1, -7, 2, -1, -2, 3)
#' d5_cands <- c(TRUE, FALSE, TRUE, FALSE, TRUE,
#' FALSE, FALSE, FALSE)
#' rdailychange:::calc_d5_method(d5_cands, dx)
#'
calc_d5_method <- function(d5_cands, dx) {
.Call(`_rdailychange_calc_d5_method`, d5_cands, dx)
}
#' Get Indices For Day-2 Method
#'
#' @description Takes a logical vector of possible indices to sum for the
#' Day-2 method, and cleans it to the exact indices to sum for
#' the Day-2 method. See Details below for more information.
#'
#' @param d2_cands A logical vector of indices associated with the vector of
#' daily snow change observations, dx. d2_cands(i) is TRUE if and only
#' if dx(i) and dx(i + 1) are positive.
#'
#' @return A logical vector, where TRUE indicates that that index
#' is to be summed with the following index for the Day-2 method vector dx.
#' As described, an index cannot be used twice. As such, there should
#' be no two consecutive TRUE values.
#'
#' @section Details:
#' Given a vector of snow changes, dx, the Day-2 method needs to sum
#' consecutive positive values. But once an index is part of a sum
#' it cannot be used again. As such d2_cands is the logical
#' vector where an index is TRUE if dx(i) and dx(i + 1) are both
#' positive. Because an index cannot be used in multiple sums
#' this function falsifies indices that follow TRUEs in the d2_cands
#' logical vector.
#'
#' @examples
#' d2_cands <- c(TRUE, FALSE, TRUE, TRUE, TRUE, TRUE,
#' TRUE, FALSE, TRUE, TRUE, FALSE)
#' rdailychange:::purge_d2_cands(d2_cands)
purge_d2_cands <- function(d2_cands) {
.Call(`_rdailychange_purge_d2_cands`, d2_cands)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.