Binary files /tmp/tmpMmJdNn/UURMtbcpK_/r-cran-pracma-2.2.2/data/brown72.rda and /tmp/tmpMmJdNn/JKdLWf6rqP/r-cran-pracma-2.2.5/data/brown72.rda differ Binary files /tmp/tmpMmJdNn/UURMtbcpK_/r-cran-pracma-2.2.2/data/nile.rda and /tmp/tmpMmJdNn/JKdLWf6rqP/r-cran-pracma-2.2.5/data/nile.rda differ Binary files /tmp/tmpMmJdNn/UURMtbcpK_/r-cran-pracma-2.2.2/data/titanium.rda and /tmp/tmpMmJdNn/JKdLWf6rqP/r-cran-pracma-2.2.5/data/titanium.rda differ diff -Nru r-cran-pracma-2.2.2/debian/changelog r-cran-pracma-2.2.5/debian/changelog --- r-cran-pracma-2.2.2/debian/changelog 2018-12-06 09:53:13.000000000 +0000 +++ r-cran-pracma-2.2.5/debian/changelog 2019-07-12 07:46:02.000000000 +0000 @@ -1,3 +1,12 @@ +r-cran-pracma (2.2.5-1) unstable; urgency=medium + + * New upstream version + * debhelper 12 + * Standards-Version: 4.4.0 + * rename debian/tests/control.autodep8 to debian/tests/control + + -- Andreas Tille Fri, 12 Jul 2019 09:46:02 +0200 + r-cran-pracma (2.2.2-1) unstable; urgency=medium * New upstream version diff -Nru r-cran-pracma-2.2.2/debian/compat r-cran-pracma-2.2.5/debian/compat --- r-cran-pracma-2.2.2/debian/compat 2018-12-06 09:53:13.000000000 +0000 +++ r-cran-pracma-2.2.5/debian/compat 2019-07-12 07:46:02.000000000 +0000 @@ -1 +1 @@ -11 +12 diff -Nru r-cran-pracma-2.2.2/debian/control r-cran-pracma-2.2.5/debian/control --- r-cran-pracma-2.2.2/debian/control 2018-12-06 09:53:13.000000000 +0000 +++ r-cran-pracma-2.2.5/debian/control 2019-07-12 07:46:02.000000000 +0000 @@ -5,10 +5,10 @@ Section: gnu-r Testsuite: autopkgtest-pkg-r Priority: optional -Build-Depends: debhelper (>= 11~), +Build-Depends: debhelper (>= 12~), dh-r, r-base-dev -Standards-Version: 4.2.1 +Standards-Version: 4.4.0 Vcs-Browser: https://salsa.debian.org/r-pkg-team/r-cran-pracma Vcs-Git: https://salsa.debian.org/r-pkg-team/r-cran-pracma.git Homepage: https://cran.r-project.org/package=pracma diff -Nru r-cran-pracma-2.2.2/debian/tests/control r-cran-pracma-2.2.5/debian/tests/control --- r-cran-pracma-2.2.2/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-pracma-2.2.5/debian/tests/control 2019-07-12 07:46:02.000000000 +0000 @@ -0,0 +1,5 @@ +Tests: run-unit-test +Depends: @, +Restrictions: allow-stderr + + diff -Nru r-cran-pracma-2.2.2/debian/tests/control.autodep8 r-cran-pracma-2.2.5/debian/tests/control.autodep8 --- r-cran-pracma-2.2.2/debian/tests/control.autodep8 2018-12-06 09:53:13.000000000 +0000 +++ r-cran-pracma-2.2.5/debian/tests/control.autodep8 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -Tests: run-unit-test -Depends: @, -Restrictions: allow-stderr - - diff -Nru r-cran-pracma-2.2.2/DESCRIPTION r-cran-pracma-2.2.5/DESCRIPTION --- r-cran-pracma-2.2.2/DESCRIPTION 2018-12-02 08:00:03.000000000 +0000 +++ r-cran-pracma-2.2.5/DESCRIPTION 2019-04-09 05:10:07.000000000 +0000 @@ -1,7 +1,7 @@ Package: pracma Type: Package -Version: 2.2.2 -Date: 2018-11-30 +Version: 2.2.5 +Date: 2019-04-08 Title: Practical Numerical Math Functions Authors@R: person("Hans W.", "Borchers", email="hwborchers@googlemail.com", @@ -21,8 +21,8 @@ Maintainer: Hans W. Borchers Repository: CRAN Repository/R-Forge/Project: optimist -Repository/R-Forge/Revision: 464 -Repository/R-Forge/DateTimeStamp: 2018-12-01 21:21:42 -Date/Publication: 2018-12-02 08:00:03 UTC +Repository/R-Forge/Revision: 472 +Repository/R-Forge/DateTimeStamp: 2019-04-08 12:29:03 +Date/Publication: 2019-04-09 05:10:07 UTC NeedsCompilation: no -Packaged: 2018-12-01 21:30:11 UTC; rforge +Packaged: 2019-04-08 12:50:10 UTC; rforge diff -Nru r-cran-pracma-2.2.2/man/broyden.Rd r-cran-pracma-2.2.5/man/broyden.Rd --- r-cran-pracma-2.2.2/man/broyden.Rd 2013-08-19 16:53:06.000000000 +0000 +++ r-cran-pracma-2.2.5/man/broyden.Rd 2019-04-08 12:29:03.000000000 +0000 @@ -19,7 +19,8 @@ } \details{ F as a function must return a vector of length \code{n}, and accept an - \code{n}-dim. vector or column vector as input. + \code{n}-dim. vector or column vector as input. F must not be univariate, + that is \code{n} must be greater than 1. Broyden's method computes the Jacobian and its inverse only at the first iteration, and does a rank-one update thereafter, applying the so-called diff -Nru r-cran-pracma-2.2.2/man/fletcherpowell.Rd r-cran-pracma-2.2.5/man/fletcherpowell.Rd --- r-cran-pracma-2.2.2/man/fletcherpowell.Rd 2018-11-27 15:53:06.000000000 +0000 +++ r-cran-pracma-2.2.5/man/fletcherpowell.Rd 2019-04-08 12:29:03.000000000 +0000 @@ -1,6 +1,5 @@ \name{fletcher_powell} \alias{fletcher_powell} -\alias{cgmin} \title{ Fletcher-Powell Conjugate Gradient Minimization } @@ -16,8 +15,6 @@ \usage{ fletcher_powell(x0, f, g = NULL, maxiter = 1000, tol = .Machine$double.eps^(2/3)) - -cgmin(x0, f, g = NULL, maxiter = 1000, tol = .Machine$double.eps^(2/3)) } \arguments{ \item{x0}{start value.} @@ -36,8 +33,6 @@ The basic idea is to generate a sequence of good approximations to the inverse Hessian matrix, in such a way that the approximations are again positive definite. - - Please note: The \code{cgmin} alias is deprecated since version 2.1.9 ! } \value{ List with following components: diff -Nru r-cran-pracma-2.2.2/man/fminsearch.Rd r-cran-pracma-2.2.5/man/fminsearch.Rd --- r-cran-pracma-2.2.2/man/fminsearch.Rd 2018-11-30 20:38:25.000000000 +0000 +++ r-cran-pracma-2.2.5/man/fminsearch.Rd 2019-04-08 12:29:03.000000000 +0000 @@ -7,7 +7,7 @@ Find minimum of multivariable functions using derivative-free methods. } \usage{ -fminsearch(fn, x0, ..., lower = NULL, upper = NULL, dfree = TRUE, +fminsearch(fn, x0, ..., lower = NULL, upper = NULL, method = c("Nelder-Mead", "Hooke-Jeeves"), minimize = TRUE, maxiter = 1000, tol = 1e-08) } @@ -16,7 +16,6 @@ \item{x0}{point considered near to the optimum.} \item{...}{additional variables to be passed to the function.} \item{lower, upper}{lower and upper bounds constraints.} - \item{dfree}{logical; DEPRECATED, only 'dfree=TRUE' is possible.} \item{method}{"Nelder-Mead" (default) or "Hooke-Jeeves"; can be abbreviated.} \item{minimize}{logical; shall a minimum or a maximum be found.} \item{maxiter}{maximal number of iterations} @@ -25,8 +24,8 @@ \details{ \code{fminsearch} finds the minimum of a nonlinear scalar multivariable function, starting at an initial estimate and returning a value x that is - a local minimizer of the function. With \code{minimize=FALSE} it seaches - for a maximum by default for a (local) minimum. + a local minimizer of the function. With \code{minimize=FALSE} it searches + for a maximum, by default for a (local) minimum. As methods/solvers "Nelder-Mead" and "Hooke-Jeeves" are available. Only Hooke-Jeeves can handle bounds constraints. For nonlinear constraints see diff -Nru r-cran-pracma-2.2.2/man/fsolve.Rd r-cran-pracma-2.2.5/man/fsolve.Rd --- r-cran-pracma-2.2.2/man/fsolve.Rd 2013-08-19 16:53:06.000000000 +0000 +++ r-cran-pracma-2.2.5/man/fsolve.Rd 2019-04-08 12:29:03.000000000 +0000 @@ -21,7 +21,8 @@ \details{ \code{fsolve} tries to solve the components of function \code{f} simultaneously and uses the Gauss-Newton method with numerical gradient - and Jacobian. If \code{m = n}, it uses \code{broyden}. + and Jacobian. If \code{m = n}, it uses \code{broyden}. Not applicable + for univariate root finding. } \value{ List with diff -Nru r-cran-pracma-2.2.2/man/linearproj.Rd r-cran-pracma-2.2.5/man/linearproj.Rd --- r-cran-pracma-2.2.2/man/linearproj.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-pracma-2.2.5/man/linearproj.Rd 2018-12-10 19:16:23.000000000 +0000 @@ -0,0 +1,147 @@ +\name{linearproj, affineproj} +\alias{linearproj} +\alias{affineproj} +\title{ + Linear Projection onto a Subspace +} +\description{ + Computes the projection of points in the columns of B onto the + linear subspace spaned by the columns of A, resp. the projection + of a point onto an affine subspace and its distance. +} +\usage{ + linearproj(A, B) + + affineproj(x0, C, b, unbound = TRUE, maxniter = 100) +} +\arguments{ + \item{A}{Matrix whose columns span a subspace of some R^n.} + \item{B}{Matrix whose columns are to be projected.} + \item{x0}{Point in R^n to be projected onto C x = b.} + \item{C, b}{Matrix and vector, defining an affine subspace as C x = b} + \item{unbound}{Logical; require all x >= 0 if unbound is false.} + \item{maxniter}{Maximum number of iterations (if is unbound is false).} +} +\details{ + \code{linearproj} projects points onto a \emph{linear} subspace in R^n. + The columns of A are assumed be the basis of a linear subspace, esp. + they are required to be linearly independent. The columns of matrix B + define points in R^n that will be projected onto A, and their resp. + coefficients in terms of the basis in A are computed. + + The columns of A need to be linearly independent; if not, generate an + orthonormal basis of this subspace with \code{orth(A)}. If you want to + project points onto a subspace that is defined by \code{A x = 0}, then + generate an orthonormal basis of the nullspace of A with \code{null(A)}. + + Technically, the orthogonal projection can be determined by a finite + 'Fourier expansion' with coefficients calculated as scalar products, + see the examples. + + \code{affineproj} projects (single) points onto an affine subspace + defined by \code{A x = b} and calculates the distance of \code{x0} from + this subspace. The calculation is based on the following formula: + \deqn{p = (I - A' (A A')^{-1}) x0 + A' (A A')^{-1} b} + + Technically, if \code{a} is one solution of \code{C x = b}, then the + projection onto C can be derived from the projection onto S = {C x = 0} + with \code{proj_C(x) = a + proj_S(x - a)}, see the examples. + + In case the user requests the coordinates of the projected point to be + positive, an iteration procedure is started where negative coordinates + are set to zero in each iteration. +} +\value{ + The functions \code{linearproj} returns a list with components P and Q. + The columns of P contain the coefficients -- in the basis of A -- of the + corresponding projected points in B, and the columns of Q are the the + coordinates of these points in the natural coordinate system of R^n. + + \code{affineproj} returns a list with components \code{proj}, \code{dist}, + and \code{niter}. \code{proj} is the projected point, \code{dist} the + distance from the subspace (and \code{niter} the number of iterations + if positivity of the coordinates was requested.). +} +\references{ + G. Strang (2006). Linear Algebra and Its Applications. Fourth Edition, + Cengage Learning, Boston, MA. +} +\note{ + Some timings show that these implementations are to a certain extent + competitive with direct applications of quadprog. +} +\author{ + Hans W. Borchers, partly based on code snippets by Ravi Varadhan. +} +\seealso{ + \code{\link{nullspace}}, \code{\link{orth}} +} +\examples{ +#-- Linear projection -------------------------------------------------- + +# Projection onto the line (1,1,1) in R^3 +A <- matrix(c(1,1,1), 3, 1) +B <- matrix(c(1,0,0, 1,2,3, -1,0,1), 3, 3) +S <- linearproj(A, B) +## S$Q +## [,1] [,2] [,3] +## [1,] 0.3333333 2 0 +## [2,] 0.3333333 2 0 +## [3,] 0.3333333 2 0 + +# Fourier expansion': sum( a_i /), a_i = A[ ,i] +dot(c(1,2,3), A) * A / dot(A, A) # A has only one column + +#-- Affine projection -------------------------------------------------- + +# Projection onto the (hyper-)surface x+y+z = 1 in R^3 +A <- t(A); b <- 1 +x0 <- c(1,2,3) +affineproj(x0, A, b) # (-2/3, 1/3, 4/3) + +# Linear translation: Let S be the linear subspace and A the parallel +# affine subspace of A x = b, a the solution of the linear system, then +# proj_A(x) = a + proj_S(x-a) +a <- qr.solve(A, b) +A0 <- nullspace(A) +xp <- c(a + linearproj(A0, x0 - a)$Q) +## [1] -0.6666667 0.3333333 1.3333333 + +#-- Projection with positivity ----------------------- 24 ms -- 1.3 s -- +s <- affineproj(x0, A, b, unbound = FALSE) +zapsmall(s$proj) # [1] 0 0 1 +## $x : 0.000000e+00 3.833092e-17 1.000000e+00 +## $niter : 35 + +#-- Extended Example ------------------------------------------ 80 ms -- +\dontrun{ +set.seed(65537) +n = 1000; m = 100 # dimension, codimension +x0 <- rep(0, n) # project (0, ..., 0) +A <- matrix(runif(m*n), nrow = m) # 100 x 1000 +b <- rep(1, m) # A x = b, linear system +a <- qr.solve(A, b) # A a = b, LS solution +A0 <- nullspace(A) # 1000 x 900, base of +xp <- a+drop(A0 \%*\% dot(x0-a, A0)) # projection +Norm(xp - x0) # [1] 0.06597077 +} + +#-- Solution with quadprog ------------------------------------ 40 ms -- +# D <- diag(1, n) # quadratic form +# A1 <- rbind(A, diag(1, n)) # A x = b and +# b1 <- c(b, rep(0, n)) # x >= 0 +# n <- nrow(A) +# sol = quadprog::solve.QP(D, x0, t(A1), b1, meq = n) +# xp <- sol$solution + +#-- Solution with CVXR ---------------------------------------- 50 ms -- +# library(CVXR) +# x = Variable(n) # n decision variables +# objective = Minimize(p_norm(x0 - x)) # min! || p0 - x || +# constraint = list(A %*% x == b, x >= 0) # A x = b, x >= 0 +# problem = Problem(objective, constraint) +# solution = solve(problem) # Solver: ECOS +# solution$value # +# xp <- solution$getValue(x) # +} +\keyword{ math } diff -Nru r-cran-pracma-2.2.2/man/qpspecial.Rd r-cran-pracma-2.2.5/man/qpspecial.Rd --- r-cran-pracma-2.2.2/man/qpspecial.Rd 2014-11-15 12:48:50.000000000 +0000 +++ r-cran-pracma-2.2.5/man/qpspecial.Rd 2018-12-10 19:16:23.000000000 +0000 @@ -1,5 +1,6 @@ -\name{qpspecial} +\name{qpspecial, qpsolve} \alias{qpspecial} +\alias{qpsolve} \title{ Special Quadratic Programming Solver } @@ -8,15 +9,21 @@ } \usage{ qpspecial(G, x, maxit = 100) + +qpsolve(d, A, b, meq = 0, tol = 1e-07) } \arguments{ \item{G}{\code{m x n}-matrix.} \item{x}{column vector of length \code{n}, the initial (feasible) iterate; if not present (or requirements on x0 not met), x0 will be found.} \item{maxit}{maximum number of iterates allowed; default 100.} + \item{d}{Linear term of the quadratic form.} + \item{A, b}{Linear equality and inequality constraints.} + \item{meq}{First meq rows are used as equality constraints.} + \item{tol}{Tolerance used for stopping the iteration.} } \details{ - Solves the QP problem + \code{qpspecial} solves the special QP problem: \code{min q(x) = || G*x ||_2^2 = x'*(G'*G)*x}\cr \code{s.t. sum(x) = 1}\cr @@ -24,6 +31,13 @@ The problem corresponds to finding the smallest vector (2-norm) in the convex hull of the columns of \code{G}. + + \code{qpsolve} solves the more general QP problem: + + \code{min q(x) = 0.5 t(x)*x - d x}\cr + \code{s.t. A x >= b} + + with \code{A x = b} for the first \code{meq} rows. } \value{ Returns a list with the following components: @@ -60,20 +74,27 @@ # [2,] 5.221698e-09 # [3,] 8.648168e-01 # [4,] 1.351831e-01 -# # $d # [,1] # [1,] 0.4940377 # [2,] 0.3972964 # [3,] 0.4886660 -# # $q # [1] 0.6407121 -# # $niter # [1] 6 -# # $info # [1] 0 -} +# Example from quadprog::solve.QP +d <- c(0,5,0) +A <- matrix(c(-4,-3,0,2,1,0,0,-2,1),3,3) +b <- c(-8,2,0) +qpsolve(d, A, b) +## $sol +## [1] 0.4761905 1.0476190 2.0952381 +## $val +## [1] -2.380952 +## $niter +## [1] 3 +} diff -Nru r-cran-pracma-2.2.2/man/steep_descent.Rd r-cran-pracma-2.2.5/man/steep_descent.Rd --- r-cran-pracma-2.2.2/man/steep_descent.Rd 2017-06-09 14:45:39.000000000 +0000 +++ r-cran-pracma-2.2.5/man/steep_descent.Rd 2019-04-08 12:29:03.000000000 +0000 @@ -38,7 +38,7 @@ Using Matlab'' by L. V.Fausett. } \seealso{ - \code{\link{cgmin}} + \code{\link{fletcher_powell}} } \examples{ ## Rosenbrock function: The flat valley of the Rosenbruck function makes diff -Nru r-cran-pracma-2.2.2/MD5 r-cran-pracma-2.2.5/MD5 --- r-cran-pracma-2.2.2/MD5 2018-12-02 08:00:03.000000000 +0000 +++ r-cran-pracma-2.2.5/MD5 2019-04-09 05:10:07.000000000 +0000 @@ -1,8 +1,8 @@ 97f6eedc10d90921a363632f2f85721d *COPYING -bc91475be882b33bb2351930fc00b63f *DESCRIPTION +0844197e37c458c8907816dcf60eebb8 *DESCRIPTION b47004d9a8e4f1d874186f4b543a3c8e *NAMESPACE -4024df886a2c13234d8fcad46f626057 *NEWS -64f404ef0727bd0a7a6c131268cae546 *NEWS.md +e32b2221c502a2a26f0c700d0dcace7f *NEWS +c8c74f3f6d76627a62c25ee8fda9fdd8 *NEWS.md 8e2ec5415edc8417dd8da8cb53d8d0b9 *R/abm3.R 556a17b11b7876e19e56a799aa125485 *R/accumarray.R 3a2bb5e25f1e3c1bbd2bfc930776a25d *R/agmean.R @@ -22,7 +22,7 @@ 1aa758af79d57e55006c0b28abc6ef8b *R/bits.R dc8f057f63bf3734aa7fb097f3f6200f *R/blkdiag.R 7ad13a757bd5ca249f0c25df820e1e42 *R/brentdekker.R -2ba69b215030ec4d902e483744a04eeb *R/broyden.R +9e28b61be213e102398571ce05417a03 *R/broyden.R 37546b6cc8a986b3ec69104407bee525 *R/bsxfun.R cf30354a8e529526a39c63faaf48c106 *R/bvp.R e8513dc322aee02d4d9f902747405d22 *R/cart2sph.R @@ -75,18 +75,18 @@ 026fba53794a295f62ce26fcf12d3f45 *R/findintervals.R 70a3e2af2035768c66f2ca75dd9217f2 *R/findpeaks.R c5d7590f1b2a1b683ab39ef041e35369 *R/findzeros.R -3caa3837ab307e9f1feaa26e98b8405d *R/fletcherpowell.R +acd19dc04b1cfe80c83bcef3e5fc03c3 *R/fletcherpowell.R d99ccd15d4f16139ee0dfa612f763064 *R/flipdim.R 30a87c9a3ada95cb756ee2b071285c4b *R/fminbnd.R 8d524888fd19d633ba8dc72f11ba3ae3 *R/fmincon.R -01d4905be1c46242c0855a4568668d3e *R/fminsearch.R +72a8d96727ab59c5e60d7c1e6b2fb87b *R/fminsearch.R 8c5d5f24e71b107fe6b9b6565b1b4e83 *R/fminunc.R 508b6a97c85342713d5b2a4b1a0ce256 *R/fnorm.R 1ecf8f2687247b9eb35da04a1c0f4d36 *R/fornberg.R f84873285a20a26b925f259c9de39918 *R/fprintf.R 74f5c84804dbe855ed1819a2b9e312c0 *R/fractalcurve.R 79a43056700701e86763f4ff1425b28e *R/fresnel.R -4b056168d0f27d4a54c5123861e77e9d *R/fsolve.R +a00c5c7193623f46ad0767efe6678ac2 *R/fsolve.R 9a58c12689e84e252ea989f816458b01 *R/fzero.R 6f52d17952b26829d2356681ffc09ad0 *R/gamma.R 9227722ce0b209ff3a377119f2d31b03 *R/gammainc.R @@ -129,6 +129,7 @@ d63ae3213447515b0f780c27ec95c035 *R/lambertW.R 40e850bebe7609cb66ac9a21036c2d3e *R/lebesgue.R 99b4c72a237265bb089138d34beb2b16 *R/legendre.R +43e229c055d04f36d71fab6babb184b3 *R/linearproj.R bdfd4166c6e97a94ee8ab3f924220414 *R/linprog.R f5ba573c81263a3fa84cb1027a5a40cb *R/linspace.R 226d83f126fe8a93823cbe245deae998 *R/lsqlin.R @@ -192,7 +193,7 @@ 2984bf2666ba87d36fa62d2a6ac297c0 *R/primes.R e805a0b620e99a42ef609668e987a7d3 *R/procrustes.R 549db7cfa6b1ed1bba389b6b2984a7ca *R/psi.R -552415148ed28839753a30fbe0d1e694 *R/qpspecial.R +c5312603e3f5fecddbfbc02d414eb6d5 *R/qpspecial.R bc41a8bd21c03cb26cbd5cc4e06d9b33 *R/qr.R 0b1ca126c97c3d5305958cfd4de1a60f *R/quad.R f536d23fe8a50dfee816923a819b286c *R/quad2d.R @@ -257,9 +258,9 @@ e09f92a7ba7e72fbfbc3e2dec887b3fc *R/zeta.R f9ccb58211bc1dfbd6910db8dc4d3250 *R/zzz.R a36ce637d7cfef4bf5da6053d8c8a1d7 *README.md -dccba2625aa0d8b8d9793996a8679bf4 *data/brown72.rda -5823b3c2cd1923da6b8661c2fe914aa0 *data/nile.rda -492fecb69f683fdcd4622e57f21818c5 *data/titanium.rda +1e8a472a7de1b94cab54cec91cac8881 *data/brown72.rda +9c6f978c745b1986461eb24b1a281f67 *data/nile.rda +da55ed9e7115ec588ebea670465ff402 *data/titanium.rda b0665e750dc8a153600fa13f2863447a *demo/00Index dadc96a0ba340629e215cdd44344dcb3 *demo/pracma.R ca30ca6722fad23dde2a739ec7b57e4f *man/abm3.Rd @@ -284,7 +285,7 @@ 20febf44ac4c2073541ab1b2ec3bc935 *man/blkdiag.Rd 3e146bd2ecf253b6e7c1ecaa7f4a89ee *man/brentdekker.Rd 28ca91b0a7740aaaa478ea7bf44966a7 *man/brown72.Rd -fa1d9614b2eaa79dc5421b47148e14e1 *man/broyden.Rd +25f37fb6eb50a7b7d517678bcc3e3d48 *man/broyden.Rd d411270e7b17fd6b9bde99400a2b0951 *man/bsxfun.Rd 3d482458ee0cc98fa4cc7732d2109f3d *man/bvp.Rd 03291f138fd823189b63fe5f7786c161 *man/cart2sph.Rd @@ -344,18 +345,18 @@ 787810a289ca07366d97554722bf1023 *man/findmins.Rd 6ba8a9627b11bf0876f7b4ac8874b2d9 *man/findpeaks.Rd 04e5c86a442ec65ef3604ffd030395e7 *man/findzeros.Rd -afdfd881bcbe2759a53d1be621f5c038 *man/fletcherpowell.Rd +b8085ff1f8ebea074ed6de9961c55ac6 *man/fletcherpowell.Rd b6ed9b3d935eb2410b319077e579b8cf *man/flipdim.Rd 304294f36ab7bf25a6b0007b3e24e510 *man/fminbnd.Rd d7bc9166e38ad0c4b47020d7b7e22fcc *man/fmincon.Rd -24c83f3df7838c577365f821f8d4b498 *man/fminsearch.Rd +09fbd882ddd7ed259bb1b455f29cacbc *man/fminsearch.Rd 1e2637ddc29d3b8ccbfc1c54fe84139d *man/fminunc.Rd 6a7c4a699841ecb4e74c63210dc54feb *man/fnorm.Rd 431b5105e9ccb1c07d506d0f9a4a3f8b *man/fornberg.Rd 4ca99f89824f99eae3055d12468289da *man/fprintf.Rd befb665b74155e19b65f5eb7dfff6209 *man/fractalcurve.Rd 5e427cde7ab20bd82defcaa3e0ce9f8d *man/fresnel.Rd -baf150526d46ca07651bb6b4f9233521 *man/fsolve.Rd +06e549833543f14e24d4f74aa3b792cb *man/fsolve.Rd a762fb3beaec8849815d39a1b356a616 *man/fzero.Rd 63e21c455522cad2f0499d29aece0066 *man/fzsolve.Rd b768e31ec73a3f718b52e29295f171ef *man/gammainc.Rd @@ -413,6 +414,7 @@ a2b047371a693ea0893f8a08e9d33f14 *man/lebesgue.Rd e0e94623450a96018b917a295bea02ed *man/legendre.Rd 3a8e5dfc121640b77b5dbcca5f596a02 *man/line_integral.Rd +2649e1c2d3c54e219bb183efa98a44c4 *man/linearproj.Rd 6dc0d582825104a3b1f7e7097c47d16f *man/linprog.Rd 4d031279caac8963f8903a7363953502 *man/linspace.Rd 0f905f01ddf2cd36654c5efee0436399 *man/logspace.Rd @@ -484,7 +486,7 @@ a9be341b14772cff514afed39fb9553a *man/primes.Rd 9cc5fe95186aa22e6261858ef06d7007 *man/procrustes.Rd e0421c3ad0f8d836e74a3329ddf6d85d *man/psi.Rd -bab2db718ead94d4cb3f8230dc970b28 *man/qpspecial.Rd +e677bd6312a5473473ef447ebdd37b52 *man/qpspecial.Rd 16a63023d4110036c7af816be884357b *man/qrSolve.Rd b70a8fc880037255fed3ef8b57ffedd2 *man/quad.Rd b4df439895084ee9c32f4bfee1c07fcd *man/quad2d.Rd @@ -540,7 +542,7 @@ 3a6f02136d4f12d82864740a78348d35 *man/squareform.Rd 51acab37df156822fef6a5d8f09e494d *man/std.Rd 29c30bc0100a966afc683cbdee85aa2b *man/std_err.Rd -40f661ca0f0085e0396154854a415f5c *man/steep_descent.Rd +bb690a941a730c77d3ba34a975d5ff6d *man/steep_descent.Rd 4863d20a9f2f5b87fc99ff145d71869e *man/str2num.Rd 3f9c488f420b7236131466008ec152d0 *man/strcat.Rd 2637efd0d40950038596265e56ac48fb *man/strcmp.Rd diff -Nru r-cran-pracma-2.2.2/NEWS r-cran-pracma-2.2.5/NEWS --- r-cran-pracma-2.2.2/NEWS 2018-12-01 21:21:42.000000000 +0000 +++ r-cran-pracma-2.2.5/NEWS 2019-04-08 12:29:03.000000000 +0000 @@ -3,6 +3,25 @@ ------------------------------------------------------------------------------ +CHANGES IN VERSION 2.2.5 (2019-04-08) + + o fsolve() and broyden() are no longer applicable to univariate + functions (Morrison-Sherman formula not working in this case). + o Alias cgmin() and option 'dfree=F' in fminsearch() are removed, + both have been deprecated since half a year. + +CHANGES IN VERSION 2.2.4 (2018-12-12) + + o qpsolve() minimizes quadratic forms such as 0.5*t(x)*x - d*x + with linear quality and inequality constraints. + o fmincon() now has an 'augmented Lagrangian' option with a + 'variable metric' approach as inner solver. + +CHANGES IN VERSION 2.2.3 (2018-12-10) + + o linearproj() linear projection onto a linear subspace, and + affineproj() linear projection onto an affine subspace of R^n. + CHANGES IN VERSION 2.2.2 (2018-11-30) o Corrected "length > 1 in coercion to logical" in expm(). diff -Nru r-cran-pracma-2.2.2/NEWS.md r-cran-pracma-2.2.5/NEWS.md --- r-cran-pracma-2.2.2/NEWS.md 2018-12-01 21:21:42.000000000 +0000 +++ r-cran-pracma-2.2.5/NEWS.md 2019-04-08 12:29:03.000000000 +0000 @@ -1,5 +1,24 @@ # pracma NEWS +## pracma 2.2.5 (2019-04-08) + +* fsolve() and broyden() are no longer applicable to univariate + functions (Morrison-Sherman formula not working in this case). +* Alias cgmin() and option 'dfree=F' in fminsearch() are removed, + both have been deprecated since half a year. + +## pracma 2.2.4 (2018-12-12) + +* qpsolve() minimizes quadratic forms such as 0.5*t(x)*x-d*x + with linear quality and inequality constraints. +* fmincon() now has an 'augmented Lagrangian' option with a + 'variable metric' approach as inner solver. + +## pracma 2.2.3 (2018-12-10) + +* linearproj() linear projection onto a linear subspace, and + affineproj() linear projection onto an affine subspace of R^n. + ## pracma 2.2.2 (2018-11-30) * Corrected "length > 1 in coercion to logical" in expm(). diff -Nru r-cran-pracma-2.2.2/R/broyden.R r-cran-pracma-2.2.5/R/broyden.R --- r-cran-pracma-2.2.2/R/broyden.R 2013-08-19 16:53:06.000000000 +0000 +++ r-cran-pracma-2.2.5/R/broyden.R 2019-04-08 12:29:03.000000000 +0000 @@ -7,6 +7,8 @@ y0 <- F(x0) if (length(x0) != length(y0)) stop("Function 'F' must be 'square', i.e. from R^n to R^n .") + if (length(x0) == 1) + stop("Function 'F' must not be a univariate function.") # Compute once the Jacobian and its inverse if (is.null(J0)) { diff -Nru r-cran-pracma-2.2.2/R/fletcherpowell.R r-cran-pracma-2.2.5/R/fletcherpowell.R --- r-cran-pracma-2.2.2/R/fletcherpowell.R 2018-11-26 16:45:27.000000000 +0000 +++ r-cran-pracma-2.2.5/R/fletcherpowell.R 2019-04-08 12:29:03.000000000 +0000 @@ -77,8 +77,8 @@ # alias -- deprecated -cgmin <- function(x0, f, g = NULL, - maxiter = 1000, tol = .Machine$double.eps^(2/3)) { - warning("Function 'cgmin' deprecated: use 'fletcher_powell' instead.") - fletcher_powell(x0, f, g, maxiter = maxiter, tol = tol) -} +# cgmin <- function(x0, f, g = NULL, +# maxiter = 1000, tol = .Machine$double.eps^(2/3)) { +# warning("Function 'cgmin' deprecated: use 'fletcher_powell' instead.") +# fletcher_powell(x0, f, g, maxiter = maxiter, tol = tol) +# } diff -Nru r-cran-pracma-2.2.2/R/fminsearch.R r-cran-pracma-2.2.5/R/fminsearch.R --- r-cran-pracma-2.2.2/R/fminsearch.R 2018-11-30 20:38:25.000000000 +0000 +++ r-cran-pracma-2.2.5/R/fminsearch.R 2019-04-08 12:29:03.000000000 +0000 @@ -3,7 +3,7 @@ ## -fminsearch <- function(fn, x0, ..., lower = NULL, upper = NULL, dfree = TRUE, +fminsearch <- function(fn, x0, ..., lower = NULL, upper = NULL, method = c("Nelder-Mead", "Hooke-Jeeves"), minimize = TRUE, maxiter = 1000, tol = 1e-08) { @@ -15,11 +15,6 @@ } method <- match.arg(method) - if (!dfree) { - method <- "Nelder-Mead" - message ("*** 'method' is set to 'Nelder-Mead. ***") - warning("'dfree = FALSE' is DEPRECATED: Use fminunc or fmincon!") - } scl <- if(minimize) 1 else -1 fun <- match.fun(fn) diff -Nru r-cran-pracma-2.2.2/R/fsolve.R r-cran-pracma-2.2.5/R/fsolve.R --- r-cran-pracma-2.2.2/R/fsolve.R 2013-08-19 16:53:06.000000000 +0000 +++ r-cran-pracma-2.2.5/R/fsolve.R 2019-04-08 12:29:03.000000000 +0000 @@ -15,6 +15,8 @@ n <- length(x0) m <- length(f(x0)) + if (n == 1) + stop("Function 'fsolve' not applicable for univariate root finding.") if (!is.null(J)) { Jun <- match.fun(J) diff -Nru r-cran-pracma-2.2.2/R/linearproj.R r-cran-pracma-2.2.5/R/linearproj.R --- r-cran-pracma-2.2.2/R/linearproj.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-pracma-2.2.5/R/linearproj.R 2018-12-10 19:16:23.000000000 +0000 @@ -0,0 +1,50 @@ +## +## l i n e a r p r o j . R Linear and affine projection +## + + +linearproj <- function(A, B) { + # Return the projection of points in the columns of B + # onto the linear subspace spaned by the columns of A. + stopifnot(is.numeric(A), is.numeric(B)) + if (!is.matrix(A)) A <- as.matrix(A) + if (!is.matrix(B)) B <- as.matrix(B) + nA <- nrow(A); mA <- ncol(A) + nB <- nrow(B); mB <- ncol(B) + if (nA != nB) # dimension of R^n + stop("Arguments 'A', 'B' must have the same number of rows.") + if (Rank(A) < mA) + stop("Matrix 'A' does not have maximal rank -- not a basis.") + + P <- qr.solve(t(A) %*% A, t(A) %*% B) + Q <- A %*% P + return(list(P = P, Q = Q)) +} + + +affineproj <- function(x0, C, b, unbound = TRUE, maxniter = 100) { + if (unbound) { + # Return projection of x0 onto the affine subspace + # C x = b and the distance of x0 from this subspace. + mC <- nrow(C); nC <- ncol(C) # n dimension, m codimension + CC <- C %*% t(C) + xp <- (diag(1, nC) - t(C) %*% qr.solve(CC, C)) %*% x0 + + t(C) %*% qr.solve(CC, b) + d <- Norm(xp) + return(list(proj = xp, dist = d, niter = 0)) + } else { + # C fast projection method for enforcing equality and + # positivity constraints: C x = b and x >= 0 + svdC <- svd(C); x <- x0 + svdmat <- svdC$v %*% diag(1/svdC$d, length(svdC$d)) %*% t(svdC$u) + iterate <- TRUE; niter <- 0 + while(iterate & niter <= maxniter) { + niter <- niter + 1 + bCx <- (b - c(C %*% x)) + x <- x + c(svdmat %*% bCx) + if (any(x < 0)) x[x < 0] <- 0 else iterate <- FALSE + } + d <- Norm(x0 - x) + return(list(proj = x, dist = d, niter = niter)) + } +} diff -Nru r-cran-pracma-2.2.2/R/qpspecial.R r-cran-pracma-2.2.5/R/qpspecial.R --- r-cran-pracma-2.2.2/R/qpspecial.R 2014-11-15 12:48:50.000000000 +0000 +++ r-cran-pracma-2.2.5/R/qpspecial.R 2018-12-10 19:16:23.000000000 +0000 @@ -113,3 +113,53 @@ q <- sum(d * d) list(x = x, d = d, q = q, niter = k, info = info) } + + +qpsolve <- function(d, A, b, meq = 0, tol = 1e-07){ + sol <- dvec <- d + bvec <- b + imeq <- seq_len(meq) + + Nmat <- NULL + wvec <- NULL + active <- NULL + niter <- 0 + repeat{ + niter <- niter + 1 + viol <- crossprod(A, sol) - bvec + viol1 <- viol / pmax(1,abs(bvec)) + iim <- viol1[imeq] >= tol + if( any(iim) ){ + iim <- which(iim) + viol[iim] <- -viol[iim] + bvec[iim] <- -bvec[iim] + A[,iim] <- -A[,iim] + } + ii <- which.min(viol1)[1] + if( viol1[ii] > -tol) break + if(ii %in% active) stop("Error in projection") + wvec <- c(wvec, 0) + active <- c(active, ii) + npvec <- A[,ii] + if( !is.null(Nmat) ){ + rvec <- solve(qr(Nmat, LAPACK=TRUE), npvec) + dvec <- npvec - c(Nmat %*% rvec) + }else{ + dvec <- npvec + rvec <- NULL + } + jj <- rvec > 0 + jj[1] <- FALSE + tmp <- wvec[jj]/rvec[jj] + t1 <- suppressWarnings(min(tmp)) + t2 <- -viol[ii]/crossprod(npvec, dvec) + t <- min(c(t1, t2)) + if( !is.finite(t) || t < 0 || t1 <= t2 ) stop("Error in projection") + sol <- sol + t * dvec + wvec <- wvec - t * c(rvec, -1) + Nmat <- cbind(Nmat, npvec) + } + sol <- c(sol) + val <- 0.5 * sum(sol * sol) - sum(d * sol) + return(list(sol = sol, val = val, niter = niter)) +}