Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nloptr c #169

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f625eef
Use Rinternals and not Rdefines and create shortcut definition for AS…
aadler Jul 1, 2024
27eedbd
Can be included via the header file.
aadler Jul 2, 2024
499ea48
Code formatting
aadler Jul 2, 2024
867b916
Reduce the number of operations in the inner loop by calculating the …
aadler Jul 2, 2024
e4cedd3
More code formatting
aadler Jul 2, 2024
5cd531f
Spelling
aadler Jul 2, 2024
b8168d2
Instead of repeatedly calling the REAL macro inside a loop, it is mor…
aadler Jul 2, 2024
38b2f34
More "R-centric" to use these accessors for single-value reals or int…
aadler Jul 2, 2024
ace5a9e
More code formatting.
aadler Jul 2, 2024
c56c592
Convert the algorithm lookup from a nested if-else chain to a lookup …
aadler Jul 2, 2024
dd38350
Minor cleanup of test file for nloptr.c
aadler Jul 2, 2024
0083ef1
This case cannot be tested since the nlopt_force_stop() function is n…
aadler Jul 2, 2024
b74463e
No longer relevant per WRE since all R is 64 bit.
aadler Jul 2, 2024
0416b66
NeedsCompilation is obvious. UseLTO is reasonable.
aadler Jul 2, 2024
5489061
Update NEWS.md
aadler Jul 2, 2024
e3f74dd
Update comments.
aadler Jul 2, 2024
7ec4772
Where possible, declare and assign on the same line.
aadler Jul 2, 2024
d3fa35e
Declare all counters inside their respective for loops and use size_t…
aadler Jul 2, 2024
6307736
All should be > 0.
aadler Jul 2, 2024
b764e60
Makes more sense to use unsigned size_t here. Adjust Rprintf accordin…
aadler Jul 2, 2024
8e046be
Combine declaration and initialization for the rest of the SEXPs.
aadler Jul 2, 2024
0a67e26
BUG FIX: Using "AS_INTEGER" coerces the value to int and nlopt_srand(…
aadler Jul 2, 2024
acc843c
Spelling/grammar
aadler Jul 8, 2024
5a492f1
Update changelog
aadler Jul 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ Description:
License: LGPL (>= 3)
SystemRequirements: cmake (>= 3.2.0) which is used only on Linux or macOS
systems when no system build of nlopt (>= 2.7.0) can be found.
Biarch: true
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Suggests: knitr, rmarkdown, covr, tinytest
VignetteBuilder: knitr
URL: https://github.com/astamm/nloptr, https://astamm.github.io/nloptr/
BugReports: https://github.com/astamm/nloptr/issues
NeedsCompilation: yes
UseLTO: yes
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
This is a patch (pre) release. It includes

* Correcting some of the unit tests in `test-global-wrapper`.
* Update the code in `nloptr.c` for compatibility with the `R` API, efficiency,
and formatting.
* Bugfix: `ranseed` expects an unsigned long but was passed as an integer, thus
reducing the range of random seeds. It is now passed as a double and converted
to a long.

# nloptr 2.1.1

Expand Down
6 changes: 3 additions & 3 deletions inst/tinytest/test-nloptr.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# https://nlopt.readthedocs.io/en/latest/NLopt_Reference/#stopping-criteria

library(nloptr)
options(digits=7)
options(digits = 7)

tol <- sqrt(.Machine$double.eps)

Expand Down Expand Up @@ -188,8 +188,8 @@ expect_identical(testRun$message, minus2mess)

## case NLOPT_FAILURE
fnl <- function(x) {
list("objective" = (x[1] - 1) ^ 2 + (x[2] - 1) ^ 2,
"gradient" = c(4 * (x[1] - 1), 3 - (x[2] - 1)))
list(objective = (x[1] - 1) ^ 2 + (x[2] - 1) ^ 2,
gradient = c(4 * (x[1] - 1), 3 - (x[2] - 1)))
}
x0 <- c(3, 3)
testRun <- nloptr(x0, fnl,
Expand Down
11 changes: 9 additions & 2 deletions src/init_nloptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@
*
* This file registers C functions to be used from R.
*
* 03/10/2017: Included registering of C functions to be used by external R packages.
* 01/10/2017: Initial version.
* CHANGELOG:
* 2017-10-01: Initial version.
* 2017-10-03: Included registering of C functions to be used by external R
* packages.
* 2023-02-07: Use "modern" method for invoking native routine registration
* (Avraham Adler).
* 2023-08-24: Delete files solely needed for testthat (Avraham Adler).
* 2024-07-02: Updated old include which is no longer maintained and other
* minor code tweaks and efficiency enhancements (Avraham Adler).
*/

#include <R.h>
Expand Down
Loading
Loading