Title: | Fast Implementation of the Iterative Proportional Fitting Procedure in C |
---|---|
Description: | A fast (C) implementation of the iterative proportional fitting procedure. |
Authors: | Alexander W Blocker |
Maintainer: | Alexander W Blocker <[email protected]> |
License: | Apache License (== 2.0) |
Version: | 1.0.2 |
Built: | 2024-11-09 06:15:13 UTC |
Source: | CRAN |
Use IPFP starting from x0 to produce vector x s.t. Ax = y within tolerance. Need to ensure that x0 > 0.
ipfp( y, A, x0, tol = sqrt(.Machine$double.eps), maxit = 1000, verbose = FALSE, full = FALSE )
ipfp( y, A, x0, tol = sqrt(.Machine$double.eps), maxit = 1000, verbose = FALSE, full = FALSE )
y |
numeric constraint vector (length nrow) |
A |
constraint matrix (nrow x ncol) |
x0 |
numeric initial vector (length ncol) |
tol |
numeric tolerance for IPFP; defaults to
|
maxit |
integer maximum number of iterations for IPFP; defaults to 1e3 |
verbose |
logical parameter to select verbose output from C function |
full |
logical parameter to select full return (with diagnostic info) |
if not full, a vector of length ncol containing solution obtained by IPFP. If full, a list containing solution (as x), the number of iterations (as iter), and the L2 norm of Ax - y (as errNorm)
A <- matrix(c(1,0,0, 1,0,0, 0,1,0, 0,1,0, 0,0,1), nrow=3) x <- rgamma(ncol(A), 10, 1/100) y <- A %*% x x0 <- x * rgamma(length(x), 10, 10) ans <- ipfp(y, A, x0, full=TRUE) print(ans) print(x)
A <- matrix(c(1,0,0, 1,0,0, 0,1,0, 0,1,0, 0,0,1), nrow=3) x <- rgamma(ncol(A), 10, 1/100) y <- A %*% x x0 <- x * rgamma(length(x), 10, 10) ans <- ipfp(y, A, x0, full=TRUE) print(ans) print(x)