# R/RcppExports.R In bcs: Bayesian Compressive Sensing Using Laplace Priors

#### Documented in FastLaplace

```# This file was generated by Rcpp::compileAttributes
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' @useDynLib bcs
#' @importFrom Rcpp sourceCpp
NULL

intersect <- function(first, second) {
.Call('bcs_intersect', PACKAGE = 'bcs', first, second)
}

setdiff <- function(first, second) {
.Call('bcs_setdiff', PACKAGE = 'bcs', first, second)
}

#'   Implements the Fast Laplace Algorithm
#'
#'   Implements the fast Laplace algorithm in Rcpp. For a more user friendly
#'   implementation of this function that makes things more convenient
#'
#'   This code implements the fast Laplace algorithm from [1], which is based
#'   on [2]. The fast Laplace algorithm is a method
#'   used to solve the compressive sensing problem, or in general, a highly
#'   underdetermined system of equations. It does this by taking the
#'   system of equations
#'   \deqn{y = \Phi w + n}
#'   and converting it into a minimization problem
#'   where we minimize the error with a constraint on \eqn{w}
#'   (the vector we are solving for) that enforces
#'   sparsity. The fast Laplace method uses a Bayesian framework, and in
#'   particular, uses a Laplace prior to enforce sparsity on \eqn{w}.
#'
#' @param PHI typically equals the product of a measurment matrix and basis
#' representation matrix, such as the wavelet basis.
#' The solution vector \eqn{w} is assumed to be sparse in the chosen basis.
#' @param y CS measurements, samples from the signal or function.
#' @param sigma2 initial noise variance.
#' @param eta threshold in determining convergence of marginal likelihood.
#' @param roundit whether or not to round the marginal likelihood, in order to
#'       avoid machine precision error when comparing across platforms.
#'       0 is False, 1 is True.
#' @param verbose print which basis are added, re-estimated, or deleted.
#' 0 is False, 1 is True.
#' @return A list containing the following elements:
#' \tabular{lll}{
#'   \code{weights} \tab \tab sparse weights, the non-zero values of the sparse
#'   vector \eqn{w}.\cr
#'   \code{used} \tab \tab the positions of the sparse weights or non-zero
#'   values.\cr
#'   \code{sigma2} \tab \tab re-estimated noise variance.\cr
#'   \code{errbars} \tab \tab one standard deviation around the sparse weights.\cr
#'   \code{alpha} \tab \tab sparse hyperparameters (1/gamma).
#' }
#' @references [1] S. D. Babacan, R. Molina and A. K. Katsaggelos, "Bayesian
#' Compressive Sensing Using Laplace Priors," in IEEE Transactions on Image
#' Processing, vol. 19, no. 1, pp. 53-63, Jan. 2010.
#' @references [2] S. Ji, Y. Xue, L. Carin, "Bayesian Compressive Sensing,"
#' IEEE Trans. Signal Processing, vol. 56, no. 6, June 2008.
#' @references [3] M. Tipping and A. Faul, "Fast marginal likelihood maximisation
#' for sparse Bayesian models," in Proc. 9th Int. Workshop Artificial Intelligence
#' and Statistics, C. M. Bishop and B. J. Frey, Eds., 2003.
#' @export
FastLaplace <- function(PHI, y, sigma2, eta, roundit = 0L, verbose = 0L) {
.Call('bcs_FastLaplace', PACKAGE = 'bcs', PHI, y, sigma2, eta, roundit, verbose)
}
```

## Try the bcs package in your browser

Any scripts or data that you put into this service are public.

bcs documentation built on May 29, 2017, 11:58 a.m.