diff --git a/.gitignore b/.gitignore
index a0a8a7f..b188e26 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
*.class
-jblas-1.2.5.jar
-jheatchart-0.6.jar
+myvenv
+.ipynb_checkpoints
+workspace.code-workspace
+NAGPythonExamples
diff --git a/BXNL/Readme.md b/BXNL/Readme.md
new file mode 100644
index 0000000..4532989
--- /dev/null
+++ b/BXNL/Readme.md
@@ -0,0 +1,101 @@
+[](https://www.nag.com)
+
+> ## Important Information
+> You can view this page as a [webpage](https://numericalalgorithmsgroup.github.io/NAGJavaExamples/BXNL) or access this as a regular github [repository](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/tree/main/BXNL).
+>
+>
+> See the top directory of this repository for instructions to set up the [NAG Library for Java](https://github.com/numericalalgorithmsgroup/NAGJavaExamples).
+
+# Nonlinear Least-Squares Trust-Region Method (BXNL)
+
+[[`e04ggf`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04ggf.html), [`e04ggc`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/clhtml/e04/e04ggc.html), [`handle_solve_bxnl`](https://www.nag.co.uk/numeric/py/nagdoc_latest/naginterfaces.library.opt.html#naginterfaces.library.opt.handle_solve_bxnl)]
+
+Data fitting and calibrating parameters of complex numerical models is one of the most common
+problems found in numerous industries such as physics, space exploration, simulations, engineering, amongs many others.
+[NAG](https://www.nag.co.uk/) introduces to the [NAG Library at Mark 27.1](https://www.nag.co.uk/content/nag-library) a novel [nonlinear least-square](https://en.wikipedia.org/wiki/Non-linear_least_squares) [trust-region solver](https://en.wikipedia.org/wiki/Trust_region) for unconstrained or bound-constrained fitting problems, [`e04gg`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04ggf.html). It offers a significant variety of algorithms and regularisation techniques.
+
+The solver [`e04gg`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04ggf.html) is aimed at small to medium sized fitting problems (up to 1000s of parameters) bound-constrained nonlinear least-squares problems
+and is also part of the [NAG Optimization Modelling Suite](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04intro.html#optsuite) common handle interface. It offers clarity and consistency of the interface of the solvers within the suite, making it trivial to switch among compatible solvers.
+
+Figure 1 shows an illustrative simple problem of data fitting ([more details](./orbit_ex/Readme.md)). The task is to find the optimal orbit path given a variety of measurements for which the orbit has to approximatly pass-by.
+
+
+
+
+
+
+**Figure 1.** Example of a NLLS orbital data fitting.
+ Given a set of 7 orbital data points the task is to estimate an optimal orbit path that minimizes the error between the path and the fixed data points. For this example assume that expert knowledge provides insight on the reliability of each measument and that for this satellite configuration operational orbit height should around 250 +/-3 units. Center plot shows a simple fit where each measurement (data point) contributes the same amount and provides an optimal orbit height of 238.76 units. The fit is quite poor in the sense that it does not satisfy expert advice. Evidently data point 0 (yellow cross closest to earch surface) unreliablity should be taken into account while doing the fitting. Weights for the residuals should be proportional to the inverse of their variability. For this example suppose we are provided with the accuracy for each of the data measurements, this can be factored using weighted nonlinear least-squares. The rightmost plot shows the weighted optimal solution with orbit height of 254.90 units wich is withing the suggested tolerance. Image credit: [Image of Earth](https://pics.eumetsat.int/viewer/index.html) was taken from [EUMETSAT, Copyright 2020](https://pics.eumetsat.int/viewer/index.html#help).
+
+
+# More Info
+ 1. [BXNL information leaflet](https://www.nag.com/content/faster-data-fitting-solver)
+ 2. [BXNL in the NAG Library for Java](https://www.nag.com/numeric/nl/nagdoc_27.1/flhtml/e04/e04ggf.html)
+ 3. Examples [[Java example](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/blob/main/simple_examples/source/int32/E04GGJE.java), [C example](https://www.nag.co.uk/numeric/nl/nagdoc_latest/clhtml/e04/e04ggc.html#example), [Fortran example](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04ggf.html#example), [Python example](https://www.nag.co.uk/numeric/py/nagdoc_latest/naginterfaces.library.opt.html#naginterfaces.library.examples.opt.handle_disable_ex.main)]
+
+
+
+
Unfolding Nuclear Track Data
+
+ [[More details for this example](./simple_BXNL/Readme.md)]
+
+This example illustrates the usage of [`handle_solve_bxnl`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/clhtml/e04/e04ggc.html) ([`e04gg`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04ggf.html)) to fit PADC
+etched nuclear track data of alpha particles to a convoluted distribution. A target
+sheet is scanned and track diameters are recorded (red wedges,
+left in Figure 2) into a histogram (Blue bars right plot of Figure 2)
+and a mixed Normal and log-Normal model is to be fitted
+to the obtained experimental histogram.
+
+The [example](./simple_BXNL/Readme.md) uses `e04gg` to fit the
+six parameter model φ(t, x = (a,b,Al,μ,σ,Ag)) = Al log-Normal(a, b) + Ag Normal(μ, σ) with 0 ≤ x,
+using as data the histogram heights. The NLLS solution provides the unfolded
+parameters for the two distributions (red and blue curves in right plot in Figure 2).
+Adding these together produces the green curve which is the one used to perform the fitting with.
+
+
+
+
+
+
+**Figure 2.** Left: example of a PADC target with alpha
+particle etched tracks, wedges in red show the track diameter.
+Right: experimental data histogram of track diameters (blue bars),
+aggregated model used in the fitting (green curve) and unfolded models (blue and red curves).
+Optimal parameter values are reported in the legend.
+
+
+# Modern Replacement Alternative
+Solver [`handle_solve_bxnl`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/clhtml/e04/e04ggc.html) ([`e04gg`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04ggf.html)) is a modern and attractive replacement for the unconstrained nonlinear least-squares solver [`lsq_uncon_quasi_deriv_comp`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/clhtml/e04/e04gbc.html) ([`e04gb`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04gbf.html)).
+
+More recent and modern methods have been incorporated into [`e04gg`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04ggf.html) making it much faster than [`e04gb`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04gbf.html). Our benchmarks comparing [`e04gg`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04ggf.html) to [`e04gb`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04gbf.html) using 68 unconstrained nonlinear least-squares CUTEst problems is reported in Figure 3 using performance profiles.
+
+Contrasting the three plots, it can be seen that the new solver is more efficient in time: solves 60%
+of the problems faster (left plot). In general terms it is more robust (solves 25% more problems) and less expensive in terms of user call-backs: 55% of problems
+require less function calls (center plot) and 65% of the problems require less gradient evaluations (right plot).
+
+
+[`e04gg`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04ggf.html)
+should present significant improvement for unconstrained or bound-constrained nonlinear
+least-squares solvers in the NAG Library and current users of [`e04gb`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04gbf.html)
+are highly encourage to try out the new solver.
+
+
+
+
+
+
+
+**Figure 3.** Performance profiles comparing solvers e04gg and e04gb over 68 CUTEst unconstrained nonlinear least-squares problems.
+Performance measure are: time in seconds (left), number of function calls (center) and number of gradient calls
+(right). For the time plot (left), higher line indicates faster solver. For the center and right plots, higher line
+represent less functions and gradients calls.
+
+
+
+# References
+
+ * Gould N I M, Rees T, and Scott J A (2017) _A higher order method for solving nonlinear least-squares problems_. Technical report, RAL-P-1027-010 RAL Library. STFC Rutherford Appleton Laboratory http://www.numerical.rl.ac.uk/people/rees/pdf/RAL-P-2017-010.pdf
+ * Kanzow C, Yamashita N, and Fukushima M (2004) _Levenberg-Marquardt methods with strong local convergence properties for solving nonlinear equations with convex constraints_. Journal of Computational and Applied Mathematics 174 375–397
+ * Nocedal J and Wright S J (2006) _Numerical Optimization_. (2nd Edition) Springer Series in Operations Research, Springer, New York
+ * Adachi S, Iwata S, Nakatsukasa Y, and Takeda A (2015) _Solving the trust region subproblem by a generalized eigenvalue problem_. Technical report, METR 2015-14. Mathematical Engineering, The University of Tokyo https://www.keisu.t.u-tokyo.ac.jp/data/2015/METR15-14.pdf
+ * Conn A R, Gould N I M and Toint Ph L (2000) _Trust Region Methods_. SIAM, Philadephia
diff --git a/BXNL/images/b-ral_sif-e04gg-e04gb-NF.png b/BXNL/images/b-ral_sif-e04gg-e04gb-NF.png
new file mode 100644
index 0000000..4175ee1
Binary files /dev/null and b/BXNL/images/b-ral_sif-e04gg-e04gb-NF.png differ
diff --git a/BXNL/images/b-ral_sif-e04gg-e04gb-NG.png b/BXNL/images/b-ral_sif-e04gg-e04gb-NG.png
new file mode 100644
index 0000000..fe629c6
Binary files /dev/null and b/BXNL/images/b-ral_sif-e04gg-e04gb-NG.png differ
diff --git a/BXNL/images/b-ral_sif-e04gg-e04gb-NT.png b/BXNL/images/b-ral_sif-e04gg-e04gb-NT.png
new file mode 100644
index 0000000..946ce3c
Binary files /dev/null and b/BXNL/images/b-ral_sif-e04gg-e04gb-NT.png differ
diff --git a/BXNL/images/est_orbit.png b/BXNL/images/est_orbit.png
new file mode 100644
index 0000000..b922ba5
Binary files /dev/null and b/BXNL/images/est_orbit.png differ
diff --git a/BXNL/images/estw_orbit.png b/BXNL/images/estw_orbit.png
new file mode 100644
index 0000000..27c01ab
Binary files /dev/null and b/BXNL/images/estw_orbit.png differ
diff --git a/BXNL/images/fig-unfolding.png b/BXNL/images/fig-unfolding.png
new file mode 100644
index 0000000..29deb0e
Binary files /dev/null and b/BXNL/images/fig-unfolding.png differ
diff --git a/BXNL/images/tracks.png b/BXNL/images/tracks.png
new file mode 100644
index 0000000..35bfd74
Binary files /dev/null and b/BXNL/images/tracks.png differ
diff --git a/BXNL/orbit_ex/Readme.md b/BXNL/orbit_ex/Readme.md
new file mode 100644
index 0000000..9c305de
--- /dev/null
+++ b/BXNL/orbit_ex/Readme.md
@@ -0,0 +1,230 @@
+> ## Important Information
+> You can view this page as a [webpage](https://numericalalgorithmsgroup.github.io/NAGJavaExamples/BXNL/orbit_ex) or access this as a regular github [repository](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/tree/main/BXNL/orbit_ex).
+>
+> The source of this example can be found [here](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/blob/main/BXNL/orbit_ex/source/OrbitEx.java) and the output [here](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/blob/main/BXNL/orbit_ex/output.txt).
+>
+> See the top directory of this repository for instructions to set up the [NAG Library for Java](https://github.com/numericalalgorithmsgroup/NAGJavaExamples).
+
+# Orbital Data Fitting
+
+Example of a nonlinear least-square orbital data fitting. Given a set of orbital data points the task is to estimate an optimal orbit path that minimizes the error between the path and the fixed data points.
+
+```java
+ double[] tx = new double[] { 441.23, 484.31, 265.15, 98.25, 180.66, 439.13, 596.54 };
+ double[] ty = new double[] { 333.92, 563.46, 577.40, 379.23, 148.62, 100.28, 285.99 };
+ double[] cc = new double[] { 355.00, 347.00 };
+ double[] tr = new double[tx.length];
+
+ for (i = 0; i < tr.length; i++) {
+ tr[i] = Math.pow(tx[i] - cc[0], 2) + Math.pow(ty[i] - cc[1], 2);
+ }
+```
+
+
+
+
+
+
+
+Image credit: [Image of Earth](https://pics.eumetsat.int/viewer/index.html) was taken from [EUMETSAT, Copyright 2020](https://pics.eumetsat.int/viewer/index.html#help).
+
+
+The previous image shows the orbit measurements to which an optimal orbit, `r`, must be estimated.
+The simple univariate problem to solve is:
+
+
+
+
+
+Here `tr[i]` contains the squared norm for the measurement point `i`, given by the coordinate pair `(tx[i], ty[i])`. Note that the coordinates for the center of the planet are provided by the vector `cc`.
+
+```java
+ // problem data
+ // number of oservations
+ int nres = tx.length;
+ // observations
+ //
+ // number of parameter to fit
+ int nvar = 1;
+```
+
+
+
+```java
+ // Define the least-square function and add first derivatives.
+ /**
+ * Objective function call back passed to the least squares solver. Return the
+ * difference between the current estimated radius squared, r^2=x^2 and the
+ * squared norm of the data point stored in tr[i] for i = 1 to nres:
+ * rx[i] = r^2 - tr[i], i = 1, ..., nres.
+ */
+ public static class LSQFUN extends E04GG.Abstract_E04GG_LSQFUN {
+ public void eval() {
+ for (int i = 0; i < this.NRES; i++) {
+ this.RX[i] = Math.pow(this.X[0], 2) - this.RUSER[i];
+ }
+ }
+ }
+
+ /**
+ * Computes the Jacobian of the least square residuals. Simply return
+ * rdx[i] = 2r, i = 1, ..., nres.
+ */
+ public static class LSQGRD extends E04GG.Abstract_E04GG_LSQGRD {
+ public void eval() {
+ Arrays.fill(this.RDX, 2.0 * this.X[0]);
+ }
+ }
+```
+
+
+
+```java
+ // Initialize the model handle
+ long handle = 0;
+ int ifail = 0;
+
+ E04RA e04ra = new E04RA();
+ e04ra.eval(handle, nvar, ifail);
+
+ handle = e04ra.getHANDLE();
+
+ // Define a dense nonlinear least-squares objective function
+ E04RM e04rm = new E04RM();
+ ifail = 0;
+ e04rm.eval(handle, nres, 0, 0, new int[] {}, new int[] {}, ifail);
+
+ // Restrict parameter space (0 <= x)
+ E04RH e04rh = new E04RH();
+ double[] bl = new double[nvar];
+ double[] bu = new double[nvar];
+ Arrays.fill(bu, 1000.0);
+ ifail = 0;
+ e04rh.eval(handle, nvar, bl, bu, ifail);
+
+ // Set some optional parameters to control the output of the solver
+ E04ZM e04zm = new E04ZM();
+ ifail = 0;
+
+ e04zm.eval(handle, "Print Options = NO", ifail);
+ e04zm.eval(handle, "Print Level = 1", ifail);
+ e04zm.eval(handle, "Print Solution = X", ifail);
+ e04zm.eval(handle, "Bxnl Iteration Limit = 100", ifail);
+
+ // Define initial guess (starting point) Away from zero which is problematic
+ double[] x = new double[nvar];
+ Arrays.fill(x, 1.0);
+```
+
+Call the solver
+
+```java
+ // Call the solver
+ E04GG e04gg = new E04GG();
+ LSQFUN lsqfun = new LSQFUN();
+ LSQGRD lsqgrd = new LSQGRD();
+ LSQHES lsqhes = new LSQHES();
+ LSQHPRD lsqhprd = new LSQHPRD();
+ MONIT monit = new MONIT();
+ double[] rx = new double[nres];
+ double[] rinfo = new double[100];
+ double[] stats = new double[100];
+ int[] iuser = new int[0];
+ double[] ruser = tr;
+ long cpuser = 0;
+ ifail = 0;
+
+ e04gg.eval(handle, lsqfun, lsqgrd, lsqhes, lsqhprd, monit, nvar, x, nres, rx, rinfo, stats, iuser, ruser,
+ cpuser, ifail);
+```
+
+
+
+```
+ E04GG, Nonlinear least squares method for bound-constrained problems
+ Status: converged, an optimal solution was found
+ Value of the objective 1.45373E+09
+ Norm of projected gradient 2.23690E-01
+ Norm of scaled projected gradient 4.14848E-06
+ Norm of step 3.75533E-06
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 0.00000E+00 2.38765E+02 1.00000E+03
+```
+
+
+
+```java
+ // Optimal parameter values
+ double rstar = x[0];
+ System.out.printf("Optimal Orbit Height: %3.2f\n", rstar);
+```
+
+
+
+
+
+
+
+Suppose expert knowledge provides insight on the reliability of each measurement and that for this satellite configuration, operational orbit height should be around 250 +/-6 units. The previous image shows a fit where each measurement (data point) contributes the same amount and provides an optimal orbit height of 238.76 units. The fit is quite poor in the sense that it does not satisfy expert advice. Evidently data point 0 (yellow cross closest to Earth surface) is unreliable. Unreliability should be taken into account while doing the fitting. For this end, weights for each residuals are introduced (weights should be set to be proportional to the inverse of their variability). For this example, suppose we are provided with the accuracy for each of the data measurements.
+
+With this new information, the problem is solved again using weighted nonlinear least-squares.
+
+```java
+ // Add weights for each residual
+ double[] weights = new double[] { 0.10, 0.98, 1.01, 1.00, 0.92, 0.97, 1.02 };
+ double weights_sum = Arrays.stream(weights).sum();
+ for (i = 0; i < weights.length; i++) {
+ weights[i] /= weights_sum;
+ }
+
+ // Define the reliability of the measurements (weights)
+ E04RX e04rx = new E04RX();
+ ifail = 0;
+ e04rx.eval(handle, "RW", 0, weights.length, weights, ifail);
+
+ // Indicate to the solver that weights are to be used
+ ifail = 0;
+ e04zm.eval(handle, "Bxnl Use weights = Yes", ifail);
+
+ // Define initial guess (starting point) Away from zero which is problematic
+ Arrays.fill(x, 1.0);
+
+ // Solve again
+ e04gg.eval(handle, lsqfun, lsqgrd, lsqhes, lsqhprd, monit, nvar, x, nres, rx, rinfo, stats, iuser, ruser,
+ cpuser, ifail);
+
+ // Objective and solution
+ rstar = x[0];
+ System.out.printf("Optimal Orbit Height: %3.2f\n", rstar);
+```
+
+
+
+```
+ E04GG, Nonlinear least squares method for bound-constrained problems
+ Status: converged, an optimal solution was found
+ Value of the objective 1.25035E+06
+ Norm of projected gradient 6.26959E-03
+ Norm of scaled projected gradient 3.96468E-06
+ Norm of step 8.72328E-03
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 0.00000E+00 2.54896E+02 1.00000E+03
+Optimal Orbit Height: 254.90
+```
+
+
+
+
+
+
+
+
+```
+Optimal Orbit Height: 254.90 (should be between 244 and 256)
+```
+
+For this weighted model the orbital solution provided concurs with expert advice.
diff --git a/BXNL/orbit_ex/img/dat_orbit.png b/BXNL/orbit_ex/img/dat_orbit.png
new file mode 100644
index 0000000..ec1b79d
Binary files /dev/null and b/BXNL/orbit_ex/img/dat_orbit.png differ
diff --git a/BXNL/orbit_ex/img/earth.png b/BXNL/orbit_ex/img/earth.png
new file mode 100644
index 0000000..a4e8421
Binary files /dev/null and b/BXNL/orbit_ex/img/earth.png differ
diff --git a/BXNL/orbit_ex/img/est_orbit.png b/BXNL/orbit_ex/img/est_orbit.png
new file mode 100644
index 0000000..b922ba5
Binary files /dev/null and b/BXNL/orbit_ex/img/est_orbit.png differ
diff --git a/BXNL/orbit_ex/img/estw_orbit.png b/BXNL/orbit_ex/img/estw_orbit.png
new file mode 100644
index 0000000..27c01ab
Binary files /dev/null and b/BXNL/orbit_ex/img/estw_orbit.png differ
diff --git a/BXNL/orbit_ex/img/ltx_optprb.png b/BXNL/orbit_ex/img/ltx_optprb.png
new file mode 100644
index 0000000..afc4d24
Binary files /dev/null and b/BXNL/orbit_ex/img/ltx_optprb.png differ
diff --git a/BXNL/orbit_ex/output.txt b/BXNL/orbit_ex/output.txt
new file mode 100644
index 0000000..65558ba
Binary files /dev/null and b/BXNL/orbit_ex/output.txt differ
diff --git a/BXNL/orbit_ex/source/OrbitEx.java b/BXNL/orbit_ex/source/OrbitEx.java
new file mode 100644
index 0000000..b138f2d
--- /dev/null
+++ b/BXNL/orbit_ex/source/OrbitEx.java
@@ -0,0 +1,264 @@
+import com.nag.routines.E04.E04RA;
+import com.nag.routines.E04.E04RM;
+import com.nag.routines.E04.E04RH;
+import com.nag.routines.E04.E04ZM;
+import com.nag.routines.E04.E04RX;
+import com.nag.routines.E04.E04RZ;
+import com.nag.routines.E04.E04GG;
+import com.nag.routines.E04.E04GGU;
+import com.nag.routines.E04.E04GGV;
+import com.nag.routines.E04.E04FFU;
+
+import javax.imageio.ImageIO;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.lang.Math;
+import java.awt.Color;
+import java.util.Arrays;
+
+public class OrbitEx {
+
+ public static void main(String[] args) {
+
+ int i;
+
+ // Orbital Data Fitting
+
+ double[] tx = new double[] { 441.23, 484.31, 265.15, 98.25, 180.66, 439.13, 596.54 };
+ double[] ty = new double[] { 333.92, 563.46, 577.40, 379.23, 148.62, 100.28, 285.99 };
+ double[] cc = new double[] { 355.00, 347.00 };
+ double[] tr = new double[tx.length];
+
+ for (i = 0; i < tr.length; i++) {
+ tr[i] = Math.pow(tx[i] - cc[0], 2) + Math.pow(ty[i] - cc[1], 2);
+ }
+
+ try {
+ // Open a JPEG file, load into a BufferedImage.
+ BufferedImage img = ImageIO.read(new File("../img/earth.png"));
+
+ // Obtain the Graphics2D context associated with the BufferedImage.
+ Graphics2D g = img.createGraphics();
+
+ // Set the Color to Yellow
+ g.setColor(Color.YELLOW);
+
+ // Draw the Points on the image
+ for (i = 0; i < tx.length; i++) {
+ drawPoint(g, (int) tx[i], (int) ty[i]);
+ }
+
+ // Save the image
+ ImageIO.write(img, "PNG", new File("../img/dat_orbit.png"));
+
+ // Clean up -- dispose the graphics context that was created.
+ g.dispose();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // problem data
+ // number of oservations
+ int nres = tx.length;
+ // observations
+ //
+ // number of parameter to fit
+ int nvar = 1;
+
+ // Initialize the model handle
+ long handle = 0;
+ int ifail = 0;
+
+ E04RA e04ra = new E04RA();
+ e04ra.eval(handle, nvar, ifail);
+
+ handle = e04ra.getHANDLE();
+
+ // Define a dense nonlinear least-squares objective function
+ E04RM e04rm = new E04RM();
+ ifail = 0;
+ e04rm.eval(handle, nres, 0, 0, new int[] {}, new int[] {}, ifail);
+
+ // Restrict parameter space (0 <= x)
+ E04RH e04rh = new E04RH();
+ double[] bl = new double[nvar];
+ double[] bu = new double[nvar];
+ Arrays.fill(bu, 1000.0);
+ ifail = 0;
+ e04rh.eval(handle, nvar, bl, bu, ifail);
+
+ // Set some optional parameters to control the output of the solver
+ E04ZM e04zm = new E04ZM();
+ ifail = 0;
+
+ e04zm.eval(handle, "Print Options = NO", ifail);
+ e04zm.eval(handle, "Print Level = 1", ifail);
+ e04zm.eval(handle, "Print Solution = X", ifail);
+ e04zm.eval(handle, "Bxnl Iteration Limit = 100", ifail);
+
+ // Define initial guess (starting point) Away from zero which is problematic
+ double[] x = new double[nvar];
+ Arrays.fill(x, 1.0);
+
+ // Call the solver
+ E04GG e04gg = new E04GG();
+ LSQFUN lsqfun = new LSQFUN();
+ LSQGRD lsqgrd = new LSQGRD();
+ LSQHES lsqhes = new LSQHES();
+ LSQHPRD lsqhprd = new LSQHPRD();
+ MONIT monit = new MONIT();
+ double[] rx = new double[nres];
+ double[] rinfo = new double[100];
+ double[] stats = new double[100];
+ int[] iuser = new int[0];
+ double[] ruser = tr;
+ long cpuser = 0;
+ ifail = 0;
+
+ e04gg.eval(handle, lsqfun, lsqgrd, lsqhes, lsqhprd, monit, nvar, x, nres, rx, rinfo, stats, iuser, ruser,
+ cpuser, ifail);
+
+ // Optimal parameter values
+ double rstar = x[0];
+ System.out.printf("Optimal Orbit Height: %3.2f\n", rstar);
+
+ try {
+ // Open a JPEG file, load into a BufferedImage.
+ BufferedImage img = ImageIO.read(new File("../img/dat_orbit.png"));
+
+ // Obtain the Graphics2D context associated with the BufferedImage.
+ Graphics2D g = img.createGraphics();
+
+ // Set the Color to White
+ g.setColor(Color.WHITE);
+
+ // Draw the Circle around the points
+ g.drawOval((int) (cc[0] - rstar), (int) (cc[1] - rstar), (int) (2 * rstar), (int) (2 * rstar));
+
+ // Save the image
+ ImageIO.write(img, "PNG", new File("../img/est_orbit.png"));
+
+ // Clean up -- dispose the graphics context that was created.
+ g.dispose();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // Add weights for each residual
+ double[] weights = new double[] { 0.10, 0.98, 1.01, 1.00, 0.92, 0.97, 1.02 };
+ double weights_sum = Arrays.stream(weights).sum();
+ for (i = 0; i < weights.length; i++) {
+ weights[i] /= weights_sum;
+ }
+
+ // Define the reliability of the measurements (weights)
+ E04RX e04rx = new E04RX();
+ ifail = 0;
+ e04rx.eval(handle, "RW", 0, weights.length, weights, ifail);
+
+ // Indicate to the solver that weights are to be used
+ ifail = 0;
+ e04zm.eval(handle, "Bxnl Use weights = Yes", ifail);
+
+ // Define initial guess (starting point) Away from zero which is problematic
+ Arrays.fill(x, 1.0);
+
+ // Solve again
+ e04gg.eval(handle, lsqfun, lsqgrd, lsqhes, lsqhprd, monit, nvar, x, nres, rx, rinfo, stats, iuser, ruser,
+ cpuser, ifail);
+
+ // Objective and solution
+ rstar = x[0];
+ System.out.printf("Optimal Orbit Height: %3.2f\n", rstar);
+
+ try {
+ // Open a JPEG file, load into a BufferedImage.
+ BufferedImage img = ImageIO.read(new File("../img/dat_orbit.png"));
+
+ // Obtain the Graphics2D context associated with the BufferedImage.
+ Graphics2D g = img.createGraphics();
+
+ // Set the Color to White
+ g.setColor(Color.WHITE);
+
+ // Draw the Circle around the points
+ g.drawOval((int) (cc[0] - rstar), (int) (cc[1] - rstar), (int) (2 * rstar), (int) (2 * rstar));
+
+ // Save the image
+ ImageIO.write(img, "PNG", new File("../img/estw_orbit.png"));
+
+ // Clean up -- dispose the graphics context that was created.
+ g.dispose();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ System.out.printf("Optimal Orbit Height: %3.2f (should be between 244 and 256)\n", rstar);
+
+ // Destroy the handle:
+ E04RZ e04rz = new E04RZ();
+ ifail = 0;
+ e04rz.eval(handle, ifail);
+ }
+
+ // Define the least-square function and add first derivatives.
+ /**
+ * Objective function call back passed to the least squares solver. Return the
+ * difference between the current estimated radius squared, r^2=x^2 and the
+ * squared norm of the data point stored in tr[i] for i = 1 to nres: rx[i] = r^2
+ * - tr[i], i = 1, ..., nres.
+ */
+ public static class LSQFUN extends E04GG.Abstract_E04GG_LSQFUN {
+ public void eval() {
+ for (int i = 0; i < this.NRES; i++) {
+ this.RX[i] = Math.pow(this.X[0], 2) - this.RUSER[i];
+ }
+ }
+ }
+
+ /**
+ * Computes the Jacobian of the least square residuals. Simply return rdx[i] =
+ * 2r, i = 1, ..., nres.
+ */
+ public static class LSQGRD extends E04GG.Abstract_E04GG_LSQGRD {
+ public void eval() {
+ Arrays.fill(this.RDX, 2.0 * this.X[0]);
+ }
+ }
+
+ public static class LSQHES extends E04GG.Abstract_E04GG_LSQHES {
+ public void eval() {
+ E04GGU e04ggu = new E04GGU();
+ e04ggu.eval(this.NVAR, this.X, this.NRES, this.LAMBDA, this.HX, this.INFORM, this.IUSER, this.RUSER,
+ this.CPUSER);
+ this.INFORM = e04ggu.getINFORM();
+ }
+ }
+
+ public static class LSQHPRD extends E04GG.Abstract_E04GG_LSQHPRD {
+ public void eval() {
+ E04GGV e04ggv = new E04GGV();
+ e04ggv.eval(this.NVAR, this.X, this.Y, this.NRES, this.HXY, this.INFORM, this.IUSER, this.RUSER,
+ this.CPUSER);
+ this.INFORM = e04ggv.getINFORM();
+ }
+ }
+
+ public static class MONIT extends E04GG.Abstract_E04GG_MONIT {
+ public void eval() {
+ E04FFU e04ffu = new E04FFU();
+ e04ffu.eval(this.NVAR, this.X, this.INFORM, this.RINFO, this.STATS, this.IUSER, this.RUSER, this.CPUSER);
+ this.INFORM = e04ffu.getINFORM();
+ }
+ }
+
+ private static void drawPoint(Graphics2D g, int x, int y) {
+ int width = 3;
+ int length = 21;
+ g.fillRect(x - (width / 2), y - (length / 2), width, length);
+ g.fillRect(x - (length / 2), y - (width / 2), length, width);
+ }
+
+}
diff --git a/BXNL/simple_BXNL/Readme.md b/BXNL/simple_BXNL/Readme.md
new file mode 100644
index 0000000..4fd5f53
--- /dev/null
+++ b/BXNL/simple_BXNL/Readme.md
@@ -0,0 +1,314 @@
+> ## Important Information
+> This file has a lot of Latex and GitHub currently cannot render it on Markdown files. You can read all the math clearly as a [webpage](https://numericalalgorithmsgroup.github.io/NAGJavaExamples/BXNL/simple_BXNL) or access this as a regular github [repository](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/tree/main/BXNL/simple_BXNL).
+>
+> The source of this example can be found [here](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/blob/main/BXNL/simple_BXNL/source/SimpleBXNL.java) and the output [here](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/blob/main/BXNL/simple_BXNL/output.txt).
+>
+> See the top directory of this repository for instructions to set up the [NAG Library for Java](https://github.com/numericalalgorithmsgroup/NAGJavaExamples).
+
+This example demontrates how to fit data to a model using weighted nonlinear least-squares.
+
+**handle_solve_bxnl** (`e04gg`) is a bound-constrained nonlinear least squares trust region solver (BXNL) from the NAG optimization modelling suite aimed for small to medium-scale problems. It solves the problem:
+
+$$
+\begin{array}{ll}
+{\underset{x \in \mathbb{R}^{n_{\text{var}}}}{minimize}\ } &
+\frac{1}{2} \sum_{i=1}^{n_{\text{res}}} w_i r_i(x)^2 + \frac{\sigma}{p}\|x\|^p_2\\
+\text{subject to} & l_{x} \leq x \leq u_{x}
+\end{array}
+$$
+
+
+where $$r_i(x),i=1,\dots,n_{\text{res}}$$, are smooth nonlinear functions called residuals, $$w_i ,i=1,\dots,n_{\text{res}}$$ are weights (by default they are all defined to 1, and the rightmost element represents the regularization term with parameter $$\sigma\geq0$$ and power $$p>0$$. The constraint elements $$l_x$$ and $$u_x$$ are $$n_{\text{var}}$$-dimensional vectors defining the bounds on the variables.
+
+Typically in a calibration or data fitting context, the residuals will be defined as the difference between the observed values $$y_i$$ at $$t_i$$ and the values provided by a nonlinear model $$\phi(t;x)$$, i.e., $$r_i(x)≔y_i-\phi(t_i;x).$$
+
+The following example illustrates the usage of `e04gg` to fit PADC target with $$\alpha$$ particle
+etched nuclear track data to a convoluted distribution. A target
+sheet is scanned and track diameters (red wedges in
+the following Figure 1) are recorded into a histogram and a mixed Normal and log-Normal model is to be fitted to the experimental histogram (see Figure 2).
+
+
+
+
+
+**Figure 1**: PADC with etched $$\alpha$$ particle tracks.
+
+`e04gg` is used to fit the six parameter model
+$$
+\begin{array}{ll}
+\phi\big(t, x = (a, b, A_{\ell}, \mu, \sigma, A_g)\big) = \text{log-Normal}(a, b, A_l) + \text{Normal}(\mu, \sigma^2, A_g)\\
+\text{subject to } 0 \leq x,
+\end{array}$$
+using the histogram heights reported in Figure 2.
+
+```java
+ // problem data
+ // number of observations
+ int nres = 64;
+ // ovservations
+ int[] diameter = new int[nres];
+ for (i = 0; i < nres; i++) {
+ diameter[i] = i + 1;
+ }
+ double[] density = new double[] { 0.0722713864, 0.0575221239, 0.0604719764, 0.0405604720, 0.0317109145,
+ 0.0309734513, 0.0258112094, 0.0228613569, 0.0213864307, 0.0213864307, 0.0147492625, 0.0213864307,
+ 0.0243362832, 0.0169616519, 0.0095870206, 0.0147492625, 0.0140117994, 0.0132743363, 0.0147492625,
+ 0.0140117994, 0.0140117994, 0.0132743363, 0.0117994100, 0.0132743363, 0.0110619469, 0.0103244838,
+ 0.0117994100, 0.0117994100, 0.0147492625, 0.0110619469, 0.0132743363, 0.0206489676, 0.0169616519,
+ 0.0169616519, 0.0280235988, 0.0221238938, 0.0235988201, 0.0221238938, 0.0206489676, 0.0228613569,
+ 0.0184365782, 0.0176991150, 0.0132743363, 0.0132743363, 0.0088495575, 0.0095870206, 0.0073746313,
+ 0.0110619469, 0.0036873156, 0.0051622419, 0.0058997050, 0.0014749263, 0.0022123894, 0.0029498525,
+ 0.0014749263, 0.0007374631, 0.0014749263, 0.0014749263, 0.0007374631, 0.0000000000, 0.0000000000,
+ 0.0000000000, 0.0000000000, 0.0000000000 };
+
+ // Define iuser and ruser to be passed to the callback functions
+ int[] iuser = diameter;
+ double[] ruser = density;
+```
+
+
+
+
+
+
+
+**Figure 2**: Histogram of etched track diameter of $$\alpha$$ particles. Bar heights are the data that will be fitted unsing the aggregated model $$\phi(x, t)$$.
+
+```java
+ // Define Normal and log-Normal distributions
+ public static double lognormal(int d, double a, double b, double Al) {
+ return Al / (d * b * Math.sqrt(2 * Math.PI)) * Math.exp(-(Math.pow(Math.log(d) - a, 2)) / (2 * Math.pow(b, 2)));
+ }
+
+ public static double gaussian(int d, double mu, double sigma, double Ag) {
+ return Ag * Math.exp(-0.5 * Math.pow((d - mu) / sigma, 2)) / (sigma * Math.sqrt(2 * Math.PI));
+ }
+
+ public static double[] lognormal(double[] d, double a, double b, double Al) {
+ double[] result = new double[d.length];
+ for (int i = 0; i < d.length; i++) {
+ result[i] = Al / (d[i] * b * Math.sqrt(2 * Math.PI)) * Math.exp(-(Math.pow(Math.log(d[i]) - a, 2)) / (2 * Math.pow(b, 2)));
+ }
+ return result;
+ }
+
+ public static double[] gaussian(double[] d, double mu, double sigma, double Ag) {
+ double[] result = new double[d.length];
+ for (int i = 0; i < d.length; i++) {
+ result[i] = Ag * Math.exp(-0.5 * Math.pow((d[i] - mu) / sigma, 2)) / (sigma * Math.sqrt(2 * Math.PI));
+ }
+ return result;
+ }
+```
+
+In terms of solving this problem, the function to minimize is the sum of residuals using the model $$\phi(x;t)$$
+and the data pair (`diameter`, `density`). The parameter vector is $$x = (a, b, A_l, \mu, \sigma, A_g)$$. The next step is to define a function to return the residual vector
+$$\text{lsqfun}(x) := \big[r_1(x), r_2(x), \dots, r_{n_{\text{res}}}(x)\big]$$.
+
+```java
+ // Define the least-square function as a mixture of Normal and log-Normal
+ // functions. Also add its first derivatives
+
+ /**
+ * Objective function callback passed to the least squares solver. x = (a, b,
+ * Al, mu, sigma, Ag)
+ */
+ public static class LSQFUN extends E04GG.Abstract_E04GG_LSQFUN {
+ public void eval() {
+ int[] d = this.IUSER;
+ double[] y = this.RUSER;
+ double a = this.X[0];
+ double b = this.X[1];
+ double Al = this.X[2];
+ double mu = this.X[3];
+ double sigma = this.X[4];
+ double Ag = this.X[5];
+
+ for (int i = 0; i < this.NRES; i++) {
+ this.RX[i] = lognormal(d[i], a, b, Al) + gaussian(d[i], mu, sigma, Ag) - y[i];
+ }
+ }
+ }
+
+ /**
+ * Computes the Jacobian of the least square residuals. x = (a, b, Al, mu,
+ * sigma, Ag)
+ */
+ public static class LSQGRD extends E04GG.Abstract_E04GG_LSQGRD {
+ public void eval() {
+ int n = this.X.length;
+ int[] d = this.IUSER;
+ double a = this.X[0];
+ double b = this.X[1];
+ double Al = this.X[2];
+ double mu = this.X[3];
+ double sigma = this.X[4];
+ double Ag = this.X[5];
+ for (int i = 0; i < this.NRES; i++) {
+ // log-Normal derivatives
+ double l = lognormal(d[i], a, b, Al);
+ // dl/da
+ this.RDX[i * n + 0] = (Math.log(d[i]) - a) / Math.pow(b, 2) * l;
+ // dl/db
+ this.RDX[i * n + 1] = (Math.pow(Math.log(d[i]) - a, 2) - Math.pow(b, 2)) / Math.pow(b, 3) * l;
+ // dl/dAl
+ this.RDX[i * n + 2] = lognormal(d[i], a, b, 1.0);
+ // Gaussian derivatives
+ double g = gaussian(d[i], mu, sigma, Ag);
+ // dg/dmu
+ this.RDX[i * n + 3] = (d[i] - mu) / Math.pow(sigma, 2) * g;
+ // dg/dsigma
+ this.RDX[i * n + 4] = (Math.pow(d[i] - mu, 2) - Math.pow(sigma, 2)) / Math.pow(sigma, 3) * g;
+ // dg/dAg
+ this.RDX[i * n + 5] = gaussian(d[i], mu, sigma, 1.0);
+ }
+ }
+ }
+```
+
+
+
+```java
+ // parameter vector: x = (a, b, Al, mu, sigma, Ag)
+ int nvar = 6;
+
+ // Initialize the model handle
+ E04RA e04ra = new E04RA();
+ long handle = 0;
+ int ifail = 0;
+ e04ra.eval(handle, nvar, ifail);
+
+ handle = e04ra.getHANDLE();
+
+ // Define a dense nonlinear least-squares objective function
+ E04RM e04rm = new E04RM();
+ ifail = 0;
+ e04rm.eval(handle, nres, 0, 0, new int[] {}, new int[] {}, ifail);
+
+ // Add weights for each residual
+ double[] weights = new double[nres];
+ Arrays.fill(weights, 1.0);
+ for (i = 55; i < 63; i++) {
+ weights[i] = 5.0;
+ }
+ double weights_sum = Arrays.stream(weights).sum();
+ for (i = 0; i < weights.length; i++) {
+ weights[i] /= weights_sum;
+ }
+
+ // Define the reliability of the measurements (weights)
+ E04RX e04rx = new E04RX();
+ ifail = 0;
+ e04rx.eval(handle, "RW", 0, weights.length, weights, ifail);
+
+ // Restrict parameter space (0 <= x)
+ E04RH e04rh = new E04RH();
+ double[] bl = new double[nvar];
+ double[] bu = new double[nvar];
+ Arrays.fill(bu, 100.0);
+ ifail = 0;
+ e04rh.eval(handle, nvar, bl, bu, ifail);
+
+ // Set some optional parameters to control the output of the solver
+ E04ZM e04zm = new E04ZM();
+ ifail = 0;
+
+ e04zm.eval(handle, "Print Options = NO", ifail);
+ e04zm.eval(handle, "Print Level = 1", ifail);
+ e04zm.eval(handle, "Print Solution = X", ifail);
+ e04zm.eval(handle, "Bxnl Iteration Limit = 100", ifail);
+ // Add cubic regularization term (avoid overfitting)
+ e04zm.eval(handle, "Bxnl Use weights = YES", ifail);
+ e04zm.eval(handle, "Bxnl Reg Order = 3", ifail);
+ e04zm.eval(handle, "Bxnl Glob Method = REG", ifail);
+
+ // Define initial guess (starting point)
+ double[] x = new double[] { 1.63, 0.88, 1.0, 30, 1.52, 0.24 };
+```
+
+Call the solver
+
+```java
+ // Call the solver
+ E04GG e04gg = new E04GG();
+ LSQFUN lsqfun = new LSQFUN();
+ LSQGRD lsqgrd = new LSQGRD();
+ LSQHES lsqhes = new LSQHES();
+ LSQHPRD lsqhprd = new LSQHPRD();
+ MONIT monit = new MONIT();
+ double[] rx = new double[nres];
+ double[] rinfo = new double[100];
+ double[] stats = new double[100];
+ long cpuser = 0;
+ ifail = 0;
+
+ e04gg.eval(handle, lsqfun, lsqgrd, lsqhes, lsqhprd, monit, nvar, x, nres, rx, rinfo, stats, iuser, ruser,
+ cpuser, ifail);
+```
+
+
+
+```
+ E04GG, Nonlinear least squares method for bound-constrained problems
+ Status: converged, an optimal solution was found
+ Value of the objective 4.44211E-08
+ Norm of projected gradient 1.18757E-09
+ Norm of scaled projected gradient 3.98428E-06
+ Norm of step 1.66812E-01
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 0.00000E+00 2.02043E+00 1.00000E+02
+ 2 0.00000E+00 1.39726E+00 1.00000E+02
+ 3 0.00000E+00 6.93255E-01 1.00000E+02
+ 4 0.00000E+00 3.65929E+01 1.00000E+02
+ 5 0.00000E+00 7.01808E+00 1.00000E+02
+ 6 0.00000E+00 3.36877E-01 1.00000E+02
+```
+
+The optimal solution $$x$$ provides the unfolded parameters for the two distributions, Normal and log-Normal (blue and red curves in Figure 4). Adding these together produces the aggragated curve (shown in color green of Figure 3 and 4) this last one is the one used to perform the fitting with. The optimal solution is
+
+```java
+ // Optimal parameter values
+ // Al * log-Normal(a, b):
+ double aopt = x[0];
+ double bopt = x[1];
+ double Alopt = x[2];
+
+ // Ag * gaussian(mu, sigma):
+ double muopt = x[3];
+ double sigmaopt = x[4];
+ double Agopt = x[5];
+```
+
+and the objective function value is
+
+```
+Objective Function Value: 4.4421102582032467E-8
+```
+
+The next plot in Figure 3 illustrates the mixed-distribution fit over the histogram:
+
+
+
+
+
+**Figure 3**: Histogram with aggregated fit.
+
+The plot below in Figure 4 shows the unfolded fit, in red the log-Normal distribution and blue the Normal one:
+
+
+
+
+
+**Figure 4**: Aggregated model used for the fitting (green curve) and unfolded models (blue and red curves).
+Optimal parameter values are ported in the legend.
+
+Finally, clean up and destroy the handle
+
+```java
+ // Destroy the handle:
+ E04RZ e04rz = new E04RZ();
+ ifail = 0;
+ e04rz.eval(handle, ifail);
+```
diff --git a/BXNL/simple_BXNL/data/density.d b/BXNL/simple_BXNL/data/density.d
new file mode 100644
index 0000000..7da020e
--- /dev/null
+++ b/BXNL/simple_BXNL/data/density.d
@@ -0,0 +1 @@
+0.0722713864 0.0575221239 0.0604719764 0.040560472 0.0317109145 0.0309734513 0.0258112094 0.0228613569 0.0213864307 0.0213864307 0.0147492625 0.0213864307 0.0243362832 0.0169616519 0.0095870206 0.0147492625 0.0140117994 0.0132743363 0.0147492625 0.0140117994 0.0140117994 0.0132743363 0.01179941 0.0132743363 0.0110619469 0.0103244838 0.01179941 0.01179941 0.0147492625 0.0110619469 0.0132743363 0.0206489676 0.0169616519 0.0169616519 0.0280235988 0.0221238938 0.0235988201 0.0221238938 0.0206489676 0.0228613569 0.0184365782 0.017699115 0.0132743363 0.0132743363 0.0088495575 0.0095870206 0.0073746313 0.0110619469 0.0036873156 0.0051622419 0.005899705 0.0014749263 0.0022123894 0.0029498525 0.0014749263 7.374631E-4 0.0014749263 0.0014749263 7.374631E-4 0.0 0.0 0.0 0.0 0.0
diff --git a/BXNL/simple_BXNL/data/dh.d b/BXNL/simple_BXNL/data/dh.d
new file mode 100644
index 0000000..9149a0c
--- /dev/null
+++ b/BXNL/simple_BXNL/data/dh.d
@@ -0,0 +1 @@
+0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11.0 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 12.0 12.1 12.2 12.3 12.4 12.5 12.6 12.7 12.8 12.9 13.0 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 14.0 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8 14.9 15.0 15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 16.0 16.1 16.2 16.3 16.4 16.5 16.6 16.7 16.8 16.9 17.0 17.1 17.2 17.3 17.4 17.5 17.6 17.7 17.8 17.9 18.0 18.1 18.2 18.3 18.4 18.5 18.6 18.7 18.8 18.9 19.0 19.1 19.2 19.3 19.4 19.5 19.6 19.7 19.8 19.9 20.0 20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.9 22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.9 25.0 25.1 25.2 25.3 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.2 26.3 26.4 26.5 26.6 26.7 26.8 26.9 27.0 27.1 27.2 27.3 27.4 27.5 27.6 27.7 27.8 27.9 28.0 28.1 28.2 28.3 28.4 28.5 28.6 28.7 28.8 28.9 29.0 29.1 29.2 29.3 29.4 29.5 29.6 29.7 29.8 29.9 30.0 30.1 30.2 30.3 30.4 30.5 30.6 30.7 30.8 30.9 31.0 31.1 31.2 31.3 31.4 31.5 31.6 31.7 31.8 31.9 32.0 32.1 32.2 32.3 32.4 32.5 32.6 32.7 32.8 32.9 33.0 33.1 33.2 33.3 33.4 33.5 33.6 33.7 33.8 33.9 34.0 34.1 34.2 34.3 34.4 34.5 34.6 34.7 34.8 34.9 35.0 35.1 35.2 35.3 35.4 35.5 35.6 35.7 35.8 35.9 36.0 36.1 36.2 36.3 36.4 36.5 36.6 36.7 36.8 36.9 37.0 37.1 37.2 37.3 37.4 37.5 37.6 37.7 37.8 37.9 38.0 38.1 38.2 38.3 38.4 38.5 38.6 38.7 38.8 38.9 39.0 39.1 39.2 39.3 39.4 39.5 39.6 39.7 39.8 39.9 40.0 40.1 40.2 40.3 40.4 40.5 40.6 40.7 40.8 40.9 41.0 41.1 41.2 41.3 41.4 41.5 41.6 41.7 41.8 41.9 42.0 42.1 42.2 42.3 42.4 42.5 42.6 42.7 42.8 42.9 43.0 43.1 43.2 43.3 43.4 43.5 43.6 43.7 43.8 43.9 44.0 44.1 44.2 44.3 44.4 44.5 44.6 44.7 44.8 44.9 45.0 45.1 45.2 45.3 45.4 45.5 45.6 45.7 45.8 45.9 46.0 46.1 46.2 46.3 46.4 46.5 46.6 46.7 46.8 46.9 47.0 47.1 47.2 47.3 47.4 47.5 47.6 47.7 47.8 47.9 48.0 48.1 48.2 48.3 48.4 48.5 48.6 48.7 48.8 48.9 49.0 49.1 49.2 49.3 49.4 49.5 49.6 49.7 49.8 49.9 50.0 50.1 50.2 50.3 50.4 50.5 50.6 50.7 50.8 50.9 51.0 51.1 51.2 51.3 51.4 51.5 51.6 51.7 51.8 51.9 52.0 52.1 52.2 52.3 52.4 52.5 52.6 52.7 52.8 52.9 53.0 53.1 53.2 53.3 53.4 53.5 53.6 53.7 53.8 53.9 54.0 54.1 54.2 54.3 54.4 54.5 54.6 54.7 54.8 54.9 55.0 55.1 55.2 55.3 55.4 55.5 55.6 55.7 55.8 55.9 56.0 56.1 56.2 56.3 56.4 56.5 56.6 56.7 56.8 56.9 57.0 57.1 57.2 57.3 57.4 57.5 57.6 57.7 57.8 57.9 58.0 58.1 58.2 58.3 58.4 58.5 58.6 58.7 58.8 58.9 59.0 59.1 59.2 59.3 59.4 59.5 59.6 59.7 59.8 59.9 60.0 60.1 60.2 60.3 60.4 60.5 60.6 60.7 60.8 60.9 61.0 61.1 61.2 61.3 61.4 61.5 61.6 61.7 61.8 61.9 62.0 62.1 62.2 62.3 62.4 62.5 62.6 62.7 62.8 62.9 63.0 63.1 63.2 63.3 63.4 63.5 63.6 63.7 63.8 63.9 64.0 64.1 64.2 64.3 64.4 64.5 64.6 64.7 64.8
diff --git a/BXNL/simple_BXNL/data/diameter.d b/BXNL/simple_BXNL/data/diameter.d
new file mode 100644
index 0000000..ce0d83f
--- /dev/null
+++ b/BXNL/simple_BXNL/data/diameter.d
@@ -0,0 +1 @@
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
diff --git a/BXNL/simple_BXNL/data/gopt.d b/BXNL/simple_BXNL/data/gopt.d
new file mode 100644
index 0000000..0e24968
--- /dev/null
+++ b/BXNL/simple_BXNL/data/gopt.d
@@ -0,0 +1 @@
+2.5753655165541875E-8 2.773145459193807E-8 2.985508062666399E-8 3.213480516109361E-8 3.4581586868438315E-8 3.720711440847843E-8 4.002385215757E-8 4.3045088598395975E-8 4.628498751023043E-8 4.975864210702609E-8 5.348213227742936E-8 5.747258508786509E-8 6.174823871713718E-8 6.632850999855895E-8 7.123406575345317E-8 7.648689810798785E-8 8.21104039936885E-8 8.812946904065071E-8 9.45705560814465E-8 1.0146179849296142E-7 1.0883309861297935E-7 1.167162314781713E-7 1.251449541403224E-7 1.3415512082810047E-7 1.4378480423245077E-7 1.5407442320481146E-7 1.6506687716874575E-7 1.7680768755731788E-7 1.8934514660060177E-7 2.0273047380004015E-7 2.1701798043909465E-7 2.3226524249258428E-7 2.48533282310429E-7 2.6588675946513634E-7 2.8439417116626596E-7 3.041280626593597E-7 3.251652480413011E-7 3.4758704193890364E-7 3.7147950251258795E-7 3.96933686262358E-7 4.2404591512891804E-7 4.5291805639862016E-7 4.836578159370194E-7 5.163790452921627E-7 5.512020632252209E-7 5.8825399224283E-7 6.276691107223715E-7 6.695892212384454E-7 7.141640357159715E-7 7.615515780526349E-7 8.119186048706638E-7 8.654410450754377E-7 9.223044589157598E-7 9.827045172580034E-7 1.0468475018038981E-6 1.1149508269986923E-6 1.1872435843939264E-6 1.2639671102458615E-6 1.3453755771474092E-6 1.4317366105082272E-6 1.5233319307135053E-6 1.620458021808343E-6 1.7234268275698936E-6 1.8325664758445828E-6 1.94822203204244E-6 2.0707562826944596E-6 2.200550549992401E-6 2.3380055382431703E-6 2.483542213181756E-6 2.6376027150980243E-6 2.800651306742734E-6 2.973175356987449E-6 3.1556863612212845E-6 3.348720999474282E-6 3.5528422332633386E-6 3.7686404421608886E-6 3.9967346010897955E-6 4.2377734993496425E-6 4.492437002379329E-6 4.761437357259783E-6 5.045520542956912E-6 5.345467666299461E-6 5.662096404679869E-6 5.996262496455892E-6 6.34886128002044E-6 6.720829282492197E-6 7.113145858963868E-6 7.526834883226361E-6 7.962966490865058E-6 8.422658875601204E-6 8.907080139723416E-6 9.417450199425253E-6 9.95504274583095E-6 1.0521187262455488E-5 1.111727109980568E-5 1.1744741607785312E-5 1.2405108326521387E-5 1.3099945236177674E-5 1.3830893066267764E-5 1.4599661664922194E-5 1.540803242850114E-5 1.6257860791879284E-5 1.7151078779658055E-5 1.8089697618485683E-5 1.9075810410587354E-5 2.01115948685222E-5 2.119931611109745E-5 2.234132952027551E-5 2.3540083658812054E-5 2.479812324826171E-5 2.6118092206877763E-5 2.7502736746822304E-5 2.895490852998336E-5 3.0477567881572963E-5 3.2073787060553974E-5 3.374675358580579E-5 3.549977361680628E-5 3.73362753874588E-5 3.925981269154483E-5 4.127406841813281E-5 4.33828581351068E-5 4.559013371882075E-5 4.789998702771147E-5 5.031665361752569E-5 5.284451649564377E-5 5.548810991178874E-5 5.825212318222723E-5 6.114140454437063E-5 6.416096503848311E-5 6.731598241300712E-5 7.061180504979964E-5 7.405395590536803E-5 7.764813646397307E-5 8.140023069824902E-5 8.531630903276786E-5 8.94026323057448E-5 9.366565572385738E-5 9.811203280491299E-5 1.0274861930286774E-4 1.0758247710946226E-4 1.1262087812649981E-4 1.1787130810255331E-4 1.233414704276464E-4 1.2903928987921027E-4 1.349729163123799E-4 1.4115072828744371E-4 1.475813366270313E-4 1.542735878953724E-4 1.612365677917277E-4 1.6847960444985773E-4 1.7601227163515764E-4 1.8384439183086017E-4 1.9198603920448216E-4 2.0044754244546417E-4 2.0923948746474615E-4 2.1837271994679794E-4 2.2785834774443234E-4 2.3770774310652386E-4 2.479325447285641E-4 2.5854465961581714E-4 2.695562647486434E-4 2.809798085394283E-4 2.928280120703707E-4 3.0511387010126527E-4 3.1785065183628325E-4 3.3105190143862504E-4 3.4473143828183967E-4 3.5890335692650435E-4 3.735820268108777E-4 3.8878209164411044E-4 4.0451846849052484E-4 4.208063465334779E-4 4.376611855073064E-4 4.550987137858625E-4 4.7313492611619854E-4 4.917860809859957E-4 5.110686976134205E-4 5.309995525481868E-4 5.515956758727061E-4 5.728743469923885E-4 5.948530900042727E-4 6.175496686333996E-4 6.409820807265382E-4 6.651685522931049E-4 6.901275310834189E-4 7.158776796946805E-4 7.424378681954367E-4 7.698271662595977E-4 7.980648348014665E-4 8.271703171036632E-4 8.571632294302157E-4 8.880633511175937E-4 9.198906141369408E-4 9.526650921212412E-4 9.864069888517867E-4 0.0010211366261987916 0.0010568744315116924 0.00109364092445526 0.001131456703288309 0.00117034243058254 0.0012103188183796912 0.0012514066127859976 0.0012936265780037002 0.0013369994798001317 0.0013815460684158045 0.0014272870609136955 0.0014742431229728859 0.001522434850130569 0.001571882748477381 0.0016226072148119853 0.0016746285162617834 0.0017279667693776393 0.001782641918711528 0.0018386737148870082 0.0018960816921735433 0.0019548851455766627 0.0020151031074571385 0.0020767543236933556 0.002139857229402197 0.0022044299242348904 0.0022704901472653193 0.002338055251489508 0.002407142177956042 0.002477767429548347 0.0025499470444408875 0.0026236965692524265 0.0026990310319206594 0.002775964914323618 0.0028545121246743143 0.00293468596971628 0.0030164991267485905 0.0030999636155101718 0.003185090769954121 0.0032718912099438243 0.003360374812903693 0.0034505506854582177 0.0035424271350940773 0.003636011641880895 0.0037313108302870755 0.003828330441128111 0.003927075303685393 0.004027549308034451 0.004129755377622194 0.004233695442133348 0.00433937041068707 0.004446780145405038 0.004555923435393064 0.004666797971178603 0.004779400319646909 0.0048937258995190745 0.005009768957415254 0.005127522544546789 0.005246978494080952 0.0053681273992221374 0.005490958592053414 0.00561546012318212 0.005741618742233235 0.005869419879233913 0.005998847626932257 0.006129884724093222 0.006262512539813822 0.006396711058899532 0.00653245886834304 0.0066697331449457895 0.0068085096441221375 0.006948762689924891 0.007090465166330238 0.007233588509819008 0.007378102703289977 0.00752397627134004 0.007671176276944479 0.007819668319569494 0.007969416534747595 0.008120383595144944 0.008272530713148324 0.00842581764499752 0.00858020269648741 0.00873564273026215 0.008892093174721859 0.009049508034560632 0.009207839902952236 0.009367039975398181 0.009527058065250588 0.009687842620919871 0.009849340744775581 0.010011498213745702 0.010174259501618134 0.010337567803045114 0.010501365059249203 0.010665591985426971 0.010830188099843905 0.010995091754611724 0.011160240168136553 0.011325569459223899 0.011491014682823925 0.011656509867397614 0.011821988053882146 0.011987381336230991 0.012152620903501585 0.012317637083461116 0.012482359387677939 0.012646716558064033 0.012810636614831016 0.012974046905819745 0.013136874157161348 0.01329904452522455 0.013460483649802285 0.013621116708487813 0.013780868472188415 0.013939663361722499 0.014097425505443665 0.014254078797833167 0.014409546959000239 0.014563753595027531 0.01471662225909735 0.014868076513332123 0.015018039991281257 0.015166436460984487 0.015313189888540513 0.015458224502108242 0.015601464856266524 0.015742835896657106 0.015882263024834378 0.016019672163244552 0.01615498982025575 0.016288143155160167 0.016419060043068354 0.01654766913961543 0.016673899945398536 0.016797682870064508 0.016918949295966806 0.017037631641310433 0.017153663422703976 0.01726697931703799 0.017377515222609302 0.01748520831941153 0.017589997128512544 0.01769182157044052 0.01779062302250111 0.01788634437494924 0.017978930085940422 0.018068326235187546 0.01815448057625069 0.01823734258738908 0.018316863520905825 0.018392996450918186 0.01846569631948772 0.01853491998104694 0.018600626245061126 0.018662775916866308 0.018721331836626724 0.018776258916357556 0.0188275241749613 0.018875096771228856 0.01891894803475903 0.018959051494753163 0.018995382906644268 0.01902792027652333 0.019056643883328186 0.01908153629876373 0.01910258240492522 0.019119769409599818 0.019133086859224574 0.019142526649482565 0.019148083033522143 0.019149752627787568 0.01914753441545279 0.01914142974745354 0.019131442341116123 0.01911757827638506 0.019099845989654748 0.01907825626521404 0.019052822224315796 0.019023559311886987 0.018990485280898133 0.01895362017441425 0.018912986305352736 0.01886860823397675 0.018820512743155906 0.018768728811429197 0.01871328758390799 0.01865422234106005 0.018591568465418422 0.01852536340626164 0.018455646642314836 0.018382459642523528 0.0183058458249548 0.018225850513882785 0.018142520895117815 0.01805590596964099 0.01796605650560767 0.01787302498878592 0.017776865571497397 0.017677634020130294 0.01757538766129546 0.01747018532669834 0.017362087296800933 0.01725115524334913 0.017137452170842025 0.01702104235702088 0.016901991292456092 0.01678036561931161 0.016656233069366637 0.01652966240137499 0.016400723337843037 0.016269486501307075 0.01613602335019135 0.016000406114327813 0.015862707730218417 0.015723001776120845 0.015581362407037551 0.015437864289688043 0.0152925825375433 0.015145592646000478 0.014996970427775383 0.014846791948588737 0.014695133463221554 0.014542071352013443 0.014387682057876258 0.014232042023894383 0.014075227631580886 0.013917315139857524 0.013758380624824696 0.01359849992038545 0.013437748559786118 0.013276201718133636 0.013113934155947967 0.012951020163805711 0.012787533508128713 0.012623547378169472 0.01245913433424244 0.012294366257248293 0.0121293142995356 0.011964048837141916 0.011798639423453992 0.011633154744323849 0.011467662574675394 0.011302229736633373 0.01113692205920392 0.010971804339533481 0.01080694030577007 0.01064239258154841 0.010478222652117803 0.010314490832128912 0.01015125623509332 0.009988576744526733 0.00982650898678457 0.009665108305595926 0.009504428738299379 0.009344522993781954 0.009185442432119646 0.009027237045916004 0.008869955443332682 0.008713644832803602 0.00855835100942233 0.00840411834298975 0.008250989767707393 0.008099006773499418 0.007948209398944393 0.007798636225796186 0.007650324375071108 0.007503309504677039 0.00735762580855833 0.007213306017328608 0.007070381400362348 0.00692888176931407 0.006788835483033168 0.006650269453840687 0.00651320915513317 0.0063776786302777826 0.00624370050276141 0.006111295987555771 0.005980484903659589 0.005851285687777825 0.005723715409097619 0.0055977897851194084 0.005473523198501531 0.00535092871487587 0.005230018101591679 0.005110801847344553 0.00499328918264689 0.004877488101096323 0.004763405381398286 0.004651046610098815 0.004540416204983887 0.004431517439101359 0.004324352465362057 0.004218922341676588 0.004115227056584725 0.004013265555334764 0.003913035766370335 0.003814534628182921 0.0037177581164886705 0.003622701271688707 0.0035293582265728744 0.00343772223422728 0.003347785696107 0.003259540190235893 0.0031729764994962973 0.0030880846399723456 0.0030048538893113147 0.0029232728150685224 0.002843329303002136 0.0027650105852852153 0.002688303268603427 0.002613193362107697 0.0025396663051923105 0.002467706995069912 0.002397299814115915 0.0023284286569561163 0.0022610769572720883 0.002195227714300368 0.0021308635190023448 0.0020679665798829894 0.002006518748437703 0.001946501544207576 0.0018878961794246015 0.0018306835832294695 0.0017748444254456033 0.0017203591398943976 0.001667207947237472 0.0016153708773330503 0.0015648277910945549 0.0015155584018405582 0.0014675422961263633 0.0014207589540483948 0.0013751877690137062 0.001330808066967835 0.0012875991250752212 0.0012455401898473965 0.001204610494714991 0.0011647892770406077 0.0011260557945704226 0.001088389341323244 0.0010517692629166287 0.0010161749713303691 9.815859591085275E-4 9.479818130018932E-4 9.153422270534492E-4 8.8364701513018E-4 8.528761229051219E-4 8.230096392942821E-4 7.940278073535989E-4 7.659110346416938E-4 7.386399030547559E-4 7.121951781403358E-4 6.865578178973905E-4 6.617089810703302E-4 6.376300349452585E-4 6.143025626570207E-4 5.917083700159955E-4 5.698294918639697E-4 5.486481979687083E-4 5.281469984671421E-4 5.083086488673653E-4 4.891161546198436E-4 4.7055277526848434E-4 4.5260202819237777E-4 4.3524769194919097E-4 4.1847380923135254E-4 4.0226468944624526E-4 3.866049109317544E-4 3.7147932281857436E-4 3.568730465507253E-4 3.4277147707578146E-4 3.2916028371629357E-4 3.1602541073391275E-4 3.0335307759767814E-4 2.911297789678929E-4 2.7934228440696437E-4 2.679776378284877E-4 2.570231566957884E-4 2.4646643098101654E-4 2.362953218957744E-4 2.2649796040413863E-4 2.1706274552877553E-4 2.0797834246071513E-4 1.9923368048317658E-4 1.9081795071966255E-4 1.8272060371636923E-4 1.7493134686874875E-4 1.6744014170188247E-4 1.6023720101410763E-4 1.5331298589312605E-4 1.466582026136195E-4 1.4026379942515588E-4 1.3412096323895954E-4 1.2822111622188016E-4 1.2255591230566214E-4 1.1711723361938603E-4 1.1189718685270241E-4 1.0688809955725302E-4 1.0208251639342268E-4 9.747319532932627E-5 9.30531037986983E-5 8.881541482409911E-5 8.475350311162367E-5 8.086094112304975E-5 7.71314951311272E-5 7.35591212634751E-5 7.013796154031284E-5 6.686233991102656E-5 6.372675829433788E-5 6.072589262661582E-5 5.785458892265552E-5 5.51078593530177E-5 5.2480878341817836E-5 4.996897868863548E-5 4.756764771800849E-5 4.5272523459776565E-5 4.307939086333468E-5 4.098417804866777E-5 3.8982952596846985E-5 3.707191788248245E-5 3.52474094504514E-5 3.350589143904215E-5 3.184395305148869E-5 3.0258305077704897E-5 2.8745776467868724E-5 2.730331095935495E-5 2.592796375836314E-5 2.4616898277448467E-5 2.3367382930022562E-5 2.2176787982759476E-5 2.104258246671656E-5 1.996233114785315E-5 1.89336915575185E-5 1.795441108336412E-5 1.7022324121030163E-5 1.6135349286854713E-5 1.529148669175431E-5 1.4488815276335041E-5 1.3725490207203956E-5 1.29997403343674E-5 1.2309865709525832E-5 1.1654235164997854E-5 1.1031283952939388E-5 1.0439511444455905E-5 9.877478888145299E-6 9.343807227551943E-6 8.83717497695701E-6 8.356316154882292E-6 7.900018274638281E-6 7.467120391202548E-6 7.056511203679459E-6 6.6671272125513135E-6 6.297950930903164E-6 5.948009148770728E-6
diff --git a/BXNL/simple_BXNL/data/lopt.d b/BXNL/simple_BXNL/data/lopt.d
new file mode 100644
index 0000000..332abdc
--- /dev/null
+++ b/BXNL/simple_BXNL/data/lopt.d
@@ -0,0 +1 @@
+0.016516515144937752 0.033885492091396414 0.04602917127104057 0.05435419955305444 0.06005616078557925 0.06393430822834725 0.06651848925630348 0.06816733923972278 0.06912957111630977 0.06958159732857115 0.06965104726548706 0.06943184658116218 0.06899413696983142 0.06839095914759145 0.06766285335157797 0.06684108812657862 0.0659499659630828 0.06500849545627922 0.06403162104125337 0.0630311387742124 0.06201638608080362 0.06099476661730581 0.059972153398849454 0.05895320106393535 0.05794158963158017 0.05694021612750475 0.05595134620209385 0.054976734801687806 0.0540177227279026 0.05307531428339725 0.052150239988899984 0.051243007448302555 0.05035394275371086 0.04948322430173461 0.04863091049373654 0.04779696248557264 0.04698126291408371 0.04618363134167532 0.0454038370144281 0.044641609414082684 0.04389664699298494 0.0431686244083743 0.042457198514214874 0.041762013322007935 0.0410827041042886 0.04041890078394081 0.03977023072761044 0.039136321041218655 0.03851680044897836 0.03791130082368672 0.037319458424841315 0.03674091489185605 0.03617531803197521 0.03562232243610971 0.03508158995051457 0.034552790027801455 0.03403559997708108 0.03352970512993166 0.033034798936288974 0.03255058300216746 0.032076767079279984 0.03161306901507108 0.031159214670365688 0.03071493781072622 0.030279979976669882 0.029854090337101465 0.029437025529640157 0.029028549490943776 0.028628433279645447 0.028236454894101516 0.027852399086795796 0.027476057176943677 0.02710722686258271 0.026745712033217715 0.026391322583902057 0.026043874231477873 0.02570318833356315 0.025369091710758504 0.0250414164724488 0.02471999984649184 0.02440468401301616 0.024095315942490165 0.023791747238175027 0.023493833983031114 0.023201436591112335 0.022914419663453364 0.022632651848429473 0.022356005706548943 0.022084357579620777 0.021817587464227007 0.021555578889417986 0.021298218798540238 0.021045397435099807 0.020797008232558922 0.02055294770796009 0.020313115359269263 0.0200774135663283 0.01984574749530605 0.019618025006537823 0.019394156565643177 0.019174055157813567 0.018957636205162526 0.018744817487033143 0.0185355190631596 0.018329663199581857 0.018127174297215123 0.017927978822978224 0.01773200524338776 0.017539183960527702 0.017349447250306595 0.017162729202917736 0.01697896566542015 0.01679809418636094 0.016620053962362626 0.01644478578660128 0.016272231999104436 0.016102336438799873 0.01593504439724918 0.01577030257400237 0.015608059033512095 0.015448263163548585 0.015290865635058448 0.015135818363412674 0.014983074470991523 0.014832588251055594 0.01468431513285483 0.014538211647928675 0.014394235397552703 0.014252345021288674 0.014112500166596691 0.013974661459469814 0.013838790476052966 0.01370484971520954 0.013572802572000546 0.013442613312042488 0.013314247046711634 0.013187669709163397 0.013062848031137003 0.012939749520516705 0.01281834243962186 0.012698595784199443 0.012580479263093528 0.012463963278567181 0.012349018907253354 0.012235617881712143 0.01212373257257274 0.012013335971239183 0.011904401673139912 0.011796903861501831 0.011690817291630387 0.011586117275677845 0.011482779667882657 0.011380780850263497 0.01128009771875209 0.011180707669749674 0.011082588587092409 0.01098571882941171 0.010890077217875924 0.010795643024300331 0.010702395959612952 0.01061031616266404 0.010519384189367743 0.010429581002164637 0.01034088795979449 0.010253286807368773 0.01016675966673306 0.010081289027109624 0.009996857736010984 0.009913448990415545 0.00983104632819665 0.00974963361979687 0.00966919506013945 0.009589715160769298 0.009511178742216103 0.009433570926572378 0.00935687713027962 0.00928108305711588 0.009206174691378372 0.009132138291254943 0.009058960382378417 0.008986627751558113 0.008915127440682919 0.008844446740790622 0.008774573186298333 0.008705494549388947 0.008637198834548922 0.008569674273252644 0.008502909318788929 0.008436892641225336 0.008371613122506052 0.008307059851679363 0.008243222120250778 0.008180089417658002 0.008117651426864164 0.008055898020065726 0.007994819254511681 0.007934405368430774 0.00787464677706346 0.007815534068795689 0.007757058001391339 0.007699209498320584 0.00764197964518131 0.007585359686210906 0.007529341020885859 0.007473915200606553 0.007419073925464921 0.007364809041092498 0.007311112535586647 0.007257976536512724 0.0072053933079800105 0.007153355247789401 0.007101854884650756 0.007050884875468021 0.007000438002690235 0.006950507171726536 0.006901085408423487 0.0068521658566029235 0.00680374177565868 0.006755806538210638 0.00670835362781445 0.006661376636725494 0.006614869263715545 0.006568825311940773 0.006523238686859659 0.006478103394199519 0.00643341353797031 0.006389163318524493 0.006345347030661674 0.006301959061776923 0.006258993890051541 0.006216446082685201 0.006174310294168379 0.006132581264594002 0.006091253818007324 0.006050322860793015 0.006009783380098516 0.005969630442292715 0.005929859191459044 0.005890464847922127 0.005851442706807108 0.005812788136630825 0.005774496577924054 0.0057365635418840065 0.005698984609056323 0.005661755428045855 0.005624871714255466 0.005588329248652202 0.00555212387656011 0.00551625150647909 0.005480708108929085 0.005445489715319027 0.005410592416839934 0.005376012363381511 0.005341745762471777 0.005307788878239055 0.005274138030395878 0.005240789593244206 0.005207739994701484 0.005174985715347048 0.00514252328748834 0.0051103492942465335 0.00507846036866104 0.005046853192812496 0.005015524496963772 0.004984471058718581 0.004953689702197287 0.004923177297229492 0.004892930758563013 0.004862947045088895 0.00483322315908204 0.004803756145457148 0.004774543091039549 0.004745581123850657 0.004716867412407661 0.00468839916503713 0.0046601736292022486 0.0046321880908433465 0.004604439873731403 0.004576926338834309 0.004549644883695479 0.004522592941824669 0.004495767982100623 0.004469167508185333 0.0044427890579496485 0.004416630202909982 0.004390688547675851 0.0043649617294080414 0.004339447417287141 0.004314143311992225 0.004289047145189457 0.004264156679030417 0.004239469705659914 0.004214984046733089 0.004190697552941636 0.004166608103548871 0.004142713605933558 0.0041190119951422105 0.004095501233449754 0.004072179309928335 0.004049044240024113 0.00402609406514188 0.0040033268522373065 0.003980740693416701 0.003958333705544083 0.003936104029855439 0.003914049831580005 0.00389216929956843 0.0038704606459276673 0.0038489221056624864 0.0038275519363234057 0.0038063484176610045 0.0037853098512863797 0.0037644345603377117 0.003743720889152753 0.0037231672029471473 0.0037027718874984646 0.003682533348835807 0.003662450012934904 0.0036425203254185677 0.0036227427512624116 0.0036031157745057122 0.0035836378979673274 0.0035643076429665577 0.003545123549048859 0.003526084173716304 0.0035071880921627076 0.0034884338970133143 0.003469820198068963 0.003451345622054631 0.0034330088123723 0.0034148084288580156 0.0033967431475431025 0.003378811660419416 0.0033610126752085757 0.003343344915135106 0.0033258071187033914 0.003308398039478379 0.0032911164458699605 0.0032739611209209613 0.003256930862098669 0.003240024481089833 0.0032232408035990524 0.0032065786691505274 0.0031900369308930617 0.003173614455408303 0.003157310122522117 0.003141122825119058 0.0031250514689598863 0.0031090949725020548 0.0030932522667231213 0.0030775222949470248 0.0030619040126731874 0.00304639638740837 0.0030309983985012424 0.0030157090369796156 0.0030005273053902853 0.0029854522176414487 0.0029704827988476226 0.002955618085177044 0.0029408571237015046 0.002926198972248548 0.0029116426992560223 0.002897187383628925 0.0028828321145984944 0.002868575991583535 0.0028544181240538983 0.0028403576313961038 0.0028263936427810736 0.002812525297033898 0.002798751742505652 0.002785072136947181 0.002771485647384849 0.002757991449998198 0.0027445887299994884 0.002731276681515108 0.0027180545074687724 0.002704921419466526 0.0026918766376835047 0.0026789193907524054 0.002666048915653661 0.002653264457607278 0.0026405652699663085 0.0026279506141119323 0.002615419759350109 0.002602971982809802 0.002590606569342705 0.0025783228114244863 0.002566120009057498 0.0025539974696749362 0.002541954508046423 0.0025299904461849945 0.002518104613255459 0.0025062963454841112 0.0024945649860697674 0.002482909885096129 0.002471330399445408 0.002459825892713231 0.0024483957351247843 0.0024370393034521673 0.0024257559809329776 0.0024145451571900424 0.0024034062281523363 0.0023923385959770363 0.0023813416689726897 0.0023704148615235074 0.0023595575940147245 0.002348769292759045 0.0023380493899241316 0.002327397323461124 0.0023168125370341907 0.0023062944799510706 0.0022958426070945996 0.002285456378855209 0.002275135261064376 0.0022648787249290167 0.00225468624696679 0.0022445573089423265 0.002234491397804333 0.002224488005623584 0.002214546629531785 0.0022046667716612766 0.0021948479390855764 0.0021850896437607533 0.002175391402467601 0.00216575273675463 0.002156173172881817 0.002146652241765154 0.002137189478921943 0.0021277844244168417 0.0021184366228086575 0.0021091456230978526 0.002099910978674771 0.0020907322472685764 0.002081608990896862 0.0020725407758159678 0.002063527172471946 0.002054567755452209 0.0020456621034378054 0.0020368097991563566 0.0020280104293356124 0.0020192635846576325 0.002010568859713578 0.002001925852959109 0.0019933341666703657 0.0019847934069005487 0.0019763031834370607 0.0019678631097592198 0.0019594728029965376 0.001951131883887533 0.0019428399767391035 0.0019345967093864107 0.0019264017131533121 0.0019182546228132965 0.0019101550765509257 0.001902102715923797 0.0018940971858249763 0.0018861381344459389 0.001878225213239978 0.0018703580768860853 0.0018625363832533114 0.001854759793365569 0.0018470279713668951 0.0018393405844871625 0.0018316973030082207 0.001824097800230482 0.001816541752439922 0.0018090288388755093 0.001801558741697042 0.0017941311459533974 0.0017867457395511833 0.0017794022132237792 0.001772100260500781 0.0017648395776778143 0.0017576198637867398 0.001750440820566231 0.0017433021524327077 0.0017362035664516562 0.0017291447723092824 0.0017221254822845351 0.001715145411221473 0.0017082042765019687 0.0017013017980187601 0.001694437698148827 0.0016876117017271032 0.0016808235360205068 0.0016740729307022943 0.0016673596178267273 0.0016606833318040487 0.00165404380937577 0.0016474407895902539 0.0016408740137785999 0.0016343432255308194 0.0016278481706723073 0.0016213885972405867 0.001614964255462347 0.0016085748977307558 0.0016022202785830398 0.0015959001546783438 0.0015896142847758486 0.0015833624297131568 0.0015771443523849339 0.0015709598177218096 0.0015648085926695241 0.0015586904461683275 0.0015526051491326267 0.0015465524744308686 0.0015405321968656649 0.0015345440931541518 0.0015285879419085796 0.0015226635236171373 0.0015167706206249967 0.0015109090171155815 0.0015050784990920593 0.0014992788543590424 0.0014935098725045147 0.0014877713448819582 0.0014820630645926956 0.001476384826468435 0.001470736427054015 0.0014651176645903584 0.001459528338997614 0.0014539682518584988 0.0014484372064018313 0.0014429350074862534 0.0014374614615841397 0.0014320163767656952 0.0014265995626832298 0.0014212108305556163 0.0014158499931529276 0.0014105168647812415 0.001405211261267631 0.0013999329999453127 0.0013946818996389714 0.00138945778065025 0.0013842604647434015 0.0013790897751311058 0.0013739455364604437 0.0013688275747990306 0.0013637357176213062 0.0013586697937949764 0.0013536296335676134 0.0013486150685533922 0.001343625931719992 0.0013386620573756314 0.0013337232811562532 0.0013288094400128523 0.001323920372198939 0.0013190559172581483 0.0013142159160119838 0.00130940021054769 0.0013046086442062741 0.0012998410615706409 0.0012950973084538753 0.001290377231887638 0.0012856806801107034 0.0012810075025576097 0.0012763575498474442 0.0012717306737727416 0.0012671267272885073 0.0012625455645013633 0.0012579870406588078 0.0012534510121385894 0.0012489373364382025 0.0012444458721644904 0.0012399764790233653 0.0012355290178096361 0.0012311033503969446 0.0012266993397278163 0.0012223168498038078 0.0012179557456757678 0.0012136158934342022 0.0012092971601997337 0.0012049994141136728 0.0012007225243286857 0.0011964663609995603 0.0011922307952740682 0.0011880156992839295 0.001183820946135869 0.0011796464099027672 0.0011754919656149067 0.0011713574892513055 0.0011672428577311515 0.0011631479489053148 0.0011590726415479564 0.001155016815348226 0.0011509803509020418 0.001146963129703958 0.0011429650341391164 0.0011389859474752843 0.001135025753854972 0.0011310843382876367 0.0011271615866419579 0.0011232573856382062 0.0011193716228406756 0.0011155041866502085 0.0011116549662967877 0.0011078238518322087 0.0011040107341228254 0.001100215504842374 0.001096438056464862 0.0010926782822575432 0.0010889360762739492 0.001085211333347007 0.0010815039490822114 0.0010778138198508792 0.001074140842783467 0.0010704849157629577 0.0010668459374183082 0.0010632238071179747 0.0010596184249634932 0.001056029691783129 0.0010524575091255927 0.0010489017792538102 0.0010453624051387676 0.0010418392904534045 0.0010383323395665859 0.0010348414575371116 0.0010313665501078052 0.0010279075236996533 0.001024464285406001 0.0010210367429868133 0.0010176248048629829 0.0010142283801107027 0.0010108473784558908 0.0010074817102686717 0.0010041312865579097 0.0010007960189657946 9.974758197624923E-4 9.94170601840828E-4 9.90880278711045E-4 9.876047644955905E-4 9.843439739239753E-4 9.81097822327664E-4 9.778662256350326E-4 9.746491003663578E-4 9.714463636288728E-4 9.682579331118562E-4 9.650837270817761E-4 9.619236643774814E-4 9.587776644054366E-4 9.556456471350042E-4 9.525275330937729E-4 9.494232433629306E-4 9.463326995726818E-4 9.432558238977084E-4 9.401925390526734E-4 9.371427682877728E-4 9.341064353843241E-4
diff --git a/BXNL/simple_BXNL/data/w.d b/BXNL/simple_BXNL/data/w.d
new file mode 100644
index 0000000..c262f99
--- /dev/null
+++ b/BXNL/simple_BXNL/data/w.d
@@ -0,0 +1 @@
+0.01651654089859292 0.033885519822851005 0.0460292011261212 0.054354231687859605 0.060056195367166124 0.06393434543546166 0.06651852928015564 0.06816738228481138 0.06912961740129728 0.06958164708721326 0.06965110074761934 0.06943190405374727 0.06899419871807014 0.06839102547610146 0.06766292458564373 0.06684116461347672 0.06595004807348678 0.06500858358574826 0.06403171561180945 0.0630312402360109 0.06201649491390223 0.06099488333353729 0.059972278543803596 0.05895333521905617 0.0579417334163844 0.05694037020192796 0.055951511268971015 0.054976911609375366 0.05401791207304921 0.053075517013871046 0.052150457006880424 0.051243239713545045 0.05035419128699317 0.04948349018849407 0.0486311948879077 0.0477972666136353 0.04698158807933175 0.04618397892871726 0.04540420849393061 0.044642006347768944 0.04389707103890007 0.0431690773264307 0.04245768217203081 0.04176252970105323 0.04108325530635183 0.04041948903793305 0.03977085839672116 0.03913699063043989 0.03851751461301407 0.037912062375264774 0.037320270343446184 0.036741780332901125 0.03617624033643413 0.03562330514062697 0.035082636798016376 0.03455390497862845 0.03403678722066548 0.03353096909704191 0.03303614431186612 0.032552014738777967 0.0320782904112107 0.031614689473092886 0.031160938097193256 0.030716770377202066 0.030281928198701926 0.02985616109338416 0.02943922608019015 0.02903088749648202 0.02863091682185863 0.028239092496816613 0.027855199738102538 0.027479030352300662 0.02711038254894393 0.02674906075421719 0.02639487542613532 0.026047642871920035 0.025707185068164242 0.025373329484257853 0.02504590890945118 0.024724761283849102 0.02440972953355912 0.024100661410156463 0.023797409334579706 0.02349983024552757 0.023207785452392354 0.022921140492735855 0.022639764994288436 0.02236353254143217 0.022092320546111644 0.021826010123102608 0.02156448596955771 0.021307636248739662 0.021055352477845637 0.020807529419821377 0.020564064979059896 0.02032486010087705 0.02008981867465482 0.019858847440542227 0.01963185589960409 0.0194087562273081 0.01918946319024207 0.018973894065954407 0.0187619685658128 0.018553608760778086 0.018348739009992444 0.018147285892083646 0.017949178139089323 0.017754346572908034 0.017562724044186514 0.017374245373554857 0.017188847295124612 0.017006468402166974 0.016827049094890925 0.0166505315302442 0.016476859573661833 0.016305978752690242 0.01613783621241668 0.01597238067263664 0.015809562386693916 0.015649333101930226 0.01549164602168369 0.015336455768777268 0.015183718350440386 0.015033391124609049 0.014885432767551237 0.014739803242766619 0.014596463771110901 0.014455376802097073 0.014316505986327157 0.014179816149009698 0.014045273264519613 0.013912844431958334 0.013782497851673514 0.013654202802698795 0.013527929621075256 0.013403649679017379 0.013281335364887254 0.013160960063941915 0.013042498139819572 0.012925924916731321 0.012811216662325943 0.01269835057119608 0.012587304748994829 0.012478058197132564 0.012370590798024524 0.012264883300860183 0.012160917307866214 0.012058675261035285 0.011958140429293558 0.011859296896080245 0.011762129547313004 0.011666624059713518 0.011572766889467978 0.011480545261197555 0.01138994715721442 0.011300961307039207 0.011213577177156143 0.011127784960982448 0.011043575569028895 0.010960940619228768 0.010879872427412684 0.010800363997907172 0.010722409014235008 0.010646001829895755 0.010571137459205055 0.010497811568171686 0.010426020465391463 0.010355761092937489 0.010287031017226422 0.01021982841984076 0.010154152088287396 0.010090001406672927 0.010027376346276604 0.009966277456001966 0.009906705852688578 0.009848663211265615 0.0097921517547293 0.009737174243926559 0.009683733967127649 0.009631834729370806 0.009581480841562386 0.009532677109316318 0.00948542882151716 0.009439741738591438 0.009395622080472366 0.009353076514243603 0.00931211214144808 0.009272736485048526 0.009234957476026803 0.009198783439609715 0.009164223081109578 0.00913128547136837 0.009099980031794942 0.009070316518985405 0.009042305008917513 0.009015955880710472 0.008991279799942466 0.00896828770151872 0.008946990772083998 0.008927400431973879 0.008909528316700275 0.008893386257967309 0.008878986264214605 0.008866340500685991 0.008855461269022358 0.008846360986378617 0.008839052164065385 0.008833547385717216 0.008829859284990105 0.008828000522791996 0.008827983764051184 0.008829821654028396 0.00883352679417955 0.008839111717577243 0.008846588863900079 0.008855970554000149 0.008867268964060062 0.008880496099352035 0.008895663767612836 0.00891278355204934 0.008931866783990813 0.008952924515205053 0.008975967489896815 0.009001006116408007 0.009028050438640406 0.009057110107222736 0.009088194350445153 0.009121311944985291 0.009156471186451237 0.009193679859767821 0.009232945209433793 0.00927427390967855 0.009317672034548124 0.009363145027951148 0.009410697673696709 0.009460334065556734 0.009512057577386792 0.00956587083333994 0.009621775678209203 0.009679773147935219 0.009739863440316219 0.009802045885958505 0.0098663189195062 0.009932680051189672 0.010001125838732925 0.010071651859660503 0.010144252684045266 0.010218921847738713 0.010295651826126 0.01037443400844816 0.01045525867273428 0.010538114961386723 0.010622990857462463 0.010709873161693913 0.010798747470292469 0.010889598153577998 0.010982408335477442 0.011077159873935396 0.011173833342279305 0.011272408011581563 0.011372861834060355 0.011475171427560573 0.011579312061155537 0.011685257641909561 0.011792980702840718 0.01190245239212218 0.01201364246355973 0.01212651926838202 0.012241049748378871 0.01235719943042208 0.012474932422401627 0.012594211410609044 0.012714997658598251 0.012837251007552605 0.012960929878185454 0.013085991274199769 0.013212390787330757 0.013340082603993553 0.013469019513556169 0.01359915291825611 0.013730432844776905 0.013862807957498804 0.013996225573435921 0.01413063167886952 0.014265970947685563 0.014402186761421553 0.014539221231026175 0.014677015220332254 0.014815508371241428 0.014954639130616428 0.015094344778874322 0.015234561460271637 0.015375224214869643 0.015516267012165536 0.015657622786372796 0.015799223473331174 0.015941000049024358 0.016082882569680747 0.01622480021342992 0.01636668132348523 0.01650845345281982 0.016650043410301338 0.016791377308247715 0.016932380611363828 0.017072978187016787 0.017213094356804556 0.017352652949370717 0.01749157735441548 0.017629790577850902 0.017767215298045903 0.01790377392310467 0.018039388649119546 0.01817398151933795 0.018307474484180283 0.018439789462044498 0.01857084840083059 0.018700573340117065 0.01882888647391939 0.01895571021395908 0.019080967253370655 0.019204580630772235 0.019326473794624432 0.019446570667800936 0.01956479571229341 0.019681073993972054 0.019795331247322877 0.019907493940081667 0.020017489337684394 0.020125245567453168 0.020230691682436807 0.020333757724824823 0.020434374788853536 0.02053247508312339 0.020627991992246568 0.020720860137744407 0.02081101543811492 0.020898395167990923 0.02098293801631048 0.02106458414342207 0.02114327523704791 0.021218954567030254 0.021291567038786596 0.02136105924540122 0.02142737951828214 0.021490477976314128 0.021550306573440304 0.021606819144606777 0.021659971450006824 0.02170972121756318 0.02175602818358943 0.021798854131573748 0.021838162929030742 0.02187392056236967 0.0219060951697301 0.021934657071738646 0.02195957880014345 0.021980835124285718 0.021998403075370952 0.02201226196850523 0.022022393422465234 0.02202878137717377 0.02203141210885584 0.0220302742428535 0.02202535876408106 0.02201665902510568 0.022004170751841468 0.021987892046848895 0.021967823390234616 0.02194396763815002 0.021916330018890713 0.02188491812660193 0.021849741912598888 0.021810813674313992 0.021768148041886475 0.021721761962413242 0.021671674681883024 0.021617907724819262 0.021560484871660256 0.02149943213390831 0.021434777727082858 0.021366552041515267 0.021294787611026357 0.021219519079530354 0.021140783165611746 0.021058618625124637 0.02097306621186623 0.020884168636379288 0.020791970522940285 0.020696518364792752 0.020597860477687413 0.020496046951792666 0.02039112960204138 0.02028316191698151 0.020172199006200063 0.02005829754639159 0.01994151572614375 0.019821913189514165 0.019699550978473913 0.019574491474294194 0.01944679833795386 0.019316536449646135 0.01918377184746395 0.019048571665343673 0.018911004070347678 0.018771138199366544 0.0186290440953218 0.018484792642950394 0.018338455504251946 0.01819010505367954 0.018039814313155034 0.017887656886988623 0.017733706896782643 0.01757803891639851 0.017420727907064854 0.0172618491527044 0.017101478195555526 0.016939690772163882 0.016776562749817776 0.016612170063499843 0.01644658865342617 0.01627989440324216 0.0161121630789431 0.01594347026858545 0.01577389132285305 0.015603501296540747 0.015432374891015453 0.01526058639771312 0.015088209642727654 0.014915317932545556 0.01474198400097813 0.014568279957340292 0.014394277235923065 0.014220046546804177 0.014045657828038778 0.01387118019926996 0.013696681916795794 0.013522230330127602 0.013347891840071178 0.013173731858360276 0.012999814768869094 0.012826203890427702 0.01265296144126199 0.012480148505076913 0.012307824998799278 0.012136049641993869 0.011964879927963794 0.01179437209654379 0.011624581108592463 0.011455560622186911 0.011287362970521056 0.011120039141506057 0.010953638759069316 0.010788210066145979 0.010623799909354527 0.010460453725346127 0.010298215528814726 0.010137127902153332 0.009977231986739396 0.009818567475830478 0.009661172609049497 0.009505084168436677 0.009350337476043934 0.009196966393045493 0.00904500332033683 0.00889447920059283 0.008745423521753993 0.008597864321908677 0.008451828195537728 0.008307340301086567 0.008164424369828966 0.008023102715985189 0.007883396248056552 0.007745324481337404 0.007608905551564564 0.0074741562296638505 0.007341091937552116 0.007209726764953187 0.0070800734871851526 0.006952143583876214 0.006825947258566026 0.006701493459148859 0.006578789899115083 0.006457843079547113 0.006338658311825918 0.006221239741004393 0.006105590369803653 0.005991712083188785 0.005879605673480637 0.005769270865960494 0.005660706344925017 0.005553909780148934 0.005448877853713741 0.005345606287160978 0.0052440898689292935 0.005144322482035221 0.0050462971319580364 0.00495000597469004 0.004855440344914237 0.004762590784272146 0.004671447069685503 0.004581998241696248 0.004494232632790332 0.00440813789567166 0.004323701031453543 0.004240908417736054 0.004159745836538565 0.004080198502057975 0.0040022510882240635 0.003925887756024495 0.003851092180573254 0.003777847577897085 0.0037061367314159496 0.003635942018094404 0.003567245434242032 0.0035000286209422174 0.003434272889089534 0.0033699592440172973 0.0033070684096979048 0.0032455808524996183 0.003185476804484756 0.0031267362862350857 0.003069339129191549 0.003013264997496386 0.0029584934093268116 0.002905003757710503 0.0028527753308140898 0.002801787331696936 0.0027520188975234516 0.0027034491182281488 0.0026560570546286383 0.002609821755982622 0.0025647222769859205 0.0025207376942093943 0.002477847121973494 0.0024360297276600305 0.002395264746461475 0.0023555314955689714 0.0023168093878009237 0.002279077944674755 0.0022423168089251563 0.0022065057564727352 0.002171624707847674 0.0021376537390735907 0.0021045730920173254 0.002072363184211009 0.0020410046181531883 0.0020104781900963293 0.0019807648983284788 0.0019518459509572424 0.0019237027732047108 0.0018963170142222696 0.0018696705534346106 0.0018437455064225835 0.0018185242303547801 0.0017939893289780687 0.0017701236571774533 0.0017469103251159285 0.0017243327019651194 0.0017023744192376984 0.001681019373732716 0.001660251730105053 0.0016400559230703438 0.0016204166592567767 0.0016013189187152157 0.0015827479560991467 0.0015646893015259296 0.0015471287611308574 0.0015300524173254945 0.0015134466287717008 0.001497298030082732 0.0014815935312626899 0.001466320316895522 0.0014514658450946894 0.0014370178462244601 0.0014229643214036989 0.0014092935408028437 0.0013959940417446446 0.0013830546266190456 0.0013704643606224298 0.0013582125693312758 0.0013462888361200542 0.001334682999433034 0.0013233851499194224 0.0013123856274410825 0.0013016750179618455 0.0012912441503271977 0.0012810840929429175 0.0012711861503609965 0.0012615418597809464 0.001252142987474358 0.0012429815251403392 0.0012340496861992108 0.0012253399020316288 0.001216844818170002 0.0012085572904489068 0.0012004703811208867 0.0011925773549438324 0.0011848716752458752 0.001177346999973501 0.0011699971777283371 0.0011628162437978561 0.0011557984161849758 0.001148938091641345 0.0011422298417088272 0.0011356684087735348 0.0011292487021364848 0.0011229657941047755 0.0011168149161069436 0.0011107914548359832 0.00110489094842327 0.0010991090826464637 0.0010934416871742605 0.0010878847318506572 0.0010824343230212501 0.001077086699903856 0.0010718382310056281 0.0010666854105886004 0.00106162485518551 0.001056653300167522 0.0010517675963653559 0.0010469647067451763 0.0010422417031404313 0.0010375957630407253 0.0010330241664386502 0.0010285242927353883 0.0010240936177057629 0.0010197297105233132 0.0010154302308458564 0.0010111929259618581 0.0010070156279978998 0.0010028962511873449 9.988327892003102E-4 9.948233125348681E-4 9.908659659694E-4 9.869589660758836E-4 9.831005987938706E-4 9.792892170647955E-4 9.75523238526232E-4 9.718011432656267E-4 9.681214716329885E-4 9.644828221119612E-4 9.608838492486552E-4 9.573232616375689E-4 9.537998199638844E-4 9.503123351013879E-4 9.468596662652247E-4 9.43440719218676E-4 9.400544445330948E-4
diff --git a/BXNL/simple_BXNL/data/x.d b/BXNL/simple_BXNL/data/x.d
new file mode 100644
index 0000000..176b53c
--- /dev/null
+++ b/BXNL/simple_BXNL/data/x.d
@@ -0,0 +1 @@
+2.0204270547382075 1.3972604937797 0.693255185390483 36.59294402449946 7.018075183201494 0.3368769824829059
diff --git a/BXNL/simple_BXNL/generate_img.py b/BXNL/simple_BXNL/generate_img.py
new file mode 100644
index 0000000..ac943f4
--- /dev/null
+++ b/BXNL/simple_BXNL/generate_img.py
@@ -0,0 +1,75 @@
+import numpy as np
+import matplotlib.pyplot as plt
+from pathlib import Path
+
+# Set the print precision
+np.set_printoptions(precision=4, suppress=True)
+
+# Set the data folder path
+data_folder = Path("data")
+
+def read_matrix_file(fname):
+ with open(data_folder / fname) as fdata:
+ a = np.array([line.split() for line in fdata], dtype = np.float64)
+ return a
+
+# Figure 2
+diameter = read_matrix_file("diameter.d")[0]
+density = read_matrix_file("density.d")[0]
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.set_title('PADC etch track diameter histogram', fontsize=16)
+ax.set_xlabel('Diameter (nm)')
+ax.set_ylabel('Density')
+ax.set_xlim(xmin=1, xmax=65)
+ax.bar(diameter, density, color='lightsteelblue')
+ax.grid()
+plt.savefig("./img/fig2.png")
+plt.clf()
+
+# Figure 3
+
+dh = read_matrix_file("dh.d")[0]
+lopt = read_matrix_file("lopt.d")[0]
+gopt = read_matrix_file("gopt.d")[0]
+w = read_matrix_file("w.d")[0]
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.set_title('PADC etch track diameter histogram and fit', fontsize=16)
+ax.set_xlabel('Diameter (nm)')
+ax.set_ylabel('Density')
+ax.set_xlim(xmin=1, xmax=65)
+ax.bar(diameter, density, color='lightsteelblue')
+ax.plot(dh, w, '-', linewidth=3, color='tab:green')
+ax.grid()
+ax.legend(['Aggregated', 'Measured track diameter density'])
+plt.savefig("./img/fig3.png")
+plt.clf()
+
+# Figure 4
+x = read_matrix_file("x.d")[0]
+aopt = x[0]
+bopt = x[1]
+Alopt = x[2]
+muopt = x[3]
+sigmaopt = x[4]
+Agopt = x[5]
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+ax.set_title('PADC etch track diameter histogram unfolding', fontsize=16)
+ax.set_xlabel('Diameter (nm)')
+ax.set_ylabel('Density')
+ax.set_xlim(xmin=1, xmax=65)
+ax.bar(diameter, density, color='lightsteelblue')
+ax.plot(dh, lopt, '-', linewidth=4, color='tab:red')
+ax.plot(dh, gopt, '-', linewidth=4, color='tab:blue')
+ax.plot(dh, w, '-', linewidth=3, color='tab:green')
+ax.grid()
+glab = 'Unfolded Normal($\\mu=%1.2f$, $\\sigma=%1.2f, A=%1.2f$)' % (muopt, sigmaopt, Agopt)
+llab = 'Unfolded log-Normal($a=%1.2f$, $b=%1.2f, A=%1.2f$)' % (aopt, bopt, Alopt)
+ax.legend([llab, glab, 'Aggregated', 'Measured track diameter density'])
+plt.savefig("./img/fig4.png")
+plt.clf()
diff --git a/BXNL/simple_BXNL/img/fig2.png b/BXNL/simple_BXNL/img/fig2.png
new file mode 100644
index 0000000..93e1899
Binary files /dev/null and b/BXNL/simple_BXNL/img/fig2.png differ
diff --git a/BXNL/simple_BXNL/img/fig3.png b/BXNL/simple_BXNL/img/fig3.png
new file mode 100644
index 0000000..9947dcc
Binary files /dev/null and b/BXNL/simple_BXNL/img/fig3.png differ
diff --git a/BXNL/simple_BXNL/img/fig4.png b/BXNL/simple_BXNL/img/fig4.png
new file mode 100644
index 0000000..5b465c9
Binary files /dev/null and b/BXNL/simple_BXNL/img/fig4.png differ
diff --git a/BXNL/simple_BXNL/output.txt b/BXNL/simple_BXNL/output.txt
new file mode 100644
index 0000000..fac1386
Binary files /dev/null and b/BXNL/simple_BXNL/output.txt differ
diff --git a/BXNL/simple_BXNL/source/SimpleBXNL.java b/BXNL/simple_BXNL/source/SimpleBXNL.java
new file mode 100644
index 0000000..5450d5f
--- /dev/null
+++ b/BXNL/simple_BXNL/source/SimpleBXNL.java
@@ -0,0 +1,301 @@
+import com.nag.routines.E04.E04RA;
+import com.nag.routines.E04.E04RM;
+import com.nag.routines.E04.E04RH;
+import com.nag.routines.E04.E04RX;
+import com.nag.routines.E04.E04ZM;
+import com.nag.routines.E04.E04RZ;
+import com.nag.routines.E04.E04GG;
+import com.nag.routines.E04.E04GGU;
+import com.nag.routines.E04.E04GGV;
+import com.nag.routines.E04.E04FFU;
+
+import java.lang.Math;
+import java.util.Arrays;
+import java.io.File;
+import java.io.IOException;
+import java.io.FileWriter;
+
+public class SimpleBXNL {
+
+ public final static String dataFolder = ".." + File.separator + "data";
+
+ public static void main(String[] args) {
+
+ int i;
+
+ // problem data
+ // number of observations
+ int nres = 64;
+ // ovservations
+ int[] diameter = new int[nres];
+ for (i = 0; i < nres; i++) {
+ diameter[i] = i + 1;
+ }
+ double[] density = new double[] { 0.0722713864, 0.0575221239, 0.0604719764, 0.0405604720, 0.0317109145,
+ 0.0309734513, 0.0258112094, 0.0228613569, 0.0213864307, 0.0213864307, 0.0147492625, 0.0213864307,
+ 0.0243362832, 0.0169616519, 0.0095870206, 0.0147492625, 0.0140117994, 0.0132743363, 0.0147492625,
+ 0.0140117994, 0.0140117994, 0.0132743363, 0.0117994100, 0.0132743363, 0.0110619469, 0.0103244838,
+ 0.0117994100, 0.0117994100, 0.0147492625, 0.0110619469, 0.0132743363, 0.0206489676, 0.0169616519,
+ 0.0169616519, 0.0280235988, 0.0221238938, 0.0235988201, 0.0221238938, 0.0206489676, 0.0228613569,
+ 0.0184365782, 0.0176991150, 0.0132743363, 0.0132743363, 0.0088495575, 0.0095870206, 0.0073746313,
+ 0.0110619469, 0.0036873156, 0.0051622419, 0.0058997050, 0.0014749263, 0.0022123894, 0.0029498525,
+ 0.0014749263, 0.0007374631, 0.0014749263, 0.0014749263, 0.0007374631, 0.0000000000, 0.0000000000,
+ 0.0000000000, 0.0000000000, 0.0000000000 };
+
+ // Define iuser and ruser to be passed to the callback functions
+ int[] iuser = diameter;
+ double[] ruser = density;
+
+ // Print data to files for creating the figures in the doc
+ printVectorToFile(diameter, "diameter.d");
+ printVectorToFile(density, "density.d");
+
+ // parameter vector: x = (a, b, Al, mu, sigma, Ag)
+ int nvar = 6;
+
+ // Initialize the model handle
+ E04RA e04ra = new E04RA();
+ long handle = 0;
+ int ifail = 0;
+ e04ra.eval(handle, nvar, ifail);
+
+ handle = e04ra.getHANDLE();
+
+ // Define a dense nonlinear least-squares objective function
+ E04RM e04rm = new E04RM();
+ ifail = 0;
+ e04rm.eval(handle, nres, 0, 0, new int[] {}, new int[] {}, ifail);
+
+ // Add weights for each residual
+ double[] weights = new double[nres];
+ Arrays.fill(weights, 1.0);
+ for (i = 55; i < 63; i++) {
+ weights[i] = 5.0;
+ }
+ double weights_sum = Arrays.stream(weights).sum();
+ for (i = 0; i < weights.length; i++) {
+ weights[i] /= weights_sum;
+ }
+
+ // Define the reliability of the measurements (weights)
+ E04RX e04rx = new E04RX();
+ ifail = 0;
+ e04rx.eval(handle, "RW", 0, weights.length, weights, ifail);
+
+ // Restrict parameter space (0 <= x)
+ E04RH e04rh = new E04RH();
+ double[] bl = new double[nvar];
+ double[] bu = new double[nvar];
+ Arrays.fill(bu, 100.0);
+ ifail = 0;
+ e04rh.eval(handle, nvar, bl, bu, ifail);
+
+ // Set some optional parameters to control the output of the solver
+ E04ZM e04zm = new E04ZM();
+ ifail = 0;
+
+ e04zm.eval(handle, "Print Options = NO", ifail);
+ e04zm.eval(handle, "Print Level = 1", ifail);
+ e04zm.eval(handle, "Print Solution = X", ifail);
+ e04zm.eval(handle, "Bxnl Iteration Limit = 100", ifail);
+ // Add cubic regularization term (avoid overfitting)
+ e04zm.eval(handle, "Bxnl Use weights = YES", ifail);
+ e04zm.eval(handle, "Bxnl Reg Order = 3", ifail);
+ e04zm.eval(handle, "Bxnl Glob Method = REG", ifail);
+
+ // Define initial guess (starting point)
+ double[] x = new double[] { 1.63, 0.88, 1.0, 30, 1.52, 0.24 };
+
+ // Call the solver
+ E04GG e04gg = new E04GG();
+ LSQFUN lsqfun = new LSQFUN();
+ LSQGRD lsqgrd = new LSQGRD();
+ LSQHES lsqhes = new LSQHES();
+ LSQHPRD lsqhprd = new LSQHPRD();
+ MONIT monit = new MONIT();
+ double[] rx = new double[nres];
+ double[] rinfo = new double[100];
+ double[] stats = new double[100];
+ long cpuser = 0;
+ ifail = 0;
+
+ e04gg.eval(handle, lsqfun, lsqgrd, lsqhes, lsqhprd, monit, nvar, x, nres, rx, rinfo, stats, iuser, ruser,
+ cpuser, ifail);
+
+ System.out.println();
+
+ // Optimal parameter values
+ // Al * log-Normal(a, b):
+ double aopt = x[0];
+ double bopt = x[1];
+ double Alopt = x[2];
+
+ // Ag * gaussian(mu, sigma):
+ double muopt = x[3];
+ double sigmaopt = x[4];
+ double Agopt = x[5];
+
+ // objective function value
+ System.out.println("Objective Function Value: " + rinfo[0]);
+
+ // Print data to files for creating the figures in the doc
+ double[] dh = new double[10 * nres + 8];
+ for (i = 0; i < dh.length; i++) {
+ dh[i] = (i + 1) / 10.0;
+ }
+ double[] lopt = lognormal(dh, aopt, bopt, Alopt);
+ double[] gopt = gaussian(dh, muopt, sigmaopt, Agopt);
+ double[] w = new double[lopt.length];
+ for (i = 0; i < w.length; i++) {
+ w[i] = lopt[i] + gopt[i];
+ }
+ printVectorToFile(dh, "dh.d");
+ printVectorToFile(lopt, "lopt.d");
+ printVectorToFile(gopt, "gopt.d");
+ printVectorToFile(w, "w.d");
+ printVectorToFile(x, "x.d");
+
+ // Destroy the handle:
+ E04RZ e04rz = new E04RZ();
+ ifail = 0;
+ e04rz.eval(handle, ifail);
+ }
+
+ // Define Normal and log-Normal distributions
+ public static double lognormal(int d, double a, double b, double Al) {
+ return Al / (d * b * Math.sqrt(2 * Math.PI)) * Math.exp(-(Math.pow(Math.log(d) - a, 2)) / (2 * Math.pow(b, 2)));
+ }
+
+ public static double gaussian(int d, double mu, double sigma, double Ag) {
+ return Ag * Math.exp(-0.5 * Math.pow((d - mu) / sigma, 2)) / (sigma * Math.sqrt(2 * Math.PI));
+ }
+
+ public static double[] lognormal(double[] d, double a, double b, double Al) {
+ double[] result = new double[d.length];
+ for (int i = 0; i < d.length; i++) {
+ result[i] = Al / (d[i] * b * Math.sqrt(2 * Math.PI)) * Math.exp(-(Math.pow(Math.log(d[i]) - a, 2)) / (2 * Math.pow(b, 2)));
+ }
+ return result;
+ }
+
+ public static double[] gaussian(double[] d, double mu, double sigma, double Ag) {
+ double[] result = new double[d.length];
+ for (int i = 0; i < d.length; i++) {
+ result[i] = Ag * Math.exp(-0.5 * Math.pow((d[i] - mu) / sigma, 2)) / (sigma * Math.sqrt(2 * Math.PI));
+ }
+ return result;
+ }
+
+ // Define the least-square function as a mixture of Normal and log-Normal
+ // functions. Also add its first derivatives
+
+ /**
+ * Objective function callback passed to the least squares solver. x = (a, b,
+ * Al, mu, sigma, Ag)
+ */
+ public static class LSQFUN extends E04GG.Abstract_E04GG_LSQFUN {
+ public void eval() {
+ int[] d = this.IUSER;
+ double[] y = this.RUSER;
+ double a = this.X[0];
+ double b = this.X[1];
+ double Al = this.X[2];
+ double mu = this.X[3];
+ double sigma = this.X[4];
+ double Ag = this.X[5];
+
+ for (int i = 0; i < this.NRES; i++) {
+ this.RX[i] = lognormal(d[i], a, b, Al) + gaussian(d[i], mu, sigma, Ag) - y[i];
+ }
+ }
+ }
+
+ /**
+ * Computes the Jacobian of the least square residuals. x = (a, b, Al, mu,
+ * sigma, Ag)
+ */
+ public static class LSQGRD extends E04GG.Abstract_E04GG_LSQGRD {
+ public void eval() {
+ int n = this.X.length;
+ int[] d = this.IUSER;
+ double a = this.X[0];
+ double b = this.X[1];
+ double Al = this.X[2];
+ double mu = this.X[3];
+ double sigma = this.X[4];
+ double Ag = this.X[5];
+ for (int i = 0; i < this.NRES; i++) {
+ // log-Normal derivatives
+ double l = lognormal(d[i], a, b, Al);
+ // dl/da
+ this.RDX[i * n + 0] = (Math.log(d[i]) - a) / Math.pow(b, 2) * l;
+ // dl/db
+ this.RDX[i * n + 1] = (Math.pow(Math.log(d[i]) - a, 2) - Math.pow(b, 2)) / Math.pow(b, 3) * l;
+ // dl/dAl
+ this.RDX[i * n + 2] = lognormal(d[i], a, b, 1.0);
+ // Gaussian derivatives
+ double g = gaussian(d[i], mu, sigma, Ag);
+ // dg/dmu
+ this.RDX[i * n + 3] = (d[i] - mu) / Math.pow(sigma, 2) * g;
+ // dg/dsigma
+ this.RDX[i * n + 4] = (Math.pow(d[i] - mu, 2) - Math.pow(sigma, 2)) / Math.pow(sigma, 3) * g;
+ // dg/dAg
+ this.RDX[i * n + 5] = gaussian(d[i], mu, sigma, 1.0);
+ }
+ }
+ }
+
+ public static class LSQHES extends E04GG.Abstract_E04GG_LSQHES {
+ public void eval() {
+ E04GGU e04ggu = new E04GGU();
+ e04ggu.eval(this.NVAR, this.X, this.NRES, this.LAMBDA, this.HX, this.INFORM, this.IUSER, this.RUSER,
+ this.CPUSER);
+ this.INFORM = e04ggu.getINFORM();
+ }
+ }
+
+ public static class LSQHPRD extends E04GG.Abstract_E04GG_LSQHPRD {
+ public void eval() {
+ E04GGV e04ggv = new E04GGV();
+ e04ggv.eval(this.NVAR, this.X, this.Y, this.NRES, this.HXY, this.INFORM, this.IUSER, this.RUSER,
+ this.CPUSER);
+ this.INFORM = e04ggv.getINFORM();
+ }
+ }
+
+ public static class MONIT extends E04GG.Abstract_E04GG_MONIT {
+ public void eval() {
+ E04FFU e04ffu = new E04FFU();
+ e04ffu.eval(this.NVAR, this.X, this.INFORM, this.RINFO, this.STATS, this.IUSER, this.RUSER, this.CPUSER);
+ this.INFORM = e04ffu.getINFORM();
+ }
+ }
+
+ public static void printVectorToFile(double[] a, String fileName) {
+ try {
+ FileWriter writer = new FileWriter(new File(dataFolder + File.separator + fileName));
+ for (int i = 0; i < a.length; i++) {
+ writer.write(a[i] + " ");
+ }
+ writer.write("\n");
+ writer.close();
+ } catch (IOException e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ public static void printVectorToFile(int[] a, String fileName) {
+ try {
+ FileWriter writer = new FileWriter(new File(dataFolder + File.separator + fileName));
+ for (int i = 0; i < a.length; i++) {
+ writer.write(a[i] + " ");
+ }
+ writer.write("\n");
+ writer.close();
+ } catch (IOException e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/FOAS/Readme.md b/FOAS/Readme.md
new file mode 100644
index 0000000..9dbf96c
--- /dev/null
+++ b/FOAS/Readme.md
@@ -0,0 +1,79 @@
+[](https://www.nag.com)
+
+> ## Important Information
+> You can view this page as a [webpage](https://numericalalgorithmsgroup.github.io/NAGJavaExamples/FOAS) or access this as a regular github [repository](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/tree/main/FOAS).
+>
+> See the top directory of this repository for instructions to set up the [NAG Library for Java](https://github.com/numericalalgorithmsgroup/NAGJavaExamples).
+
+# First-order active-set method (FOAS)
+[ [`e04kff`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04kff.html) |
+[`e04kfc`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/clhtml/e04/e04kfc.html) |
+[`handle_solve_bounds_foas`](https://www.nag.co.uk/numeric/py/nagdoc_latest/naginterfaces.library.opt.html#naginterfaces.library.opt.handle_solve_bounds_foas) ]
+
+Implementations of first-order methods not only are ubiquitous and have a widespread use, they have also demonstrated to endure the challenges of ever-growing problems sizes imposed by the industry. Most notable are applications in statistics, e.g. parameter calibration for log-linear models, conditional random fields (L2-regularisation) or logistic multi-class regression, amongs many other. First-order methods and the Conjugate Gradient method inparticular have been a research subject for well over 50 years and continue to be improved.
+
+FOAS is a [first-order nonlinear conjugate method](https://en.wikipedia.org/wiki/Nonlinear_conjugate_gradient_method) for large-scale bound-constrained nonlinear optimization. The solver is ideal for very large problems (tens of thousands or more variables) where the first-order derivatives are available or are relatively _cheap_ to estimate.
+
+e04kf is also part of the [NAG Optimization Modelling Suite](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04intro.html#optsuite) common handle interface. It offers clarity and consistency of the interface of the solvers within the suite, making it trivial to switch among compatible solvers.
+
+The following example illustrates the simple usage of FOAS to solve the bound-constrained 2D version of the [Rosenbrock function](https://en.wikipedia.org/wiki/Rosenbrock_function) which is a classical test function to measure and profile performance of solvers. Source of this example is avaible in [Rosenbrock2d.java](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/tree/main/FOAS/example/Rosenbrock2d.java). It is also adviced to read this [page](./example) that explains the example.
+
+
+
+
+
+
+**Figure 1.** 2D Rosenbrock function, (left) the minimum is shown as a yellow dot at x=(1,1). On the right a bound constrained version showing with a purple dotted line a path towards the constrained solution point on the border.
+
+# More information
+ 1. [FOAS information page](https://www.nag.com/content/limited-memory-nonlinear-conjugate-gradient-solver)
+ 2. [FOAS in the NAG Library](https://www.nag.com/numeric/nl/nagdoc_27.1/flhtml/e04/e04kff.html)
+ 3. [FOAS documentation page [C]](https://www.nag.co.uk/numeric/nl/nagdoc_latest/clhtml/e04/e04kfc.html)
+ 4. Examples [ [Java example](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/blob/main/simple_examples/source/int32/E04KFJE.java) |
+ [C example](https://www.nag.co.uk/numeric/nl/nagdoc_latest/clhtml/e04/e04kfc.html#example) |
+ [Fortran example](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04kff.html#example) |
+ [Python example](https://www.nag.co.uk/numeric/py/nagdoc_latest/naginterfaces.library.opt.html#naginterfaces.library.examples.opt.handle_solve_bounds_foas_ex.main) ]
+
+## A modern replacement for NAG solver [uncon_conjgrd_comp (e04dg)](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04dgf.html)
+One of the main design objectives for `handle_solve_bounds_foas` (`e04kf`) was to provide a modern and attractive replacement for the CG solver `e04dg` introduced in Mark 12. While this solver was targeted for unconstrained NLPs, `e04kf` has been extended with an active-set method in order to solve bound-constrained NLPs.
+
+More recent and modern methods have been incorporated into `e04kf` making it much faster than `e04dg`. The following Figure 2 reports performance profiles over 114 unconstrained NLP CUTEst problems for both solvers `e04kf` and `e04dg`. Contrasting the three plots, it is evident that the new solver is more efficient in time (40% faster) and in general terms is less expensive: requires less function and gradient evaluations.
+
+
+
+
+
+
+
+**Figure 2.** Performance profiles comparing solvers `e04kf` and `e04dg`. In the time plot on the left, higher line indicates faster solver. For the center and right plots higher line represent less functions (NF) or gradients (NG) calls. For all three plots it can be seen that `e04kf` is 40% faster in time and requires less function and gradient calls.
+
+## Migrating from Marks 25 and 26 to Mark 27
+
+Notes and comments on migrating your code from [`uncon_conjgrd_comp (e04dg)`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04dgf.html) to the new FOAS solver [`handle_solve_bounds_foas`, (`e04kff`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/flhtml/e04/e04kff.html),
+[`e04kfc`](https://www.nag.co.uk/numeric/nl/nagdoc_latest/clhtml/e04/e04kfc.html)):
+
+
+ * [Java](./migration)
+ * [Fortran 90](https://www.nag.com/numeric/nl/nagdoc_latest/flhtml/genint/replace.html#e04dgf)
+ * [C](https://www.nag.com/numeric/nl/nagdoc_latest/clhtml/genint/replace.html#e04dgc)
+ * [Python](https://github.com/numericalalgorithmsgroup/NAGPythonExamples/blob/master/local_optimization/FOAS/migration/migration_e04dg_e04kf.ipynb)
+
+## Beale's function
+This example compares the steps taken by FOAS and L-BFGS-B 3.0 to find the solution point to [Beale's function](https://en.wikipedia.org/wiki/Test_functions_for_optimization). It is a classic nonconvex test function used to benchmark nonlinear optimization solvers.
+
+Both solvers are used to find a minimum to the function and are started at the same initial point (2, 2). The following figure shows an animation of the steps taken by each solver to find a minimum to the function.
+It illustrates the agressive steps taken by the [Conjugate Gradient method](https://en.wikipedia.org/wiki/Conjugate_gradient_method) compared to the more conservative steps of BFGS.
+
+
+
+
+
+**Figure 3.** Contour plots for Beale's function (thin blue lines), and the steps taken by FOAS (red) and L-BFGS-B 3.0 (blue) to find the minimum of Beale's funtion at (3, 0.5) marked with a magenta star. It can be seen that FOAS by the 8th step provides a reasonable approximation to the solution point while L-BFGS-B is still relatively far from it.
+
+## References
+
+ * Hager W W and Zhang H (2005) _A New Conjugate Gradient Method with Guaranteed Descent and an Efficient Line Search_. SIAM J. Optim. 16(1) 170–192
+ * Hager W W and Zhang H (2006a) _Algorithm 851: CG DESCENT, a Conjugate Gradient Method with Guaranteed Descent_. ACM Trans. Math. Software 32(1) 113–137
+ * Hager W W and Zhang H (2006b) _A New Active Set Algorithm for Box Constrained Optimization_. SIAM J. Optim. 17(2) 525–557
+ * Hager W W and Zhang H (2013) _The Limited Memory Conjugate Gradient Method_. SIAM J. Optim. 23(4) 2150–2168
+ * Nocedal J and Wright S J (2006) _Numerical Optimization_. (2nd Edition) Springer Series in Operations Research, Springer, New York
diff --git a/FOAS/example/Readme.md b/FOAS/example/Readme.md
new file mode 100644
index 0000000..dca5559
--- /dev/null
+++ b/FOAS/example/Readme.md
@@ -0,0 +1,301 @@
+> ## Important Information
+> You can view this page as a [webpage](https://numericalalgorithmsgroup.github.io/NAGJavaExamples/FOAS/example) or access this as a regular github [repository](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/tree/main/FOAS/example).
+>
+> The source of this example can be found [here](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/tree/main/FOAS/example/Rosenbrock2d.java) and the output [here](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/tree/main/FOAS/example/output.txt).
+>
+> See the top directory of this repository for instructions to set up the [NAG Library for Java](https://github.com/numericalalgorithmsgroup/NAGJavaExamples).
+
+# Rosenbrock function: Bound constrained optimization
+First order active set bound-constrained nonlinear programming
+
+2d Rosenbrock example: This page illustrates the usage of FOAS to solve the bound-constrained 2d Rosenbrock function. There is a plot at the end showing the steps taken by the solver to find the solution point.
+
+Add objective function, gradient and monitoring callback
+
+```java
+/**
+ * The objective's function.
+ */
+public static class OBJFUN extends E04KF.Abstract_E04KF_OBJFUN {
+ public void eval() {
+ this.FX = objfunEval(this.X[0], this.X[1]);
+ }
+}
+
+/**
+ * The objective's gradient.
+ */
+public static class OBJGRD extends E04KF.Abstract_E04KF_OBJGRD {
+ public void eval() {
+ this.FDX[0] = 2.0 * this.X[0] - 400.0 * this.X[0] * (this.X[1] - Math.pow(this.X[0], 2)) - 2.0;
+ this.FDX[1] = 200.0 * (this.X[1] - Math.pow(this.X[0], 2));
+ }
+}
+
+/**
+ * The monitor function.
+ */
+public static class MONIT extends E04KF.Abstract_E04KF_MONIT {
+ public void eval() {
+ steps[0].add(this.X[0]);
+ steps[1].add(this.X[1]);
+ steps[2].add(this.RINFO[0]);
+ }
+}
+```
+
+Specify initial guess
+
+```java
+double[] x = new double[] { -1.0, -1.5 };
+```
+
+Define the nonlinear objective (add to handle)
+
+```java
+E04RA e04ra = new E04RA();
+E04RG e04rg = new E04RG();
+E04RH e04rh = new E04RH();
+E04ZM e04zm = new E04ZM();
+E04KF e04kf = new E04KF();
+
+ifail = 0;
+e04ra.eval(handle, nvar, ifail);
+handle = e04ra.getHANDLE();
+
+ifail = 0;
+e04rg.eval(handle, nvar, idxfd, ifail);
+```
+
+Add the box bounds on the variable x to the handle
+
+```java
+double[] bl = new double[] { -1.0, -2.0 };
+double[] bu = new double[] { 0.8, 2.0 };
+ifail = 0;
+e04rh.eval(handle, nvar, bl, bu, ifail);
+```
+
+Set some algorithmic options
+
+```java
+ifail = 0;
+e04zm.eval(handle, "FOAS Print Frequency = 1", ifail);
+e04zm.eval(handle, "Print Solution = yes", ifail);
+e04zm.eval(handle, "FOAS Monitor Frequency = 1", ifail);
+e04zm.eval(handle, "Print Level = 2", ifail);
+e04zm.eval(handle, "Monitoring Level = 1", ifail);
+```
+
+Solve the problem
+
+```java
+OBJFUN objfun = new OBJFUN();
+OBJGRD objgrd = new OBJGRD();
+MONIT monit = new MONIT();
+double[] rinfo = new double[100];
+double[] stats = new double[100];
+int[] iuser = new int[0];
+double[] ruser = new double[0];
+long cpuser = 0;
+ifail = 0;
+e04kf.eval(handle, objfun, objgrd, monit, nvar, x, rinfo, stats, iuser, ruser, cpuser, ifail);
+
+// Add last step
+steps[0].add(x[0]);
+steps[1].add(x[1]);
+steps[2].add(rinfo[0]);
+```
+
+
+
+```
+ ----------------------------------------------------------
+ E04KF, First order method for bound-constrained problems
+ ----------------------------------------------------------
+
+ Begin of Options
+ Print File = 6 * d
+ Print Level = 2 * U
+ Print Options = Yes * d
+ Print Solution = All * U
+ Monitoring File = -1 * d
+ Monitoring Level = 1 * U
+ Foas Monitor Frequency = 1 * U
+ Foas Print Frequency = 1 * U
+
+ Infinite Bound Size = 1.00000E+20 * d
+ Task = Minimize * d
+ Stats Time = No * d
+ Time Limit = 1.00000E+06 * d
+ Verify Derivatives = No * d
+
+ Foas Estimate Derivatives = No * d
+ Foas Finite Diff Interval = 1.05367E-08 * d
+ Foas Iteration Limit = 10000000 * d
+ Foas Memory = 11 * d
+ Foas Progress Tolerance = 1.08158E-12 * d
+ Foas Rel Stop Tolerance = 1.08158E-12 * d
+ Foas Restart Factor = 6.00000E+00 * d
+ Foas Slow Tolerance = 1.01316E-02 * d
+ Foas Stop Tolerance = 1.00000E-06 * d
+ Foas Tolerance Norm = Infinity * d
+ End of Options
+
+ Problem Statistics
+ No of variables 2
+ free (unconstrained) 0
+ bounded 2
+ Objective function Nonlinear
+
+
+ -------------------------------------------------------------------------------
+ iters | objective | optim | dir
+ -------------------------------------------------------------------------------
+ 0 6.29000E+02 5.00E+02 3.50E+00
+ 1 6.29000E+02 5.00E+02 3.50E+00
+ 2 4.00000E+00 0.00E+00 1.80E+00
+ 3 4.00000E+00 0.00E+00 1.80E+00
+ 4 3.99156E+00 2.80E+00 2.80E+00
+ 5 3.99156E+00 2.80E+00 2.80E+00
+ 6 3.98433E+00 1.44E+00 1.44E+00
+ 7 3.97076E+00 5.76E+00 1.79E+00
+ 8 3.41157E+00 1.66E+01 1.60E+00
+ 9 3.15876E+00 2.07E+01 1.65E+00
+ 10 2.34744E+00 2.55E+00 2.29E+00
+ 11 2.06122E+00 5.09E+00 1.83E+00
+ 12 1.97065E+00 6.49E+00 1.88E+00
+ 13 1.77751E+00 9.58E+00 1.99E+00
+ 14 1.19453E+00 2.20E+00 8.93E-01
+ 15 1.12429E+00 2.33E+00 2.01E+00
+ 16 1.01998E+00 5.04E+00 2.02E+00
+ 17 8.94996E-01 8.97E+00 2.02E+00
+ 18 7.06184E-01 1.32E+00 1.10E+00
+ 19 5.06340E-01 5.11E+00 1.91E+00
+ -------------------------------------------------------------------------------
+ iters | objective | optim | dir
+ -------------------------------------------------------------------------------
+ 20 3.21115E-01 1.03E+00 3.67E-01
+ 21 2.99551E-01 9.31E-01 9.31E-01
+ 22 2.51003E-01 2.68E+00 1.75E+00
+ 23 2.14196E-01 4.82E+00 1.66E+00
+ 24 1.15236E-01 1.17E+00 3.70E-01
+ 25 8.06733E-02 1.98E+00 1.73E+00
+ 26 6.60815E-02 4.33E+00 1.79E+00
+ 27 5.37636E-02 3.33E+00 1.80E+00
+ 28 4.02960E-02 3.44E-01 3.44E-01
+ 29 4.02960E-02 3.44E-01 3.44E-01
+ 30 4.00937E-02 1.94E-01 1.94E-01
+ 31 4.00937E-02 1.94E-01 1.94E-01
+ 32 4.00000E-02 0.00E+00 0.00E+00
+ -------------------------------------------------------------------------------
+ Status: converged, an optimal solution was found
+ -------------------------------------------------------------------------------
+ Value of the objective 4.00000E-02
+ Norm of inactive gradient 0.00000E+00
+ Norm of projected direction 0.00000E+00
+ Iterations 32
+ Function evaluations 75
+ FD func. evaluations 0
+ Gradient evaluations 36
+ NPG function calls 18
+ NPG gradient calls 3
+ CG function calls 9
+ CG gradient calls 5
+ LCG function calls 48
+ LCG gradient calls 28
+ -------------------------------------------------------------------------------
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 -1.00000E+00 8.00000E-01 8.00000E-01
+ 2 -2.00000E+00 6.40000E-01 2.00000E+00
+
+ Box bounds dual variables:
+ idx Lower bound Value Upper bound Value
+ 1 -1.00000E+00 0.00000E+00 8.00000E-01 4.00000E-01
+ 2 -2.00000E+00 0.00000E+00 2.00000E+00 0.00000E+00
+
+```
+
+Retrieve Lagrange multipliers
+
+```java
+double[] mult = new double[2 * nvar];
+Arrays.fill(mult, 0.0);
+
+E04RX e04rx = new E04RX();
+ifail = 0;
+e04rx.eval(handle, "Dual Variables", 1, 2 * nvar, mult, ifail);
+
+double[] mult_t = new double[mult.length / 2];
+for (int i = 0; i < mult.length; i += 2) {
+ mult_t[i / 2] = mult[i] - mult[i + 1];
+}
+```
+
+
+
+```
+Lagrange multipliers: [ -0.4 0.0 ]
+```
+
+Destroy the handle
+
+```java
+E04RZ e04rz = new E04RZ();
+e04rz.eval(handle, ifail);
+```
+
+Evaluate the funtion over the domain
+
+```java
+double[] x_m = linspace(bl[0] - 0.5, bu[0] + 0.5, 101);
+double[] y_m = linspace(bl[1] - 0.5, bu[1] + 0.5, 101);
+double[][] z_m = new double[101][101];
+
+for (int i = 0; i < 101; i++) {
+ for (int j = 0; j < 101; j++) {
+ z_m[i][j] = objfunEval(x_m[i], y_m[i]);
+ }
+}
+int inform = 1;
+
+int nb = 25;
+double[] x_box = linspace(bl[0], bu[0], nb);
+double[] y_box = linspace(bl[1], bu[1], nb);
+
+double[][] box = new double[2][100];
+
+for (int i = 0; i < nb; i++) {
+ box[0][i] = x_box[i];
+ box[0][nb + i] = bu[0];
+ box[0][nb * 2 + i] = x_box[nb - 1 - i];
+ box[0][nb * 3 + i] = bl[0];
+
+ box[1][i] = bl[1];
+ box[1][nb + i] = y_box[i];
+ box[1][nb * 2 + i] = bu[1];
+ box[1][nb * 3 + i] = y_box[nb - 1 - i];
+}
+
+double[] z_box = new double[box[0].length];
+
+for (int i = 0; i < z_box.length; i++) {
+ z_box[i] = objfunEval(box[0][i], box[1][i]);
+}
+
+double[][] X = new double[x_m.length][x_m.length];
+double[][] Y = new double[y_m.length][y_m.length];
+
+for (int i = 0; i < X.length; i++) {
+ Arrays.fill(X[i], x_m[i]);
+ Arrays.fill(Y[i], y_m[i]);
+}
+```
+
+Plot function and steps taken
+
+
+
+For each stock $$i$$, we first estimate the $$j$$th daily relative return as
+
+$$relative~return_{i,j} = \frac{closing~price_{i,j+1}-closing~price_{i,j}}{closing~price_{i,j}}.$$
+
+```java
+ // Relative return
+ double[][] relRtn = new double[m - 1][n];
+ for (j = 0; j < m - 1; j++) {
+ for (i = 0; i < n; i++) {
+ relRtn[j][i] = (data[j + 1][i] - data[j][i]) / data[j][i];
+ }
+ }
+```
+
+
+
+
+
+
+Simply take arithmetic mean of each column of relative return to get mean return $$r$$ for each stock, followed by estimating covariance $$V$$ using numpy.
+
+```java
+ // Mean return
+ double[] r = new double[n];
+ for (j = 0; j < n; j++) {
+ double sum = 0;
+ for (i = 0; i < m - 1; i++) {
+ sum += relRtn[i][j];
+ }
+ r[j] = sum;
+ r[j] /= m - 1;
+ }
+
+ // Covariance matrix
+ G02BX g02bx = new G02BX();
+ String weight = "U";
+ n = relRtn.length;
+ m = relRtn[0].length;
+ int ldx = n;
+ double[] x1d = convert2DTo1D(relRtn);
+ double[] wt = new double[0];
+ double[] xbar = new double[m];
+ double[] std = new double[m];
+ int ldv = m;
+ double[] v1d = new double[ldv * m];
+ double[] r1d = new double[ldv * m];
+ int ifail = 0;
+ g02bx.eval(weight, n, m, x1d, ldx, wt, xbar, std, v1d, ldv, r1d, ifail);
+
+ double[][] V = convert1DTo2D(v1d, m);
+```
+
+# Classic Mean-Variance Model
+## Efficient Frontier
+
+One of the major goals of portfolio management is to achieve a certain level of return under a specific risk measurement. Here we demonstrate how to use NAG Library to build efficient frontier by solving classical Markowitz model with long-only constraint (meaning, buy to hold and short selling is not allowed):
+
+$$
+\begin{equation}\label{MV_model}
+\begin{array}{ll}
+\underset{x\in\Re^n}{\mbox{minimize}} & -r^Tx+\mu x^TVx\\[0.6ex]
+\mbox{subject to} & e^Tx = 1,\\[0.6ex]
+ & x\geq0,
+\end{array}
+\end{equation}
+$$
+
+where $$e\in\Re^n$$ is vector of all ones and $$\mu$$ is a scalar controling trade-off between return and risk. Note one could build the efficient frontier by varying $$\mu$$ from $$0$$ to a certain value.
+
+```java
+int itemsDiagLength = V.length;
+ int itemsAboveDiagLength = (int) (Math.pow(itemsDiagLength, 2) - itemsDiagLength) / 2 + itemsDiagLength;
+ int[] irowq = new int[itemsAboveDiagLength];
+ int[] icolq = new int[itemsAboveDiagLength];
+ double[] vVal = new double[itemsAboveDiagLength];
+ int c = 0;
+ // Input for quadratic objective
+ // Sparsity pattern of upper triangular V
+ for (i = 0; i < V.length; i++) {
+ for (j = i; j < V[0].length; j++) {
+ vVal[c] = V[i][j];
+ irowq[c] = i + 1;
+ icolq[c] = j + 1;
+ c++;
+ }
+ }
+
+ n = closePrice.size();
+ // Sparsity pattern of r, which is actually dense in this application
+ int[] idxr = new int[n];
+ for (i = 0; i < n; i++) {
+ idxr[i] = i + 1;
+ }
+
+ // Input for linear constraint: e'x = 1
+ int[] irowa = new int[n];
+ int[] icola = new int[n];
+ double[] a = new double[n];
+ double[] bl = new double[1];
+ double[] bu = new double[1];
+ double[] blx = new double[n];
+ double[] bux = new double[n];
+
+ Arrays.fill(irowa, 1);
+ for (i = 0; i < n; i++) {
+ icola[i] = i + 1;
+ }
+ Arrays.fill(a, 1.0);
+ bl[0] = 1.0;
+ bu[0] = 1.0;
+
+ // Input for bound constraint: x >= 0
+ Arrays.fill(blx, 0.0);
+ Arrays.fill(bux, 1.0e20);
+```
+
+The input data is ready, we can easily build the efficient frontier as follows.
+
+```java
+// Set step for mu
+ int step = 2001;
+
+ // Initialize output data: absolute risk and return
+ ArrayList abRisk = new ArrayList<>();
+ ArrayList abRtn = new ArrayList<>();
+
+ int mu;
+ long handle = 0;
+ double[] q = new double[vVal.length];
+ int idqc;
+ double[] invertSignR = invertSignVector(r);
+ double[] x = new double[n];
+ double[] u = new double[0];
+ double[] uc = new double[0];
+ double[] rinfo = new double[100];
+ double[] stats = new double[100];
+ int[] iuser = new int[2];
+ double[] ruser = new double[1];
+ long cpuser = 0;
+ double[][] x2d;
+ double[][] VX;
+ double[][] XVX;
+ double[][] r2d;
+ double[][] RX;
+
+ for (mu = 0; mu < step; mu++) {
+ ifail = 0;
+
+ // Create problem handle
+ e04ra.eval(handle, n, ifail);
+ handle = e04ra.getHANDLE();
+
+ // Set quadratic objective function
+ // In qcqp standard form q should be 2*mu*V
+ for (i = 0; i < q.length; i++) {
+ q[i] = 2.0 * mu * vVal[i];
+ }
+
+ idqc = -1;
+ e04rs.eval(handle, 0.0, nonZeroLength(invertSignR), idxr, invertSignR, nonZeroLength(q), irowq, icolq, q,
+ idqc, ifail);
+
+ // Set linear constraint e'x = 1
+ e04rj.eval(handle, bl.length, bl, bu, nonZeroLength(a), irowa, icola, a, 0, ifail);
+
+ // Set bound constraint
+ e04rh.eval(handle, n, blx, bux, ifail);
+
+ // set options
+ e04zm.eval(handle, "Print Options = NO", ifail);
+ e04zm.eval(handle, "Print Level = 1", ifail);
+ e04zm.eval(handle, "Print File = -1", ifail);
+ e04zm.eval(handle, "SOCP Scaling = A", ifail);
+
+ // Call socp interior point solver
+ ifail = 1;
+ e04pt.eval(handle, n, x, 0, u, 0, uc, rinfo, stats, monit, iuser, ruser, cpuser, ifail);
+
+ ifail = e04pt.getIFAIL();
+ if (ifail == 0) {
+ // Compute risk and return from the portfolio
+ x2d = convert1DTo2D(x, x.length);
+ VX = multiplyMatrices(V, x2d);
+ XVX = multiplyMatrices(invertRowColMatrix(x2d), VX);
+
+ abRisk.add(Math.sqrt(XVX[0][0]));
+
+ r2d = convert1DTo2D(r, r.length);
+ RX = multiplyMatrices(invertRowColMatrix(r2d), x2d);
+
+ abRtn.add(RX[0][0]);
+ }
+
+ // Destroy the handle:
+ e04rz.eval(handle, ifail);
+ handle = e04rz.getHANDLE();
+ }
+```
+
+
+
+
+
+
+
+## Maximizing the Sharpe ratio
+
+The Sharpe ratio is defined as the ratio of return of portfolio and standard deviation of the portfolio's excess return. It is usually used to measure the efficiency of a portfolio. Find the most efficient portfolio is equivalent to solve the following optimization problem.
+
+$$
+\begin{equation}
+\label{eq:sr_model}
+\begin{array}{ll}
+\underset{x\in\Re^n}{\mbox{minimize}} & \frac{\sqrt{x^TVx}}{r^Tx}\\[0.6ex]
+\mbox{subject to} & e^Tx = 1,\\[0.6ex]
+ & x\geq0.
+\end{array}
+\end{equation}
+$$
+
+By replacing $$x$$ with $$\frac{y}{\lambda}, \lambda\gt0$$, model $$(\ref{eq:sr_model})$$ is equivalent to
+
+$$
+\begin{equation}
+\label{sr_model_eq}
+\begin{array}{ll}
+\underset{y\in\Re^n, \lambda\in\Re}{\mbox{minimize}} & y^TVy\\[0.6ex]
+\mbox{subject to} & e^Ty = \lambda,\\[0.6ex]
+ & r^Ty=1, \\
+ & y\geq0, \\
+ & \lambda\geq0.
+\end{array}
+\end{equation}
+$$
+
+Problem $$(\ref{sr_model_eq})$$ is similar to problem $$(\ref{MV_model})$$ in the sense that they both have a quadratic objective function and linear constraints.
+
+```java
+// Input for linear constraint: e'y = lambda
+ irowa = new int[(n + 1) + n];
+ icola = new int[(n + 1) + n];
+ a = new double[(n + 1) + n];
+ bl = new double[2];
+ bu = new double[2];
+ blx = new double[n + 1];
+ bux = new double[n + 1];
+
+ Arrays.fill(irowa, 0, n + 1, 1);
+ for (i = 0; i <= n; i++) {
+ icola[i] = i + 1;
+ }
+ Arrays.fill(a, 0, n, 1.0);
+ a[n] = -1.0;
+ bl[0] = 0.0;
+ bu[0] = 0.0;
+
+ // Input for linear constraint: r'y = 1
+ Arrays.fill(irowa, n + 1, irowa.length, 2);
+ for (i = 0; i < n; i++) {
+ icola[(n + 1) + i] = i + 1;
+ }
+ for (i = 0; i < n; i++) {
+ a[(n + 1) + i] = r[i];
+ }
+ bl[1] = 1.0;
+ bu[1] = 1.0;
+
+ // Input for bound constraint: x >= 0
+ Arrays.fill(blx, 0.0);
+ Arrays.fill(bux, 1.0e20);
+```
+
+Now we can call the NAG SOCP solver as follows.
+
+```java
+ ifail = 0;
+
+ // Create problem handle
+ e04ra.eval(handle, n + 1, ifail);
+ handle = e04ra.getHANDLE();
+
+ // Set quadratic objective function
+ // In qcqp standard form q should be 2*V
+ for (i = 0; i < q.length; i++) {
+ q[i] = 2.0 * vVal[i];
+ }
+ idqc = -1;
+ e04rs.eval(handle, 0.0, 0, idxr, r, nonZeroLength(q), irowq, icolq, q, idqc, ifail);
+
+ // Set linear constraints
+ e04rj.eval(handle, bl.length, bl, bu, nonZeroLength(a), irowa, icola, a, 0, ifail);
+
+ // Set bound constraint
+ e04rh.eval(handle, blx.length, blx, bux, ifail);
+
+ // Set options
+ e04zm.eval(handle, "Print Options = NO", ifail);
+ e04zm.eval(handle, "Print Level = 1", ifail);
+ e04zm.eval(handle, "Print File = -1", ifail);
+ e04zm.eval(handle, "SOCP Scaling = A", ifail);
+
+ // Call socp interior point solver
+ x = new double[n + 1];
+ e04pt.eval(handle, n + 1, x, 0, u, 0, uc, rinfo, stats, monit, iuser, ruser, cpuser, ifail);
+
+ x2d = convert1DTo2D(x, n);
+ VX = multiplyMatrices(V, x2d);
+ XVX = multiplyMatrices(invertRowColMatrix(x2d), VX);
+
+ double srRisk = Math.sqrt(XVX[0][0]) / x[n];
+
+ r2d = convert1DTo2D(r, n);
+ RX = multiplyMatrices(invertRowColMatrix(r2d), x2d);
+
+ double srRtn = RX[0][0] / x[n];
+
+ double[] srX = new double[n];
+ for (i = 0; i < srX.length; i++) {
+ srX[i] = x[i] / x[n];
+ }
+
+ // Destroy the handle:
+ e04rz.eval(handle, ifail);
+ handle = e04rz.getHANDLE();
+```
+
+
+
+
+
+
+
+# Portfolio optimization with tracking-error constraint
+
+To avoid taking unnecessary risk when beating a benchmark, the investors commonly impose a limit on the volatility of the deviation of the active portfolio from the benchmark, which is also known as tracking-error volatility (TEV) [[1](#cit-J03)]. The model to build efficient frontier in excess-return space is
+
+$$
+\begin{equation}\label{er_tev}
+\begin{array}{ll}
+\underset{x\in\Re^n}{\mbox{maximize}} & r^Tx\\
+\mbox{subject to} & e^Tx = 0,\\
+ & x^TVx\leq tev,
+\end{array}
+\end{equation}
+$$
+
+where $$tev$$ is a limit on the track-error. Roll [[2](#cit-R92)] noted that problem $$(\ref{er_tev})$$ is totally independent of the benchmark and leads to the unpalatable result that the active portfolio has systematically higher risk than the benchmark and is not optimal. Therefore, in this section we solve a more advanced model by taking absolute risk into account as follows.
+
+$$
+\begin{equation}\label{tev_model}
+\begin{array}{ll}
+\underset{x\in\Re^n}{\mbox{minimize}} & -r^Tx+\mu (x+b)^TV(x+b)\\
+\mbox{subject to} & e^Tx = 0,\\
+ & x^TVx\leq tev,\\
+ & x+b\geq0,
+\end{array}
+\end{equation}
+$$
+
+where $$b$$ is a benchmark portfolio. In this demonstration, it is generated synthetically. Note here we use the same covariance matrix $$V$$ for tev and absolute risk measurement for demonstration purpose. In practice one could use different covariance matrices from different markets.
+
+```java
+// Generate a benchmark portfolio from efficient portfolio that maximize the
+ // Sharpe ratio
+ // Perturb x
+ double[] b = new double[n];
+ double sumB = 0;
+ for (i = 0; i < b.length; i++) {
+ b[i] = srX[i] + 1.0e-1;
+ sumB += b[i];
+ }
+
+ // Normalize b
+ for (i = 0; i < b.length; i++) {
+ b[i] /= sumB;
+ }
+
+ // Set limit on tracking-error
+ double tev = 0.000002;
+
+ // Compute risk and return at the benchmark
+ double[][] b2d = convert1DTo2D(b, n);
+ double[][] VB = multiplyMatrices(V, b2d);
+ double[][] BVB = multiplyMatrices(invertRowColMatrix(b2d), VB);
+
+ double bRisk = Math.sqrt(BVB[0][0]);
+
+ r2d = convert1DTo2D(r, n);
+ double[][] RB = multiplyMatrices(invertRowColMatrix(r2d), b2d);
+
+ double bRtn = RB[0][0];
+```
+
+
+
+```java
+ irowa = new int[n];
+ icola = new int[n];
+ a = new double[n];
+ bl = new double[1];
+ bu = new double[1];
+
+ // Input for linear constraint: e'x = 0
+ Arrays.fill(irowa, 1);
+ for (i = 0; i < icola.length; i++) {
+ icola[i] = i + 1;
+ }
+ Arrays.fill(a, 1.0);
+ bl[0] = 0;
+ bu[0] = 0;
+
+ // Input for bound constraint: x >= -b
+ blx = invertSignVector(b);
+ Arrays.fill(bux, 1.0e20);
+```
+
+
+
+```java
+// Initialize output data: TEV risk and return
+ ArrayList tevRisk = new ArrayList<>();
+ ArrayList tevRtn = new ArrayList<>();
+
+ double[] rMu = new double[n];
+ double[][] Vb;
+ double[] Vb1d;
+ x = new double[n];
+ double[] xb;
+ double[][] xb2d;
+ double[][] xbVxb;
+
+ for (mu = 0; mu < step; mu++) {
+ ifail = 0;
+
+ // Create problem handle
+ e04ra.eval(handle, n, ifail);
+ handle = e04ra.getHANDLE();
+
+ // Set quadratic objective function
+ // In qcqp standard form q should be 2*mu*V
+ for (i = 0; i < q.length; i++) {
+ q[i] = 2.0 * mu * vVal[i];
+ }
+ Vb = multiplyMatrices(V, b2d);
+ Vb1d = convert2DTo1D(Vb);
+ for (i = 0; i < rMu.length; i++) {
+ rMu[i] = 2.0 * mu * Vb1d[i] - r[i];
+ }
+ idqc = -1;
+ e04rs.eval(handle, 0.0, nonZeroLength(rMu), idxr, rMu, nonZeroLength(q), irowq, icolq, q, idqc, ifail);
+
+ // Set quadratic constraint
+ // In qcqp standard form q should be 2*V
+ for (i = 0; i < q.length; i++) {
+ q[i] = 2.0 * vVal[i];
+ }
+ idqc = 0;
+ e04rs.eval(handle, -tev, 0, idxr, rMu, nonZeroLength(q), irowq, icolq, q, idqc, ifail);
+
+ // Set linear constraint e'x = 1
+ e04rj.eval(handle, bl.length, bl, bu, nonZeroLength(a), irowa, icola, a, 0, ifail);
+
+ // Set bound constraint
+ e04rh.eval(handle, blx.length, blx, bux, ifail);
+
+ // Set options
+ e04zm.eval(handle, "Print Options = NO", ifail);
+ e04zm.eval(handle, "Print Level = 1", ifail);
+ e04zm.eval(handle, "Print File = -1", ifail);
+ e04zm.eval(handle, "SOCP Scaling = A", ifail);
+
+ // Call socp interior point solver
+ // Mute warnings and do not count results from warnings
+ ifail = -1;
+ e04pt.eval(handle, n, x, 0, u, 0, uc, rinfo, stats, monit, iuser, ruser, cpuser, ifail);
+
+ ifail = e04pt.getIFAIL();
+ if (ifail == 0) {
+ // Compute risk and return from the portfolio
+ xb = addVectors(x, b);
+ xb2d = convert1DTo2D(xb, xb.length);
+ xbVxb = multiplyMatrices(invertRowColMatrix(xb2d), multiplyMatrices(V, xb2d));
+ tevRisk.add(Math.sqrt(xbVxb[0][0]));
+
+ tevRtn.add(multiplyMatrices(invertRowColMatrix(r2d), xb2d)[0][0]);
+ }
+
+ // Destroy the handle:
+ e04rz.eval(handle, ifail);
+ handle = e04rz.getHANDLE();
+ }
+```
+
+
+
+
+
+
+
+
+ {% if site.google_analytics %}
+
+ {% endif %}
+
+
+
+
+
diff --git a/assets/css/style.scss b/assets/css/style.scss
new file mode 100644
index 0000000..d9a1e0f
--- /dev/null
+++ b/assets/css/style.scss
@@ -0,0 +1,20 @@
+---
+---
+
+@import "{{ site.theme }}";
+
+.inner {
+ max-width: 65%;
+}
+
+table {
+ margin-right: auto;
+ margin-left: auto;
+}
+
+#nag_logo {
+ border: none;
+ box-shadow: none;
+ max-height: 74px;
+ max-width: 144.5px;
+}
diff --git a/assets/img/logo-white.png b/assets/img/logo-white.png
new file mode 100644
index 0000000..b2b57e2
Binary files /dev/null and b/assets/img/logo-white.png differ
diff --git a/debug.log b/debug.log
new file mode 100644
index 0000000..49a1365
--- /dev/null
+++ b/debug.log
@@ -0,0 +1 @@
+[0113/105617.913:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
diff --git a/nag_logo-removebg.png b/nag_logo-removebg.png
new file mode 100644
index 0000000..68858dc
Binary files /dev/null and b/nag_logo-removebg.png differ
diff --git a/nag_logo.png b/nag_logo.png
deleted file mode 100644
index 17b2c26..0000000
Binary files a/nag_logo.png and /dev/null differ
diff --git a/nearest_correlation_matrices/NcmNag.java b/nearest_correlation_matrices/NcmNag.java
index 31f86f4..70c6ebe 100644
--- a/nearest_correlation_matrices/NcmNag.java
+++ b/nearest_correlation_matrices/NcmNag.java
@@ -1,4 +1,7 @@
import com.nag.routines.G02.G02AA;
+import com.nag.routines.G02.G02AB;
+import com.nag.routines.G02.G02AJ;
+import com.nag.routines.G02.G02AN;
import com.nag.routines.F01.F01CK;
import com.nag.routines.F08.F08NA;
import com.nag.routines.F06.F06RC;
@@ -10,8 +13,13 @@
import java.io.FileWriter;
public class NcmNag {
+
+ public final static String dataFolder = "data";
public static void main(String[] args) {
+ // Initialize our P matrix of observations
+
+ // Define a 2-d array and use Double.NaN to set elements as NaNs
double[][] P = new double[][] { { 59.875, 42.734, 47.938, 60.359, 54.016, 69.625, 61.500, 62.125 },
{ 53.188, 49.000, 39.500, Double.NaN, 34.750, Double.NaN, 83.000, 44.500 },
{ 55.750, 50.000, 38.938, Double.NaN, 30.188, Double.NaN, 70.875, 29.938 },
@@ -23,12 +31,16 @@ public static void main(String[] args) {
{ 52.900, 52.690, 54.230, Double.NaN, 68.170, 70.600, 57.870, 88.640 },
{ 57.370, 59.040, 59.870, 62.090, 61.620, 66.470, 65.370, 85.840 } };
+ // Compute the approximate correlation matrix
+
double[][] G = cor_bar(P);
System.out.println("The approximate correlation matrix");
printMatrix(G);
System.out.println();
+ // Compute the eigenvalues of our (indefinite) G.
+
F08NA f08na = new F08NA();
String jobvl = "N";
String jobvr = "N";
@@ -45,13 +57,18 @@ public static void main(String[] args) {
double[] work = new double[lwork];
int info = 0;
f08na.eval(jobvl, jobvr, n, G1d, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info);
+ Arrays.sort(wr);
System.out.print("Sorted eigenvalues of G: ");
- Arrays.sort(wr);
printVector(wr);
System.out.println();
+
+ // Nearest Correlation Matrices
+
+ // Using G02AA to compute the nearest correlation matrix in the Frobenius norm
+
// Call NAG routine G02AA and print the result
G02AA g02aa = new G02AA();
G1d = convert2DTo1D(G);
@@ -69,7 +86,6 @@ public static void main(String[] args) {
g02aa.eval(G1d, ldg, n, errtol, maxits, maxit, X1d, ldx, iter, feval, nrmgrd, ifail);
double[][] X = convert1DTo2D(X1d, ldx);
-
iter = g02aa.getITER();
System.out.println("Nearest correlation matrix");
@@ -91,30 +107,233 @@ public static void main(String[] args) {
work = new double[lwork];
info = 0;
f08na.eval(jobvl, jobvr, n, X1d, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info);
+ Arrays.sort(wr);
System.out.print("Sorted eigenvalues of X: ");
+ printVector(wr);
+
+ System.out.println();
+
+ double[][] X_G = matrixSub(X, G);
+ F06RC f06rc = new F06RC();
+ String norm = "F";
+ String uplo = "U";
+ n = X_G[0].length;
+ double[] X_G1d = convert2DTo1D(X_G);
+ lda = X_G.length;
+ work = new double[n];
+ double X_G_norm = f06rc.eval(norm, uplo, n, X_G1d, lda, work);
+
+ printDataToFile("G02AA.d", iter, X_G, X_G_norm);
+
+
+ // Weighting rows and columns of elements
+
+ // Use G02AB to compute the nearest correlation matrix with row and column weighting
+
+ // Define an arrray of weights
+ double[] W = new double[] { 10, 10, 10, 1, 1, 1, 1, 1 };
+
+ // Set up and call the NAG routine using weights and a minimum eigenvalue
+ G02AB g02ab = new G02AB();
+ G1d = convert2DTo1D(G);
+ ldg = G.length;
+ n = G[0].length;
+ String opt = "B";
+ double alpha = 0.001;
+ errtol = 0.0;
+ maxits = 0;
+ maxit = 0;
+ ldx = n;
+ X1d = new double[ldx * n];
+ iter = 0;
+ feval = 0;
+ nrmgrd = 0;
+ ifail = 0;
+ g02ab.eval(G1d, ldg, n, opt, alpha, W, errtol, maxits, maxit, X1d, ldx, iter, feval, nrmgrd, ifail);
+
+ X = convert1DTo2D(X1d, ldx);
+ iter = g02ab.getITER();
+
+ System.out.println("Nearest correlation matrix using row and column weighting");
+ printMatrix(X);
+
+ System.out.println();
+
+ jobvl = "N";
+ jobvr = "N";
+ n = X[0].length;
+ lda = X.length;
+ wr = new double[n];
+ wi = new double[n];
+ ldvl = 1;
+ vl = new double[ldvl];
+ ldvr = 1;
+ vr = new double[ldvr];
+ lwork = 3 * n;
+ work = new double[lwork];
+ info = 0;
+ f08na.eval(jobvl, jobvr, n, X1d, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info);
Arrays.sort(wr);
+
+ System.out.print("Sorted eigenvalues of X: ");
printVector(wr);
System.out.println();
- try {
- FileWriter writer = new FileWriter(new File("g02aa.d"));
- writer.write(iter + "\n");
- writer.write(X.sub(G).norm2() + "\n");
- for (int i = 0; i < X.rows; i++) {
- for (int j = 0; j < X.columns; j++) {
- writer.write(matrixAbs(X.sub(G)).get(i, j) + " ");
+ X_G = matrixSub(X, G);
+ norm = "F";
+ uplo = "U";
+ n = X_G[0].length;
+ X_G1d = convert2DTo1D(X_G);
+ lda = X_G.length;
+ work = new double[n];
+ X_G_norm = f06rc.eval(norm, uplo, n, X_G1d, lda, work);
+
+ printDataToFile("G02AB.d", iter, X_G, X_G_norm);
+
+
+ // Weighting Individual Elements
+
+ // Use G02AJ to compute the nearest correlation matrix with element-wise weighting
+
+ // Set up a matrix of weights
+ n = P[0].length;
+ double[][] H = new double[n][n];
+ for (int i = 0; i < n; i++) {
+ for (int j = 0; j < n; j++) {
+ if ((i < 3) && (j < 3)) {
+ H[i][j] = 100.0;
+ } else {
+ H[i][j] = 1;
}
- writer.write("\n");
}
- writer.close();
-
- } catch (IOException e) {
- System.out.println(e.getMessage());
- e.printStackTrace();
}
+ printMatrix(H);
+
+ System.out.println();
+
+ // Call the NAG routine specifying a minimum eigenvalue
+ G02AJ g02aj = new G02AJ();
+ G1d = convert2DTo1D(G);
+ ldg = G.length;
+ n = G[0].length;
+ alpha = 0.001;
+ double[] H1d = convert2DTo1D(H);
+ int ldh = H.length;
+ errtol = 0;
+ maxit = 0;
+ ldx = n;
+ X1d = new double[ldx * n];
+ iter = 0;
+ double norm2 = 0;
+ ifail = 0;
+ g02aj.eval(G1d, ldg, n, alpha, H1d, ldh, errtol, maxit, X1d, ldx, iter, norm2, ifail);
+
+ X = convert1DTo2D(X1d, ldx);
+ iter = g02aj.getITER();
+
+ System.out.println("Nearest correlation matrix using element-wise weighting");
+ printMatrix(X);
+
+ System.out.println();
+
+ jobvl = "N";
+ jobvr = "N";
+ n = X[0].length;
+ lda = X.length;
+ wr = new double[n];
+ wi = new double[n];
+ ldvl = 1;
+ vl = new double[ldvl];
+ ldvr = 1;
+ vr = new double[ldvr];
+ lwork = 3 * n;
+ work = new double[lwork];
+ info = 0;
+ f08na.eval(jobvl, jobvr, n, X1d, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info);
+ Arrays.sort(wr);
+
+ System.out.print("Sorted eigenvalues of X: ");
+ printVector(wr);
+ System.out.println();
+
+ X_G = matrixSub(X, G);
+ norm = "F";
+ uplo = "U";
+ n = X_G[0].length;
+ X_G1d = convert2DTo1D(X_G);
+ lda = X_G.length;
+ work = new double[n];
+ X_G_norm = f06rc.eval(norm, uplo, n, X_G1d, lda, work);
+
+ printDataToFile("G02AJ.d", iter, X_G, X_G_norm);
+
+
+ // Fixing a Block of Elements
+
+ // Use G02AN to compute the nearest correlation matrix with fixed leading block
+
+ // Call the NAG routine fixing the top 3-by-3 block
+ G02AN g02an = new G02AN();
+ G1d = convert2DTo1D(G);
+ ldg = G.length;
+ n = G[0].length;
+ int k = 3;
+ errtol = 0;
+ double eigtol = 0;
+ ldx = n;
+ X1d = new double[ldx * n];
+ alpha = 0.001;
+ iter = 0;
+ double eigmin = 0;
+ norm2 = 0;
+ ifail = 0;
+ g02an.eval(G1d, ldg, n, k, errtol, eigtol, X1d, ldx, alpha, iter, eigmin, norm2, ifail);
+
+ X = convert1DTo2D(X1d, ldx);
+ iter = g02an.getITER();
+ alpha = g02an.getALPHA();
+
+ System.out.println("Nearest correlation matrix with fixed leading block");
+ printMatrix(X);
+
+ System.out.println();
+
+ jobvl = "N";
+ jobvr = "N";
+ n = X[0].length;
+ lda = X.length;
+ wr = new double[n];
+ wi = new double[n];
+ ldvl = 1;
+ vl = new double[ldvl];
+ ldvr = 1;
+ vr = new double[ldvr];
+ lwork = 3 * n;
+ work = new double[lwork];
+ info = 0;
+ f08na.eval(jobvl, jobvr, n, X1d, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info);
+ Arrays.sort(wr);
+
+ System.out.print("Sorted eigenvalues of X: ");
+ printVector(wr);
+
+ System.out.printf("Value of alpha returned: %.4f\n", alpha);
+
+ System.out.println();
+
+ X_G = matrixSub(X, G);
+ norm = "F";
+ uplo = "U";
+ n = X_G[0].length;
+ X_G1d = convert2DTo1D(X_G);
+ lda = X_G.length;
+ work = new double[n];
+ X_G_norm = f06rc.eval(norm, uplo, n, X_G1d, lda, work);
+
+ printDataToFile("G02AN.d", iter, X_G, X_G_norm);
}
/**
@@ -124,7 +343,6 @@ public static void main(String[] args) {
* @return
*/
public static double[][] cov_bar(double[][] P) {
-
double[] xi, xj;
boolean[] xib, xjb, notp;
int n = P[0].length;
@@ -134,6 +352,7 @@ public static double[][] cov_bar(double[][] P) {
for (int i = 0; i < n; i++) {
// Take the ith column
xi = getMatrixColumn(P, i);
+
for (int j = 0; j < i + 1; j++) {
// Take the jth column, where j <= i
xj = getMatrixColumn(P, j);
@@ -144,6 +363,7 @@ public static double[][] cov_bar(double[][] P) {
notp = addBoolArrOr(xib, xjb);
+ // S[i][j] = (xi - mean(xi)) * (xj - mean(xj))
S[i][j] = matrixMaskedDot(vectorSubScalar(xi, vectorMaskedMean(xi, notp)),
vectorSubScalar(xj, vectorMaskedMean(xj, notp)), notp);
@@ -169,8 +389,10 @@ public static double[][] cov_bar(double[][] P) {
public static double[][] cor_bar(double[][] P) {
double[][] S, D;
S = cov_bar(P);
+ // D = 1.0 / SQRT(S)
D = getMatrixFromDiag(vectorRightDiv(vectorSqrt(getMatrixDiag(S)), 1.0));
+ // S_ = S * D
F01CK f01ck = new F01CK();
double[] S_ = new double[S.length * S[0].length];
double[] S1d = convert2DTo1D(S);
@@ -184,12 +406,33 @@ public static double[][] cor_bar(double[][] P) {
int ifail = 0;
f01ck.eval(S_, S1d, D1d, n, p, m, z, iz, opt, ifail);
+ // D_ = D * S_
double[] D_ = new double[n * n];
f01ck.eval(D_, D1d, S_, n, p, m, z, iz, opt, ifail);
return convert1DTo2D(D_, n);
}
+ public static void printDataToFile(String fileName, int iter, double[][] X_G, double X_G_norm) {
+ double[][] absX_G = matrixAbs(X_G);
+ try {
+ FileWriter writer = new FileWriter(new File(dataFolder + File.separator + fileName));
+ writer.write(iter + "\n");
+ writer.write(X_G_norm + "\n");
+ for (int i = 0; i < X_G.length; i++) {
+ for (int j = 0; j < X_G[0].length; j++) {
+ writer.write(absX_G[i][j] + " ");
+ }
+ writer.write("\n");
+ }
+ writer.close();
+
+ } catch (IOException e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
public static double matrixMaskedDot(double[] a, double[] b, boolean[] mask) {
if ((a.length != b.length) || (a.length != mask.length) || (b.length != mask.length)) {
System.out.println("Arrays a(" + a.length + "), b(" + b.length + ") and mask(" + mask.length
@@ -267,6 +510,21 @@ public static double[] vectorSubScalar(double[] a, double s) {
return t;
}
+ public static double[][] matrixSub(double[][] a, double[][] b) {
+ if (a.length != b.length) {
+ System.out.println("Arrays a(" + a.length + ") and b(" + b.length + ") need to have the same length.");
+ System.exit(-1);
+ }
+
+ double[][] t = new double[a.length][a[0].length];
+ for (int i = 0; i < t.length; i++) {
+ for (int j = 0; j < t[0].length; j++) {
+ t[i][j] = a[i][j] - b[i][j];
+ }
+ }
+ return t;
+ }
+
public static boolean[] getNanMask(double[] a) {
boolean[] t = new boolean[a.length];
for (int i = 0; i < t.length; i++) {
@@ -326,22 +584,45 @@ public static double[][] convert1DTo2D(double[] a, int n) {
public static void printMatrix(double[][] a) {
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[0].length; j++) {
- System.out.printf("%7.4f ", a[i][j]);
+ System.out.printf("%8.4f ", a[i][j]);
}
System.out.println();
}
}
- public static void printVector(double[] a) {
- for (int i = 0; i < a.length; i++) {
- System.out.printf("%7.4f ", a[i]);
+ public static void printMatrixToFile(double[][] a, String fileName) {
+ try {
+ FileWriter writer = new FileWriter(new File(dataFolder + File.separator + fileName));
+ for (int i = 0; i < a.length; i++) {
+ for (int j = 0; j < a[0].length; j++) {
+ writer.write(a[i][j] + " ");
+ }
+ writer.write("\n");
+ }
+ writer.close();
+ } catch (IOException e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
}
- System.out.println();
}
- public static void printVector(boolean[] a) {
+ public static void printVectorToFile(double[] a, String fileName) {
+ try {
+ FileWriter writer = new FileWriter(new File(dataFolder + File.separator + fileName));
+ for (int i = 0; i < a.length; i++) {
+ writer.write(a[i] + " ");
+ }
+ writer.write("\n");
+ writer.close();
+ } catch (IOException e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ public static void printVector(double[] a) {
for (int i = 0; i < a.length; i++) {
- System.out.printf("%5b ", a[i]);
+ System.out.printf("%8.4f ", a[i]);
}
System.out.println();
}
diff --git a/nearest_correlation_matrices/Readme.md b/nearest_correlation_matrices/Readme.md
index f5d71c9..8c987ae 100644
--- a/nearest_correlation_matrices/Readme.md
+++ b/nearest_correlation_matrices/Readme.md
@@ -1,5 +1,741 @@
-# Nearest Correlation Matrices using the NAG Library for Java
+> ## Important Information
+> This file has a lot of Latex and GitHub currently cannot render it on Markdown files. You can read all the math clearly as a [webpage](https://numericalalgorithmsgroup.github.io/NAGJavaExamples/nearest_correlation_matrices) or access this as a regular github [repository](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/tree/main/nearest_correlation_matrices).
+>
+> The source of this example can be found [here](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/blob/main/nearest_correlation_matrices/NcmNag.java) and the output [here](https://github.com/numericalalgorithmsgroup/NAGJavaExamples/blob/main/nearest_correlation_matrices/output.txt).
+>
+> See the top directory of this repository for instructions to set up the [NAG Library for Java](https://github.com/numericalalgorithmsgroup/NAGJavaExamples).
-* [ncm_whitepaper_2019.pdf](./ncm_whitepaper_2019.pdf) Nearest Correlation Matrices whitepaper
-* [ncm_nag.ipynb](./ncm_nag.ipynb) Nearest Correlation Matrices Tutorial
+# Nearest Correlation Matrices
+This notebook looks at computing *nearest correlation matrices* using the NAG Library for *Java*.
+
+## Correlation Matrices
+
+* An $$n$$ by $$n$$ matrix is a correlation matrix if:
+ * it is symmetric
+ * it has ones on the diagonal
+ * its eigenvalues are non-negative (positive semidefinite)
+
+
+ $$ \Large Ax = \lambda x, \quad x \neq 0$$
+
+
+* The element in the $$i$$th row and $$j$$th column is the correlation between the $$i$$th and $$j$$th variables. This could be stock process, for example.
+
+## Empirical Correlation Matrices
+
+* Empirical correlation matrices are often **not mathematically true** due to inconsistent or missing data.
+
+
+* Thus we are required to find a true correlation matrix, where our input, $$G$$, is an approximate correlation matrix.
+
+
+* In particular we seek the *nearest* correlation matrix, in most cases.
+
+## Computing Correlation Matrices
+
+* The vector $$p_i$$, the $$i$$th column of a matrix, $$P$$, holds the $$m$$ observations of the $$i$$th variable, of which there are $$n$$. $$\bar{p}_i$$ is the sample mean.
+
+
+$$ \large S_{ij}=\frac{1}{m-1}(p_i - \bar{p}_i )^T(p_j - \bar{p}_j) $$
+
+* $$S$$ is a covariance matrix, with $$S_{ij}$$ the covariance between variables $$i$$ and $$j$$
+
+
+* $$R$$ is the corresponding correlation matrix, given by:
+
+$$
+\begin{align*} \large D_S^{1/2} & = \large \textrm{ diag}(s_{11}^{-1/2},s_{22}^{-1/2}, \ldots, s_{nn}^{-1/2}) \nonumber \\ & \\
+\large R & = \large D_S^{1/2} S D_S^{1/2}
+\end{align*}
+$$
+
+
+## Approximate Correlation Matrices
+
+* Now, what if we don't have all observations for each variable?
+
+
+* We compute each covariance with observations that are available for *both* the *i*th and *j*th variable.
+
+
+* For example NAG routine **G02BB**.
+
+
+* We then compute the correlation matrix as before.
+
+# Missing Stock Price Example
+
+* Prices for 8 stocks on the first working day of 10 consecutive months.
+
+
+| | Stock A | Stock B | Stock C | Stock D | Stock E | Stock F | Stock G | Stock H
+| --- | --- | --- | --- | --- | --- | --- | --- | --- |
+| **Month 1** | 59.875 | 42.734 | 47.938 | 60.359 | 54.016 | 69.625 | 61.500 | 62.125 |
+| **Month 2** | 53.188 | 49.000 | 39.500 | | 34.750 | | 83.000 | 44.500 |
+| **Month 3** | 55.750 | 50.000 | 38.938 | | 30.188 | | 70.875 | 29.938 |
+| **Month 4** | 65.500 | 51.063 | 45.563 | 69.313 | 48.250 | 62.375 | 85.250 | |
+| **Month 5** | 69.938 | 47.000 | 52.313 | 71.016 | | 59.359 | 61.188 | 48.219 |
+| **Month 6** | 61.500 | 44.188 | 53.438 | 57.000 | 35.313 | 55.813 | 51.500 | 62.188 |
+| **Month 7** | 59.230 | 48.210 | 62.190 | 61.390 | 54.310 | 70.170 | 61.750 | 91.080 |
+| **Month 8** | 61.230 | 48.700 | 60.300 | 68.580 | 61.250 | 70.340 | | |
+| **Month 9** | 52.900 | 52.690 | 54.230 | | 68.170 | 70.600 | 57.870 | 88.640 |
+| **Month 10** | 57.370 | 59.040 | 59.870 | 62.090 | 61.620 | 66.470 | 65.370 | 85.840 |
+
+
+* We will use NaNs where there is missing data.
+
+* So our $$P = \left[p_1, p_2, \ldots, p_n \right]$$ is:
+
+
+$$
+P=\left[\begin{array}{rrrrrrrr}
+ 59.875 & 42.734 & {\color{blue}{47.938}} & {\color{blue}{60.359}} & 54.016 & 69.625 & 61.500 & 62.125 \\
+ 53.188 & 49.000 & 39.500 & \textrm{NaN} & 34.750 & \textrm{NaN} & 83.000 & 44.500 \\
+ 55.750 & 50.000 & 38.938 & \textrm{NaN} & 30.188 & \textrm{NaN} & 70.875 & 29.938 \\
+ 65.500 & 51.063 & {\color{blue}{45.563}} & {\color{blue}{69.313}} & 48.250 & 62.375 & 85.250 & \textrm{NaN} \\
+ 69.938 & 47.000 & {\color{blue}{52.313}} & {\color{blue}{71.016}} & \textrm{NaN} & 59.359 & 61.188 & 48.219 \\
+ 61.500 & 44.188 & {\color{blue}{53.438}} & {\color{blue}{57.000}} & 35.313 & 55.813 & 51.500 & 62.188 \\
+ 59.230 & 48.210 & {\color{blue}{62.190}} & {\color{blue}{61.390}} & 54.310 & 70.170 & 61.750 &
+ 91.080 \\
+ 61.230 & 48.700 & {\color{blue}{60.300}} & {\color{blue}{68.580}} & 61.250 & 70.340 & \textrm{NaN} & \textrm{NaN} \\
+ 52.900 & 52.690 & 54.230 & \textrm{NaN} & 68.170 & 70.600 & 57.870 & 88.640 \\
+ 57.370 & 59.040 & {\color{blue}{59.870}} & {\color{blue}{62.090}} & 61.620 & 66.470 & 65.370 &
+ 85.840
+\end{array}\right].
+$$
+
+
+* And to compute the covariance between the 3rd and 4th variables:
+
+$$
+\begin{align*}
+\large v_1^T & = \large [47.938, 45.563, 52.313, 53.438, 62.190, 60.300, 59.870] \\
+\large v_2^T & = \large [60.359, 69.313, 71.016, 57.000, 61.390, 68.580, 62.090] \\
+S_{3,4} & = \large \frac{1}{6} (v_1 - \bar{v}_1 )^T(v_2 - \bar{v}_2)
+\end{align*}
+$$
+
+* Let's compute this in Java.
+
+### Initialize our *P* matrix of observations
+
+```java
+// Define a 2-d array and use Double.NaN to set elements as NaNs
+double[][] P = new double[][] {
+ { 59.875, 42.734, 47.938, 60.359, 54.016, 69.625, 61.500, 62.125 },
+ { 53.188, 49.000, 39.500, Double.NaN, 34.750, Double.NaN, 83.000, 44.500 },
+ { 55.750, 50.000, 38.938, Double.NaN, 30.188, Double.NaN, 70.875, 29.938 },
+ { 65.500, 51.063, 45.563, 69.313, 48.250, 62.375, 85.250, Double.NaN },
+ { 69.938, 47.000, 52.313, 71.016, Double.NaN, 59.359, 61.188, 48.219 },
+ { 61.500, 44.188, 53.438, 57.000, 35.313, 55.813, 51.500, 62.188 },
+ { 59.230, 48.210, 62.190, 61.390, 54.310, 70.170, 61.750, 91.080 },
+ { 61.230, 48.700, 60.300, 68.580, 61.250, 70.340, Double.NaN, Double.NaN },
+ { 52.900, 52.690, 54.230, Double.NaN, 68.170, 70.600, 57.870, 88.640 },
+ { 57.370, 59.040, 59.870, 62.090, 61.620, 66.470, 65.370, 85.840 } };
+```
+
+### Compute the covariance, ignoring missing values
+
+```java
+public static double[][] cov_bar(double[][] P) {
+ double[] xi, xj;
+ boolean[] xib, xjb, notp;
+ int n = P[0].length;
+ double[][] S = new double[n][n];
+ int notpFalseCount;
+
+ for (int i = 0; i < n; i++) {
+ // Take the ith column
+ xi = getMatrixColumn(P, i);
+
+ for (int j = 0; j < i + 1; j++) {
+ // Take the jth column, where j <= i
+ xj = getMatrixColumn(P, j);
+
+ // Set mask such that all NaNs are true
+ xib = getNanMask(xi);
+ xjb = getNanMask(xj);
+
+ notp = addBoolArrOr(xib, xjb);
+
+ // S[i][j] = (xi - mean(xi)) * (xj - mean(xj))
+ S[i][j] = matrixMaskedDot(vectorSubScalar(xi, vectorMaskedMean(xi, notp)),
+ vectorSubScalar(xj, vectorMaskedMean(xj, notp)), notp);
+
+ // Take the sum over !notp to normalize
+ notpFalseCount = 0;
+ for (boolean b : notp) {
+ if (!b) {
+ notpFalseCount++;
+ }
+ }
+ S[i][j] = 1.0 / (notpFalseCount - 1) * S[i][j];
+ S[j][i] = S[i][j];
+ }
+ }
+ return S;
+}
+```
+
+
+
+```java
+public static double[][] cor_bar(double[][] P) {
+ double[][] S, D;
+ S = cov_bar(P);
+ // D = 1.0 / SQRT(S)
+ D = getMatrixFromDiag(vectorRightDiv(vectorSqrt(getMatrixDiag(S)), 1.0));
+
+ // S_ = S * D
+ F01CK f01ck = new F01CK();
+ double[] S_ = new double[S.length * S[0].length];
+ double[] S1d = convert2DTo1D(S);
+ double[] D1d = convert2DTo1D(D);
+ int n = S.length;
+ int p = n;
+ int m = n;
+ double[] z = new double[0];
+ int iz = 0;
+ int opt = 1;
+ int ifail = 0;
+ f01ck.eval(S_, S1d, D1d, n, p, m, z, iz, opt, ifail);
+
+ // D_ = D * S_
+ double[] D_ = new double[n * n];
+ f01ck.eval(D_, D1d, S_, n, p, m, z, iz, opt, ifail);
+
+ return convert1DTo2D(D_, n);
+}
+```
+
+### Compute the *approximate* correlation matrix
+
+```java
+double[][] G = cor_bar(P);
+```
+
+
+
+```
+The approximate correlation matrix
+ 1.0000 -0.3250 0.1881 0.5760 0.0064 -0.6111 -0.0724 -0.1589
+ -0.3250 1.0000 0.2048 0.2436 0.4058 0.2730 0.2869 0.4241
+ 0.1881 0.2048 1.0000 -0.1325 0.7658 0.2765 -0.6172 0.9006
+ 0.5760 0.2436 -0.1325 1.0000 0.3041 0.0126 0.6452 -0.3210
+ 0.0064 0.4058 0.7658 0.3041 1.0000 0.6652 -0.3293 0.9939
+ -0.6111 0.2730 0.2765 0.0126 0.6652 1.0000 0.0492 0.5964
+ -0.0724 0.2869 -0.6172 0.6452 -0.3293 0.0492 1.0000 -0.3983
+ -0.1589 0.4241 0.9006 -0.3210 0.9939 0.5964 -0.3983 1.0000
+```
+
+### Compute the eigenvalues of our (indefinite) *G*.
+
+* We see below that our matrix $$G$$ is not a mathematically true correlation matrix.
+
+```java
+F08NA f08na = new F08NA();
+String jobvl = "N";
+String jobvr = "N";
+int n = G[0].length;
+double[] G1d = convert2DTo1D(G);
+int lda = G.length;
+double[] wr = new double[n];
+double[] wi = new double[n];
+int ldvl = 1;
+double[] vl = new double[ldvl];
+int ldvr = 1;
+double[] vr = new double[ldvr];
+int lwork = 3 * n;
+double[] work = new double[lwork];
+int info = 0;
+f08na.eval(jobvl, jobvr, n, G1d, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info);
+Arrays.sort(wr);
+```
+
+
+
+```
+Sorted eigenvalues of G: -0.2498 -0.0160 0.0895 0.2192 0.7072 1.7534 1.9611 3.5355
+```
+
+# Nearest Correlation Matrices
+
+* Our problem now is to solve:
+
+
+$$
+\large
+\min \frac{1}{2} \| G-X \|^2_F =
+\min \frac{1}{2} \sum_{i=1}^{n} \sum_{i=1}^{n}
+\left| G(i,j)-X(i,j) \right| ^2
+$$
+
+
+* In order to find $$X$$, a true correlation matrix, where $$G$$ is an approximate correlation matrix.
+
+
+* An algorithm by Qi and Sun (2006), applies an inexact Newton method to a dual (unconstrained) formulation of this problem.
+
+
+* Improvements were suggested by Borsdorf and Higham (2010 MSc).
+
+
+* It is globally and quadratically (fast!) convergent.
+
+
+* This is implemented in NAG routine **G02AA**.
+
+## Using G02AA to compute the nearest correlation matrix in the Frobenius norm
+
+```java
+// Call NAG routine G02AA and print the result
+G02AA g02aa = new G02AA();
+G1d = convert2DTo1D(G);
+n = G.length;
+int ldg = n;
+int ldx = n;
+double errtol = 0.0;
+int maxits = 0;
+int maxit = 0;
+double[] X1d = new double[ldx * n];
+int iter = 0;
+int feval = 0;
+double nrmgrd = 0.0;
+int ifail = 0;
+g02aa.eval(G1d, ldg, n, errtol, maxits, maxit, X1d, ldx, iter, feval, nrmgrd, ifail);
+
+double[][] X = convert1DTo2D(X1d, ldx);
+iter = g02aa.getITER();
+```
+
+
+
+```
+Nearest correlation matrix
+ 1.0000 -0.3112 0.1889 0.5396 0.0268 -0.5925 -0.0621 -0.1921
+ -0.3112 1.0000 0.2050 0.2265 0.4148 0.2822 0.2915 0.4088
+ 0.1889 0.2050 1.0000 -0.1468 0.7880 0.2727 -0.6085 0.8802
+ 0.5396 0.2265 -0.1468 1.0000 0.2137 0.0015 0.6069 -0.2208
+ 0.0268 0.4148 0.7880 0.2137 1.0000 0.6580 -0.2812 0.8762
+ -0.5925 0.2822 0.2727 0.0015 0.6580 1.0000 0.0479 0.5932
+ -0.0621 0.2915 -0.6085 0.6069 -0.2812 0.0479 1.0000 -0.4470
+ -0.1921 0.4088 0.8802 -0.2208 0.8762 0.5932 -0.4470 1.0000
+```
+
+
+
+```java
+jobvl = "N";
+jobvr = "N";
+n = X[0].length;
+lda = X.length;
+wr = new double[n];
+wi = new double[n];
+ldvl = 1;
+vl = new double[ldvl];
+ldvr = 1;
+vr = new double[ldvr];
+lwork = 3 * n;
+work = new double[lwork];
+info = 0;
+f08na.eval(jobvl, jobvr, n, X1d, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info);
+Arrays.sort(wr);
+```
+
+
+
+```
+Sorted eigenvalues of X: -0.0000 0.0000 0.0380 0.1731 0.6894 1.7117 1.9217 3.4661
+```
+
+
+
+
+
+# Weighting rows and columns of elements
+
+* Now, we note that for Stocks A to C we have a complete set of observations.
+
+
+$$
+P=\left[\begin{array}{rrrrrrrr}
+ {\color{blue}{59.875}} & {\color{blue}{42.734}} & {\color{blue}{47.938}} & 60.359 & 54.016 & 69.625 & 61.500 & 62.125 \\
+ {\color{blue}{53.188}} & {\color{blue}{49.000}} & {\color{blue}{39.500}} & \textrm{NaN} & 34.750 & \textrm{NaN} & 83.000 & 44.500 \\
+ {\color{blue}{55.750}} & {\color{blue}{50.000}} & {\color{blue}{38.938}} & \textrm{NaN} & 30.188 & \textrm{NaN} & 70.875 & 29.938 \\
+ {\color{blue}{65.500}} & {\color{blue}{51.063}} & {\color{blue}{45.563}} & 69.313 & 48.250 & 62.375 & 85.250 & \textrm{NaN} \\
+ {\color{blue}{69.938}} & {\color{blue}{47.000}} & {\color{blue}{52.313}} & 71.016 & \textrm{NaN} & 59.359 & 61.188 & 48.219 \\
+ {\color{blue}{61.500}} & {\color{blue}{44.188}} & {\color{blue}{53.438}} & 57.000 & 35.313 & 55.813 & 51.500 & 62.188 \\
+ {\color{blue}{59.230}} & {\color{blue}{48.210}} & {\color{blue}{62.190}} & 61.390 & 54.310 & 70.170 & 61.750 & 91.080 \\
+ {\color{blue}{61.230}} & {\color{blue}{48.700}} & {\color{blue}{60.300}} & 68.580 & 61.250 & 70.340 & \textrm{NaN} & \textrm{NaN} \\
+ {\color{blue}{52.900}} & {\color{blue}{52.690}} & {\color{blue}{54.230}} & \textrm{NaN} & 68.170 & 70.600 & 57.870 & 88.640 \\
+ {\color{blue}{57.370}} & {\color{blue}{59.040}} & {\color{blue}{59.870}} & 62.090 & 61.620 &66.470 & 65.370 & 85.840
+\end{array}\right].
+$$
+
+
+* Perhaps we wish to preserve part of the correlation matrix?
+
+
+* We could solve the *weighted* problem, NAG routine **G02AB**
+
+
+$$ \Large \|W^{\frac{1}{2}} (G-X) W^{\frac{1}{2}} \|_F$$
+
+
+* Here $$W$$ is a diagonal matrix.
+
+
+* We can also force the resulting matrix to be positive definite.
+
+### Use G02AB to compute the nearest correlation matrix with row and column weighting
+
+```java
+// Define an arrray of weights
+double[] W = new double[] { 10, 10, 10, 1, 1, 1, 1, 1 };
+
+// Set up and call the NAG routine using weights and a minimum eigenvalue
+G02AB g02ab = new G02AB();
+G1d = convert2DTo1D(G);
+ldg = G.length;
+n = G[0].length;
+String opt = "B";
+double alpha = 0.001;
+errtol = 0.0;
+maxits = 0;
+maxit = 0;
+ldx = n;
+X1d = new double[ldx * n];
+iter = 0;
+feval = 0;
+nrmgrd = 0;
+ifail = 0;
+g02ab.eval(G1d, ldg, n, opt, alpha, W, errtol, maxits, maxit, X1d, ldx, iter, feval, nrmgrd, ifail);
+
+X = convert1DTo2D(X1d, ldx);
+iter = g02ab.getITER();
+```
+
+
+
+```
+Nearest correlation matrix using row and column weighting
+ 1.0000 -0.3250 0.1881 0.5739 0.0067 -0.6097 -0.0722 -0.1598
+ -0.3250 1.0000 0.2048 0.2426 0.4060 0.2737 0.2870 0.4236
+ 0.1881 0.2048 1.0000 -0.1322 0.7661 0.2759 -0.6171 0.9004
+ 0.5739 0.2426 -0.1322 1.0000 0.2085 -0.0890 0.5954 -0.1805
+ 0.0067 0.4060 0.7661 0.2085 1.0000 0.6556 -0.2780 0.8757
+ -0.6097 0.2737 0.2759 -0.0890 0.6556 1.0000 0.0490 0.5746
+ -0.0722 0.2870 -0.6171 0.5954 -0.2780 0.0490 1.0000 -0.4550
+ -0.1598 0.4236 0.9004 -0.1805 0.8757 0.5746 -0.4550 1.0000
+
+```
+
+
+
+```java
+jobvl = "N";
+jobvr = "N";
+n = X[0].length;
+lda = X.length;
+wr = new double[n];
+wi = new double[n];
+ldvl = 1;
+vl = new double[ldvl];
+ldvr = 1;
+vr = new double[ldvr];
+lwork = 3 * n;
+work = new double[lwork];
+info = 0;
+f08na.eval(jobvl, jobvr, n, X1d, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info);
+Arrays.sort(wr);
+```
+
+
+
+```
+Sorted eigenvalues of X: 0.0010 0.0010 0.0305 0.1646 0.6764 1.7716 1.8910 3.4639
+```
+
+
+
+
+
+
+
+# Weighting Individual Elements
+
+* Would it be better to be able to *weight individual elements* in our approximate matrix?
+
+
+* In our example the top left 3 by 3 block of exact correlations, perhaps.
+
+
+* Element-wise weighting means we wish to find the minimum of
+
+
+$$ \Large \|H \circ(G-X) \|_F $$
+
+
+* So individually $$h_{ij} \times (g_{ij} - x_{ij}).$$
+
+
+* However, this is a more “difficult” problem, and more computationally expensive.
+
+
+* This is implemented in the NAG routine **G02AJ**.
+
+### Use G02AJ to compute the nearest correlation matrix with element-wise weighting
+
+```java
+// Set up a matrix of weights
+n = P[0].length;
+double[][] H = new double[n][n];
+for (int i = 0; i < n; i++) {
+ for (int j = 0; j < n; j++) {
+ if ((i < 3) && (j < 3)) {
+ H[i][j] = 100.0;
+ } else {
+ H[i][j] = 1;
+ }
+ }
+}
+```
+
+
+
+```
+100.0000 100.0000 100.0000 1.0000 1.0000 1.0000 1.0000 1.0000
+100.0000 100.0000 100.0000 1.0000 1.0000 1.0000 1.0000 1.0000
+100.0000 100.0000 100.0000 1.0000 1.0000 1.0000 1.0000 1.0000
+ 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
+ 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
+ 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
+ 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
+ 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
+```
+
+
+
+```java
+// Call the NAG routine specifying a minimum eigenvalue
+G02AJ g02aj = new G02AJ();
+G1d = convert2DTo1D(G);
+ldg = G.length;
+n = G[0].length;
+alpha = 0.001;
+double[] H1d = convert2DTo1D(H);
+int ldh = H.length;
+errtol = 0;
+maxit = 0;
+ldx = n;
+X1d = new double[ldx * n];
+iter = 0;
+double norm2 = 0;
+ifail = 0;
+g02aj.eval(G1d, ldg, n, alpha, H1d, ldh, errtol, maxit, X1d, ldx, iter, norm2, ifail);
+
+X = convert1DTo2D(X1d, ldx);
+iter = g02aj.getITER();
+```
+
+
+
+```
+Nearest correlation matrix using element-wise weighting
+ 1.0000 -0.3251 0.1881 0.5371 0.0255 -0.5893 -0.0625 -0.1929
+ -0.3251 1.0000 0.2048 0.2249 0.4144 0.2841 0.2914 0.4081
+ 0.1881 0.2048 1.0000 -0.1462 0.7883 0.2718 -0.6084 0.8804
+ 0.5371 0.2249 -0.1462 1.0000 0.2138 -0.0002 0.6070 -0.2199
+ 0.0255 0.4144 0.7883 0.2138 1.0000 0.6566 -0.2807 0.8756
+ -0.5893 0.2841 0.2718 -0.0002 0.6566 1.0000 0.0474 0.5930
+ -0.0625 0.2914 -0.6084 0.6070 -0.2807 0.0474 1.0000 -0.4471
+ -0.1929 0.4081 0.8804 -0.2199 0.8756 0.5930 -0.4471 1.0000
+```
+
+
+
+```java
+jobvl = "N";
+jobvr = "N";
+n = X[0].length;
+lda = X.length;
+wr = new double[n];
+wi = new double[n];
+ldvl = 1;
+vl = new double[ldvl];
+ldvr = 1;
+vr = new double[ldvr];
+lwork = 3 * n;
+work = new double[lwork];
+info = 0;
+f08na.eval(jobvl, jobvr, n, X1d, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info);
+Arrays.sort(wr);
+```
+
+
+
+```
+Sorted eigenvalues of X: 0.0010 0.0010 0.0375 0.1734 0.6882 1.7106 1.9224 3.4660
+```
+
+
+
+
+
+
+
+# Fixing a Block of Elements
+
+* We probably really wish to *fix* our leading block of true correlations, so it does not change at all.
+
+
+* We have the NAG routine **G02AN**.
+
+
+* This routine fixes a leading block, which we require to be positive definite.
+
+
+* We apply the *shrinking algorithm* of Higham, Strabić and Šego. The approach is **not** computationally expensive.
+
+
+* What we find is the smallest α, such that *X* is a true correlation matrix:
+
+
+$$ \large X = \alpha \left(
+\begin{array}{ll}G_{11} & 0 \\ 0 & I \end{array} \right) +(1-\alpha)G,
+\qquad G = \left(
+\begin{array}{ll} G_{11} & G_{12} \\ G_{12}^T & G_{22} \end{array}
+\right)
+$$
+
+
+* $$G_{11}$$ is the leading $$k$$ by $$k$$ block of the approximate correlation matrix that we wish to fix.
+
+
+* $$\alpha$$ is in the interval $$[0,1]$$.
+
+### Use G02AN to compute the nearest correlation matrix with fixed leading block
+
+```java
+// Call the NAG routine fixing the top 3-by-3 block
+G02AN g02an = new G02AN();
+G1d = convert2DTo1D(G);
+ldg = G.length;
+n = G[0].length;
+int k = 3;
+errtol = 0;
+double eigtol = 0;
+ldx = n;
+X1d = new double[ldx * n];
+alpha = 0.001;
+iter = 0;
+double eigmin = 0;
+norm2 = 0;
+ifail = 0;
+g02an.eval(G1d, ldg, n, k, errtol, eigtol, X1d, ldx, alpha, iter, eigmin, norm2, ifail);
+
+X = convert1DTo2D(X1d, ldx);
+iter = g02an.getITER();
+alpha = g02an.getALPHA();
+```
+
+
+
+```
+Nearest correlation matrix with fixed leading block
+ 1.0000 -0.3250 0.1881 0.4606 0.0051 -0.4887 -0.0579 -0.1271
+ -0.3250 1.0000 0.2048 0.1948 0.3245 0.2183 0.2294 0.3391
+ 0.1881 0.2048 1.0000 -0.1060 0.6124 0.2211 -0.4936 0.7202
+ 0.4606 0.1948 -0.1060 1.0000 0.2432 0.0101 0.5160 -0.2567
+ 0.0051 0.3245 0.6124 0.2432 1.0000 0.5320 -0.2634 0.7949
+ -0.4887 0.2183 0.2211 0.0101 0.5320 1.0000 0.0393 0.4769
+ -0.0579 0.2294 -0.4936 0.5160 -0.2634 0.0393 1.0000 -0.3185
+ -0.1271 0.3391 0.7202 -0.2567 0.7949 0.4769 -0.3185 1.0000
+ ```
+
+
+
+```java
+jobvl = "N";
+jobvr = "N";
+n = X[0].length;
+lda = X.length;
+wr = new double[n];
+wi = new double[n];
+ldvl = 1;
+vl = new double[ldvl];
+ldvr = 1;
+vr = new double[ldvr];
+lwork = 3 * n;
+work = new double[lwork];
+info = 0;
+f08na.eval(jobvl, jobvr, n, X1d, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info);
+Arrays.sort(wr);
+```
+
+
+
+```
+Sorted eigenvalues of X: 0.0000 0.1375 0.2744 0.3804 0.7768 1.6263 1.7689 3.0356
+Value of alpha returned: 0.2003
+```
+
+
+
+
+
+
+
+# Fixing Arbitrary Elements
+
+* The routine **G02AP** fixes arbitrary elements by finding the smallest α, such that *X* is a true correlation matrix in:
+
+
+$$ X = \large \alpha T+(1-\alpha)G, \quad T = H \circ G, \quad h_{ij} \in [0,1] $$
+
+
+* A "1" in *H* fixes corresponding elements in *G*.
+
+
+* $$0 < h_{ij} < 1$$ weights corresponding element in *G*.
+
+
+* $$\alpha$$ is again in the interval $$[0,1]$$.
+
+## Alternating Projections
+
+* First method proposed to solve our original problem, however, it is very slow.
+
+
+* The idea is we alternate projecting onto two sets, which are:
+ * the set of smeidefinite matrices (S1), and
+ * matrices with unit diagonal (s2)
+
+
+* We do this until we converge on a matrix with both properties.
+
+
+
+Before introducing our new NAG Library routine, let’s demonstrate how one might naively
+compute implied volatilities using a general purpose root finder.
+
+Let's generate some input data using a random number generator from the NAG Library:
+
+```java
+ G05KG g05kg = new G05KG();
+ G05SQ g05sq = new G05SQ();
+ int ifail = 0;
+ int lstate = 17;
+ int[] state = new int[lstate];
+ int n = 10000; // This is the number of volatilities we will be computing
+
+ double[] p = new double[n];
+ double[] k = new double[n];
+ double[] s0 = new double[n];
+ double[] t = new double[n];
+ double[] r = new double[n];
+
+ g05kg.eval(1, 0, state, lstate, ifail);
+ g05sq.eval(n, 3.9, 5.8, state, p, ifail);
+ g05sq.eval(n, 271.5, 272.0, state, k, ifail);
+ g05sq.eval(n, 259.0, 271.0, state, s0, ifail);
+ g05sq.eval(n, 0.016, 0.017, state, t, ifail);
+ g05sq.eval(n, 0.017, 0.018, state, r, ifail);
+```
+
+We have chosen the limits of the various uniform distributions above to ensure the input data takes
+sensible values.
+
+There are various standard root finding techniques that we could use to compute implied volatilities,
+a common example being bisection. The NAG Library routine ```C05AW```, is a general
+purpose root finder based on the secant method. It uses a *callback*, with data passed in via a communication object:
+
+```java
+ public static class BlackScholes extends C05AW.Abstract_C05AW_F {
+ public double eval() {
+ double[] price = new double[1];
+ int ifail = 1;
+
+ S30AA s30aa = new S30AA();
+ s30aa.eval("C", 1, 1, new double[]{this.getRUSER()[1]}, this.getRUSER()[2], new double[]{this.getRUSER()[3]}, this.getX(), this.getRUSER()[4], 0.0, price, 1, ifail);
+
+ ifail = s30aa.getIFAIL();
+
+ if (ifail != 0)
+ price[0] = 0.0;
+
+ return price[0] - this.getRUSER()[0];
+ }
+ }
+```
+
+ ```C05AW``` operates on scalars, so we need to call the routine
+once for every volatility we want to compute. We will time the computation and count how many errors are caught:
+
+```java
+ int[] iuser = new int[5];
+ double[] ruser = new double[5];
+ int errorcount = 0;
+ double sigma;
+
+ C05AW c05aw = new C05AW();
+ BlackScholes blackScholes = new BlackScholes();
+
+ long tic = System.currentTimeMillis();
+ for (i = 0; i < n; i++) {
+ //System.out.println("Info: i = " + i);
+ ruser[0] = p[i];
+ ruser[1] = k[i];
+ ruser[2] = s0[i];
+ ruser[3] = t[i];
+ ruser[4] = r[i];
+
+ ifail = 1;
+ c05aw.eval(0.15, 1.0e-14, 0.0, blackScholes, 500, iuser, ruser, ifail);
+
+ sigma = c05aw.getX();
+ ifail = c05aw.getIFAIL();
+
+ if ((sigma < 0.0) || (ifail != 0)) {
+ errorcount++;
+ }
+ }
+ long toc = System.currentTimeMillis();
+
+ System.out.println("Using a general purpose root finder:");
+ System.out.printf(" Time taken: %.5f seconds\n", (toc-tic)/1000.0);
+ System.out.printf(" There were %d failures\n", errorcount);
+```
+
+Can a bespoke implied volatility routine do better? Our new routine at Mark 27.1 is called ```S30AC```. We call it as follows:
+
+```s30ac.eval("C", n, p, k, s0, t, r, sigma_arr, 2, ivalid, ifail);```
+
+The return argument ```ivalid``` is an array recording any data points for which the volatility could not be computed. The argument ```mode``` allows us to select which algorithm to use – more on that in a moment, but
+for now we choose ```mode=2```. This selects the algorithm of Jäckel (2015), a very accurate method based
+on third order Householder iterations.
+
+Here is the call surrounded by some timing code:
+
+```java
+ S30AC s30ac = new S30AC();
+ double[] sigma_arr = new double[n];
+ int[] ivalid = new int[n];
+
+ tic = System.currentTimeMillis();
+ ifail = 0;
+ s30ac.eval("C", n, p, k, s0, t, r, sigma_arr, 2, ivalid, ifail);
+ toc = System.currentTimeMillis();
+
+ System.out.println("S30AC with mode = 2 (Jäckel algorithm):");
+ System.out.printf(" Time taken: %.5f seconds\n", (toc-tic)/1000.0);
+ System.out.printf(" There were %d failures\n", nonZeroLength(ivalid));
+```
+
+The new routine is several orders of magnitude faster than the root finder, with no failures reported. We could try
+tweaking the convergence parameters and iteration limits in ```C05AW```, and we could certainly
+improve the way data is passed through the callback, but we are unlikely to match the
+performance of ```S30AC```.
+
+Recently NAG embarked upon a collaboration with mathematicians at Queen Mary University of
+London, who have been developing an alternative algorithm for computing implied volatilities. The new
+algorithm (based on Glau et. al. (2018)) uses Chebyshev interpolation to remove branching and give
+increased SIMD performance. We access it by setting ```mode=1``` in the call to ```S30AC```:
+
+```java
+ tic = System.currentTimeMillis();
+ ifail = 0;
+ s30ac.eval("C", n, p, k, s0, t, r, sigma_arr, 1, ivalid, ifail);
+ toc = System.currentTimeMillis();
+
+ System.out.println("S30AC with mode = 1 (Glau algorithm):");
+ System.out.printf(" Time taken: %.5f seconds\n", (toc-tic)/1000.0);
+ System.out.printf(" There were %d failures\n", nonZeroLength(ivalid));
+```
+
+Depending on your system, you should find that, for similar accuracy, there is a modest speedup over the Jäckel algorithm. Our numerical experiments have shown that for very small arrays (containing fewer than 100 elements) the Jäckel algorithm actually
+outperforms that of Glau et.al., but for larger arrays the converse is true. As vector units continue
+to improve in the future, we expect the performance of the highly vectorizable Glau et.al. approach to
+improve similarly.
+
+So far, we have been computing implied volatilities with a relative accuracy as close as possible to
+double precision. However, in some applications implied volatilities are only required with a few decimal
+places of precision. One advantage of the Glau et.al. algorithm is that it can be run in a lower accuracy
+mode, aiming only for seven decimal places of accuracy. This is accessed by setting ```mode=0``` in the call
+to ```S30AC```. It roughly doubles the speed of the routine:
+
+```java
+ tic = System.currentTimeMillis();
+ ifail = 0;
+ s30ac.eval("C", n, p, k, s0, t, r, sigma_arr, 0, ivalid, ifail);
+ toc = System.currentTimeMillis();
+
+ System.out.println("S30AC with mode = 0 (lower accuracy Glau algorithm):");
+ System.out.printf(" Time taken: %.5f seconds\n", (toc-tic)/1000.0);
+ System.out.printf(" There were %d failures\n", nonZeroLength(ivalid));
+```
+
+The charts below summarize the results, using timings collected on an Intel Skylake machine. We can see that the Glau et.al. algorithm outperforms the Jäckel algorithm for large arrays but not for small arrays. Note that the general purpose root finder
+is omitted here as it is so much slower ```S30AC```.
+
+
+
+
+
+In summary, NAG’s new state-of-the art algorithm can be run in three different modes, according to
+the length of the input arrays and the required accuracy. For more information, and to access the NAG
+Library, go to: https://www.nag.co.uk/content/nag-library.
+
+### References
+
+P. Jäckel (2015). Let’s be rational. *Wilmott* 2015, 40-53.
+
+K. Glau, P. Herold, D. B. Madan, C. Pötz (2019). The Chebyshev method for the implied volatility.
+*Journal of Computational Finance*, 23(3).
diff --git a/opt_imp_vol/graphs.PNG b/opt_imp_vol/graphs.PNG
new file mode 100644
index 0000000..0b51c1c
Binary files /dev/null and b/opt_imp_vol/graphs.PNG differ
diff --git a/opt_imp_vol/impVolDemo.java b/opt_imp_vol/impVolDemo.java
new file mode 100644
index 0000000..7b46843
--- /dev/null
+++ b/opt_imp_vol/impVolDemo.java
@@ -0,0 +1,157 @@
+import com.nag.routines.G05.G05SQ;
+import com.nag.routines.G05.G05KG;
+import com.nag.routines.S.S30AA;
+import com.nag.routines.S.S30AC;
+import com.nag.routines.C05.C05AW;
+
+import java.util.Map;
+import java.util.HashMap;
+
+public class impVolDemo {
+
+ public static void main(String[] args) {
+
+ int i;
+
+
+
+ // Let's generate some input data using a random number generator from the NAG
+ // Library:
+ G05KG g05kg = new G05KG();
+ G05SQ g05sq = new G05SQ();
+ int ifail = 0;
+ int lstate = 17;
+ int[] state = new int[lstate];
+ int n = 10000; // This is the number of volatilities we will be computing
+
+ double[] p = new double[n];
+ double[] k = new double[n];
+ double[] s0 = new double[n];
+ double[] t = new double[n];
+ double[] r = new double[n];
+
+ g05kg.eval(1, 0, state, lstate, ifail);
+ g05sq.eval(n, 3.9, 5.8, state, p, ifail);
+ g05sq.eval(n, 271.5, 272.0, state, k, ifail);
+ g05sq.eval(n, 259.0, 271.0, state, s0, ifail);
+ g05sq.eval(n, 0.016, 0.017, state, t, ifail);
+ g05sq.eval(n, 0.017, 0.018, state, r, ifail);
+
+
+ int[] iuser = new int[5];
+ double[] ruser = new double[5];
+ int errorcount = 0;
+ double sigma;
+
+ C05AW c05aw = new C05AW();
+ BlackScholes blackScholes = new BlackScholes();
+
+ long tic = System.currentTimeMillis();
+ for (i = 0; i < n; i++) {
+ //System.out.println("Info: i = " + i);
+ ruser[0] = p[i];
+ ruser[1] = k[i];
+ ruser[2] = s0[i];
+ ruser[3] = t[i];
+ ruser[4] = r[i];
+
+ ifail = 1;
+ c05aw.eval(0.15, 1.0e-14, 0.0, blackScholes, 500, iuser, ruser, ifail);
+
+ sigma = c05aw.getX();
+ ifail = c05aw.getIFAIL();
+
+ if ((sigma < 0.0) || (ifail != 0)) {
+ errorcount++;
+ }
+ }
+ long toc = System.currentTimeMillis();
+
+ System.out.println("Using a general purpose root finder:");
+ System.out.printf(" Time taken: %.5f seconds\n", (toc-tic)/1000.0);
+ System.out.printf(" There were %d failures\n", errorcount);
+
+ System.out.println();
+
+
+ S30AC s30ac = new S30AC();
+ double[] sigma_arr = new double[n];
+ int[] ivalid = new int[n];
+
+ tic = System.currentTimeMillis();
+ ifail = 0;
+ s30ac.eval("C", n, p, k, s0, t, r, sigma_arr, 2, ivalid, ifail);
+ toc = System.currentTimeMillis();
+
+ System.out.println("S30AC with mode = 2 (Jäckel algorithm):");
+ System.out.printf(" Time taken: %.5f seconds\n", (toc-tic)/1000.0);
+ System.out.printf(" There were %d failures\n", nonZeroLength(ivalid));
+
+ System.out.println();
+
+
+ tic = System.currentTimeMillis();
+ ifail = 0;
+ s30ac.eval("C", n, p, k, s0, t, r, sigma_arr, 1, ivalid, ifail);
+ toc = System.currentTimeMillis();
+
+ System.out.println("S30AC with mode = 1 (Glau algorithm):");
+ System.out.printf(" Time taken: %.5f seconds\n", (toc-tic)/1000.0);
+ System.out.printf(" There were %d failures\n", nonZeroLength(ivalid));
+
+ System.out.println();
+
+
+ tic = System.currentTimeMillis();
+ ifail = 0;
+ s30ac.eval("C", n, p, k, s0, t, r, sigma_arr, 0, ivalid, ifail);
+ toc = System.currentTimeMillis();
+
+ System.out.println("S30AC with mode = 0 (lower accuracy Glau algorithm):");
+ System.out.printf(" Time taken: %.5f seconds\n", (toc-tic)/1000.0);
+ System.out.printf(" There were %d failures\n", nonZeroLength(ivalid));
+
+ System.out.println();
+ }
+
+ public static class BlackScholes extends C05AW.Abstract_C05AW_F {
+ public double eval() {
+ double[] price = new double[1];
+ int ifail = 1;
+
+ S30AA s30aa = new S30AA();
+ s30aa.eval("C", 1, 1, new double[]{this.getRUSER()[1]}, this.getRUSER()[2], new double[]{this.getRUSER()[3]}, this.getX(), this.getRUSER()[4], 0.0, price, 1, ifail);
+
+ ifail = s30aa.getIFAIL();
+
+ if (ifail != 0)
+ price[0] = 0.0;
+
+ return price[0] - this.getRUSER()[0];
+ }
+ }
+
+ public static int nonZeroLength(int[] a) {
+ int c = 0;
+ for (int i = 0; i < a.length; i++) {
+ if (a[i] != 0) {
+ c++;
+ }
+ }
+ return c;
+ }
+
+ public static void printVector(double[] a) {
+ for (int i = 0; i < a.length; i++) {
+ System.out.printf("%8.4f ", a[i]);
+ }
+ System.out.println();
+ }
+
+ public static void printVector(int[] a) {
+ for (int i = 0; i < a.length; i++) {
+ System.out.printf("%5d ", a[i]);
+ }
+ System.out.println();
+ }
+}
diff --git a/opt_imp_vol/impvolsurf.png b/opt_imp_vol/impvolsurf.png
new file mode 100644
index 0000000..20b4c23
Binary files /dev/null and b/opt_imp_vol/impvolsurf.png differ
diff --git a/opt_imp_vol/output.txt b/opt_imp_vol/output.txt
new file mode 100644
index 0000000..ddbddd7
Binary files /dev/null and b/opt_imp_vol/output.txt differ
diff --git a/simple_examples/baseresults/a00aaje.r b/simple_examples/baseresults/a00aaje.r
new file mode 100644
index 0000000..282acb3
--- /dev/null
+++ b/simple_examples/baseresults/a00aaje.r
@@ -0,0 +1,10 @@
+ A00AAJ Example Program Results
+
+ *** Start of NAG Library implementation details ***
+
+ Implementation title: Linux, 64-bit, Intel C/C++ (32-bit integers)
+ Precision: double precision
+ Product Code: CLL6I262CL
+ Mark: 27.2.1 (self-contained)
+
+ *** End of NAG Library implementation details ***
diff --git a/simple_examples/baseresults/a00acje.r b/simple_examples/baseresults/a00acje.r
new file mode 100644
index 0000000..0012531
--- /dev/null
+++ b/simple_examples/baseresults/a00acje.r
@@ -0,0 +1,3 @@
+ A00ACJ Example Program Results
+
+ A valid licence key is available
diff --git a/simple_examples/baseresults/a00adje.r b/simple_examples/baseresults/a00adje.r
new file mode 100644
index 0000000..5fb1839
--- /dev/null
+++ b/simple_examples/baseresults/a00adje.r
@@ -0,0 +1,17 @@
+ A00ADJ Example Program Results
+
+*** Start of NAG Library implementation details ***
+
+Implementation title: Linux, 64-bit, Intel C/C++ (32-bit integers)
+ Precision: Fortran double precision
+ Product code: CLL6I262CL
+ Mark: 26.2
+ Vendor Library: None
+Applicable to:
+ hardware: x86_64
+ operating system: Linux 2.6.32-696.6.3.el6.x86_64
+ Fortran compiler: Intel ifort Version 18.0.1.163 20171018
+and compatible systems.
+ Licence query: Successful
+
+*** End of NAG Library implementation details ***
diff --git a/simple_examples/baseresults/c02aaje.r b/simple_examples/baseresults/c02aaje.r
new file mode 100644
index 0000000..fa3083b
--- /dev/null
+++ b/simple_examples/baseresults/c02aaje.r
@@ -0,0 +1,19 @@
+ C02AAJ Example Program Results
+
+ Example 1: Basic Problem
+
+ i z conv berr cond
+ ---------------------------------------------------
+ 1 6.53E-03, 7.42E-03 3 9.25E-18 4.84E+00
+ 2 -6.93E-03, -7.44E-03 2 0.00E+00 4.95E+00
+ 3 -2.43E+01, -4.86E+00 3 8.41E-18 1.13E+01
+ 4 1.47E+01, -1.66E+01 3 1.07E-17 9.99E+00
+ 5 5.25E+00, 2.27E+01 3 2.08E-17 1.06E+01
+
+ Example 2: Polishing Processes
+
+ polish relerr fwderr
+ ----------------------------
+ 0 3.18E-10 1.15E-04
+ 1 6.16E-11 8.49E-06
+ 2 1.11E-16 1.11E-16
diff --git a/simple_examples/baseresults/c02abje.r b/simple_examples/baseresults/c02abje.r
new file mode 100644
index 0000000..01b29cd
--- /dev/null
+++ b/simple_examples/baseresults/c02abje.r
@@ -0,0 +1,12 @@
+ C02ABJ Example Program Results
+
+ Basic Problem
+
+ i z conv berr cond
+ -----------------------------------------------------
+ 1 ( 1.15E+00, 7.36E-01) 3 5.37E-18 1.34E+01
+ 2 ( -1.67E+00, 3.25E-01) 3 6.34E-18 2.20E+01
+ 3 ( 3.79E-01, -1.25E+00) 3 2.98E-18 1.02E+01
+ 4 ( -1.67E+00, -3.25E-01) 3 4.57E-18 2.20E+01
+ 5 ( 1.15E+00, -7.36E-01) 3 1.04E-17 1.34E+01
+ 6 ( 3.79E-01, 1.25E+00) 2 1.66E-18 1.02E+01
diff --git a/simple_examples/baseresults/c02afje.r b/simple_examples/baseresults/c02afje.r
new file mode 100644
index 0000000..386d4fe
--- /dev/null
+++ b/simple_examples/baseresults/c02afje.r
@@ -0,0 +1,28 @@
+ C02AFJ Example Program Results
+
+
+ Example 1
+
+ Degree of polynomial = 5
+
+ Computed roots of polynomial
+
+ z = -2.4328E+01 -4.8555E+00*i
+ z = 5.2487E+00 +2.2736E+01*i
+ z = 1.4653E+01 -1.6569E+01*i
+ z = -6.9264E-03 -7.4434E-03*i
+ z = 6.5264E-03 +7.4232E-03*i
+
+
+ Example 2
+
+ Degree of polynomial = 5
+
+ Computed roots of polynomial Error estimates
+ (machine-dependent)
+
+ z = -2.4328E+01 -4.8555E+00*i 5.7E-16
+ z = 5.2487E+00 +2.2736E+01*i 1.5E-16
+ z = 1.4653E+01 -1.6569E+01*i 4.8E-16
+ z = -6.9264E-03 -7.4434E-03*i 1.1E-16
+ z = 6.5264E-03 +7.4232E-03*i 1.8E-16
diff --git a/simple_examples/baseresults/c02agje.r b/simple_examples/baseresults/c02agje.r
new file mode 100644
index 0000000..8e10c18
--- /dev/null
+++ b/simple_examples/baseresults/c02agje.r
@@ -0,0 +1,27 @@
+ C02AGJ Example Program Results
+
+
+ Example 1
+
+
+ Degree of polynomial = 5
+
+ Computed roots of polynomial
+
+ z = -1.4918E+00
+ z = 5.5169E-01 +/- 1.2533E+00*i
+ z = -8.0579E-01 +/- 1.2229E+00*i
+
+
+ Example 2
+
+ Degree of polynomial = 5
+
+ Computed roots of polynomial Error estimates
+ (machine-dependent)
+
+ z = -1.4918E+00 +0.0000E+00*i 7.4E-16
+ z = 5.5169E-01 +1.2533E+00*i 1.1E-16
+ z = 5.5169E-01 -1.2533E+00*i 1.1E-16
+ z = -8.0579E-01 +1.2229E+00*i 3.0E-16
+ z = -8.0579E-01 -1.2229E+00*i 3.0E-16
diff --git a/simple_examples/baseresults/c02ahje.r b/simple_examples/baseresults/c02ahje.r
new file mode 100644
index 0000000..e3efc97
--- /dev/null
+++ b/simple_examples/baseresults/c02ahje.r
@@ -0,0 +1,6 @@
+ C02AHJ Example Program Results
+
+ Roots of quadratic equation
+
+ z = 1.0000E+00 +2.0000E+00*i
+ z = 2.0000E+00 -3.0000E+00*i
diff --git a/simple_examples/baseresults/c02ajje.r b/simple_examples/baseresults/c02ajje.r
new file mode 100644
index 0000000..944fa06
--- /dev/null
+++ b/simple_examples/baseresults/c02ajje.r
@@ -0,0 +1,6 @@
+ C02AJJ Example Program Results
+
+ Roots of quadratic equation
+
+ z = 2.0000E+00
+ z = -5.0000E+00
diff --git a/simple_examples/baseresults/c02akje.r b/simple_examples/baseresults/c02akje.r
new file mode 100644
index 0000000..34b3e74
--- /dev/null
+++ b/simple_examples/baseresults/c02akje.r
@@ -0,0 +1,8 @@
+ C02AKJ Example Program Results
+
+ Roots of cubic equation Error estimates
+ (machine-dependent)
+
+ z = 1.0000E+00 +0.0000E+00*i 1.0E-15
+ z = -2.0000E+00 +3.0000E+00*i 1.0E-15
+ z = -2.0000E+00 -3.0000E+00*i 1.0E-15
diff --git a/simple_examples/baseresults/c02alje.r b/simple_examples/baseresults/c02alje.r
new file mode 100644
index 0000000..ff49a36
--- /dev/null
+++ b/simple_examples/baseresults/c02alje.r
@@ -0,0 +1,9 @@
+ C02ALJ Example Program Results
+
+ Roots of quartic equation Error estimates
+ (machine-dependent)
+
+ z = 2.0000E+00 +0.0000E+00*i 1.2E-15
+ z = -2.0000E+00 +0.0000E+00*i 1.1E-15
+ z = -1.0000E+00 +3.0000E+00*i 1.1E-15
+ z = -1.0000E+00 -3.0000E+00*i 1.1E-15
diff --git a/simple_examples/baseresults/c02amje.r b/simple_examples/baseresults/c02amje.r
new file mode 100644
index 0000000..c2c70b4
--- /dev/null
+++ b/simple_examples/baseresults/c02amje.r
@@ -0,0 +1,8 @@
+ C02AMJ Example Program Results
+
+ Roots of cubic equation Error estimates
+ (machine-dependent)
+
+ z = -2.0000E+00 +3.0000E+00*i 1.3E-15
+ z = 1.0000E+00 -2.0000E+00*i 2.2E-15
+ z = 3.0000E+00 -4.0000E+00*i 2.1E-15
diff --git a/simple_examples/baseresults/c02anje.r b/simple_examples/baseresults/c02anje.r
new file mode 100644
index 0000000..4361b7e
--- /dev/null
+++ b/simple_examples/baseresults/c02anje.r
@@ -0,0 +1,9 @@
+ C02ANJ Example Program Results
+
+ Roots of quartic equation Error estimates
+ (machine-dependent)
+
+ z = 3.0000E+00 -2.0000E+00*i 1.8E-15
+ z = 1.0000E+00 -2.0000E+00*i 1.8E-15
+ z = -2.0000E+00 +1.0000E+00*i 1.8E-15
+ z = -2.0000E+00 +3.0000E+00*i 1.8E-15
diff --git a/simple_examples/baseresults/c05auje.r b/simple_examples/baseresults/c05auje.r
new file mode 100644
index 0000000..1c8bb18
--- /dev/null
+++ b/simple_examples/baseresults/c05auje.r
@@ -0,0 +1,4 @@
+C05AUJ Example Program Results
+
+Root is : 0.56714
+Interval searched is : [ 0.50000, 0.90000]
diff --git a/simple_examples/baseresults/c05awje.r b/simple_examples/baseresults/c05awje.r
new file mode 100644
index 0000000..0868382
--- /dev/null
+++ b/simple_examples/baseresults/c05awje.r
@@ -0,0 +1,4 @@
+C05AWJ Example Program Results
+
+With eps = 1.00e-03 root = 0.56715
+With eps = 1.00e-04 root = 0.56715
diff --git a/simple_examples/baseresults/c05ayje.r b/simple_examples/baseresults/c05ayje.r
new file mode 100644
index 0000000..50a0010
--- /dev/null
+++ b/simple_examples/baseresults/c05ayje.r
@@ -0,0 +1,3 @@
+C05AYJ Example Program Results
+
+Zero at x = 0.56714
diff --git a/simple_examples/baseresults/c05azje.r b/simple_examples/baseresults/c05azje.r
new file mode 100644
index 0000000..1d3b6bc
--- /dev/null
+++ b/simple_examples/baseresults/c05azje.r
@@ -0,0 +1,15 @@
+ C05AZJ Example Program Results
+
+ Iterations
+
+ X = 0.00000 FX = 1.0000E+00 IND = 2
+ X = 1.00000 FX = -6.3212E-01 IND = 3
+ X = 0.61270 FX = -7.0814E-02 IND = 4
+ X = 0.56707 FX = 1.1542E-04 IND = 4
+ X = 0.56714 FX = -9.4481E-07 IND = 4
+ X = 0.56713 FX = 1.4727E-05 IND = 4
+ X = 0.56714 FX = -9.4481E-07 IND = 4
+
+ Solution
+
+ X = 0.56714 Y = 0.56713
diff --git a/simple_examples/baseresults/c05bbje.r b/simple_examples/baseresults/c05bbje.r
new file mode 100644
index 0000000..a963b94
--- /dev/null
+++ b/simple_examples/baseresults/c05bbje.r
@@ -0,0 +1,10 @@
+C05BBJ Example Program Results
+Branch = 0
+Offset = false
+
+ Z W(Z) RESID IFAIL
+
+(5.00000e-01, -1.00000e+00) (5.16511e-01, -4.22053e-01) 5.55112e-17 0
+(1.00000e+00, 2.30000e+00) (8.73606e-01, 5.76978e-01) 1.11022e-16 0
+(4.50000e+00, -1.00000e-01) (1.26735e+00, -1.24194e-02) 0.00000e+00 0
+(6.00000e+00, 6.00000e+00) (1.61492e+00, 4.90515e-01) 1.25607e-15 0
diff --git a/simple_examples/baseresults/c05mbje.r b/simple_examples/baseresults/c05mbje.r
new file mode 100644
index 0000000..49cdab8
--- /dev/null
+++ b/simple_examples/baseresults/c05mbje.r
@@ -0,0 +1,8 @@
+C05MBJ Example Program Results
+
+
+Final 2-norm of the residuals = 2.4765e-08
+
+Final approximate solution
+
+ 0.7682 0.7862 0.6948 0.6180
diff --git a/simple_examples/baseresults/c05qbje.r b/simple_examples/baseresults/c05qbje.r
new file mode 100644
index 0000000..e161a18
--- /dev/null
+++ b/simple_examples/baseresults/c05qbje.r
@@ -0,0 +1,8 @@
+ C05QBJ Example Program Results
+
+ Final 2-norm of the residuals = 1.1926E-08
+
+ Final approximate solution
+ -0.5707 -0.6816 -0.7017
+ -0.7042 -0.7014 -0.6919
+ -0.6658 -0.5960 -0.4164
diff --git a/simple_examples/baseresults/c06baje.r b/simple_examples/baseresults/c06baje.r
new file mode 100644
index 0000000..7049ba9
--- /dev/null
+++ b/simple_examples/baseresults/c06baje.r
@@ -0,0 +1,15 @@
+C06BAJ Example Program Results
+
+ Estimated Actual
+I SEQN RESULT abs error error
+
+1 1.0000 1.0000 - 1.78e-01
+2 0.7500 0.7500 - -7.25e-02
+3 0.8611 0.8269 - 4.46e-03
+4 0.7986 0.8211 2.56e-01 -1.36e-03
+5 0.8386 0.8226 7.84e-02 1.23e-04
+6 0.8108 0.8224 5.97e-03 -3.26e-05
+7 0.8312 0.8225 1.52e-03 3.50e-06
+8 0.8156 0.8225 1.60e-04 -8.51e-07
+9 0.8280 0.8225 3.70e-05 1.01e-07
+10 0.8180 0.8225 4.48e-06 -2.32e-08
\ No newline at end of file
diff --git a/simple_examples/baseresults/c06fkje.r b/simple_examples/baseresults/c06fkje.r
new file mode 100644
index 0000000..8ef60db
--- /dev/null
+++ b/simple_examples/baseresults/c06fkje.r
@@ -0,0 +1,13 @@
+C06FKJ Example Program Results
+
+ Covolution Correlation
+
+0 0.50000 2.00000
+1 1.00000 1.50000
+2 1.50000 1.00000
+3 2.00000 0.50000
+4 2.00000 0.00000
+5 1.50000 0.50000
+6 1.00000 1.00000
+7 0.50000 1.50000
+8 0.00000 2.00000
diff --git a/simple_examples/baseresults/c09aaje.r b/simple_examples/baseresults/c09aaje.r
new file mode 100644
index 0000000..950c020
--- /dev/null
+++ b/simple_examples/baseresults/c09aaje.r
@@ -0,0 +1,18 @@
+C09AAJ Example Program Results
+
+Parameters read from file ::
+ Wavelet : Haar End mode : Zero N = 8
+Input data X :
+2.000 5.000 8.000 9.000 7.000 4.000 -1.000 1.000
+
+Length of wavelet filter : 2
+Number of Levels : 3
+Number of coefficients in each level:
+ 1 1 2 4
+Total number of wavelength coefficients : 8
+
+Wavelet coefficients C:
+12.374 4.596 -5.000 5.500 -2.121 -0.707 2.121 -1.414
+
+Reconstruction Y :
+2.000 5.000 8.000 9.000 7.000 4.000 -1.000 1.000
\ No newline at end of file
diff --git a/simple_examples/baseresults/complexargumentexample.r b/simple_examples/baseresults/complexargumentexample.r
new file mode 100644
index 0000000..19fc96c
--- /dev/null
+++ b/simple_examples/baseresults/complexargumentexample.r
@@ -0,0 +1 @@
+(1.0, 1.0)/(2.0, 2.0) = (0.5, 0.0)
diff --git a/simple_examples/baseresults/d01bdje.r b/simple_examples/baseresults/d01bdje.r
new file mode 100644
index 0000000..23c78d1
--- /dev/null
+++ b/simple_examples/baseresults/d01bdje.r
@@ -0,0 +1,9 @@
+ D01BDJ Example Program Results
+
+ A - lower limit of integration = 0.0000
+ B - upper limit of integration = 1.0000
+ EPSABS - absolute accuracy requested = 0.00E+00
+ EPSREL - relative accuracy requested = 1.00E-04
+
+ RESULT - approximation to the integral = -0.03183
+ ABSERR - estimate to the absolute error = 1.34E-11
diff --git a/simple_examples/baseresults/d02neje.r b/simple_examples/baseresults/d02neje.r
new file mode 100644
index 0000000..b735aaf
--- /dev/null
+++ b/simple_examples/baseresults/d02neje.r
@@ -0,0 +1,25 @@
+ D02NEJ Example Program Results
+
+ D02NEF Example 1
+
+ t Y(1) Y(2) Y(3)
+ 0.0000 1.000000 0.000000 0.000000
+ 0.0200 0.999204 0.000036 0.000760
+ 0.0400 0.998415 0.000036 0.001549
+ 0.0600 0.997631 0.000036 0.002333
+ 0.0800 0.996852 0.000036 0.003112
+ 0.1000 0.996080 0.000036 0.003884
+
+ The integrator completed task, ITASK = 3
+
+ D02NEF Example 2
+
+ t y(1)
+ 0.0000 2.000000
+ 0.2000 2.038016
+ 0.4000 2.078379
+ 0.6000 2.121462
+ 0.8000 2.167736
+ 1.0000 2.217821
+
+ The integrator completed task, ITASK = 3
diff --git a/simple_examples/baseresults/d02tkje.r b/simple_examples/baseresults/d02tkje.r
new file mode 100644
index 0000000..4029a48
--- /dev/null
+++ b/simple_examples/baseresults/d02tkje.r
@@ -0,0 +1,113 @@
+ D02TKJ Example Program Results
+
+
+ Tolerance = 1.0E-04 R = 1.000E+06
+
+ Used a mesh of 21 points
+ Maximum error = 6.16E-10 in interval 20 for component 3
+
+
+ Mesh points:
+ 1(1) 0.000E+00 2(3) 5.000E-02 3(2) 1.000E-01 4(3) 1.500E-01
+ 5(2) 2.000E-01 6(3) 2.500E-01 7(2) 3.000E-01 8(3) 3.500E-01
+ 9(2) 4.000E-01 10(3) 4.500E-01 11(2) 5.000E-01 12(3) 5.500E-01
+ 13(2) 6.000E-01 14(3) 6.500E-01 15(2) 7.000E-01 16(3) 7.500E-01
+ 17(2) 8.000E-01 18(3) 8.500E-01 19(2) 9.000E-01 20(3) 9.500E-01
+ 21(1) 1.000E+00
+
+ x f f' g
+ 0.000 0.0000 0.0000 1.0000
+ 0.050 0.0070 0.1805 0.4416
+ 0.100 0.0141 0.0977 0.1886
+ 0.150 0.0171 0.0252 0.0952
+ 0.200 0.0172 -0.0165 0.0595
+ 0.250 0.0157 -0.0400 0.0427
+ 0.300 0.0133 -0.0540 0.0322
+ 0.350 0.0104 -0.0628 0.0236
+ 0.400 0.0071 -0.0683 0.0156
+ 0.450 0.0036 -0.0714 0.0078
+ 0.500 0.0000 -0.0724 0.0000
+ 0.550 -0.0036 -0.0714 -0.0078
+ 0.600 -0.0071 -0.0683 -0.0156
+ 0.650 -0.0104 -0.0628 -0.0236
+ 0.700 -0.0133 -0.0540 -0.0322
+ 0.750 -0.0157 -0.0400 -0.0427
+ 0.800 -0.0172 -0.0165 -0.0595
+ 0.850 -0.0171 0.0252 -0.0952
+ 0.900 -0.0141 0.0977 -0.1886
+ 0.950 -0.0070 0.1805 -0.4416
+ 1.000 -0.0000 0.0000 -1.0000
+
+ Tolerance = 1.0E-04 R = 1.000E+08
+
+ Used a mesh of 21 points
+ Maximum error = 4.49E-09 in interval 6 for component 3
+
+
+ Mesh points:
+ 1(1) 0.000E+00 2(3) 1.757E-02 3(2) 3.515E-02 4(3) 5.203E-02
+ 5(2) 6.891E-02 6(3) 8.593E-02 7(2) 1.030E-01 8(3) 1.351E-01
+ 9(2) 1.672E-01 10(3) 2.306E-01 11(2) 2.939E-01 12(3) 4.713E-01
+ 13(2) 6.486E-01 14(3) 7.455E-01 15(2) 8.423E-01 16(3) 8.824E-01
+ 17(2) 9.225E-01 18(3) 9.449E-01 19(2) 9.673E-01 20(3) 9.836E-01
+ 21(1) 1.000E+00
+
+ x f f' g
+ 0.000 0.0000 0.0000 1.0000
+ 0.018 0.0025 0.1713 0.3923
+ 0.035 0.0047 0.0824 0.1381
+ 0.052 0.0056 0.0267 0.0521
+ 0.069 0.0058 0.0025 0.0213
+ 0.086 0.0057 -0.0073 0.0097
+ 0.103 0.0056 -0.0113 0.0053
+ 0.135 0.0052 -0.0135 0.0027
+ 0.167 0.0047 -0.0140 0.0020
+ 0.231 0.0038 -0.0142 0.0015
+ 0.294 0.0029 -0.0142 0.0012
+ 0.471 0.0004 -0.0143 0.0002
+ 0.649 -0.0021 -0.0143 -0.0008
+ 0.745 -0.0035 -0.0142 -0.0014
+ 0.842 -0.0049 -0.0139 -0.0022
+ 0.882 -0.0054 -0.0127 -0.0036
+ 0.922 -0.0058 -0.0036 -0.0141
+ 0.945 -0.0057 0.0205 -0.0439
+ 0.967 -0.0045 0.0937 -0.1592
+ 0.984 -0.0023 0.1753 -0.4208
+ 1.000 -0.0000 0.0000 -1.0000
+
+ Tolerance = 1.0E-04 R = 1.000E+10
+
+ Used a mesh of 21 points
+ Maximum error = 3.13E-06 in interval 7 for component 3
+
+
+ Mesh points:
+ 1(1) 0.000E+00 2(3) 6.256E-03 3(2) 1.251E-02 4(3) 1.851E-02
+ 5(2) 2.450E-02 6(3) 3.076E-02 7(2) 3.702E-02 8(3) 4.997E-02
+ 9(2) 6.292E-02 10(3) 9.424E-02 11(2) 1.256E-01 12(3) 4.190E-01
+ 13(2) 7.125E-01 14(3) 8.246E-01 15(2) 9.368E-01 16(3) 9.544E-01
+ 17(2) 9.719E-01 18(3) 9.803E-01 19(2) 9.886E-01 20(3) 9.943E-01
+ 21(1) 1.000E+00
+
+ x f f' g
+ 0.000 0.0000 0.0000 1.0000
+ 0.006 0.0009 0.1623 0.3422
+ 0.013 0.0016 0.0665 0.1021
+ 0.019 0.0018 0.0204 0.0318
+ 0.025 0.0019 0.0041 0.0099
+ 0.031 0.0019 -0.0014 0.0028
+ 0.037 0.0019 -0.0031 0.0007
+ 0.050 0.0019 -0.0038 -0.0002
+ 0.063 0.0018 -0.0038 -0.0003
+ 0.094 0.0017 -0.0039 -0.0003
+ 0.126 0.0016 -0.0039 -0.0002
+ 0.419 0.0004 -0.0041 -0.0001
+ 0.712 -0.0008 -0.0042 0.0001
+ 0.825 -0.0013 -0.0043 0.0002
+ 0.937 -0.0018 -0.0043 0.0003
+ 0.954 -0.0019 -0.0042 0.0001
+ 0.972 -0.0019 -0.0003 -0.0049
+ 0.980 -0.0019 0.0152 -0.0252
+ 0.989 -0.0015 0.0809 -0.1279
+ 0.994 -0.0008 0.1699 -0.3814
+ 1.000 0.0000 -0.0000 -1.0000
diff --git a/simple_examples/baseresults/d02tlje.r b/simple_examples/baseresults/d02tlje.r
new file mode 100644
index 0000000..b56a57d
--- /dev/null
+++ b/simple_examples/baseresults/d02tlje.r
@@ -0,0 +1,113 @@
+ D02TLJ Example Program Results
+
+
+ Tolerance = 1.0E-04 R = 1.000E+06
+
+ Used a mesh of 21 points
+ Maximum error = 6.16E-10 in interval 20 for component 3
+
+
+ Mesh points:
+ 1(1) 0.000E+00 2(3) 5.000E-02 3(2) 1.000E-01 4(3) 1.500E-01
+ 5(2) 2.000E-01 6(3) 2.500E-01 7(2) 3.000E-01 8(3) 3.500E-01
+ 9(2) 4.000E-01 10(3) 4.500E-01 11(2) 5.000E-01 12(3) 5.500E-01
+ 13(2) 6.000E-01 14(3) 6.500E-01 15(2) 7.000E-01 16(3) 7.500E-01
+ 17(2) 8.000E-01 18(3) 8.500E-01 19(2) 9.000E-01 20(3) 9.500E-01
+ 21(1) 1.000E+00
+
+ x f f' g
+ 0.000 0.0000 0.0000 1.0000
+ 0.050 0.0070 0.1805 0.4416
+ 0.100 0.0141 0.0977 0.1886
+ 0.150 0.0171 0.0252 0.0952
+ 0.200 0.0172 -0.0165 0.0595
+ 0.250 0.0157 -0.0400 0.0427
+ 0.300 0.0133 -0.0540 0.0322
+ 0.350 0.0104 -0.0628 0.0236
+ 0.400 0.0071 -0.0683 0.0156
+ 0.450 0.0036 -0.0714 0.0078
+ 0.500 0.0000 -0.0724 0.0000
+ 0.550 -0.0036 -0.0714 -0.0078
+ 0.600 -0.0071 -0.0683 -0.0156
+ 0.650 -0.0104 -0.0628 -0.0236
+ 0.700 -0.0133 -0.0540 -0.0322
+ 0.750 -0.0157 -0.0400 -0.0427
+ 0.800 -0.0172 -0.0165 -0.0595
+ 0.850 -0.0171 0.0252 -0.0952
+ 0.900 -0.0141 0.0977 -0.1886
+ 0.950 -0.0070 0.1805 -0.4416
+ 1.000 -0.0000 0.0000 -1.0000
+
+ Tolerance = 1.0E-04 R = 1.000E+08
+
+ Used a mesh of 21 points
+ Maximum error = 4.49E-09 in interval 6 for component 3
+
+
+ Mesh points:
+ 1(1) 0.000E+00 2(3) 1.757E-02 3(2) 3.515E-02 4(3) 5.203E-02
+ 5(2) 6.891E-02 6(3) 8.593E-02 7(2) 1.030E-01 8(3) 1.351E-01
+ 9(2) 1.672E-01 10(3) 2.306E-01 11(2) 2.939E-01 12(3) 4.713E-01
+ 13(2) 6.486E-01 14(3) 7.455E-01 15(2) 8.423E-01 16(3) 8.824E-01
+ 17(2) 9.225E-01 18(3) 9.449E-01 19(2) 9.673E-01 20(3) 9.836E-01
+ 21(1) 1.000E+00
+
+ x f f' g
+ 0.000 0.0000 0.0000 1.0000
+ 0.018 0.0025 0.1713 0.3923
+ 0.035 0.0047 0.0824 0.1381
+ 0.052 0.0056 0.0267 0.0521
+ 0.069 0.0058 0.0025 0.0213
+ 0.086 0.0057 -0.0073 0.0097
+ 0.103 0.0056 -0.0113 0.0053
+ 0.135 0.0052 -0.0135 0.0027
+ 0.167 0.0047 -0.0140 0.0020
+ 0.231 0.0038 -0.0142 0.0015
+ 0.294 0.0029 -0.0142 0.0012
+ 0.471 0.0004 -0.0143 0.0002
+ 0.649 -0.0021 -0.0143 -0.0008
+ 0.745 -0.0035 -0.0142 -0.0014
+ 0.842 -0.0049 -0.0139 -0.0022
+ 0.882 -0.0054 -0.0127 -0.0036
+ 0.922 -0.0058 -0.0036 -0.0141
+ 0.945 -0.0057 0.0205 -0.0439
+ 0.967 -0.0045 0.0937 -0.1592
+ 0.984 -0.0023 0.1753 -0.4208
+ 1.000 -0.0000 0.0000 -1.0000
+
+ Tolerance = 1.0E-04 R = 1.000E+10
+
+ Used a mesh of 21 points
+ Maximum error = 3.13E-06 in interval 7 for component 3
+
+
+ Mesh points:
+ 1(1) 0.000E+00 2(3) 6.256E-03 3(2) 1.251E-02 4(3) 1.851E-02
+ 5(2) 2.450E-02 6(3) 3.076E-02 7(2) 3.702E-02 8(3) 4.997E-02
+ 9(2) 6.292E-02 10(3) 9.424E-02 11(2) 1.256E-01 12(3) 4.190E-01
+ 13(2) 7.125E-01 14(3) 8.246E-01 15(2) 9.368E-01 16(3) 9.544E-01
+ 17(2) 9.719E-01 18(3) 9.803E-01 19(2) 9.886E-01 20(3) 9.943E-01
+ 21(1) 1.000E+00
+
+ x f f' g
+ 0.000 0.0000 0.0000 1.0000
+ 0.006 0.0009 0.1623 0.3422
+ 0.013 0.0016 0.0665 0.1021
+ 0.019 0.0018 0.0204 0.0318
+ 0.025 0.0019 0.0041 0.0099
+ 0.031 0.0019 -0.0014 0.0028
+ 0.037 0.0019 -0.0031 0.0007
+ 0.050 0.0019 -0.0038 -0.0002
+ 0.063 0.0018 -0.0038 -0.0003
+ 0.094 0.0017 -0.0039 -0.0003
+ 0.126 0.0016 -0.0039 -0.0002
+ 0.419 0.0004 -0.0041 -0.0001
+ 0.712 -0.0008 -0.0042 0.0001
+ 0.825 -0.0013 -0.0043 0.0002
+ 0.937 -0.0018 -0.0043 0.0003
+ 0.954 -0.0019 -0.0042 0.0001
+ 0.972 -0.0019 -0.0003 -0.0049
+ 0.980 -0.0019 0.0152 -0.0252
+ 0.989 -0.0015 0.0809 -0.1279
+ 0.994 -0.0008 0.1699 -0.3814
+ 1.000 0.0000 -0.0000 -1.0000
diff --git a/simple_examples/baseresults/d03pcje.r b/simple_examples/baseresults/d03pcje.r
new file mode 100644
index 0000000..154a2d9
--- /dev/null
+++ b/simple_examples/baseresults/d03pcje.r
@@ -0,0 +1,28 @@
+D03PCJ Example Program Results
+Accuracy requirement = 1.00000e-03
+ Parameter ALPHA = 1.000e+00
+T / X 0.0000 0.4000 0.6000 0.8000 0.9000 1.0000
+
+0.0001 U(1) 0.0000 0.8008 1.1988 1.5990 1.7958 1.8485
+ U(2) 0.9997 0.9995 0.9994 0.9988 0.9663 -0.0000
+
+
+0.0010 U(1) 0.0000 0.7982 1.1940 1.5841 1.7179 1.6734
+ U(2) 0.9969 0.9952 0.9937 0.9484 0.6385 -0.0000
+
+
+0.0100 U(1) 0.0000 0.7676 1.1239 1.3547 1.3635 1.2830
+ U(2) 0.9627 0.9495 0.8754 0.5537 0.2908 -0.0000
+
+
+0.1000 U(1) 0.0000 0.3908 0.5007 0.5297 0.5120 0.4744
+ U(2) 0.5468 0.4299 0.2995 0.1479 0.0724 -0.0000
+
+
+1.0000 U(1) 0.0000 0.0007 0.0008 0.0008 0.0008 0.0007
+ U(2) 0.0010 0.0007 0.0005 0.0002 0.0001 -0.0000
+
+Number of Integration steps in time 78
+Number of residual evaluations of resulting ODE system 378
+Number of Jacobian evaluations 25
+Number of iterations of nonlinear solver 190
diff --git a/simple_examples/baseresults/d03raje.r b/simple_examples/baseresults/d03raje.r
new file mode 100644
index 0000000..59cf403
--- /dev/null
+++ b/simple_examples/baseresults/d03raje.r
@@ -0,0 +1,409 @@
+ D03RAJ Example Program Results
+
+ Statistics:
+ Time = 0.2400
+ Total number of accepted timesteps = 77
+ Total number of rejected timesteps = 0
+
+ Total number (rounded) of
+ Residual Jacobian Newton Lin sys
+ evals evals iters iters
+ At level
+ 1 600 80 200 200
+
+ Maximum number of
+ Newton iters Lin sys iters
+ At level
+ 1 2 3
+
+ Solution at every 4th grid point in level 2 at time 0.2500:
+
+ x y approx u
+
+ 6.7500E-01 0.000E+00 2.000E+00
+ 7.2500E-01 0.000E+00 1.980E+00
+ 7.7500E-01 0.000E+00 1.342E+00
+ 8.2500E-01 0.000E+00 1.190E+00
+ 7.1250E-01 1.250E-02 1.996E+00
+ 7.6250E-01 1.250E-02 1.468E+00
+ 8.1250E-01 1.250E-02 1.213E+00
+ 7.0000E-01 2.500E-02 1.999E+00
+ 7.5000E-01 2.500E-02 1.625E+00
+ 8.0000E-01 2.500E-02 1.240E+00
+ 6.8750E-01 3.750E-02 2.000E+00
+ 7.3750E-01 3.750E-02 1.870E+00
+ 7.8750E-01 3.750E-02 1.283E+00
+ 6.7500E-01 5.000E-02 2.000E+00
+ 7.2500E-01 5.000E-02 1.980E+00
+ 7.7500E-01 5.000E-02 1.342E+00
+ 8.2500E-01 5.000E-02 1.190E+00
+ 7.1250E-01 6.250E-02 1.996E+00
+ 7.6250E-01 6.250E-02 1.468E+00
+ 8.1250E-01 6.250E-02 1.213E+00
+ 7.0000E-01 7.500E-02 1.999E+00
+ 7.5000E-01 7.500E-02 1.625E+00
+ 8.0000E-01 7.500E-02 1.240E+00
+ 6.8750E-01 8.750E-02 2.000E+00
+ 7.3750E-01 8.750E-02 1.870E+00
+ 7.8750E-01 8.750E-02 1.283E+00
+ 6.7500E-01 1.000E-01 2.000E+00
+ 7.2500E-01 1.000E-01 1.980E+00
+ 7.7500E-01 1.000E-01 1.342E+00
+ 8.2500E-01 1.000E-01 1.190E+00
+ 7.1250E-01 1.125E-01 1.996E+00
+ 7.6250E-01 1.125E-01 1.468E+00
+ 8.1250E-01 1.125E-01 1.213E+00
+ 7.0000E-01 1.250E-01 1.999E+00
+ 7.5000E-01 1.250E-01 1.625E+00
+ 8.0000E-01 1.250E-01 1.240E+00
+ 6.8750E-01 1.375E-01 2.000E+00
+ 7.3750E-01 1.375E-01 1.870E+00
+ 7.8750E-01 1.375E-01 1.283E+00
+ 6.7500E-01 1.500E-01 2.000E+00
+ 7.2500E-01 1.500E-01 1.980E+00
+ 7.7500E-01 1.500E-01 1.341E+00
+ 8.2500E-01 1.500E-01 1.190E+00
+ 7.1250E-01 1.625E-01 1.995E+00
+ 7.6250E-01 1.625E-01 1.467E+00
+ 8.1250E-01 1.625E-01 1.213E+00
+ 7.0000E-01 1.750E-01 1.999E+00
+ 7.5000E-01 1.750E-01 1.624E+00
+ 8.0000E-01 1.750E-01 1.240E+00
+ 6.8750E-01 1.875E-01 2.000E+00
+ 7.3750E-01 1.875E-01 1.869E+00
+ 7.8750E-01 1.875E-01 1.282E+00
+ 6.7500E-01 2.000E-01 2.000E+00
+ 7.2500E-01 2.000E-01 1.980E+00
+ 7.7500E-01 2.000E-01 1.341E+00
+ 8.2500E-01 2.000E-01 1.189E+00
+ 7.1250E-01 2.125E-01 1.995E+00
+ 7.6250E-01 2.125E-01 1.465E+00
+ 8.1250E-01 2.125E-01 1.212E+00
+ 7.0000E-01 2.250E-01 1.999E+00
+ 7.5000E-01 2.250E-01 1.621E+00
+ 8.0000E-01 2.250E-01 1.240E+00
+ 6.8750E-01 2.375E-01 2.000E+00
+ 7.3750E-01 2.375E-01 1.869E+00
+ 7.8750E-01 2.375E-01 1.282E+00
+ 6.7500E-01 2.500E-01 2.000E+00
+ 7.2500E-01 2.500E-01 1.980E+00
+ 7.7500E-01 2.500E-01 1.340E+00
+ 8.2500E-01 2.500E-01 1.189E+00
+ 7.1250E-01 2.625E-01 1.995E+00
+ 7.6250E-01 2.625E-01 1.462E+00
+ 8.1250E-01 2.625E-01 1.212E+00
+ 7.0000E-01 2.750E-01 1.999E+00
+ 7.5000E-01 2.750E-01 1.616E+00
+ 8.0000E-01 2.750E-01 1.239E+00
+ 6.8750E-01 2.875E-01 2.000E+00
+ 7.3750E-01 2.875E-01 1.866E+00
+ 7.8750E-01 2.875E-01 1.281E+00
+ 6.7500E-01 3.000E-01 2.000E+00
+ 7.2500E-01 3.000E-01 1.979E+00
+ 7.7500E-01 3.000E-01 1.337E+00
+ 8.2500E-01 3.000E-01 1.189E+00
+ 7.1250E-01 3.125E-01 1.995E+00
+ 7.6250E-01 3.125E-01 1.455E+00
+ 8.1250E-01 3.125E-01 1.212E+00
+ 7.0000E-01 3.250E-01 1.999E+00
+ 7.5000E-01 3.250E-01 1.605E+00
+ 8.0000E-01 3.250E-01 1.239E+00
+ 6.8750E-01 3.375E-01 2.000E+00
+ 7.3750E-01 3.375E-01 1.862E+00
+ 7.8750E-01 3.375E-01 1.279E+00
+ 6.7500E-01 3.500E-01 2.000E+00
+ 7.2500E-01 3.500E-01 1.977E+00
+ 7.7500E-01 3.500E-01 1.332E+00
+ 8.2500E-01 3.500E-01 1.189E+00
+ 7.1250E-01 3.625E-01 1.993E+00
+ 7.6250E-01 3.625E-01 1.442E+00
+ 8.1250E-01 3.625E-01 1.211E+00
+ 7.0000E-01 3.750E-01 1.999E+00
+ 7.5000E-01 3.750E-01 1.585E+00
+ 8.0000E-01 3.750E-01 1.236E+00
+ 6.8750E-01 3.875E-01 2.000E+00
+ 7.3750E-01 3.875E-01 1.849E+00
+ 7.8750E-01 3.875E-01 1.274E+00
+ 6.7500E-01 4.000E-01 2.000E+00
+ 7.2500E-01 4.000E-01 1.972E+00
+ 7.7500E-01 4.000E-01 1.324E+00
+ 8.2500E-01 4.000E-01 1.187E+00
+ 7.1250E-01 4.125E-01 1.990E+00
+ 7.6250E-01 4.125E-01 1.420E+00
+ 8.1250E-01 4.125E-01 1.209E+00
+ 7.0000E-01 4.250E-01 1.997E+00
+ 7.5000E-01 4.250E-01 1.549E+00
+ 8.0000E-01 4.250E-01 1.233E+00
+ 6.8750E-01 4.375E-01 1.999E+00
+ 7.3750E-01 4.375E-01 1.813E+00
+ 7.8750E-01 4.375E-01 1.267E+00
+ 6.7500E-01 4.500E-01 2.000E+00
+ 7.2500E-01 4.500E-01 1.952E+00
+ 7.7500E-01 4.500E-01 1.310E+00
+ 8.2500E-01 4.500E-01 1.185E+00
+ 7.1250E-01 4.625E-01 1.976E+00
+ 7.6250E-01 4.625E-01 1.387E+00
+ 8.1250E-01 4.625E-01 1.206E+00
+ 6.7500E-01 4.750E-01 2.000E+00
+ 7.2500E-01 4.750E-01 1.924E+00
+ 7.7500E-01 4.750E-01 1.301E+00
+ 8.2500E-01 4.750E-01 1.184E+00
+ 6.8750E-01 4.875E-01 1.999E+00
+ 7.3750E-01 4.875E-01 1.714E+00
+ 7.8750E-01 4.875E-01 1.257E+00
+ 6.5000E-01 5.000E-01 2.000E+00
+ 7.0000E-01 5.000E-01 1.991E+00
+ 7.5000E-01 5.000E-01 1.454E+00
+ 8.0000E-01 5.000E-01 1.224E+00
+ 6.6250E-01 5.125E-01 2.000E+00
+ 7.1250E-01 5.125E-01 1.932E+00
+ 7.6250E-01 5.125E-01 1.346E+00
+ 6.5000E-01 5.250E-01 2.000E+00
+ 7.0000E-01 5.250E-01 1.986E+00
+ 7.5000E-01 5.250E-01 1.414E+00
+ 8.0000E-01 5.250E-01 1.219E+00
+ 6.8750E-01 5.375E-01 1.996E+00
+ 7.3750E-01 5.375E-01 1.545E+00
+ 7.8750E-01 5.375E-01 1.243E+00
+ 6.5000E-01 5.500E-01 2.000E+00
+ 7.0000E-01 5.500E-01 1.978E+00
+ 7.5000E-01 5.500E-01 1.373E+00
+ 8.0000E-01 5.500E-01 1.214E+00
+ 6.6250E-01 5.625E-01 1.999E+00
+ 7.1250E-01 5.625E-01 1.843E+00
+ 7.6250E-01 5.625E-01 1.302E+00
+ 6.2500E-01 5.750E-01 2.000E+00
+ 6.7500E-01 5.750E-01 1.995E+00
+ 7.2500E-01 5.750E-01 1.545E+00
+ 7.7500E-01 5.750E-01 1.256E+00
+ 6.3750E-01 5.875E-01 2.000E+00
+ 6.8750E-01 5.875E-01 1.954E+00
+ 7.3750E-01 5.875E-01 1.392E+00
+ 7.8750E-01 5.875E-01 1.226E+00
+ 6.2500E-01 6.000E-01 2.000E+00
+ 6.7500E-01 6.000E-01 1.984E+00
+ 7.2500E-01 6.000E-01 1.443E+00
+ 7.7500E-01 6.000E-01 1.243E+00
+ 6.1250E-01 6.125E-01 2.000E+00
+ 6.6250E-01 6.125E-01 1.988E+00
+ 7.1250E-01 6.125E-01 1.531E+00
+ 7.6250E-01 6.125E-01 1.263E+00
+ 5.5000E-01 6.250E-01 2.000E+00
+ 6.0000E-01 6.250E-01 2.000E+00
+ 6.5000E-01 6.250E-01 1.993E+00
+ 7.0000E-01 6.250E-01 1.577E+00
+ 7.5000E-01 6.250E-01 1.280E+00
+ 8.0000E-01 6.250E-01 1.194E+00
+ 5.8750E-01 6.375E-01 2.000E+00
+ 6.3750E-01 6.375E-01 1.992E+00
+ 6.8750E-01 6.375E-01 1.672E+00
+ 7.3750E-01 6.375E-01 1.300E+00
+ 4.7500E-01 6.500E-01 2.000E+00
+ 5.2500E-01 6.500E-01 2.000E+00
+ 5.7500E-01 6.500E-01 2.000E+00
+ 6.2500E-01 6.500E-01 1.993E+00
+ 6.7500E-01 6.500E-01 1.680E+00
+ 7.2500E-01 6.500E-01 1.314E+00
+ 7.7500E-01 6.500E-01 1.218E+00
+ 5.1250E-01 6.625E-01 2.000E+00
+ 5.6250E-01 6.625E-01 1.999E+00
+ 6.1250E-01 6.625E-01 1.988E+00
+ 6.6250E-01 6.625E-01 1.721E+00
+ 7.1250E-01 6.625E-01 1.331E+00
+ 7.6250E-01 6.625E-01 1.229E+00
+ 2.5000E-02 6.750E-01 2.000E+00
+ 7.5000E-02 6.750E-01 2.000E+00
+ 1.2500E-01 6.750E-01 2.000E+00
+ 1.7500E-01 6.750E-01 2.000E+00
+ 2.2500E-01 6.750E-01 2.000E+00
+ 2.7500E-01 6.750E-01 2.000E+00
+ 3.2500E-01 6.750E-01 2.000E+00
+ 3.7500E-01 6.750E-01 2.000E+00
+ 4.2500E-01 6.750E-01 2.000E+00
+ 4.7500E-01 6.750E-01 2.000E+00
+ 5.2500E-01 6.750E-01 2.000E+00
+ 5.7500E-01 6.750E-01 1.995E+00
+ 6.2500E-01 6.750E-01 1.932E+00
+ 6.7500E-01 6.750E-01 1.447E+00
+ 7.2500E-01 6.750E-01 1.277E+00
+ 7.7500E-01 6.750E-01 1.205E+00
+ 3.7500E-02 6.875E-01 2.000E+00
+ 8.7500E-02 6.875E-01 2.000E+00
+ 1.3750E-01 6.875E-01 2.000E+00
+ 1.8750E-01 6.875E-01 2.000E+00
+ 2.3750E-01 6.875E-01 2.000E+00
+ 2.8750E-01 6.875E-01 2.000E+00
+ 3.3750E-01 6.875E-01 2.000E+00
+ 3.8750E-01 6.875E-01 2.000E+00
+ 4.3750E-01 6.875E-01 1.999E+00
+ 4.8750E-01 6.875E-01 1.999E+00
+ 5.3750E-01 6.875E-01 1.996E+00
+ 5.8750E-01 6.875E-01 1.954E+00
+ 6.3750E-01 6.875E-01 1.672E+00
+ 6.8750E-01 6.875E-01 1.343E+00
+ 7.3750E-01 6.875E-01 1.244E+00
+ 2.5000E-02 7.000E-01 1.999E+00
+ 7.5000E-02 7.000E-01 1.999E+00
+ 1.2500E-01 7.000E-01 1.999E+00
+ 1.7500E-01 7.000E-01 1.999E+00
+ 2.2500E-01 7.000E-01 1.999E+00
+ 2.7500E-01 7.000E-01 1.999E+00
+ 3.2500E-01 7.000E-01 1.999E+00
+ 3.7500E-01 7.000E-01 1.999E+00
+ 4.2500E-01 7.000E-01 1.997E+00
+ 4.7500E-01 7.000E-01 1.994E+00
+ 5.2500E-01 7.000E-01 1.986E+00
+ 5.7500E-01 7.000E-01 1.941E+00
+ 6.2500E-01 7.000E-01 1.577E+00
+ 6.7500E-01 7.000E-01 1.336E+00
+ 7.2500E-01 7.000E-01 1.247E+00
+ 1.2500E-02 7.125E-01 1.996E+00
+ 6.2500E-02 7.125E-01 1.996E+00
+ 1.1250E-01 7.125E-01 1.995E+00
+ 1.6250E-01 7.125E-01 1.995E+00
+ 2.1250E-01 7.125E-01 1.995E+00
+ 2.6250E-01 7.125E-01 1.995E+00
+ 3.1250E-01 7.125E-01 1.995E+00
+ 3.6250E-01 7.125E-01 1.993E+00
+ 4.1250E-01 7.125E-01 1.990E+00
+ 4.6250E-01 7.125E-01 1.976E+00
+ 5.1250E-01 7.125E-01 1.932E+00
+ 5.6250E-01 7.125E-01 1.843E+00
+ 6.1250E-01 7.125E-01 1.531E+00
+ 6.6250E-01 7.125E-01 1.331E+00
+ 7.1250E-01 7.125E-01 1.250E+00
+ 2.5000E-02 7.250E-01 1.980E+00
+ 7.5000E-02 7.250E-01 1.980E+00
+ 1.2500E-01 7.250E-01 1.980E+00
+ 1.7500E-01 7.250E-01 1.980E+00
+ 2.2500E-01 7.250E-01 1.980E+00
+ 2.7500E-01 7.250E-01 1.979E+00
+ 3.2500E-01 7.250E-01 1.978E+00
+ 3.7500E-01 7.250E-01 1.975E+00
+ 4.2500E-01 7.250E-01 1.965E+00
+ 4.7500E-01 7.250E-01 1.924E+00
+ 5.2500E-01 7.250E-01 1.772E+00
+ 5.7500E-01 7.250E-01 1.545E+00
+ 6.2500E-01 7.250E-01 1.366E+00
+ 6.7500E-01 7.250E-01 1.277E+00
+ 7.2500E-01 7.250E-01 1.222E+00
+ 3.7500E-02 7.375E-01 1.870E+00
+ 8.7500E-02 7.375E-01 1.870E+00
+ 1.3750E-01 7.375E-01 1.870E+00
+ 1.8750E-01 7.375E-01 1.869E+00
+ 2.3750E-01 7.375E-01 1.868E+00
+ 2.8750E-01 7.375E-01 1.866E+00
+ 3.3750E-01 7.375E-01 1.862E+00
+ 3.8750E-01 7.375E-01 1.849E+00
+ 4.3750E-01 7.375E-01 1.813E+00
+ 4.8750E-01 7.375E-01 1.714E+00
+ 5.3750E-01 7.375E-01 1.545E+00
+ 5.8750E-01 7.375E-01 1.392E+00
+ 6.3750E-01 7.375E-01 1.300E+00
+ 6.8750E-01 7.375E-01 1.244E+00
+ 2.5000E-02 7.500E-01 1.625E+00
+ 7.5000E-02 7.500E-01 1.625E+00
+ 1.2500E-01 7.500E-01 1.625E+00
+ 1.7500E-01 7.500E-01 1.624E+00
+ 2.2500E-01 7.500E-01 1.621E+00
+ 2.7500E-01 7.500E-01 1.616E+00
+ 3.2500E-01 7.500E-01 1.605E+00
+ 3.7500E-01 7.500E-01 1.585E+00
+ 4.2500E-01 7.500E-01 1.549E+00
+ 4.7500E-01 7.500E-01 1.491E+00
+ 5.2500E-01 7.500E-01 1.414E+00
+ 5.7500E-01 7.500E-01 1.337E+00
+ 6.2500E-01 7.500E-01 1.280E+00
+ 6.7500E-01 7.500E-01 1.237E+00
+ 1.2500E-02 7.625E-01 1.468E+00
+ 6.2500E-02 7.625E-01 1.468E+00
+ 1.1250E-01 7.625E-01 1.468E+00
+ 1.6250E-01 7.625E-01 1.467E+00
+ 2.1250E-01 7.625E-01 1.465E+00
+ 2.6250E-01 7.625E-01 1.462E+00
+ 3.1250E-01 7.625E-01 1.455E+00
+ 3.6250E-01 7.625E-01 1.442E+00
+ 4.1250E-01 7.625E-01 1.420E+00
+ 4.6250E-01 7.625E-01 1.387E+00
+ 5.1250E-01 7.625E-01 1.345E+00
+ 5.6250E-01 7.625E-01 1.302E+00
+ 6.1250E-01 7.625E-01 1.263E+00
+ 6.6250E-01 7.625E-01 1.229E+00
+ 2.5000E-02 7.750E-01 1.342E+00
+ 7.5000E-02 7.750E-01 1.342E+00
+ 1.2500E-01 7.750E-01 1.342E+00
+ 1.7500E-01 7.750E-01 1.341E+00
+ 2.2500E-01 7.750E-01 1.340E+00
+ 2.7500E-01 7.750E-01 1.339E+00
+ 3.2500E-01 7.750E-01 1.335E+00
+ 3.7500E-01 7.750E-01 1.329E+00
+ 4.2500E-01 7.750E-01 1.317E+00
+ 4.7500E-01 7.750E-01 1.301E+00
+ 5.2500E-01 7.750E-01 1.280E+00
+ 5.7500E-01 7.750E-01 1.256E+00
+ 6.2500E-01 7.750E-01 1.231E+00
+ 6.7500E-01 7.750E-01 1.205E+00
+ 3.7500E-02 7.875E-01 1.283E+00
+ 8.7500E-02 7.875E-01 1.283E+00
+ 1.3750E-01 7.875E-01 1.283E+00
+ 1.8750E-01 7.875E-01 1.282E+00
+ 2.3750E-01 7.875E-01 1.282E+00
+ 2.8750E-01 7.875E-01 1.281E+00
+ 3.3750E-01 7.875E-01 1.279E+00
+ 3.8750E-01 7.875E-01 1.274E+00
+ 4.3750E-01 7.875E-01 1.267E+00
+ 4.8750E-01 7.875E-01 1.257E+00
+ 5.3750E-01 7.875E-01 1.243E+00
+ 5.8750E-01 7.875E-01 1.226E+00
+ 0.0000E+00 8.000E-01 1.240E+00
+ 5.0000E-02 8.000E-01 1.240E+00
+ 1.0000E-01 8.000E-01 1.240E+00
+ 1.5000E-01 8.000E-01 1.240E+00
+ 2.0000E-01 8.000E-01 1.240E+00
+ 2.5000E-01 8.000E-01 1.240E+00
+ 3.0000E-01 8.000E-01 1.239E+00
+ 3.5000E-01 8.000E-01 1.238E+00
+ 4.0000E-01 8.000E-01 1.235E+00
+ 4.5000E-01 8.000E-01 1.230E+00
+ 5.0000E-01 8.000E-01 1.224E+00
+ 5.5000E-01 8.000E-01 1.214E+00
+ 6.0000E-01 8.000E-01 1.202E+00
+ 1.2500E-02 8.125E-01 1.213E+00
+ 6.2500E-02 8.125E-01 1.213E+00
+ 1.1250E-01 8.125E-01 1.213E+00
+ 1.6250E-01 8.125E-01 1.213E+00
+ 2.1250E-01 8.125E-01 1.212E+00
+ 2.6250E-01 8.125E-01 1.212E+00
+ 3.1250E-01 8.125E-01 1.212E+00
+ 3.6250E-01 8.125E-01 1.211E+00
+ 4.1250E-01 8.125E-01 1.209E+00
+ 4.6250E-01 8.125E-01 1.206E+00
+ 0.0000E+00 8.250E-01 1.190E+00
+ 5.0000E-02 8.250E-01 1.190E+00
+ 1.0000E-01 8.250E-01 1.190E+00
+ 1.5000E-01 8.250E-01 1.190E+00
+ 2.0000E-01 8.250E-01 1.189E+00
+ 2.5000E-01 8.250E-01 1.189E+00
+ 3.0000E-01 8.250E-01 1.189E+00
+ 3.5000E-01 8.250E-01 1.189E+00
+ 4.0000E-01 8.250E-01 1.187E+00
+ 4.5000E-01 8.250E-01 1.185E+00
+ 5.0000E-01 8.250E-01 1.182E+00
+
+ Statistics:
+ Time = 0.2500
+ Total number of accepted timesteps = 161
+ Total number of rejected timesteps = 2
+
+ Total number (rounded) of
+ Residual Jacobian Newton Lin sys
+ evals evals iters iters
+ At level
+ 1 1000 200 400 400
+ 2 200 20 50 50
+
+ Maximum number of
+ Newton iters Lin sys iters
+ At level
+ 1 4 3
+ 2 4 1
diff --git a/simple_examples/baseresults/d03rbje.r b/simple_examples/baseresults/d03rbje.r
new file mode 100644
index 0000000..f49a127
--- /dev/null
+++ b/simple_examples/baseresults/d03rbje.r
@@ -0,0 +1,59 @@
+ D03RBJ Example Program Results
+
+ Solution at every 2nd grid point in level 1 at time 1.0000:
+
+ x y approx u exact u approx v exact v
+
+ 0.00 0.00 0.50 0.50 1.00 1.00
+ 0.20 0.00 0.50 0.50 1.00 1.00
+ 0.10 0.10 0.50 0.50 1.00 1.00
+ 0.30 0.10 0.50 0.50 1.00 1.00
+ 0.50 0.10 0.50 0.50 1.00 1.00
+ 0.70 0.10 0.50 0.50 1.00 1.00
+ 0.90 0.10 0.50 0.50 1.00 1.00
+ 0.00 0.20 0.50 0.50 1.00 1.00
+ 0.20 0.20 0.50 0.50 1.00 1.00
+ 0.40 0.20 0.50 0.50 1.00 1.00
+ 0.60 0.20 0.50 0.50 1.00 1.00
+ 0.80 0.20 0.50 0.50 1.00 1.00
+ 1.00 0.20 0.50 0.50 1.00 1.00
+ 0.10 0.30 0.50 0.50 1.00 1.00
+ 0.30 0.30 0.50 0.50 1.00 1.00
+ 0.50 0.30 0.50 0.50 1.00 1.00
+ 0.70 0.30 0.50 0.50 1.00 1.00
+ 0.90 0.30 0.50 0.50 1.00 1.00
+ 0.00 0.40 0.75 0.75 0.75 0.75
+ 0.20 0.40 0.50 0.50 1.00 1.00
+ 0.40 0.40 0.50 0.50 1.00 1.00
+ 0.80 0.40 0.50 0.50 1.00 1.00
+ 1.00 0.40 0.50 0.50 1.00 1.00
+ 0.10 0.50 0.75 0.75 0.75 0.75
+ 0.30 0.50 0.50 0.50 1.00 1.00
+ 0.50 0.50 0.50 0.50 1.00 1.00
+ 0.70 0.50 0.50 0.50 1.00 1.00
+ 0.90 0.50 0.50 0.50 1.00 1.00
+ 0.00 0.60 0.75 0.75 0.75 0.75
+ 0.20 0.60 0.75 0.75 0.75 0.75
+ 0.40 0.60 0.50 0.50 1.00 1.00
+ 0.60 0.60 0.50 0.50 1.00 1.00
+ 0.80 0.60 0.50 0.50 1.00 1.00
+ 1.00 0.60 0.50 0.50 1.00 1.00
+ 0.10 0.70 0.75 0.75 0.75 0.75
+ 0.30 0.70 0.75 0.75 0.75 0.75
+ 0.50 0.70 0.50 0.50 1.00 1.00
+ 0.70 0.70 0.50 0.50 1.00 1.00
+ 0.90 0.70 0.50 0.50 1.00 1.00
+ 0.00 0.80 0.75 0.75 0.75 0.75
+ 0.20 0.80 0.75 0.75 0.75 0.75
+ 0.40 0.80 0.75 0.75 0.75 0.75
+ 0.60 0.80 0.50 0.50 1.00 1.00
+ 0.80 0.80 0.50 0.50 1.00 1.00
+ 0.10 0.90 0.75 0.75 0.75 0.75
+ 0.30 0.90 0.75 0.75 0.75 0.75
+ 0.50 0.90 0.75 0.75 0.75 0.75
+ 0.70 0.90 0.50 0.50 1.00 1.00
+ 0.00 1.00 0.75 0.75 0.75 0.75
+ 0.20 1.00 0.75 0.75 0.75 0.75
+ 0.40 1.00 0.75 0.75 0.75 0.75
+ 0.60 1.00 0.75 0.75 0.75 0.75
+ 0.80 1.00 0.50 0.50 1.00 1.00
diff --git a/simple_examples/baseresults/d05baje.r b/simple_examples/baseresults/d05baje.r
new file mode 100644
index 0000000..0833ea2
--- /dev/null
+++ b/simple_examples/baseresults/d05baje.r
@@ -0,0 +1,12 @@
+D05BAJ Example Program Results
+
+Size of workplace = 486
+Tolerance = 1.0000e-03
+
+T Approx. Sol. True Sol. Est. Error Actual Error
+3.33 1.80037 1.80033 8.03776e-05 2.38466e-05
+6.67 2.23916 2.23911 1.77740e-04 2.34772e-05
+10.00 2.54310 2.54304 2.45949e-04 2.24564e-05
+13.33 2.77587 2.77581 3.05737e-04 2.17430e-05
+16.67 2.96456 2.96450 3.61698e-04 2.13821e-05
+20.00 3.12324 3.12317 4.17127e-04 2.13102e-05
diff --git a/simple_examples/baseresults/d05beje.r b/simple_examples/baseresults/d05beje.r
new file mode 100644
index 0000000..95731f4
--- /dev/null
+++ b/simple_examples/baseresults/d05beje.r
@@ -0,0 +1,46 @@
+D05BEJ Example Program Results
+
+Example 1
+
+The stepsize h = 0.1000
+
+ T Approximate
+ Solution
+
+ 0.5000 0.1191
+ 1.0000 0.0528
+ 1.5000 0.0265
+ 2.0000 0.0146
+ 2.5000 0.0086
+ 3.0000 0.0052
+ 3.5000 0.0033
+ 4.0000 0.0022
+ 4.5000 0.0014
+ 5.0000 0.0010
+ 5.5000 0.0007
+ 6.0000 0.0004
+ 6.5000 0.0003
+ 7.0000 0.0002
+
+The maximum absolute error, 2.86e-03, occured at T = 0.1000 with solution 0.0326
+
+
+Example 2
+
+The stepsize h = 0.0714
+
+ T Approximate
+ Solution
+
+ 0.5000 0.6667
+ 1.0000 0.5000
+ 1.5000 0.4000
+ 2.0000 0.3333
+ 2.5000 0.2857
+ 3.0000 0.2500
+ 3.5000 0.2222
+ 4.0000 0.2000
+ 4.5000 0.1818
+ 5.0000 0.1667
+
+The maximum absolute error, 3.17e-06, occured at T = 0.0714 with solution 0.9333
\ No newline at end of file
diff --git a/simple_examples/baseresults/dtfsmje.r b/simple_examples/baseresults/dtfsmje.r
new file mode 100644
index 0000000..761a9ed
--- /dev/null
+++ b/simple_examples/baseresults/dtfsmje.r
@@ -0,0 +1,10 @@
+ DTFSMJ Example Program Results
+
+ The Solution
+ 1 2 3 4
+ 1 13.5562 5.7677 9.7251 1.2209
+ 2 -10.1040 -1.9787 -8.9252 -4.4205
+ 3 -0.8280 0.2386 2.0348 2.0769
+ 4 2.8488 -7.1745 -3.7925 -2.9505
+ 5 -3.9321 0.8652 -1.4082 3.1217
+ 6 -2.3127 1.8398 2.0152 1.5198
diff --git a/simple_examples/baseresults/e01daje.r b/simple_examples/baseresults/e01daje.r
new file mode 100644
index 0000000..a9c2ddb
--- /dev/null
+++ b/simple_examples/baseresults/e01daje.r
@@ -0,0 +1,25 @@
+ E01DAJ Example Program Results
+
+ I Knot LAMDA(I) J Knot MU(j)
+ 4 1.0000 4 0.0000
+ 5 1.3000 5 0.4000
+ 6 1.5000 6 0.7000
+ 7 1.6000 7 1.0000
+ 8 2.0000
+
+ The B-Spline coefficients:
+ 1.0000 1.1333 1.3667 1.7000 1.9000 2.0000 1.2000 1.3333
+ 1.5667 1.9000 2.1000 2.2000 1.5833 1.7167 1.9500 2.2833
+ 2.4833 2.5833 2.1433 2.2767 2.5100 2.8433 3.0433 3.1433
+ 2.8667 3.0000 3.2333 3.5667 3.7667 3.8667 3.4667 3.6000
+ 3.8333 4.1667 4.3667 4.4667 4.0000 4.1333 4.3667 4.7000
+ 4.9000 5.0000
+
+ Spline evaluated on a regular mesh (X across, Y down):
+ 1.00 1.20 1.40 1.60 1.80 2.00
+ 0.00 1.000 1.440 1.960 2.560 3.240 4.000
+ 0.20 1.200 1.640 2.160 2.760 3.440 4.200
+ 0.40 1.400 1.840 2.360 2.960 3.640 4.400
+ 0.60 1.600 2.040 2.560 3.160 3.840 4.600
+ 0.80 1.800 2.240 2.760 3.360 4.040 4.800
+ 1.00 2.000 2.440 2.960 3.560 4.240 5.000
diff --git a/simple_examples/baseresults/e02alje.r b/simple_examples/baseresults/e02alje.r
new file mode 100644
index 0000000..6dfc758
--- /dev/null
+++ b/simple_examples/baseresults/e02alje.r
@@ -0,0 +1,24 @@
+E02ALJ Example Program Results
+
+ Polynomial coefficients
+ 1.0000e+00
+ 1.0001e+00
+ 4.9909e-01
+ 1.7042e-01
+ 3.4784e-02
+ 1.3909e-02
+
+ Reference deviation = 1.09e-06
+
+ X Fit exp(x) Residual
+ 0.00 1.0000 1.0000 -1.09e-06
+ 0.10 1.1052 1.1052 9.74e-07
+ 0.20 1.2214 1.2214 -7.44e-07
+ 0.30 1.3499 1.3499 -9.18e-07
+ 0.40 1.4918 1.4918 2.99e-07
+ 0.50 1.6487 1.6487 1.09e-06
+ 0.60 1.8221 1.8221 4.59e-07
+ 0.70 2.0138 2.0138 -8.16e-07
+ 0.80 2.2255 2.2255 -8.42e-07
+ 0.90 2.4596 2.4596 8.75e-07
+ 1.00 2.7183 2.7183 -1.09e-06
diff --git a/simple_examples/baseresults/e04abje.r b/simple_examples/baseresults/e04abje.r
new file mode 100644
index 0000000..18b685b
--- /dev/null
+++ b/simple_examples/baseresults/e04abje.r
@@ -0,0 +1,6 @@
+E04ABJ Example Program Results
+
+The minimum lies in the interval 4.49340940 to 4.49340951
+Its estimated position is 4.49340945,
+where the function value is -0.2172
+10 function evaluations were required
diff --git a/simple_examples/baseresults/e04bbje.r b/simple_examples/baseresults/e04bbje.r
new file mode 100644
index 0000000..86a41ba
--- /dev/null
+++ b/simple_examples/baseresults/e04bbje.r
@@ -0,0 +1,7 @@
+E04BBJ Example Program Results
+
+The minimum lies in the interval 4.49340946 to 4.49340952
+Its estimated position is 4.49340946,
+where the function value is -0.2172
+and the gradient is -3.8e-16 (machine dependent)
+6 function evaluations were required
diff --git a/simple_examples/baseresults/e04cbje.r b/simple_examples/baseresults/e04cbje.r
new file mode 100644
index 0000000..67cd53d
--- /dev/null
+++ b/simple_examples/baseresults/e04cbje.r
@@ -0,0 +1,4 @@
+E04CBJ Example Program Results
+
+The final function value is 0.0000
+at the point 0.5000 -0.9999
diff --git a/simple_examples/baseresults/e04fcje.r b/simple_examples/baseresults/e04fcje.r
new file mode 100644
index 0000000..bd90f04
--- /dev/null
+++ b/simple_examples/baseresults/e04fcje.r
@@ -0,0 +1,22 @@
+ E04FCJ Example Program Results
+
+ On exit, the sum of squares is 0.0082
+ at the point 0.0824 1.1330 2.3437
+ The estimated gradient is -1.607e-09 -7.436e-11 6.130e-10
+ (machine dependent)
+ and the residuals are
+ -5.9e-03
+ -2.7e-04
+ 2.7e-04
+ 6.5e-03
+ -8.2e-04
+ -1.3e-03
+ -4.5e-03
+ -2.0e-02
+ 8.2e-02
+ -1.8e-02
+ -1.5e-02
+ -1.5e-02
+ -1.1e-02
+ -4.2e-03
+ 6.8e-03
diff --git a/simple_examples/baseresults/e04ffje.r b/simple_examples/baseresults/e04ffje.r
new file mode 100644
index 0000000..a772ab7
--- /dev/null
+++ b/simple_examples/baseresults/e04ffje.r
@@ -0,0 +1,73 @@
+ E04FFJ Example Program Results
+
+ ---------------------------------------------------
+ E04F(G|F)), Derivative free solver for data fitting
+ (nonlinear least-squares problems)
+ ---------------------------------------------------
+
+ Problem statistics
+ Number of variables 4
+ Number of unconstrained variables 2
+ Number of fixed variables 0
+ Starting interpolation points 5
+ Total interpolation points 5
+ Number of residuals 11
+
+ Begin of Options
+ Print File = 6 * d
+ Print Level = 2 * d
+ Print Options = Yes * d
+ Print Solution = All * U
+ Monitoring File = -1 * d
+ Monitoring Level = 4 * d
+ Dfo Print Frequency = 1 * d
+ Dfo Monitor Frequency = 0 * d
+
+ Infinite Bound Size = 1.00000E+20 * d
+ Stats Time = No * d
+ Time Limit = 1.00000E+06 * d
+
+ Dfo Initial Interp Points = Coordinate * d
+ Dfo Max Objective Calls = 500 * d
+ Dfo Max Soft Restarts = 5 * d
+ Dfo Max Unsucc Soft Restarts = 3 * d
+ Dfo Maximum Slow Steps = 20 * d
+ Dfo Noise Level = 0.00000E+00 * d
+ Dfo Noisy Problem = No * d
+ Dfo Number Initial Points = 0 * d
+ Dfo Number Interp Points = 0 * d
+ Dfo Number Soft Restarts Pts = 3 * d
+ Dfo Random Seed = -1 * d
+ Dfo Starting Trust Region = 1.00000E-01 * d
+ Dfo Trust Region Slow Tol = 1.02648E-04 * d
+ Dfo Trust Region Tolerance = 5.00000E-06 * U
+ Dfo Version = Latest * d
+ Dfls Small Residuals Tol = 1.08158E-12 * d
+ End of Options
+ ----------------------------------------
+ step | obj rho | nf |
+ ----------------------------------------
+ 1 | 1.72E-03 1.00E-01 | 6 |
+ 2 | 6.41E-04 1.00E-01 | 7 |
+ 3 | 4.52E-04 1.00E-01 | 8 |
+ 4 | 4.05E-04 1.00E-02 | 9 |
+ 5 | 4.04E-04 1.00E-02 | 10 |
+ 6 | 4.03E-04 1.00E-02 | 14 |
+ 7 | 4.02E-04 1.00E-02 | 15 |
+ 8 | 4.02E-04 1.00E-03 | 20 |
+ 9 | 4.02E-04 7.07E-05 | 21 |
+ 10 | 4.02E-04 7.07E-05 | 23 | s
+ ----------------------------------------
+ Status: Converged, small trust region size
+
+ Value of the objective 4.02423E-04
+ Number of objective function evaluations 27
+ Number of steps 10
+
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 -inf 1.81300E-01 inf
+ 2 2.00000E-01 5.90128E-01 1.00000E+00
+ 3 -inf 2.56929E-01 inf
+ 4 3.00000E-01 3.00000E-01 inf
diff --git a/simple_examples/baseresults/e04gbje.r b/simple_examples/baseresults/e04gbje.r
new file mode 100644
index 0000000..6e9e25e
--- /dev/null
+++ b/simple_examples/baseresults/e04gbje.r
@@ -0,0 +1,22 @@
+ E04GBJ Example Program Results
+
+ On exit, the sum of squares is 0.0082
+ at the point 0.0824 1.1330 2.3437
+ The corresponding gradient is 1.199E-09 -1.865E-11 1.807E-11
+ (machine dependent)
+ and the residuals are
+ -5.9E-03
+ -2.7E-04
+ 2.7E-04
+ 6.5E-03
+ -8.2E-04
+ -1.3E-03
+ -4.5E-03
+ -2.0E-02
+ 8.2E-02
+ -1.8E-02
+ -1.5E-02
+ -1.5E-02
+ -1.1E-02
+ -4.2E-03
+ 6.8E-03
diff --git a/simple_examples/baseresults/e04ggje.r b/simple_examples/baseresults/e04ggje.r
new file mode 100644
index 0000000..b5dd970
--- /dev/null
+++ b/simple_examples/baseresults/e04ggje.r
@@ -0,0 +1,44 @@
+ E04GGJ Example Program Results
+
+ E04GG, Nonlinear least squares method for bound-constrained problems
+ Begin of Options
+ Print File = 6 * d
+ Print Level = 1 * U
+ Print Options = Yes * d
+ Print Solution = No * d
+ Monitoring File = -1 * d
+ Monitoring Level = 4 * d
+
+ Infinite Bound Size = 1.00000E+20 * d
+ Stats Time = No * d
+ Time Limit = 1.00000E+06 * d
+
+ Bxnl Model = Gauss-newton * U
+ Bxnl Nlls Method = Galahad * d
+ Bxnl Glob Method = Reg * U
+ Bxnl Reg Order = Auto * d
+ Bxnl Tn Method = Min-1-var * d
+ Bxnl Basereg Type = None * d
+ Bxnl Basereg Pow = 2.00000E+00 * d
+ Bxnl Basereg Term = 1.00000E-02 * d
+ Bxnl Iteration Limit = 1000 * d
+ Bxnl Monitor Frequency = 0 * d
+ Bxnl Print Header = 30 * d
+ Bxnl Save Covariance Matrix = No * d
+ Bxnl Stop Abs Tol Fun = 1.05367E-08 * d
+ Bxnl Stop Abs Tol Grd = 1.05737E-05 * d
+ Bxnl Stop Rel Tol Fun = 1.05367E-08 * d
+ Bxnl Stop Rel Tol Grd = 1.05367E-08 * d
+ Bxnl Stop Step Tol = 2.22045E-16 * d
+ Bxnl Use Second Derivatives = Yes * U
+ Bxnl Use Weights = No * d
+ End of Options
+
+ Status: converged, an optimal solution was found
+ Value of the objective 2.17328E-06
+ Norm of projected gradient 1.51989E-08
+ Norm of scaled projected gradient 7.29019E-06
+ Norm of step 4.98107E-04
+
+Solver stored solution iterate in the handle
+X: 4.45E-01 1.87E+00 3.07E+00 4.64E+00 -9.98E-01 4.64E+00
diff --git a/simple_examples/baseresults/e04kfje.r b/simple_examples/baseresults/e04kfje.r
new file mode 100644
index 0000000..421d894
--- /dev/null
+++ b/simple_examples/baseresults/e04kfje.r
@@ -0,0 +1,55 @@
+ E04KFJ Example Program Results
+
+ E04KF, First order method for bound-constrained problems
+ Begin of Options
+ Print File = 6 * d
+ Print Level = 1 * U
+ Print Options = Yes * d
+ Print Solution = All * U
+ Monitoring File = 9 * U
+ Monitoring Level = 3 * U
+ Foas Monitor Frequency = 0 * d
+ Foas Print Frequency = 5 * U
+
+ Infinite Bound Size = 1.00000E+20 * d
+ Task = Minimize * d
+ Stats Time = No * d
+ Time Limit = 1.00000E+06 * d
+ Verify Derivatives = No * d
+
+ Foas Estimate Derivatives = No * d
+ Foas Finite Diff Interval = 1.05367E-08 * d
+ Foas Iteration Limit = 10000000 * d
+ Foas Memory = 11 * d
+ Foas Progress Tolerance = 1.08158E-12 * d
+ Foas Rel Stop Tolerance = 1.08158E-12 * d
+ Foas Restart Factor = 6.00000E+00 * d
+ Foas Slow Tolerance = 1.01316E-02 * d
+ Foas Stop Tolerance = 1.00000E-06 * d
+ Foas Tolerance Norm = Infinity * d
+ End of Options
+
+
+ Status: converged, an optimal solution was found
+ Value of the objective 4.00000E-02
+ Norm of inactive gradient 0.00000E+00
+ Norm of projected direction 0.00000E+00
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 -1.00000E+00 8.00000E-01 8.00000E-01
+ 2 -2.00000E+00 6.40000E-01 2.00000E+00
+
+ Box bounds dual variables:
+ idx Lower bound Value Upper bound Value
+ 1 -1.00000E+00 0.00000E+00 8.00000E-01 4.00000E-01
+ 2 -2.00000E+00 0.00000E+00 2.00000E+00 0.00000E+00
+
+
+ Solution found:
+ Objective function value at solution: 4.0E-02
+ Gradient at solution: -4.0E-01 0.0E+00
+
+ Estimated Lagrange multipliers: blx 0.0E+00 0.0E+00
+ Estimated Lagrange multipliers: bux 4.0E-01 0.0E+00
+
diff --git a/simple_examples/baseresults/e04mtje.r b/simple_examples/baseresults/e04mtje.r
new file mode 100644
index 0000000..033d40f
--- /dev/null
+++ b/simple_examples/baseresults/e04mtje.r
@@ -0,0 +1,162 @@
+ E04MTJ Example Program Results
+
+++++++++++ Use the Primal-Dual algorithm ++++++++++
+
+ ----------------------------------------------
+ E04MT, Interior point method for LP problems
+ ----------------------------------------------
+
+ Original Problem Statistics
+
+ Number of variables 7
+ Number of constraints 7
+ Free variables 0
+ Number of nonzeros 41
+
+
+ Presolved Problem Statistics
+
+ Number of variables 13
+ Number of constraints 7
+ Free variables 0
+ Number of nonzeros 47
+
+
+ ------------------------------------------------------------------------------
+ it| pobj | dobj | optim | feas | compl | mu | mcc | I
+ ------------------------------------------------------------------------------
+ 0 -7.86591E-02 1.71637E-02 1.27E+00 1.06E+00 8.89E-02 1.5E-01
+ 1 5.74135E-03 -2.24369E-02 6.11E-16 1.75E-01 2.25E-02 2.8E-02 0
+ 2 1.96803E-02 1.37067E-02 5.06E-16 2.28E-02 2.91E-03 3.4E-03 0
+ 3 2.15232E-02 1.96162E-02 7.00E-15 9.24E-03 1.44E-03 1.7E-03 0
+ 4 2.30321E-02 2.28676E-02 1.15E-15 2.21E-03 2.97E-04 3.4E-04 0
+ 5 2.35658E-02 2.35803E-02 1.32E-15 1.02E-04 8.41E-06 9.6E-06 0
+ 6 2.35965E-02 2.35965E-02 1.64E-15 7.02E-08 6.35E-09 7.2E-09 0
+Iteration 7
+ monit() reports good approximate solution (tol = 1.20E-08):
+ 7 2.35965E-02 2.35965E-02 1.35E-15 3.52E-11 3.18E-12 3.6E-12 0
+ ------------------------------------------------------------------------------
+ Status: converged, an optimal solution found
+ ------------------------------------------------------------------------------
+ Final primal objective value 2.359648E-02
+ Final dual objective value 2.359648E-02
+ Absolute primal infeasibility 4.168797E-15
+ Relative primal infeasibility 1.350467E-15
+ Absolute dual infeasibility 5.084353E-11
+ Relative dual infeasibility 3.518607E-11
+ Absolute complementarity gap 2.685778E-11
+ Relative complementarity gap 3.175366E-12
+ Iterations 7
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 -1.00000E-02 -1.00000E-02 1.00000E-02
+ 2 -1.00000E-01 -1.00000E-01 1.50000E-01
+ 3 -1.00000E-02 3.00000E-02 3.00000E-02
+ 4 -4.00000E-02 2.00000E-02 2.00000E-02
+ 5 -1.00000E-01 -6.74853E-02 5.00000E-02
+ 6 -1.00000E-02 -2.28013E-03 inf
+ 7 -1.00000E-02 -2.34528E-04 inf
+
+ Box bounds dual variables:
+ idx Lower bound Value Upper bound Value
+ 1 -1.00000E-02 3.30098E-01 1.00000E-02 0.00000E+00
+ 2 -1.00000E-01 1.43844E-02 1.50000E-01 0.00000E+00
+ 3 -1.00000E-02 0.00000E+00 3.00000E-02 9.09967E-02
+ 4 -4.00000E-02 0.00000E+00 2.00000E-02 7.66124E-02
+ 5 -1.00000E-01 3.51391E-11 5.00000E-02 0.00000E+00
+ 6 -1.00000E-02 3.42902E-11 inf 0.00000E+00
+ 7 -1.00000E-02 8.61040E-12 inf 0.00000E+00
+
+ Constraints dual variables:
+ idx Lower bound Value Upper bound Value
+ 1 -1.30000E-01 0.00000E+00 -1.30000E-01 1.43111E+00
+ 2 -inf 0.00000E+00 -4.90000E-03 4.00339E-10
+ 3 -inf 0.00000E+00 -6.40000E-03 1.54305E-08
+ 4 -inf 0.00000E+00 -3.70000E-03 3.80136E-10
+ 5 -inf 0.00000E+00 -1.20000E-03 4.72629E-11
+ 6 -9.92000E-02 1.50098E+00 inf 0.00000E+00
+ 7 -3.00000E-03 1.51661E+00 2.00000E-03 0.00000E+00
+
+++++++++++ Use the Self-Dual algorithm ++++++++++
+
+ ----------------------------------------------
+ E04MT, Interior point method for LP problems
+ ----------------------------------------------
+
+ Original Problem Statistics
+
+ Number of variables 7
+ Number of constraints 7
+ Free variables 0
+ Number of nonzeros 41
+
+
+ Presolved Problem Statistics
+
+ Number of variables 13
+ Number of constraints 7
+ Free variables 0
+ Number of nonzeros 47
+
+
+ ------------------------------------------------------------------------------
+ it| pobj | dobj | p.inf | d.inf | d.gap | tau | mcc | I
+ ------------------------------------------------------------------------------
+ 0 -6.39941E-01 4.94000E-02 1.07E+01 2.69E+00 5.54E+00 1.0E+00
+ 1 -8.56025E-02 -1.26938E-02 2.07E-01 2.07E-01 2.07E-01 1.7E+00 0
+ 2 4.09196E-03 1.24373E-02 4.00E-02 4.00E-02 4.00E-02 2.8E+00 0
+ 3 1.92404E-02 2.03658E-02 6.64E-03 6.64E-03 6.64E-03 3.2E+00 1
+ 4 1.99631E-02 2.07574E-02 3.23E-03 3.23E-03 3.23E-03 2.3E+00 1
+ 5 2.03834E-02 2.11141E-02 1.68E-03 1.68E-03 1.68E-03 1.4E+00 0
+ 6 2.22419E-02 2.25057E-02 5.73E-04 5.73E-04 5.73E-04 1.4E+00 1
+ 7 2.35051E-02 2.35294E-02 6.58E-05 6.58E-05 6.58E-05 1.4E+00 6
+ 8 2.35936E-02 2.35941E-02 1.19E-06 1.19E-06 1.19E-06 1.4E+00 0
+Iteration 9
+ monit() reports good approximate solution (tol = 1.20E-08):
+ 9 2.35965E-02 2.35965E-02 5.37E-10 5.37E-10 5.37E-10 1.4E+00 0
+Iteration 10
+ monit() reports good approximate solution (tol = 1.20E-08):
+ 10 2.35965E-02 2.35965E-02 2.68E-13 2.68E-13 2.68E-13 1.4E+00 0
+ ------------------------------------------------------------------------------
+ Status: converged, an optimal solution found
+ ------------------------------------------------------------------------------
+ Final primal objective value 2.359648E-02
+ Final dual objective value 2.359648E-02
+ Absolute primal infeasibility 2.853383E-12
+ Relative primal infeasibility 2.677658E-13
+ Absolute dual infeasibility 1.485749E-12
+ Relative dual infeasibility 2.679654E-13
+ Absolute complementarity gap 7.228861E-13
+ Relative complementarity gap 2.683908E-13
+ Iterations 10
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 -1.00000E-02 -1.00000E-02 1.00000E-02
+ 2 -1.00000E-01 -1.00000E-01 1.50000E-01
+ 3 -1.00000E-02 3.00000E-02 3.00000E-02
+ 4 -4.00000E-02 2.00000E-02 2.00000E-02
+ 5 -1.00000E-01 -6.74853E-02 5.00000E-02
+ 6 -1.00000E-02 -2.28013E-03 inf
+ 7 -1.00000E-02 -2.34528E-04 inf
+
+ Box bounds dual variables:
+ idx Lower bound Value Upper bound Value
+ 1 -1.00000E-02 3.30098E-01 1.00000E-02 0.00000E+00
+ 2 -1.00000E-01 1.43844E-02 1.50000E-01 0.00000E+00
+ 3 -1.00000E-02 0.00000E+00 3.00000E-02 9.09967E-02
+ 4 -4.00000E-02 0.00000E+00 2.00000E-02 7.66124E-02
+ 5 -1.00000E-01 3.66960E-12 5.00000E-02 0.00000E+00
+ 6 -1.00000E-02 2.47652E-11 inf 0.00000E+00
+ 7 -1.00000E-02 7.82645E-13 inf 0.00000E+00
+
+ Constraints dual variables:
+ idx Lower bound Value Upper bound Value
+ 1 -1.30000E-01 0.00000E+00 -1.30000E-01 1.43111E+00
+ 2 -inf 0.00000E+00 -4.90000E-03 1.07904E-10
+ 3 -inf 0.00000E+00 -6.40000E-03 1.14799E-09
+ 4 -inf 0.00000E+00 -3.70000E-03 4.09190E-12
+ 5 -inf 0.00000E+00 -1.20000E-03 1.52421E-12
+ 6 -9.92000E-02 1.50098E+00 inf 0.00000E+00
+ 7 -3.00000E-03 1.51661E+00 2.00000E-03 0.00000E+00
diff --git a/simple_examples/baseresults/e04mxje.r b/simple_examples/baseresults/e04mxje.r
new file mode 100644
index 0000000..1928db4
--- /dev/null
+++ b/simple_examples/baseresults/e04mxje.r
@@ -0,0 +1,38 @@
+ E04MXJ Example Program Results
+
+ MPSX INPUT LISTING
+ ------------------
+ Searching for indicator line
+ Line 1: Found NAME indicator line
+ Query mode - Ignoring NAME data.
+ Line 2: Found ROWS indicator line
+ Query mode - Counting ROWS data.
+ Line 7: Found COLUMNS indicator line
+ Query mode - Counting COLUMNS data.
+ Line 26: Found RHS indicator line
+ Query mode - Ignoring RHS data.
+ Line 31: Found RANGES indicator line
+ Query mode - Ignoring RANGES data.
+ Line 35: Found BOUNDS indicator line
+ Query mode - Counting BOUNDS data.
+ Line 54: Found QUADOBJ indicator line
+ Query mode - Counting QUADOBJ data.
+ Query mode - End of QUADOBJ data. Exit
+
+ MPSX INPUT LISTING
+ ------------------
+ Searching for indicator line
+ Line 1: Found NAME indicator line
+ Line 2: Found ROWS indicator line
+ Line 7: Found COLUMNS indicator line
+ Line 26: Found RHS indicator line
+ Line 31: Found RANGES indicator line
+ Line 35: Found BOUNDS indicator line
+ Line 54: Found QUADOBJ indicator line
+ Line 64: Found ENDATA indicator line
+
+ Problem contains 9 variables and 4 linear constraints
+
+ Final objective value = -8.068E+00
+ Optimal X =
+ 2.00 -0.23 -0.27 -0.30 -0.10 2.00 2.00 -1.78 -0.46
diff --git a/simple_examples/baseresults/e04ncje.r b/simple_examples/baseresults/e04ncje.r
new file mode 100644
index 0000000..65a6326
--- /dev/null
+++ b/simple_examples/baseresults/e04ncje.r
@@ -0,0 +1,23 @@
+ E04NCJ Example Program Results
+
+ Varbl Istate Value Lagr Mult
+
+ V 1 1 0.000E+00 1.572E-01
+ V 2 0 4.153E-02 0.000E+00
+ V 3 0 5.872E-01 0.000E+00
+ V 4 1 0.000E+00 8.782E-01
+ V 5 0 9.964E-02 0.000E+00
+ V 6 1 0.000E+00 1.473E-01
+ V 7 0 4.906E-02 0.000E+00
+ V 8 1 0.000E+00 8.603E-01
+ V 9 0 3.056E-01 0.000E+00
+
+
+ L Con Istate Value Lagr Mult
+
+ L 1 1 2.000E+00 3.777E-01
+ L 2 2 2.000E+00 -5.791E-02
+ L 3 1 1.000E+00 1.075E-01
+
+
+ Final objective value = 8.134E-02
diff --git a/simple_examples/baseresults/e04nfje.r b/simple_examples/baseresults/e04nfje.r
new file mode 100644
index 0000000..13101d2
--- /dev/null
+++ b/simple_examples/baseresults/e04nfje.r
@@ -0,0 +1,66 @@
+ E04NFJ Example Program Results
+
+ *** e04nf
+
+ Parameters
+ ----------
+
+ Problem type........... QP2
+
+ Linear constraints..... 7 Feasibility tolerance.. 1.05E-08
+ Variables.............. 7 Optimality tolerance... 1.05E-08
+ Hessian rows........... 7 Rank tolerance......... 1.11E-14
+
+ Infinite bound size.... 1.00E+20 COLD start.............
+ Infinite step size..... 1.00E+20 EPS (machine precision) 1.11E-16
+
+ Check frequency........ 50 Expand frequency....... 5
+ Minimum sum of infeas.. NO Crash tolerance........ 1.00E-02
+
+ Max degrees of freedom. 7 Print level............ 10
+ Feasibility phase itns. 70 Monitoring file........ -1
+ Optimality phase itns. 70
+
+ Workspace provided is IWORK( 17), WORK( 189).
+ To solve problem we need IWORK( 17), WORK( 189).
+
+
+ Itn Step Ninf Sinf/Objective Norm Gz
+ 0 0.0E+00 3 1.038000E-01 0.0E+00
+ 1 4.1E-02 1 3.000000E-02 0.0E+00
+ 2 4.2E-02 0 0.000000E+00 0.0E+00
+ Itn 2 -- Feasible point found.
+ 2 0.0E+00 0 4.580000E-02 0.0E+00
+ 3 1.3E-01 0 4.161596E-02 0.0E+00
+ 4 1.0E+00 0 3.936227E-02 4.2E-17
+ 5 4.1E-01 0 3.758935E-02 1.2E-02
+ 6 1.0E+00 0 3.755377E-02 1.0E-17
+ 7 1.0E+00 0 3.703165E-02 3.8E-17
+
+
+ Varbl State Value Lower Bound Upper Bound Lagr Mult Slack
+
+ V 1 LL -1.000000E-02 -1.000000E-02 1.000000E-02 0.4700 .
+ V 2 FR -6.986465E-02 -0.100000 0.150000 . 3.0135E-02
+ V 3 FR 1.825915E-02 -1.000000E-02 3.000000E-02 . 1.1741E-02
+ V 4 FR -2.426081E-02 -4.000000E-02 2.000000E-02 . 1.5739E-02
+ V 5 FR -6.200564E-02 -0.100000 5.000000E-02 . 3.7994E-02
+ V 6 FR 1.380544E-02 -1.000000E-02 None . 2.3805E-02
+ V 7 FR 4.066496E-03 -1.000000E-02 None . 1.4066E-02
+
+
+ L Con State Value Lower Bound Upper Bound Lagr Mult Slack
+
+ L 1 EQ -0.130000 -0.130000 -0.130000 -1.908 -5.5511E-17
+ L 2 FR -5.879898E-03 None -4.900000E-03 . 9.7990E-04
+ L 3 UL -6.400000E-03 None -6.400000E-03 -0.3144 8.6736E-19
+ L 4 FR -4.537323E-03 None -3.700000E-03 . 8.3732E-04
+ L 5 FR -2.915996E-03 None -1.200000E-03 . 1.7160E-03
+ L 6 LL -9.920000E-02 -9.920000E-02 None 1.955 .
+ L 7 LL -3.000000E-03 -3.000000E-03 2.000000E-03 1.972 4.3368E-18
+
+ Exit e04nf - Optimal QP solution.
+
+ Final QP objective value = 0.3703165E-01
+
+ Exit from QP problem after 7 iterations.
diff --git a/simple_examples/baseresults/e04nkje.r b/simple_examples/baseresults/e04nkje.r
new file mode 100644
index 0000000..bbfdea9
--- /dev/null
+++ b/simple_examples/baseresults/e04nkje.r
@@ -0,0 +1,26 @@
+E04NKJ Example Program Results
+
+ Variable Istate Value Lagr Mult
+
+ ...X1... 0 0.00000 2361
+ ...X2... 3 349.399 -3.657e-12
+ ...X3... 2 648.853 -5.924e-12
+ ...X4... 2 172.847 1.949e-12
+ ...X5... 3 407.521 0.000
+ ...X6... 3 271.356 -3.280e-12
+ ...X7... 3 150.023 -1.413e-12
+
+
+ Constrnt Istate Value Lagr Mult
+
+ ..ROW1.. 0 2000.00 -1.290e+04
+ ..ROW2.. 3 49.2316 0.000
+ ..ROW3.. 1 100.000 -2325
+ ..ROW4.. 3 32.0719 0.000
+ ..ROW5.. 3 14.5572 0.000
+ ..ROW6.. 0 1500.00 1.445e+04
+ ..ROW7.. 0 250.000 1.458e+04
+ ..COST.. 3 -2.98869e+06 -1.000
+
+
+Final objetive value = -1847785
diff --git a/simple_examples/baseresults/e04nqje.r b/simple_examples/baseresults/e04nqje.r
new file mode 100644
index 0000000..8515ce8
--- /dev/null
+++ b/simple_examples/baseresults/e04nqje.r
@@ -0,0 +1,6 @@
+ E04NQJ Example Program Results
+
+ QP problem contains 7 variables and 8 linear constraints
+
+ Final objective value = -1.848E+06
+ Optimal X = 0.00 349.40 648.85 172.85 407.52 271.36 150.02
diff --git a/simple_examples/baseresults/e04ptje.r b/simple_examples/baseresults/e04ptje.r
new file mode 100644
index 0000000..24d78ba
--- /dev/null
+++ b/simple_examples/baseresults/e04ptje.r
@@ -0,0 +1,39 @@
+E04PTJ Example Program Results
+
+
+ ------------------------------------------------
+ E04PT, Interior point method for SOCP problems
+ ------------------------------------------------
+
+ Begin of Options
+ Print File = 6 * d
+ Print Level = 1 * U
+ Print Options = Yes * d
+ Print Solution = No * d
+ Monitoring File = -1 * d
+ Monitoring Level = 4 * d
+ Socp Monitor Frequency = 1 * U
+
+ Infinite Bound Size = 1.00000E+20 * d
+ Task = Minimize * d
+ Stats Time = No * d
+ Time Limit = 1.00000E+06 * d
+
+ Socp Iteration Limit = 100 * d
+ Socp Max Iterative Refinement = 9 * d
+ Socp Presolve = Yes * d
+ Socp Scaling = None * d
+ Socp Stop Tolerance = 1.05367E-08 * d
+ Socp Stop Tolerance 2 = 1.05367E-08 * d
+ Socp System Formulation = Auto * d
+ End of Options
+
+monit() reports good approximate solution (tol = 1.00E-07)
+ Status: converged, an optimal solution found
+ Final primal objective value 2.571350E+00
+ Final dual objective value 2.571350E+00
+ Optimal X:
+ x_idx Value
+ 1 1.174E+00
+ 2 -4.257E+00
+ 3 9.814E-01
diff --git a/simple_examples/baseresults/e04rpje.r b/simple_examples/baseresults/e04rpje.r
new file mode 100644
index 0000000..93e29fb
--- /dev/null
+++ b/simple_examples/baseresults/e04rpje.r
@@ -0,0 +1,105 @@
+E04RPJ Example Program Results
+
+Passing SDP problem to solver
+
+ Overview
+ Status: Problem and option settings are editable.
+ No of variables: 5
+ Objective function: linear
+ Simple bounds: not defined yet
+ Linear constraints: not defined yet
+ Nonlinear constraints: not defined yet
+ Cone constraints: not defined yet
+ Matrix constraints: 2
+ Matrix constraints
+ IDblk = 1, size = 2 x 2, polynomial of order 2
+ IDblk = 2, size = 2 x 2, linear
+ E04SV, NLP-SDP Solver (Pennon)
+ ------------------------------
+ Number of variables 5 [eliminated 0]
+ simple linear nonlin
+ (Standard) inequalities 0 0 0
+ (Standard) equalities 0 0
+ Matrix inequalities 1 1 [dense 2, sparse 0]
+ [max dimension 2]
+
+ Begin of Options
+ Print File = 6 * d
+ Print Level = 2 * d
+ Print Options = Yes * d
+ Monitoring File = -1 * d
+ Monitoring Level = 4 * d
+ Monitor Frequency = 0 * d
+
+ Infinite Bound Size = 1.00000E+20 * d
+ Task = Minimize * d
+ Stats Time = No * d
+
+ Dimacs Measures = No * S
+ Hessian Density = Dense * S
+ Init Value P = 1.00000E+00 * d
+ Init Value Pmat = 1.00000E+00 * d
+ Initial P = Automatic * d
+ Initial U = Automatic * d
+ Initial X = User * d
+ Inner Iteration Limit = 100 * d
+ Inner Stop Criteria = Heuristic * d
+ Inner Stop Tolerance = 1.00000E-02 * d
+ Linesearch Mode = Goldstein * S
+ Outer Iteration Limit = 100 * d
+ P Min = 1.05367E-08 * d
+ P Update Speed = 12 * d
+ Pmat Min = 1.05367E-08 * d
+ Preference = Speed * d
+ Presolve Block Detect = Yes * d
+ Stop Criteria = Soft * d
+ Stop Tolerance 1 = 1.00000E-06 * d
+ Stop Tolerance 2 = 1.00000E-07 * d
+ Stop Tolerance Feasibility = 1.00000E-07 * d
+ Transform Constraints = No * S
+ U Update Restriction = 5.00000E-01 * d
+ Umat Update Restriction = 3.00000E-01 * d
+ End of Options
+ --------------------------------------------------------------
+ it| objective | optim | feas | compl | pen min |inner
+ --------------------------------------------------------------
+ 0 0.00000E+00 1.82E+01 1.00E+00 4.00E+00 2.00E+00 0
+ 1 4.11823E+00 3.85E-03 0.00E+00 1.73E+00 2.00E+00 6
+ 2 2.58252E+00 5.36E-03 0.00E+00 4.93E-01 9.04E-01 4
+ 3 2.06132E+00 1.02E-03 0.00E+00 7.70E-02 4.08E-01 4
+ 4 2.00050E+00 3.00E-03 8.91E-03 1.78E-02 1.85E-01 3
+ 5 1.99929E+00 1.55E-03 3.16E-03 3.65E-03 8.34E-02 2
+ 6 1.99985E+00 1.03E-04 3.16E-04 7.19E-04 3.77E-02 4
+ 7 1.99997E+00 7.04E-04 5.76E-05 1.41E-04 1.70E-02 1
+ 8 2.00000E+00 1.32E-04 6.52E-06 2.76E-05 7.70E-03 1
+ 9 2.00000E+00 8.49E-06 7.86E-07 5.37E-06 3.48E-03 1
+ 10 2.00000E+00 5.88E-07 1.06E-07 1.04E-06 1.57E-03 1
+ 11 2.00000E+00 5.55E-08 4.87E-08 2.02E-07 7.11E-04 1
+ 12 2.00000E+00 5.34E-09 5.37E-09 3.93E-08 3.21E-04 1
+ 13 2.00000E+00 5.03E-10 5.45E-09 7.62E-09 1.45E-04 1
+ 14 2.00000E+00 4.45E-11 5.55E-09 1.48E-09 6.56E-05 1
+ --------------------------------------------------------------
+ it| objective | optim | feas | compl | pen min |inner
+ --------------------------------------------------------------
+ 15 2.00000E+00 4.36E-12 5.67E-09 2.87E-10 2.96E-05 1
+ 16 2.00000E+00 1.61E-11 5.82E-09 5.57E-11 1.34E-05 1
+ 17 2.00000E+00 3.13E-11 6.00E-09 1.08E-11 6.06E-06 1
+ 18 2.00000E+00 8.65E-11 6.22E-09 2.10E-12 2.74E-06 1
+ 19 2.00000E+00 1.31E-10 6.48E-09 4.07E-13 1.24E-06 1
+ --------------------------------------------------------------
+ Status: converged, an optimal solution found
+ --------------------------------------------------------------
+ Final objective value 2.000000E+00
+ Relative precision 8.141636E-16
+ Optimality 1.310533E-10
+ Feasibility 6.484489E-09
+ Complementarity 4.066867E-13
+ Iteration counts
+ Outer iterations 19
+ Inner iterations 36
+ Linesearch steps 56
+ Evaluation counts
+ Augm. Lagr. values 76
+ Augm. Lagr. gradient 56
+ Augm. Lagr. hessian 36
+ --------------------------------------------------------------
\ No newline at end of file
diff --git a/simple_examples/baseresults/e04rsje.r b/simple_examples/baseresults/e04rsje.r
new file mode 100644
index 0000000..170a9e9
--- /dev/null
+++ b/simple_examples/baseresults/e04rsje.r
@@ -0,0 +1,35 @@
+ E04RSJ Example Program Results
+ E04PT, Interior point method for SOCP problems
+ Begin of Options
+ Print File = 6 * d
+ Print Level = 1 * U
+ Print Options = Yes * d
+ Print Solution = No * d
+ Monitoring File = -1 * d
+ Monitoring Level = 4 * d
+ Socp Monitor Frequency = 1 * U
+
+ Infinite Bound Size = 1.00000E+20 * d
+ Task = Minimize * d
+ Stats Time = No * d
+ Time Limit = 1.00000E+06 * d
+
+ Socp Iteration Limit = 100 * d
+ Socp Max Iterative Refinement = 9 * d
+ Socp Presolve = Yes * d
+ Socp Scaling = None * d
+ Socp Stop Tolerance = 1.05367E-08 * d
+ Socp Stop Tolerance 2 = 1.05367E-08 * d
+ Socp System Formulation = Auto * d
+ End of Options
+
+
+ monit() reports good approximate solution (tol = 1.00e-07)
+ Status: converged, an optimal solution found
+ Final primal objective value 2.571350E+00
+ Final dual objective value 2.571350E+00
+ Optimal X:
+ x_idx Value
+ 0 1.174e+00
+ 1 -4.257e+00
+ 2 9.814e-01
diff --git a/simple_examples/baseresults/e04rtje.r b/simple_examples/baseresults/e04rtje.r
new file mode 100644
index 0000000..65ffe25
--- /dev/null
+++ b/simple_examples/baseresults/e04rtje.r
@@ -0,0 +1,35 @@
+ E04RTJ Example Program Results
+ E04PT, Interior point method for SOCP problems
+ Begin of Options
+ Print File = 6 * d
+ Print Level = 1 * U
+ Print Options = Yes * d
+ Print Solution = No * d
+ Monitoring File = -1 * d
+ Monitoring Level = 4 * d
+ Socp Monitor Frequency = 1 * U
+
+ Infinite Bound Size = 1.00000E+20 * d
+ Task = Minimize * d
+ Stats Time = No * d
+ Time Limit = 1.00000E+06 * d
+
+ Socp Iteration Limit = 100 * d
+ Socp Max Iterative Refinement = 9 * d
+ Socp Presolve = Yes * d
+ Socp Scaling = None * d
+ Socp Stop Tolerance = 1.05367E-08 * d
+ Socp Stop Tolerance 2 = 1.05367E-08 * d
+ Socp System Formulation = Auto * d
+ End of Options
+
+
+ monit() reports good approximate solution (tol = 1.00e-07)
+ Status: converged, an optimal solution found
+ Final primal objective value 1.313004E-01
+ Final dual objective value 1.313004E-01
+ Optimal X:
+ x_idx Value
+ 0 1.000e+00
+ 1 -9.722e-01
+ 2 9.722e-01
diff --git a/simple_examples/baseresults/e04saje.r b/simple_examples/baseresults/e04saje.r
new file mode 100644
index 0000000..c10990a
--- /dev/null
+++ b/simple_examples/baseresults/e04saje.r
@@ -0,0 +1,33 @@
+ E04SAJ Example Program Results
+ E04PT, Interior point method for SOCP problems
+ Begin of Options
+ Print File = 6 * d
+ Print Level = 1 * U
+ Print Options = Yes * d
+ Print Solution = No * d
+ Monitoring File = -1 * d
+ Monitoring Level = 4 * d
+ Socp Monitor Frequency = 0 * d
+
+ Infinite Bound Size = 1.00000E+20 * d
+ Task = Minimize * d
+ Stats Time = No * d
+ Time Limit = 1.00000E+06 * d
+
+ Socp Iteration Limit = 100 * d
+ Socp Max Iterative Refinement = 9 * d
+ Socp Presolve = Yes * d
+ Socp Scaling = None * d
+ Socp Stop Tolerance = 1.05367E-08 * d
+ Socp Stop Tolerance 2 = 1.05367E-08 * d
+ Socp System Formulation = Auto * d
+ End of Options
+
+ Status: converged, an optimal solution found
+ Final primal objective value -1.951817E+01
+ Final dual objective value -1.951817E+01
+ Optimal X:
+ x_idx Value
+ 0 -1.26819e+00
+ 1 -4.08429e-01
+ 2 1.33234e+00
diff --git a/simple_examples/baseresults/e04taje.r b/simple_examples/baseresults/e04taje.r
new file mode 100644
index 0000000..a6cf135
--- /dev/null
+++ b/simple_examples/baseresults/e04taje.r
@@ -0,0 +1,39 @@
+ E04TAJ Example Program Results
+
+ Solve the first LP
+
+ E04MT, Interior point method for LP problems
+ Status: converged, an optimal solution found
+ Final primal objective value 8.500000E+02
+ Final dual objective value 8.500000E+02
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 0.00000E+00 2.00000E+02 inf
+ 2 0.00000E+00 1.00000E+02 1.00000E+02
+
+ The new variable has been added, solve the handle again
+
+ E04MT, Interior point method for LP problems
+ Status: converged, an optimal solution found
+ Final primal objective value 9.000000E+02
+ Final dual objective value 9.000000E+02
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 0.00000E+00 5.00000E+01 inf
+ 2 0.00000E+00 1.00000E+02 1.00000E+02
+ 3 0.00000E+00 5.00000E+01 5.00000E+01
+
+ The new constraint has been added, solve the handle again
+
+ E04MT, Interior point method for LP problems
+ Status: converged, an optimal solution found
+ Final primal objective value 8.750000E+02
+ Final dual objective value 8.750000E+02
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 0.00000E+00 1.50000E+02 inf
+ 2 0.00000E+00 5.00000E+01 1.00000E+02
+ 3 0.00000E+00 5.00000E+01 5.00000E+01
diff --git a/simple_examples/baseresults/e04tcje.r b/simple_examples/baseresults/e04tcje.r
new file mode 100644
index 0000000..cd501a1
--- /dev/null
+++ b/simple_examples/baseresults/e04tcje.r
@@ -0,0 +1,58 @@
+ E04TCJ Example Program Results
+
+ First solve the problem with the outliers
+
+ --------------------------------------------------------
+ E04GG, Nonlinear least squares method for bound-constrained problems
+ Status: converged, an optimal solution was found
+ Value of the objective 1.05037E+00
+ Norm of gradient 8.78014E-06
+ Norm of scaled gradient 6.05781E-06
+ Norm of step 1.47886E-01
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 -inf 3.61301E-01 inf
+ 2 -inf 9.10227E-01 inf
+ 3 -inf 3.42138E-03 inf
+ 4 -inf -6.08965E+00 inf
+ 5 -inf 6.24881E-04 inf
+ --------------------------------------------------------
+
+ Now remove the outlier residuals from the problem handle
+
+ --------------------------------------------------------
+ E04GG, Nonlinear least squares method for bound-constrained problems
+ Status: converged, an optimal solution was found
+ Value of the objective 5.96811E-02
+ Norm of gradient 1.19914E-06
+ Norm of scaled gradient 3.47087E-06
+ Norm of step 3.49256E-06
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 -inf 3.53888E-01 inf
+ 2 -inf 1.06575E+00 inf
+ 3 -inf 1.91383E-03 inf
+ 4 -inf 2.17299E-01 inf
+ 5 -inf 5.17660E+00 inf
+ --------------------------------------------------------
+
+ Assuming the outliers points are measured again
+ we can enable the residuals and adjust the values
+
+ --------------------------------------------------------
+ E04GG, Nonlinear least squares method for bound-constrained problems
+ Status: converged, an optimal solution was found
+ Value of the objective 6.51802E-02
+ Norm of gradient 2.57338E-07
+ Norm of scaled gradient 7.12740E-07
+ Norm of step 1.56251E-05
+
+ Primal variables:
+ idx Lower bound Value Upper bound
+ 1 3.00000E-01 3.00000E-01 3.00000E-01
+ 2 -inf 1.06039E+00 inf
+ 3 -inf 2.11765E-02 inf
+ 4 -inf 2.11749E-01 inf
+ 5 -inf 5.16415E+00 inf
diff --git a/simple_examples/baseresults/e04uc_example.r b/simple_examples/baseresults/e04uc_example.r
new file mode 100644
index 0000000..abde1c6
--- /dev/null
+++ b/simple_examples/baseresults/e04uc_example.r
@@ -0,0 +1,95 @@
+ E04UC_Example Example Program Results
+
+ *** e04uc
+
+ Parameters
+ ----------
+
+ Linear constraints..... 1 Variables.............. 4
+ Nonlinear constraints.. 2
+
+ Infinite bound size.... 1.00E+20 COLD start.............
+ Infinite step size..... 1.00E+20 EPS (machine precision) 1.11E-16
+ Step limit............. 2.00E+00 Hessian................ NO
+
+ Linear feasibility..... 1.05E-08 Crash tolerance........ 1.00E-02
+ Nonlinear feasibility.. 1.05E-08 Optimality tolerance... 3.26E-12
+ Line search tolerance.. 9.00E-01 Function precision..... 4.37E-15
+
+ Derivative level....... 3 Monitoring file........ -1
+ Verify level........... 0
+
+ Major iterations limit. 50 Major print level...... 10
+ Minor iterations limit. 50 Minor print level...... 0
+
+ Start point
+ 1.000000E+00 5.000000E+00 5.000000E+00 1.000000E+00
+
+ Workspace provided is IWORK( 17), WORK( 185).
+ To solve problem we need IWORK( 17), WORK( 185).
+
+
+ Verification of the constraint gradients.
+ -----------------------------------------
+
+ The constraint Jacobian seems to be ok.
+
+ The largest relative error was 2.29E-07 in constraint 2
+
+
+
+ Verification of the objective gradients.
+ ----------------------------------------
+
+ The objective gradients seem to be ok.
+
+ Directional derivative of the objective 8.15250000E-01
+ Difference approximation 8.15249734E-01
+
+
+ Maj Mnr Step Merit Function Norm Gz Violtn Cond Hz
+ 0 4 0.0E+00 1.738281E+01 7.1E-01 1.2E+01 1.0E+00
+ 1 1 1.0E+00 1.703169E+01 4.6E-02 1.9E+00 1.0E+00
+ 2 1 1.0E+00 1.701442E+01 2.1E-02 8.8E-02 1.0E+00
+ 3 1 1.0E+00 1.701402E+01 3.1E-04 5.4E-04 1.0E+00
+ 4 1 1.0E+00 1.701402E+01 7.0E-06 9.9E-08 1.0E+00
+ 5 1 1.0E+00 1.701402E+01 1.1E-08 4.6E-11 1.0E+00
+
+ Exit from NP problem after 5 major iterations,
+ 9 minor iterations.
+
+
+ Varbl State Value Lower Bound Upper Bound Lagr Mult Slack
+
+ V 1 LL 1.00000 1.00000 5.00000 1.088 .
+ V 2 FR 4.74300 1.00000 5.00000 . 0.2570
+ V 3 FR 3.82115 1.00000 5.00000 . 1.179
+ V 4 FR 1.37941 1.00000 5.00000 . 0.3794
+
+
+ L Con State Value Lower Bound Upper Bound Lagr Mult Slack
+
+ L 1 FR 10.9436 None 20.0000 . 9.056
+
+
+ N Con State Value Lower Bound Upper Bound Lagr Mult Slack
+
+ N 1 UL 40.0000 None 40.0000 -0.1615 -3.5264E-11
+ N 2 LL 25.0000 25.0000 None 0.5523 -2.8791E-11
+
+ Exit e04uc - Optimal solution found.
+
+ Final objective value = 17.01402
+
+ Varbl Istate Value Lagr Mult
+
+ V 0 1 1.000000 1.0879
+ V 1 0 4.743000 0.0000
+ V 2 0 3.821150 0.0000
+ V 3 0 1.379408 0.0000
+
+ L Con Istate Value Lagr Mult
+
+ L 0 0 10.943558 0.0000
+
+ Final objective value = 17.0140173
diff --git a/simple_examples/baseresults/e04ucje.r b/simple_examples/baseresults/e04ucje.r
new file mode 100644
index 0000000..c024cfc
--- /dev/null
+++ b/simple_examples/baseresults/e04ucje.r
@@ -0,0 +1,22 @@
+ E04UCJ Example Program Results
+
+ Varbl Istate Value Lagr Mult
+
+ V 1 1 1.00000 1.088
+ V 2 0 4.74300 0.000
+ V 3 0 3.82115 0.000
+ V 4 0 1.37941 0.000
+
+
+ L Con Istate Value Lagr Mult
+
+ L 1 0 10.9436 0.000
+
+
+ N Con Istate Value Lagr Mult
+
+ N 1 2 40.0000 -0.1615
+ N 2 1 25.0000 0.5523
+
+
+ Final objective value = 17.01402
diff --git a/simple_examples/baseresults/e04yaje.r b/simple_examples/baseresults/e04yaje.r
new file mode 100644
index 0000000..463bd7f
--- /dev/null
+++ b/simple_examples/baseresults/e04yaje.r
@@ -0,0 +1,25 @@
+ E04YAJ Example Program Results
+
+The test point is
+ 0.19000 -1.34000 0.88000
+
+1st derivatives are consistent with residual values
+
+At the test point, LSQFUN gives
+
+ Residuals 1st derivatives
+ -2.029E-03 1.000E+00 -4.061E-02 -2.707E-03
+ -1.076E-01 1.000E+00 -9.689E-02 -1.384E-02
+ -2.330E-01 1.000E+00 -1.785E-01 -4.120E-02
+ -3.785E-01 1.000E+00 -3.043E-01 -1.014E-01
+ -5.836E-01 1.000E+00 -5.144E-01 -2.338E-01
+ -8.689E-01 1.000E+00 -9.100E-01 -5.460E-01
+ -1.346E+00 1.000E+00 -1.810E+00 -1.408E+00
+ -2.374E+00 1.000E+00 -4.726E+00 -4.726E+00
+ -2.975E+00 1.000E+00 -6.076E+00 -6.076E+00
+ -4.013E+00 1.000E+00 -7.876E+00 -7.876E+00
+ -5.323E+00 1.000E+00 -1.040E+01 -1.040E+01
+ -7.292E+00 1.000E+00 -1.418E+01 -1.418E+01
+ -1.057E+01 1.000E+00 -2.048E+01 -2.048E+01
+ -1.713E+01 1.000E+00 -3.308E+01 -3.308E+01
+ -3.681E+01 1.000E+00 -7.089E+01 -7.089E+01
diff --git a/simple_examples/baseresults/f01adje.r b/simple_examples/baseresults/f01adje.r
new file mode 100644
index 0000000..c8570bc
--- /dev/null
+++ b/simple_examples/baseresults/f01adje.r
@@ -0,0 +1,9 @@
+ F01ADJ Example Program Results
+
+ Lower triangle of inverse
+ 1 2 3 4
+ 1
+ 2 68.0000
+ 3 -41.0000 25.0000
+ 4 -17.0000 10.0000 5.0000
+ 5 10.0000 -6.0000 -3.0000 2.0000
diff --git a/simple_examples/baseresults/f01ckje.r b/simple_examples/baseresults/f01ckje.r
new file mode 100644
index 0000000..3264e43
--- /dev/null
+++ b/simple_examples/baseresults/f01ckje.r
@@ -0,0 +1,5 @@
+ F01CKJ Example Program Results
+
+ Matrix A
+ 5.0 8.0
+ 8.0 14.0
diff --git a/simple_examples/baseresults/f01crje.r b/simple_examples/baseresults/f01crje.r
new file mode 100644
index 0000000..0b33f3a
--- /dev/null
+++ b/simple_examples/baseresults/f01crje.r
@@ -0,0 +1,6 @@
+ F01CRJ Example Program Results
+
+ 1.0 4.0 7.0 10.0 13.0 16.0 19.0
+ 2.0 5.0 8.0 11.0 14.0 17.0 20.0
+ 3.0 6.0 9.0 12.0 15.0 18.0 21.0
+
diff --git a/simple_examples/baseresults/f01dgje.r b/simple_examples/baseresults/f01dgje.r
new file mode 100644
index 0000000..85c8df1
--- /dev/null
+++ b/simple_examples/baseresults/f01dgje.r
@@ -0,0 +1,8 @@
+F01DGJ Example Program Results
+
+ Solution matrix B
+ 1 2 3 4
+ 1 2.1000 1.2600 2.4000 1.2600
+ 2 3.2200 9.5480 6.5360 5.3320
+ 3 9.3800 17.7240 20.7640 14.5920
+ 4 2.6600 20.8600 11.6240 28.5400
diff --git a/simple_examples/baseresults/f01elje.r b/simple_examples/baseresults/f01elje.r
new file mode 100644
index 0000000..06a7a20
--- /dev/null
+++ b/simple_examples/baseresults/f01elje.r
@@ -0,0 +1,10 @@
+ F01ELJ Example Program Results
+
+ F(A) = COS(2A)
+ 1 2 3 4
+ 1 -0.1704 -1.1597 -0.1878 -0.7307
+ 2 -0.3950 -0.4410 0.7606 0.0655
+ 3 -0.0950 -0.0717 0.0619 -0.4351
+ 4 -0.1034 0.6424 -1.3964 0.1042
+
+Imnorm = 0.0
diff --git a/simple_examples/baseresults/f01emje.r b/simple_examples/baseresults/f01emje.r
new file mode 100644
index 0000000..d805f3c
--- /dev/null
+++ b/simple_examples/baseresults/f01emje.r
@@ -0,0 +1,10 @@
+F01EMJ Example Program Results
+
+ F(A) = EXP(2A)
+ 1 2 3 4
+ 1 -12.1880 0.0000 -3.4747 8.3697
+ 2 -13.7274 54.5982 -23.9801 82.8593
+ 3 -9.7900 0.0000 -25.4527 26.5294
+ 4 -18.1597 0.0000 -34.8991 49.2404
+
+Imnorm = 0.00
diff --git a/simple_examples/baseresults/f02ekje.r b/simple_examples/baseresults/f02ekje.r
new file mode 100644
index 0000000..925d7cb
--- /dev/null
+++ b/simple_examples/baseresults/f02ekje.r
@@ -0,0 +1,20 @@
+ F02EKJ Example Program Results
+
+Iteration Limit= 500
+ Arnoldi basis vectors used: 20
+ The following Ritz values (mu) are related to the
+ true eigenvalues (lambda) by lambda = sigma + 1/mu
+
+ Iteration number 1
+ Ritz values converged so far ( 2) and their Ritz estimates:
+ 1 ( 5.69917E-01, 8.80810E-01) 1.30081E-20
+ 2 ( 5.69917E-01, -8.80810E-01) 1.30081E-20
+ Next (unconverged) Ritz value:
+ 3 ( 6.07774E-01, 0.00000E+00)
+
+ The 5 Ritz values of closest to 5.50000E+00 are:
+ 1 ( 6.01781E+00 , -8.00277E-01 )
+ 2 ( 6.01781E+00 , 8.00277E-01 )
+ 3 ( 4.34309E+00 , -1.94557E+00 )
+ 4 ( 4.34309E+00 , 1.94557E+00 )
+ 5 ( 7.14535E+00 , 0.00000E+00 )
diff --git a/simple_examples/baseresults/f02fkje.r b/simple_examples/baseresults/f02fkje.r
new file mode 100644
index 0000000..8217134
--- /dev/null
+++ b/simple_examples/baseresults/f02fkje.r
@@ -0,0 +1,14 @@
+ F02FKJ Example Program Results
+
+ Iteration Limit= 500
+
+ Ritz values and residuals
+ 1 2
+ 1 1.9702E+01 5.6583E-13
+ 2 4.9036E+01 7.2456E-13
+ 3 4.9036E+01 7.0022E-13
+ 4 7.8370E+01 8.8089E-13
+ 5 9.7197E+01 8.7693E-13
+ 6 9.7197E+01 8.7672E-13
+ 7 1.2653E+02 6.8423E-13
+ 8 1.2653E+02 9.8310E-13
diff --git a/simple_examples/baseresults/f02wgje.r b/simple_examples/baseresults/f02wgje.r
new file mode 100644
index 0000000..b4e345c
--- /dev/null
+++ b/simple_examples/baseresults/f02wgje.r
@@ -0,0 +1,7 @@
+ F02WGJ Example Program Results
+
+ Singular Value Residual
+ 0.00830 2.7E-19
+ 0.01223 5.9E-18
+ 0.02381 1.2E-17
+ 0.11274 7.8E-17
diff --git a/simple_examples/baseresults/f03baje.r b/simple_examples/baseresults/f03baje.r
new file mode 100644
index 0000000..c4c40d7
--- /dev/null
+++ b/simple_examples/baseresults/f03baje.r
@@ -0,0 +1,14 @@
+F03BAJ Example Program Results
+
+ Array A after factorization
+ 1 2 3
+ 1 33.0000 16.0000 72.0000
+ 2 -0.7273 1.6364 -4.6364
+ 3 -0.2424 -0.0741 0.1111
+
+Pivots
+ 1 2 3
+
+D = 0.37500 ID = 4
+
+Value of determinant = 6.00000e+00
\ No newline at end of file
diff --git a/simple_examples/baseresults/f04amje.r b/simple_examples/baseresults/f04amje.r
new file mode 100644
index 0000000..86bd893
--- /dev/null
+++ b/simple_examples/baseresults/f04amje.r
@@ -0,0 +1,4 @@
+F04AMJ Example Program Results
+Solution
+1.3010
+0.7935
\ No newline at end of file
diff --git a/simple_examples/baseresults/f04baje.r b/simple_examples/baseresults/f04baje.r
new file mode 100644
index 0000000..eb52050
--- /dev/null
+++ b/simple_examples/baseresults/f04baje.r
@@ -0,0 +1,14 @@
+F04BAJ Example Program Results
+
+ Solution
+ 1 2
+ 1 1.0000 3.0000
+ 2 -1.0000 2.0000
+ 3 3.0000 4.0000
+ 4 -5.0000 1.0000
+
+Estimate of condition number
+1.5e+02
+
+Esttimate of error bound for computed solutions
+1.7e-14
\ No newline at end of file
diff --git a/simple_examples/baseresults/f05aaje.r b/simple_examples/baseresults/f05aaje.r
new file mode 100644
index 0000000..74b6ae6
--- /dev/null
+++ b/simple_examples/baseresults/f05aaje.r
@@ -0,0 +1,11 @@
+F05AAJ Example Program Results
+
+N1 = 2 N2 = 4
+
+CC = 0.5822 ICOL = 4
+
+Final Vectors
+-0.6325 0.3310 -0.5404
+0.3162 -0.2483 0.2119
+-0.6325 -0.0000 0.7735
+0.3162 0.9104 0.2543
\ No newline at end of file
diff --git a/simple_examples/baseresults/f06clje.r b/simple_examples/baseresults/f06clje.r
new file mode 100644
index 0000000..d167816
--- /dev/null
+++ b/simple_examples/baseresults/f06clje.r
@@ -0,0 +1,3 @@
+ F06CLJ Example Program Results
+
+ (1.0, 1.0)/(2.0, 2.0) = (0.5, 0.0)
diff --git a/simple_examples/baseresults/f07aaje.r b/simple_examples/baseresults/f07aaje.r
new file mode 100644
index 0000000..086448e
--- /dev/null
+++ b/simple_examples/baseresults/f07aaje.r
@@ -0,0 +1,14 @@
+ F07AAJ Example Program Results
+
+ Solution
+ 1.0000 -1.0000 3.0000 -5.0000
+
+ Details of factorization
+ 1 2 3 4
+ 1 5.2500 -2.9500 -0.9500 -3.8000
+ 2 0.3429 3.8914 2.3757 0.4129
+ 3 0.3010 -0.4631 -1.5139 0.2948
+ 4 -0.2114 -0.3299 0.0047 0.1314
+
+ Pivot indices
+ 2 2 3 4
diff --git a/simple_examples/baseresults/f07abje.r b/simple_examples/baseresults/f07abje.r
new file mode 100644
index 0000000..922ca67
--- /dev/null
+++ b/simple_examples/baseresults/f07abje.r
@@ -0,0 +1,23 @@
+F07ABJ Example Program Results
+
+ Solution(s)
+ 1 2
+ 1 1.0000 3.0000
+ 2 -1.0000 2.0000
+ 3 3.0000 4.0000
+ 4 -5.0000 1.0000
+
+Backward errors (machine-dependent)
+ 7.7e-17 5.8e-17
+
+Estimated forward error bounds (machine-dependent)
+ 2.5e-14 3.4e-14
+
+A has been row scaled as diag(R)*A
+
+Reciprocal condition number estimate of scaled matrix
+ 1.8e-02
+
+Estimate of reciprocal pivot growth factor
+ 7.4e-01
+
diff --git a/simple_examples/baseresults/f07adje.r b/simple_examples/baseresults/f07adje.r
new file mode 100644
index 0000000..8aa1615
--- /dev/null
+++ b/simple_examples/baseresults/f07adje.r
@@ -0,0 +1,10 @@
+F07ADJ Example Program Results
+
+ Details of factorization
+ 1 2 3 4
+ 1 5.2500 -2.9500 -0.9500 -3.8000
+ 2 0.3429 3.8914 2.3757 0.4129
+ 3 0.3010 -0.4631 -1.5139 0.2948
+ 4 -0.2114 -0.3299 0.0047 0.1314
+IPIV
+ 2 2 3 4
diff --git a/simple_examples/baseresults/f07aqje.r b/simple_examples/baseresults/f07aqje.r
new file mode 100644
index 0000000..11cdfa0
--- /dev/null
+++ b/simple_examples/baseresults/f07aqje.r
@@ -0,0 +1,7 @@
+ F07AQJ Example Program Results
+
+ Solution
+ ( 1.0000, 1.0000) ( 2.0000,-3.0000) (-4.0000,-5.0000) ( 0.0000, 6.0000)
+
+ Pivot indices
+ 3 2 3 4
diff --git a/simple_examples/baseresults/f07faje.r b/simple_examples/baseresults/f07faje.r
new file mode 100644
index 0000000..381aa43
--- /dev/null
+++ b/simple_examples/baseresults/f07faje.r
@@ -0,0 +1,11 @@
+ F07FAJ Example Program Results
+
+ Solution
+ 1.0000 -1.0000 2.0000 -3.0000
+
+ Cholesky factor U
+ 1 2 3 4
+ 1 2.0396 -1.5297 0.2746 -0.0490
+ 2 1.6401 -0.2500 0.6737
+ 3 0.7887 0.6617
+ 4 0.5347
diff --git a/simple_examples/baseresults/f07fbje.r b/simple_examples/baseresults/f07fbje.r
new file mode 100644
index 0000000..38b2bb5
--- /dev/null
+++ b/simple_examples/baseresults/f07fbje.r
@@ -0,0 +1,19 @@
+ F07FBJ Example Program Results
+
+ Solution(s)
+ 1 2
+ 1 1.0000 4.0000
+ 2 -1.0000 3.0000
+ 3 2.0000 2.0000
+ 4 -3.0000 1.0000
+
+ Backward errors (machine-dependent)
+ 6.7e-17 8.2e-17
+
+ Estimated forward error bounds (machine-dependent)
+ 2.3e-14 2.4e-14
+
+ Estimate of reciprocal condition number
+ 1.0e-02
+
+ A has not been equilibrated
diff --git a/simple_examples/baseresults/f08btje.r b/simple_examples/baseresults/f08btje.r
new file mode 100644
index 0000000..b663c71
--- /dev/null
+++ b/simple_examples/baseresults/f08btje.r
@@ -0,0 +1,16 @@
+ F08BTJ Example Program Results
+
+ Tolerance used to estimate the rank of A
+ 1.00E-02
+ Estimated rank of A
+ 3
+ Least squares solution(s)
+
+ 1 2
+ 1 ( 0.0000, 0.0000) ( 0.0000, 0.0000)
+ 2 ( 2.7020, 8.0911) (-2.2682,-2.9884)
+ 3 ( 2.8888, 2.5012) ( 0.9779, 1.3565)
+ 4 ( 2.7100, 0.4791) (-1.3734, 0.2212)
+
+ Square root(s) of the residual sum(s) of squares
+ 2.51E-01 8.10E-02
diff --git a/simple_examples/baseresults/f08faje.r b/simple_examples/baseresults/f08faje.r
new file mode 100644
index 0000000..31df0c1
--- /dev/null
+++ b/simple_examples/baseresults/f08faje.r
@@ -0,0 +1,16 @@
+ F08FAJ Example Program Results
+
+ Eigenvalues
+ -2.0531 -0.5146 -0.2943 12.8621
+ Eigenvectors
+ 1 2 3 4
+ 1 0.7003 -0.5144 -0.2767 0.4103
+ 2 0.3592 0.4851 0.6634 0.4422
+ 3 -0.1569 0.5420 -0.6504 0.5085
+ 4 -0.5965 -0.4543 0.2457 0.6144
+
+ Error estimate for the eigenvalues
+ 1.4e-15
+
+ Error estimates for the eigenvectors
+ 9.3e-16 6.5e-15 6.5e-15 1.1e-16
diff --git a/simple_examples/baseresults/f08xpje.r b/simple_examples/baseresults/f08xpje.r
new file mode 100644
index 0000000..96e35e9
--- /dev/null
+++ b/simple_examples/baseresults/f08xpje.r
@@ -0,0 +1,8 @@
+F08XPJ Example Program Results
+
+Number of eigenvalues for which SELCTG is true = 2
+(dimension of deflating subspaces)
+
+Selected generalized eigenvalues
+ 1 (2.00, -5.00)
+ 2 (3.00, -1.00)
diff --git a/simple_examples/baseresults/g01alje.r b/simple_examples/baseresults/g01alje.r
new file mode 100644
index 0000000..3473f35
--- /dev/null
+++ b/simple_examples/baseresults/g01alje.r
@@ -0,0 +1,7 @@
+G01ALJ Example Program Results
+
+Maximum 12.0000
+Upper Hinge (75% quantile) 9.5000
+Median (50% quantile) 6.5000
+Lower Hinge (25% quantile) 2.5000
+Minimum 1.0000
diff --git a/simple_examples/baseresults/g02akje.r b/simple_examples/baseresults/g02akje.r
new file mode 100644
index 0000000..a4260ce
--- /dev/null
+++ b/simple_examples/baseresults/g02akje.r
@@ -0,0 +1,14 @@
+G02AKJ Example Program Results
+
+ NCM with rank constraint
+ 1 2 3 4
+ 1 1.0000 -0.9021 0.2448 0.1975
+ 2 -0.9021 1.0000 -0.6392 0.2448
+ 3 0.2448 -0.6392 1.0000 -0.9021
+ 4 0.1975 0.2448 -0.9021 1.0000
+
+Number of subproblems solved: 4
+
+Squared Frobenius norm of difference: 0.3082
+
+Rank error: 0.0000
diff --git a/simple_examples/baseresults/g02bjje.r b/simple_examples/baseresults/g02bjje.r
new file mode 100644
index 0000000..053b912
--- /dev/null
+++ b/simple_examples/baseresults/g02bjje.r
@@ -0,0 +1,38 @@
+ G02BJJ Example Program Results
+
+ Number of variables (columns) = 4
+ Number of cases (rows) = 5
+
+ Data matrix is:-
+ 1 2 3 4
+ 1 3.0000 3.0000 1.0000 2.0000
+ 2 6.0000 4.0000 -1.0000 4.0000
+ 3 9.0000 0.0000 5.0000 9.0000
+ 4 12.0000 2.0000 0.0000 0.0000
+ 5 -1.0000 5.0000 4.0000 12.0000
+
+ Variable Mean St.dev.
+ 4 6.7500 4.5735
+ 1 7.5000 3.8730
+ 2 3.5000 1.2910
+
+ Sums of squares and cross-products of deviations
+ 4 1 2
+ 4 62.7500 21.0000 10.0000
+ 1 21.0000 45.0000 -6.0000
+ 2 10.0000 -6.0000 5.0000
+
+ Correlation coefficients
+ 4 1 2
+ 4 1.0000 0.9707 0.9449
+ 1 0.9707 1.0000 -0.6547
+ 2 0.9449 -0.6547 1.0000
+
+ Minimum number of cases used for any pair of variables: 3
+
+ Numbers used for each pair are:
+ 4 1 2
+ 4 4.0000 3.0000 3.0000
+ 1 3.0000 4.0000 3.0000
+ 2 3.0000 3.0000 4.0000
+
diff --git a/simple_examples/baseresults/g02brje.r b/simple_examples/baseresults/g02brje.r
new file mode 100644
index 0000000..7621bb4
--- /dev/null
+++ b/simple_examples/baseresults/g02brje.r
@@ -0,0 +1,29 @@
+G02BRJ Example Program Results
+
+Number of variables (columns) = 3
+Number of case (rows) = 9
+
+Data matrix is:-
+
+
+ 1 2 3
+ 1 1.7000 1.0000 0.5000
+ 2 2.8000 4.0000 3.0000
+ 3 0.6000 6.0000 2.5000
+ 4 1.8000 9.0000 6.0000
+ 5 0.9900 4.0000 2.5000
+ 6 1.4000 2.0000 5.5000
+ 7 1.8000 9.0000 7.5000
+ 8 2.5000 7.0000 0.0000
+ 9 0.9900 5.0000 3.0000
+
+Matrix of rank correlation coefficients:
+Upper triangle -- Spearman's
+Lower triangle -- Kendall's tau
+
+ 1 2 3
+ 1 1.0000 0.2941 0.4058
+ 2 0.1429 1.0000 0.7537
+ 3 0.2760 0.5521 1.0000
+
+Number of cases actually used: 6
diff --git a/simple_examples/baseresults/g02daje.r b/simple_examples/baseresults/g02daje.r
new file mode 100644
index 0000000..9c6e2f0
--- /dev/null
+++ b/simple_examples/baseresults/g02daje.r
@@ -0,0 +1,31 @@
+G02DAJ Example Program Results
+
+Model not of full rank, rank = 4
+Residual sum of squares = 2.2227e+01
+Degrees of freedom = 8
+R-squared = 7.0042e-01
+Adjusted R-squared = 5.8808e-01
+AIC = 1.5397e+01
+
+Variable Parameter estimate Standard error
+
+ 1 3.0557e+01 3.8494e-01
+ 2 5.4467e+00 8.3896e-01
+ 3 6.7433e+00 8.3896e-01
+ 4 1.1047e+01 8.3896e-01
+ 5 7.3200e+00 8.3896e-01
+
+ Obs Residuals H
+
+ 1 -2.3733e+00 3.3333e-01
+ 2 1.7433e+00 3.3333e-01
+ 3 8.8000e-01 3.3333e-01
+ 4 -1.4333e-01 3.3333e-01
+ 5 1.4333e-01 3.3333e-01
+ 6 -1.4700e+00 3.3333e-01
+ 7 -1.8867e+00 3.3333e-01
+ 8 5.7667e-01 3.3333e-01
+ 9 1.3167e+00 3.3333e-01
+ 10 1.7967e+00 3.3333e-01
+ 11 -1.1733e+00 3.3333e-01
+ 12 5.9000e-01 3.3333e-01
diff --git a/simple_examples/baseresults/g02eeje.r b/simple_examples/baseresults/g02eeje.r
new file mode 100644
index 0000000..c66f9b6
--- /dev/null
+++ b/simple_examples/baseresults/g02eeje.r
@@ -0,0 +1,20 @@
+ G02EEJ Example Program Results
+
+ Step 1
+ Added variable is TS
+ Change in residual sum of squares = 4.7126E-01
+ F Statistic = 7.38
+
+ Variables in model: COD TS
+
+ Residual sum of squares = 1.0850E+00
+ Degrees of freedom = 17
+
+ Free variables: TKN BOD TVS
+ Change in residual sums of squares for free variables:
+ 0.1175 0.0600 0.2276
+ Step 2
+ No further variables added maximum F = 1.59
+ Free variables: TKN BOD TVS
+ Change in residual sums of squares for free variables:
+ 0.0979 0.0207 0.0217
diff --git a/simple_examples/baseresults/g02maje.r b/simple_examples/baseresults/g02maje.r
new file mode 100644
index 0000000..dd042fa
--- /dev/null
+++ b/simple_examples/baseresults/g02maje.r
@@ -0,0 +1,23 @@
+G02MAJ Example Program Results
+
+ Step Parameter Estimate
+------------------------------------------------------
+ 1 0.000 0.000 3.125 0.000 0.000 0.000
+ 2 0.000 0.000 3.792 0.000 0.000 -0.713
+ 3 -0.446 0.000 3.998 0.000 0.000 -1.151
+ 4 -0.628 -0.295 4.098 0.000 0.000 -1.466
+ 5 -1.060 -1.056 4.110 -0.864 0.000 -1.948
+ 6 -1.073 -1.132 4.118 -0.935 -0.059 -1.981
+
+alpha: -50.037
+
+ Step Sum RSS df Cp Ck Step Size
+---------------------------------------------------------
+ 1 72.446 8929.855 3 13.355 123.227 72.446
+ 2 103.385 6404.701 7 7.054 50.781 24.841
+ 3 126.243 5258.247 51 5.286 30.836 16.225
+ 4 145.277 4657.051 25 5.309 19.319 11.587
+ 5 198.223 3959.401 126 5.016 12.266 24.520
+ 6 203.529 3954.571 5258 7.000 0.910 2.198
+
+sigma^2: 304.198
diff --git a/simple_examples/baseresults/g03gaje.r b/simple_examples/baseresults/g03gaje.r
new file mode 100644
index 0000000..37ab236
--- /dev/null
+++ b/simple_examples/baseresults/g03gaje.r
@@ -0,0 +1,79 @@
+ G03GAJ Example Program Results
+
+
+ Mixing proportions
+ 1 2
+ 1 0.4798 0.5202
+
+ Group means
+ 1 2
+ 1 4.0041 3.3350
+ 2 3.9949 3.4434
+ 3 5.5894 4.9870
+ 4 5.4432 5.3602
+
+ Pooled Variance-covariance matrix
+ 1 2 3 4
+ 1 0.4539 0.2891 0.6075 0.3413
+ 2 0.2891 0.2048 0.4101 0.2490
+ 3 0.6075 0.4101 1.0648 0.6011
+ 4 0.3413 0.2490 0.6011 0.3759
+
+ Densities
+ 1 2
+ 1 2.5836E-01 1.1853E-02
+ 2 3.7065E-07 1.1241E-01
+ 3 5.3069E-03 1.8080E-06
+ 4 4.2461E-01 2.8584E-05
+ 5 5.0387E-02 1.1544E+00
+ 6 1.1260E+00 7.2224E-02
+ 7 2.0911E+00 2.1224E-02
+ 8 5.7856E-03 1.3227E+00
+ 9 1.1609E+00 2.9411E-02
+ 10 8.9826E-02 2.4260E-05
+ 11 3.0170E-01 1.0106E+00
+ 12 1.2930E+00 3.5422E-01
+ 13 2.8644E-02 6.7851E-07
+ 14 2.0759E-02 3.1690E+00
+ 15 7.6461E-02 1.5231E+00
+ 16 3.0279E-04 8.4017E-01
+ 17 5.6101E-01 4.6699E-05
+ 18 2.6573E-05 6.4442E-01
+ 19 2.1250E+00 5.1006E-02
+ 20 8.6822E-04 2.7626E+00
+ 21 1.9223E-01 2.3971E+00
+ 22 1.2469E-02 2.8179E+00
+ 23 1.8389E-02 5.3572E-01
+ 24 1.2409E+00 9.6489E-03
+ 25 2.1037E-05 4.8674E-02
+
+ Membership probabilities
+ 1 2
+ 1 9.5018E-01 4.9823E-02
+ 2 3.3259E-06 1.0000E+00
+ 3 9.9961E-01 3.8664E-04
+ 4 9.9992E-01 7.9913E-05
+ 5 3.8999E-02 9.6100E-01
+ 6 9.3270E-01 6.7295E-02
+ 7 9.8881E-01 1.1190E-02
+ 8 4.1252E-03 9.9587E-01
+ 9 9.7252E-01 2.7479E-02
+ 10 9.9969E-01 3.0805E-04
+ 11 2.1722E-01 7.8278E-01
+ 12 7.6938E-01 2.3062E-01
+ 13 9.9997E-01 2.6937E-05
+ 14 6.1133E-03 9.9389E-01
+ 15 4.4189E-02 9.5581E-01
+ 16 3.5006E-04 9.9965E-01
+ 17 9.9990E-01 9.7029E-05
+ 18 4.0270E-05 9.9996E-01
+ 19 9.7380E-01 2.6202E-02
+ 20 3.0204E-04 9.9970E-01
+ 21 6.9471E-02 9.3053E-01
+ 22 4.1603E-03 9.9584E-01
+ 23 3.0839E-02 9.6916E-01
+ 24 9.9116E-01 8.8421E-03
+ 25 4.1534E-04 9.9958E-01
+
+No. iterations: 14
+Log-likelihood: -29.6831
diff --git a/simple_examples/baseresults/g05kfje.r b/simple_examples/baseresults/g05kfje.r
new file mode 100644
index 0000000..830c10a
--- /dev/null
+++ b/simple_examples/baseresults/g05kfje.r
@@ -0,0 +1,7 @@
+G05KFJ Example Program Results
+
+0.6364
+0.1065
+0.7460
+0.7983
+0.1046
\ No newline at end of file
diff --git a/simple_examples/baseresults/g13awje.r b/simple_examples/baseresults/g13awje.r
new file mode 100644
index 0000000..25be8b6
--- /dev/null
+++ b/simple_examples/baseresults/g13awje.r
@@ -0,0 +1,4 @@
+ G13AWJ Example Program Results
+
+Dickey-Fuller test statistic = -2.540
+associated p-value = 0.013
diff --git a/simple_examples/baseresults/g13meje.r b/simple_examples/baseresults/g13meje.r
new file mode 100644
index 0000000..07a391e
--- /dev/null
+++ b/simple_examples/baseresults/g13meje.r
@@ -0,0 +1,39 @@
+G13MEJ Example Program Results
+
+ Iterated
+ Time EMA
+
+--------------------------------
+ 1 7.5 0.531
+ 2 8.2 0.544
+ 3 18.1 0.754
+ 4 22.8 0.406
+ 5 25.8 0.232
+
+ 6 26.8 0.217
+ 7 31.1 0.357
+ 8 38.4 0.630
+ 9 45.9 0.263
+ 10 48.2 0.241
+ 11 48.9 0.279
+ 12 57.9 0.713
+ 13 58.5 0.717
+ 14 63.9 0.385
+ 15 65.2 0.346
+
+ 16 66.6 0.330
+ 17 67.4 0.315
+ 18 69.3 0.409
+ 19 69.9 0.459
+ 20 73.0 0.377
+ 21 75.6 0.411
+ 22 77.0 0.536
+ 23 84.7 0.632
+ 24 86.8 0.538
+ 25 88.0 0.444
+ 26 88.5 0.401
+ 27 91.0 0.331
+ 28 93.0 0.495
+ 29 93.7 0.585
+ 30 94.0 0.612
+
diff --git a/simple_examples/baseresults/g13naje.r b/simple_examples/baseresults/g13naje.r
new file mode 100644
index 0000000..b87dda8
--- /dev/null
+++ b/simple_examples/baseresults/g13naje.r
@@ -0,0 +1,11 @@
+G13NAJ Example Program Results
+
+ -- Charge Points -- --- Distribution ---
+ Number Position Parameters
+=================================================
+ 1 12 0.34 1.00
+ 2 32 2.57 1.00
+ 3 49 1.45 1.00
+ 4 52 -0.48 1.00
+ 5 70 1.20 1.00
+ 6 100 -0.23 1.00
diff --git a/simple_examples/baseresults/h02bbje.r b/simple_examples/baseresults/h02bbje.r
new file mode 100644
index 0000000..64136ef
--- /dev/null
+++ b/simple_examples/baseresults/h02bbje.r
@@ -0,0 +1,79 @@
+H02BBJ Example Program Results
+
+
+ *** IP solver
+
+ Parameters
+ ----------
+
+ Linear constraints...... 3 First integer solution.. OFF
+ Variables............... 2 Max depth of the tree... 4
+
+ Feasibility tolerance... 1.05E-08 Print level............. 10
+ Infinite bound size..... 1.00E+20 EPS (machine precision). 1.11E-16
+
+ Integer feasibility tol. 1.00E-05 Iteration limit......... 50
+ Max number of nodes..... NONE
+
+ ** Workspace provided with MAXDPT = 4: LRWORK = 84 LIWORK = 137
+ ** Workspace required with MAXDPT = 4: LRWORK = 84 LIWORK = 137
+
+
+ *** Optimum LP solution *** -17.50000
+
+
+ Varbl State Value Lower Bound Upper Bound Lagr Mult Residual
+
+ V 1 FR 3.92857 0.00000 None 0.000 3.929
+ V 2 FR 1.42857 0.00000 None 0.000 1.429
+
+
+ L Con State Value Lower Bound Upper Bound Lagr Mult Residual
+
+ L 1 UL 15.0000 None 15.0000 -1.000 0.000
+ L 2 UL 5.00000 None 5.00000 -0.5000 -8.8818E-16
+ L 3 FR 14.6429 5.00000 None 0.000 9.643
+
+
+ *** Start of tree search ***
+
+
+ Node Parent Obj Varbl Value Lower Upper Value Depth
+ No Node Value Chosen Before Bound Bound After
+ 2 1 No Feas Soln 1 3.93 4.00 None 4.00 1
+ 3 1 -16.2 1 3.93 0.00 3.00 3.00 1
+ 4 3 -15.5 2 1.80 2.00 None 2.00 2
+ 5 3 -13.0 2 1.80 0.00 1.00 1.00 2
+ *** Integer solution ***
+
+
+ Node Parent Obj Varbl Value Lower Upper Value Depth
+ No Node Value Chosen Before Bound Bound After
+ 6 4 No Feas Soln 1 2.50 3.00 3.00 3.00 3
+ 7 4 -14.8 1 2.50 0.00 2.00 2.00 3
+ 8 7 -12.0 CO 2 2.20 3.00 None 3.00 4
+ 9 7 -14.0 2 2.20 2.00 2.00 2.00 4
+ *** Integer solution ***
+
+ *** End of tree search ***
+
+
+ Total of 9 nodes investigated.
+
+ Exit IP solver - Optimum IP solution found.
+
+ Final IP objective value = -14.00000
+
+
+
+ Varbl State Value Lower Bound Upper Bound Lagr Mult Residual
+
+ V 1 UL 2.00000 0.00000 2.00000 -3.000 0.000
+ V 2 EQ 2.00000 2.00000 2.00000 -4.000 0.000
+
+
+ L Con State Value Lower Bound Upper Bound Lagr Mult Residual
+
+ L 1 FR 14.0000 None 15.0000 0.000 1.000
+ L 2 FR 0.00000 None 5.00000 0.000 5.000
+ L 3 FR 10.0000 5.00000 None 0.000 5.000
diff --git a/simple_examples/baseresults/h02daje.r b/simple_examples/baseresults/h02daje.r
new file mode 100644
index 0000000..125c5bf
--- /dev/null
+++ b/simple_examples/baseresults/h02daje.r
@@ -0,0 +1,14 @@
+H02DAJ Example Program Results
+
+ Final Esimate:
+ 1
+ 1 0.3750
+ 2 0.0000
+ 3 0.5250
+ 4 0.1000
+ 5 1.0000
+ 6 0.0000
+ 7 1.0000
+ 8 1.0000
+Requested accuracy of QP subproblems 1.0000e-10
+Optimised value: 2.925
diff --git a/simple_examples/baseresults/m01ccje.r b/simple_examples/baseresults/m01ccje.r
new file mode 100644
index 0000000..33e1712
--- /dev/null
+++ b/simple_examples/baseresults/m01ccje.r
@@ -0,0 +1,15 @@
+ M01CCJ Example Program Results
+
+ Records sorted on columns 7 to 12
+
+ C05AZF 2181
+ C05AUF 1351
+ C02AEF 599
+ A02ACF 531
+ A02ABF 523
+ A02AAF 289
+ C05AVF 240
+ C05AXF 211
+ C05AYF 183
+ C02ADF 169
+ C05AWF 136
diff --git a/simple_examples/baseresults/nagcomplexexample.r b/simple_examples/baseresults/nagcomplexexample.r
new file mode 100644
index 0000000..2040ba1
--- /dev/null
+++ b/simple_examples/baseresults/nagcomplexexample.r
@@ -0,0 +1,60 @@
+Please read the source of NAGComplexExample.java for a better understanding of how to use NAGComplex
+
+*****BASICS*****
+
+Constructing z1 and z2;
+z1 = (0.0, 0.0)
+z2 = (2.0, 3.0)
+
+Changing z1 values using NAGComplex.setRe() and NAGComplex.setIm();
+z1 = (3.0, 4.0)
+
+Copying z2 to z3 using NAGComplex.clone();
+z3 = (2.0, 3.0)
+Copying z1 to z4 using static method NAGComplex.clone(NAGComplex z)
+z4 = (3.0, 4.0)
+
+Array created using NAGComplex.createArray(5);
+(0.0, 0.0) (0.0, 0.0) (0.0, 0.0) (0.0, 0.0) (0.0, 0.0)
+
+The same array updated using NAGComplex[i].setRe() and NAGComplex[i].setIm();
+(1.0, 9.0) (2.0, 8.0) (3.0, 7.0) (4.0, 6.0) (5.0, 5.0)
+
+*****ARITHMETIC*****
+
+z1 = (3.0, 4.0)
+z2 = (2.0, 3.0)
+z3 = (6.0, -2.0)
+z4 = (4.0, -5.0)
+
+z1 + z2 = (5.0, 7.0)
+z3 + z4 = (10.0, -7.0)
+
+z1 - z2 = (1.0, 1.0)
+z3 - z4 = (2.0, 3.0)
+
+z1 * z2 = (-6.0, 17.0)
+z3 * z4 = (14.0, -38.0)
+
+z1 / z2 = (1.3846153846153846, -0.07692307692307696)
+z3 / z4 = (0.829268292682927, 0.5365853658536587)
+
+-(z1) = (-3.0, -4.0)
+-(z2) = (-2.0, -3.0)
+
+conjugate(z1) = (3.0, -4.0)
+conjugate(z2) = (2.0, -3.0)
+
+z3 == z4? - false
+z4 = (6.0, -2.0)
+z3 == z4? - true
+|z1| = 5.0
+|z2| = 3.6055512754639896
+
+arg(z1) = 0.9272952180016122
+arg(z2) = 0.982793723247329
+
+z5 = (-5.0, 12.0)
+z6 = (-9.0, 40.0)
+Sqrt(z5) = (2.0, 3.0)
+Sqrt(z6) = (4.0, 5.0)
\ No newline at end of file
diff --git a/simple_examples/baseresults/outputexample.r b/simple_examples/baseresults/outputexample.r
new file mode 100644
index 0000000..fd4bc95
--- /dev/null
+++ b/simple_examples/baseresults/outputexample.r
@@ -0,0 +1,10 @@
+ *** Start of NAG Library implementation details ***
+
+ Implementation title: Linux, 64-bit, Intel C/C++ or Intel Fortran
+ Precision: double precision
+ Product Code: NLL6I27DBL
+ Mark: 27.2.1 (self-contained)
+
+ This is a 64-bit library using 32-bit integers.
+
+ *** End of NAG Library implementation details ***
diff --git a/simple_examples/baseresults/s01baje.r b/simple_examples/baseresults/s01baje.r
new file mode 100644
index 0000000..b3b20dd
--- /dev/null
+++ b/simple_examples/baseresults/s01baje.r
@@ -0,0 +1,9 @@
+S01BAJ Example Program Results
+
+ X Y
+ 2.5000e+00 1.2528e+00
+ 1.2500e-01 1.1778e-01
+ -9.0600e-01 -2.3645e+00
+ 1.2900e-03 1.2892e-03
+ -7.8300e-06 -7.8300e-06
+ 1.0000e-09 1.0000e-09
diff --git a/simple_examples/baseresults/s10aaje.r b/simple_examples/baseresults/s10aaje.r
new file mode 100644
index 0000000..eac481e
--- /dev/null
+++ b/simple_examples/baseresults/s10aaje.r
@@ -0,0 +1,7 @@
+S10AAJ Example Program Results
+
+ X Y
+ -2.000e+01 -1.000e+00
+ -5.000e+00 -9.999e-01
+ 5.000e-01 4.621e-01
+ 5.000e+00 9.999e-01
diff --git a/simple_examples/baseresults/s10abje.r b/simple_examples/baseresults/s10abje.r
new file mode 100644
index 0000000..54e3b1c
--- /dev/null
+++ b/simple_examples/baseresults/s10abje.r
@@ -0,0 +1,8 @@
+S10ABJ Example Program Results
+
+ X Y
+ -1.000e+01 -1.101e+04
+ -5.000e-01 -5.211e-01
+ 0.000e+00 0.000e+00
+ 5.000e-01 5.211e-01
+ 2.500e+01 3.600e+10
diff --git a/simple_examples/baseresults/s10acje.r b/simple_examples/baseresults/s10acje.r
new file mode 100644
index 0000000..e71c76b
--- /dev/null
+++ b/simple_examples/baseresults/s10acje.r
@@ -0,0 +1,8 @@
+S10ACJ Example Program Results
+
+ X Y
+ -1.000e+01 1.101e+04
+ -5.000e-01 1.128e+00
+ 0.000e+00 1.000e+00
+ 5.000e-01 1.128e+00
+ 2.500e+01 3.600e+10
diff --git a/simple_examples/baseresults/s14abje.r b/simple_examples/baseresults/s14abje.r
new file mode 100644
index 0000000..86c60ea
--- /dev/null
+++ b/simple_examples/baseresults/s14abje.r
@@ -0,0 +1,12 @@
+S14ABJ Example Program Results
+
+ X Y
+ 1.000e+00 0.000e+00
+ 1.250e+00 -9.827e-02
+ 1.500e+00 -1.208e-01
+ 1.750e+00 -8.440e-02
+ 2.000e+00 0.000e+00
+ 5.000e+00 3.178e+00
+ 1.000e+01 1.280e+01
+ 2.000e+01 3.934e+01
+ 1.000e+03 5.905e+03
diff --git a/simple_examples/baseresults/s14acje.r b/simple_examples/baseresults/s14acje.r
new file mode 100644
index 0000000..cda0185
--- /dev/null
+++ b/simple_examples/baseresults/s14acje.r
@@ -0,0 +1,8 @@
+S14ACJ Example Program Results
+
+ X psi(X)-log(X)
+
+ 0.1000 -8.1212
+ 0.5000 -1.2704
+ 3.6000 -0.1453
+ 8.0000 -0.0638
diff --git a/simple_examples/baseresults/s14afje.r b/simple_examples/baseresults/s14afje.r
new file mode 100644
index 0000000..68a5fd5
--- /dev/null
+++ b/simple_examples/baseresults/s14afje.r
@@ -0,0 +1,5 @@
+S14AFJ Example Program Results
+
+ Z K (d^K/dz^K)psi(Z)
+
+ (-1.5, 2.5) 1 (-1.9737e-01, -2.4271e-01)
diff --git a/simple_examples/baseresults/s17dcje.r b/simple_examples/baseresults/s17dcje.r
new file mode 100644
index 0000000..845aae3
--- /dev/null
+++ b/simple_examples/baseresults/s17dcje.r
@@ -0,0 +1,10 @@
+S17DCF Example Program Results
+
+Calling with N = 2
+
+FNU Z SCAL CY[0] CY[1] NZ
+0.0000 (0.3000, 0.4000) U (-0.4983, 0.6700) (-1.0149, 0.9485) 0
+2.3000 (2.0000, 0.0000) U (-0.7398, 0.0000) (-1.4120, 0.0000) 0
+2.1200 (-1.0000, 0.0000) U (-1.7279, 0.8602) (6.5331, -2.6154) 0
+1.5800 (-2.3000, 5.6000) U (36.4755, -1.5521) (-2.6788, 25.9112) 0
+1.5800 (-2.3000, 5.6000) S (0.1349, -0.0057) (-0.0099, 0.0958) 0
diff --git a/simple_examples/baseresults/s17dgje.r b/simple_examples/baseresults/s17dgje.r
new file mode 100644
index 0000000..c26ff48
--- /dev/null
+++ b/simple_examples/baseresults/s17dgje.r
@@ -0,0 +1,9 @@
+ S17DGJ Example Program Results
+
+ DERIV Z SCAL AI NZ
+
+ F ( 0.3000, 0.4000) U ( 0.2716, -0.1002) 0
+ F ( 0.2000, 0.0000) U ( 0.3037, 0.0000) 0
+ F ( 1.1000, -6.6000) U (-43.6632,-47.9030) 0
+ F ( 1.1000, -6.6000) S ( 0.1655, 0.0597) 0
+ D ( -1.0000, 0.0000) U ( -0.0102, 0.0000) 0
diff --git a/simple_examples/baseresults/s30aaje.r b/simple_examples/baseresults/s30aaje.r
new file mode 100644
index 0000000..32fc477
--- /dev/null
+++ b/simple_examples/baseresults/s30aaje.r
@@ -0,0 +1,16 @@
+S30AAJ Example Program Results
+
+Black-Scholes-Merton formula
+European Call :
+ Spot = 55.0000
+ Volatility = 0.3000
+ Rate = 0.1000
+ Dividend = 0.0000
+
+ Strike Expiry Option Price
+ 58.0000 0.7000 5.9198
+ 58.0000 0.8000 6.5506
+ 60.0000 0.7000 5.0809
+ 60.0000 0.8000 5.6992
+ 62.0000 0.7000 4.3389
+ 62.0000 0.8000 4.9379
diff --git a/simple_examples/baseresults/s30acje.r b/simple_examples/baseresults/s30acje.r
new file mode 100644
index 0000000..134730e
--- /dev/null
+++ b/simple_examples/baseresults/s30acje.r
@@ -0,0 +1,9 @@
+ S30ACJ Example Program Results
+
+ SIGMA IVALID
+
+ 7.834E-01 0
+ 7.386E-01 0
+ 4.096E-01 0
+ 4.085E-01 0
+ 4.179E-01 0
diff --git a/simple_examples/baseresults/simpleroutineexample.r b/simple_examples/baseresults/simpleroutineexample.r
new file mode 100644
index 0000000..e1f6a4e
--- /dev/null
+++ b/simple_examples/baseresults/simpleroutineexample.r
@@ -0,0 +1,15 @@
+ C05AZ Example Program results:
+
+ Iterations
+
+ X = 0.00000 FX= 1.0000e+00 IND = 2
+ X = 1.00000 FX= -6.3212e-01 IND = 3
+ X = 0.61270 FX= -7.0814e-02 IND = 4
+ X = 0.56707 FX= 1.1542e-04 IND = 4
+ X = 0.56714 FX= -9.4481e-07 IND = 4
+ X = 0.56713 FX= 1.4727e-05 IND = 4
+ X = 0.56714 FX= -9.4481e-07 IND = 4
+
+ Solution
+
+ X = 0.56714 Y = 0.56713
diff --git a/simple_examples/baseresults/userdefinedfunctionexample1.r b/simple_examples/baseresults/userdefinedfunctionexample1.r
new file mode 100644
index 0000000..c2fd510
--- /dev/null
+++ b/simple_examples/baseresults/userdefinedfunctionexample1.r
@@ -0,0 +1 @@
+The result is -0.03183098861837909
diff --git a/simple_examples/baseresults/userdefinedfunctionexample2.r b/simple_examples/baseresults/userdefinedfunctionexample2.r
new file mode 100644
index 0000000..c2fd510
--- /dev/null
+++ b/simple_examples/baseresults/userdefinedfunctionexample2.r
@@ -0,0 +1 @@
+The result is -0.03183098861837909
diff --git a/simple_examples/baseresults/x03aaje.r b/simple_examples/baseresults/x03aaje.r
new file mode 100644
index 0000000..d2b7138
--- /dev/null
+++ b/simple_examples/baseresults/x03aaje.r
@@ -0,0 +1,3 @@
+X03AAF Example Program Results
+
+D1 = -5.0 D2 = 0.0
\ No newline at end of file
diff --git a/simple_examples/baseresults/x04cbje.r b/simple_examples/baseresults/x04cbje.r
new file mode 100644
index 0000000..6b842ef
--- /dev/null
+++ b/simple_examples/baseresults/x04cbje.r
@@ -0,0 +1,21 @@
+X04CBJ Example Program Results
+
+ Example 1
+ 1 2 3 4 5
+ 1 11.0000 12.0000 13.0000 14.0000 15.0000
+ 2 21.0000 22.0000 23.0000 24.0000 25.0000
+ 3 31.0000 32.0000 33.0000 34.0000 35.0000
+
+ Example 2:
+ Un Deux Trois Quatre Cinq
+ Uno 11.00 12.00 13.00 14.00 15.00
+ Due 22.00 23.00 24.00 25.00
+ Tre 33.00 34.00 35.00
+ Quattro 44.00 45.00
+ Cinque 55.00
+
+ A = [
+ 11.00 0.00 0.00 0.00 0.00;
+ 21.00 22.00 0.00 0.00 0.00;
+ 31.00 32.00 33.00 0.00 0.00;
+ ];
diff --git a/simple_examples/baseresults/x05abje.r b/simple_examples/baseresults/x05abje.r
new file mode 100644
index 0000000..f94235c
--- /dev/null
+++ b/simple_examples/baseresults/x05abje.r
@@ -0,0 +1,2 @@
+ X05ABJ Example Program Results
+Tue 14th Jul 1789 13:11:48.320
diff --git a/simple_examples/data/c02abje.d b/simple_examples/data/c02abje.d
new file mode 100644
index 0000000..3f2dfd1
--- /dev/null
+++ b/simple_examples/data/c02abje.d
@@ -0,0 +1,14 @@
+C02ABJ Example Program Data
+
+Example 1: Basic Problem
+ 6 : Degree, n
+ 3.5 : Coefficients, a
+ 1.0
+ -7.0
+ 12.5
+ 2.5
+ -17.0
+ 32.5
+
+Example 2: Polishing Processes
+ 10 : Degree, n
diff --git a/simple_examples/data/c02afje.d b/simple_examples/data/c02afje.d
new file mode 100644
index 0000000..0e31bab
--- /dev/null
+++ b/simple_examples/data/c02afje.d
@@ -0,0 +1,19 @@
+C02AFJ Example Program Data
+
+Example 1
+ 5
+ 5.0 6.0
+ 30.0 20.0
+ -0.2 -6.0
+ 50.0 100000.0
+ -2.0 40.0
+ 10.0 1.0
+
+Example 2
+ 5
+ 5.0 6.0
+ 30.0 20.0
+ -0.2 -6.0
+ 50.0 100000.0
+ -2.0 40.0
+ 10.0 1.0
diff --git a/simple_examples/data/c02agje.d b/simple_examples/data/c02agje.d
new file mode 100644
index 0000000..ada6a96
--- /dev/null
+++ b/simple_examples/data/c02agje.d
@@ -0,0 +1,9 @@
+C02AGJ Example Program Data
+
+Example 1
+ 5
+ 1.0 2.0 3.0 4.0 5.0 6.0
+
+Example 2
+ 5
+ 1.0 2.0 3.0 4.0 5.0 6.0
diff --git a/simple_examples/data/c02ahje.d b/simple_examples/data/c02ahje.d
new file mode 100644
index 0000000..0e1a9ea
--- /dev/null
+++ b/simple_examples/data/c02ahje.d
@@ -0,0 +1,2 @@
+C02AHJ Example Program Data
+ 1.0 0.0 -3.0 1.0 8.0 1.0 :AR AI BR BI CR CI
diff --git a/simple_examples/data/c02ajje.d b/simple_examples/data/c02ajje.d
new file mode 100644
index 0000000..c24b295
--- /dev/null
+++ b/simple_examples/data/c02ajje.d
@@ -0,0 +1,2 @@
+C02AJJ Example Program Data
+ 1.0 3.0 -10.0 :A B C
diff --git a/simple_examples/data/c02akje.d b/simple_examples/data/c02akje.d
new file mode 100644
index 0000000..0b71c64
--- /dev/null
+++ b/simple_examples/data/c02akje.d
@@ -0,0 +1,2 @@
+C02AKJ Example Program Data
+ 1.0 3.0 9.0 -13.0 : Values of U, R, S and T
diff --git a/simple_examples/data/c02alje.d b/simple_examples/data/c02alje.d
new file mode 100644
index 0000000..a519a24
--- /dev/null
+++ b/simple_examples/data/c02alje.d
@@ -0,0 +1,2 @@
+C02ALJ Example Program Data
+ 1.0 2.0 6.0 -8.0 -40.0 : Values of E, A, B, C and D
diff --git a/simple_examples/data/c02amje.d b/simple_examples/data/c02amje.d
new file mode 100644
index 0000000..9bff4dc
--- /dev/null
+++ b/simple_examples/data/c02amje.d
@@ -0,0 +1,5 @@
+C02AMJ Example Program Data
+ ( 1.0, 0.0)
+ ( -2.0, 3.0)
+ ( 5.0, 14.0)
+ (-40.0, -5.0) : Values of U, R, S and T
diff --git a/simple_examples/data/c02anje.d b/simple_examples/data/c02anje.d
new file mode 100644
index 0000000..c331b10
--- /dev/null
+++ b/simple_examples/data/c02anje.d
@@ -0,0 +1,6 @@
+C02ANJ Example Program Data
+ ( 1.0, 0.0)
+ ( 0.0, 0.0)
+ ( 0.0, 16.0)
+ ( -8.0, 8.0)
+ (-65.0, 0.0) : Values of E, A, B, C and D
diff --git a/simple_examples/data/c05bbje.d b/simple_examples/data/c05bbje.d
new file mode 100644
index 0000000..6c78ea9
--- /dev/null
+++ b/simple_examples/data/c05bbje.d
@@ -0,0 +1,7 @@
+C05BBJ Example Program Data
+0 : BRANCH
+false : OFFSET
+0.5 -1.0
+1.0 2.3
+4.5 -0.1
+6.0 6.0 : Z
diff --git a/simple_examples/data/c06fkje.d b/simple_examples/data/c06fkje.d
new file mode 100644
index 0000000..e042218
--- /dev/null
+++ b/simple_examples/data/c06fkje.d
@@ -0,0 +1,11 @@
+C06FKJ Example Program Data
+9 : n
+1.00 0.50
+1.00 0.50
+1.00 0.50
+1.00 0.50
+1.00 0.00
+0.00 0.00
+0.00 0.00
+0.00 0.00
+0.00 0.00 : xa, ya
diff --git a/simple_examples/data/c09aaje.d b/simple_examples/data/c09aaje.d
new file mode 100644
index 0000000..8313509
--- /dev/null
+++ b/simple_examples/data/c09aaje.d
@@ -0,0 +1,11 @@
+C09AAF Example Program Data
+ 8 : n
+ Haar Zero : wavnam, mode
+ 2.0
+ 5.0
+ 8.0
+ 9.0
+ 7.0
+ 4.0
+-1.0
+ 1.0 : x(1:n)
diff --git a/simple_examples/data/d03pcje.d b/simple_examples/data/d03pcje.d
new file mode 100644
index 0000000..9e78e1f
--- /dev/null
+++ b/simple_examples/data/d03pcje.d
@@ -0,0 +1,6 @@
+D03PCJ Example Program Data
+6 20 1 : intpts, npts, itype
+0.0 0.4 0.6 0.8 0.9 1.0 : xout(1:intpts)
+1.0E-3 1.0 : acc, alpha
+1 0 : m, itrace
+0.0 0.1E-4 : ts, tout
diff --git a/simple_examples/data/e02alje.d b/simple_examples/data/e02alje.d
new file mode 100644
index 0000000..b1c9d44
--- /dev/null
+++ b/simple_examples/data/e02alje.d
@@ -0,0 +1,23 @@
+E02ALJ Example Program Data
+ 21 5 11 : N, M, NEVAL
+ 0.00 1.0000000000
+ 0.05 1.0512710964
+ 0.10 1.1051709181
+ 0.15 1.1618342427
+ 0.20 1.2214027582
+ 0.25 1.2840254167
+ 0.30 1.3498588076
+ 0.35 1.4190675486
+ 0.40 1.4918246976
+ 0.45 1.5683121855
+ 0.50 1.6487212707
+ 0.55 1.7332530179
+ 0.60 1.8221188004
+ 0.65 1.9155408290
+ 0.70 2.0137527075
+ 0.75 2.1170000166
+ 0.80 2.2255409285
+ 0.85 2.3396468519
+ 0.90 2.4596031112
+ 0.95 2.5857096593
+ 1.00 2.7182818285 : X, Y
diff --git a/simple_examples/data/e04fcje.d b/simple_examples/data/e04fcje.d
new file mode 100644
index 0000000..963a616
--- /dev/null
+++ b/simple_examples/data/e04fcje.d
@@ -0,0 +1,16 @@
+E04FCF Example Program Data
+ 0.14 1.0 15.0 1.0
+ 0.18 2.0 14.0 2.0
+ 0.22 3.0 13.0 3.0
+ 0.25 4.0 12.0 4.0
+ 0.29 5.0 11.0 5.0
+ 0.32 6.0 10.0 6.0
+ 0.35 7.0 9.0 7.0
+ 0.39 8.0 8.0 8.0
+ 0.37 9.0 7.0 7.0
+ 0.58 10.0 6.0 6.0
+ 0.73 11.0 5.0 5.0
+ 0.96 12.0 4.0 4.0
+ 1.34 13.0 3.0 3.0
+ 2.10 14.0 2.0 2.0
+ 4.39 15.0 1.0 1.0
diff --git a/simple_examples/data/e04mxje.d b/simple_examples/data/e04mxje.d
new file mode 100644
index 0000000..7d45bf8
--- /dev/null
+++ b/simple_examples/data/e04mxje.d
@@ -0,0 +1,64 @@
+NAME E04MX.EX
+ROWS
+ L ..ROW1..
+ L ..ROW2..
+ L ..ROW3..
+ N ..COST..
+COLUMNS
+ ...X1... ..ROW1.. 1.0 ..ROW2.. 1.0
+ ...X1... ..ROW3.. 1.0 ..COST.. -4.0
+ ...X2... ..ROW1.. 1.0 ..ROW2.. 2.0
+ ...X2... ..ROW3.. -1.0 ..COST.. -1.0
+ ...X3... ..ROW1.. 1.0 ..ROW2.. 3.0
+ ...X3... ..ROW3.. 1.0 ..COST.. -1.0
+ ...X4... ..ROW1.. 1.0 ..ROW2.. 4.0
+ ...X4... ..ROW3.. -1.0 ..COST.. -1.0
+ ...X5... ..ROW1.. 1.0 ..ROW2.. -2.0
+ ...X5... ..ROW3.. 1.0 ..COST.. -1.0
+ ...X6... ..ROW1.. 1.0 ..ROW2.. 1.0
+ ...X6... ..ROW3.. 1.0 ..COST.. -1.0
+ ...X7... ..ROW1.. 1.0 ..ROW2.. 1.0
+ ...X7... ..ROW3.. 1.0 ..COST.. -1.0
+ ...X8... ..ROW1.. 1.0 ..ROW2.. 1.0
+ ...X8... ..ROW3.. 1.0 ..COST.. -0.1
+ ...X9... ..ROW1.. 4.0 ..ROW2.. 1.0
+ ...X9... ..ROW3.. 1.0 ..COST.. -0.3
+RHS
+ RHS1 ..ROW1.. 1.5
+ RHS1 ..ROW2.. 1.5
+ RHS1 ..ROW3.. 4.0
+ RHS1 ..COST.. 1000.0
+RANGES
+ RANGE1 ..ROW1.. 3.5
+ RANGE1 ..ROW2.. 3.5
+ RANGE1 ..ROW3.. 6.0
+BOUNDS
+ LO BOUND ...X1... -2.0
+ LO BOUND ...X2... -2.0
+ LO BOUND ...X3... -2.0
+ LO BOUND ...X4... -2.0
+ LO BOUND ...X5... -2.0
+ LO BOUND ...X6... -2.0
+ LO BOUND ...X7... -2.0
+ LO BOUND ...X8... -2.0
+ LO BOUND ...X9... -2.0
+ UP BOUND ...X1... 2.0
+ UP BOUND ...X2... 2.0
+ UP BOUND ...X3... 2.0
+ UP BOUND ...X4... 2.0
+ UP BOUND ...X5... 2.0
+ UP BOUND ...X6... 2.0
+ UP BOUND ...X7... 2.0
+ UP BOUND ...X8... 2.0
+ UP BOUND ...X9... 2.0
+QUADOBJ
+ ...X1... ...X1... 2.00000000E0 ...X2... 1.00000000E0
+ ...X1... ...X3... 1.00000000E0 ...X4... 1.00000000E0
+ ...X1... ...X5... 1.00000000E0
+ ...X2... ...X2... 2.00000000E0 ...X3... 1.00000000E0
+ ...X2... ...X4... 1.00000000E0 ...X5... 1.00000000E0
+ ...X3... ...X3... 2.00000000E0 ...X4... 1.00000000E0
+ ...X3... ...X5... 1.00000000E0
+ ...X4... ...X4... 2.00000000E0 ...X5... 1.00000000E0
+ ...X5... ...X5... 2.00000000E0
+ENDATA
diff --git a/simple_examples/data/e04ncje.d b/simple_examples/data/e04ncje.d
new file mode 100644
index 0000000..bdf378b
--- /dev/null
+++ b/simple_examples/data/e04ncje.d
@@ -0,0 +1,21 @@
+E04NCA Example Program Data
+ 10 9 3 :Values of M, N and NCLIN
+ 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
+ 1.0 2.0 1.0 1.0 1.0 1.0 2.0 0.0 0.0
+ 1.0 1.0 3.0 1.0 1.0 1.0 -1.0 -1.0 -3.0
+ 1.0 1.0 1.0 4.0 1.0 1.0 1.0 1.0 1.0
+ 1.0 1.0 1.0 3.0 1.0 1.0 1.0 1.0 1.0
+ 1.0 1.0 2.0 1.0 1.0 0.0 0.0 0.0 -1.0
+ 1.0 1.0 1.0 1.0 0.0 1.0 1.0 1.0 1.0
+ 1.0 1.0 1.0 0.0 1.0 1.0 1.0 1.0 1.0
+ 1.0 1.0 0.0 1.0 1.0 1.0 2.0 2.0 3.0
+ 1.0 0.0 1.0 1.0 1.0 1.0 0.0 2.0 2.0 :End of matrix A
+ 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 :End of B
+ 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 4.0
+ 1.0 2.0 3.0 4.0 -2.0 1.0 1.0 1.0 1.0
+ 1.0 -1.0 1.0 -1.0 1.0 1.0 1.0 1.0 1.0 :End of matrix C
+ 0.0 0.0 -1.0E+25 0.0 0.0 0.0 0.0 0.0 0.0
+ 2.0 -1.0E+25 1.0 :End of BL
+ 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0
+ 1.0E+25 2.0 4.0 :End of BU
+ 1.0 0.5 0.3333 0.25 0.2 0.1667 0.1428 0.125 0.1111 :End of X
diff --git a/simple_examples/data/e04nfje.d b/simple_examples/data/e04nfje.d
new file mode 100644
index 0000000..f2c6165
--- /dev/null
+++ b/simple_examples/data/e04nfje.d
@@ -0,0 +1,22 @@
+E04NFA Example Program Data
+ 7 7 :Values of N and NCLIN
+ -0.02 -0.20 -0.20 -0.20 -0.20 0.04 0.04 :End of CVEC
+ 1.00 1.00 1.00 1.00 1.00 1.00 1.00
+ 0.15 0.04 0.02 0.04 0.02 0.01 0.03
+ 0.03 0.05 0.08 0.02 0.06 0.01 0.00
+ 0.02 0.04 0.01 0.02 0.02 0.00 0.00
+ 0.02 0.03 0.00 0.00 0.01 0.00 0.00
+ 0.70 0.75 0.80 0.75 0.80 0.97 0.00
+ 0.02 0.06 0.08 0.12 0.02 0.01 0.97 :End of matrix A
+ -0.01 -0.10 -0.01 -0.04 -0.10 -0.01 -0.01
+ -0.13 -1.0E+25 -1.0E+25 -1.0E+25 -1.0E+25 -9.92E-02 -3.0E-03 :End of BL
+ 0.01 0.15 0.03 0.02 0.05 1.0E+25 1.0E+25
+ -0.13 -4.9E-03 -6.4E-03 -3.7E-03 -1.2E-03 1.0E+25 2.0E-03 :End of BU
+ -0.01 -0.03 0.00 -0.01 -0.10 0.02 0.01 :End of X
+ 2.00 0.00 0.00 0.00 0.00 0.00 0.00
+ 0.00 2.00 0.00 0.00 0.00 0.00 0.00
+ 0.00 0.00 2.00 2.00 0.00 0.00 0.00
+ 0.00 0.00 2.00 2.00 0.00 0.00 0.00
+ 0.00 0.00 0.00 0.00 2.00 0.00 0.00
+ 0.00 0.00 0.00 0.00 0.00 -2.00 -2.00
+ 0.00 0.00 0.00 0.00 0.00 -2.00 -2.00 :End of matrix H
diff --git a/simple_examples/data/e04nqje.d b/simple_examples/data/e04nqje.d
new file mode 100644
index 0000000..a1c9039
--- /dev/null
+++ b/simple_examples/data/e04nqje.d
@@ -0,0 +1,67 @@
+E04NQF Example Program Data
+ 7 8 : Values of N and M
+48 8 7 'C' 15 : Values of NNZ, IOBJ, NCOLH, START and NNAME
+
+'...X1...' '...X2...' '...X3...' '...X4...' '...X5...'
+'...X6...' '...X7...' '..ROW1..' '..ROW2..' '..ROW3..'
+'..ROW4..' '..ROW5..' '..ROW6..' '..ROW7..' '..COST..' : End of array NAMES
+
+ 0.02 7 1 : Sparse matrix A, ordered by increasing column index;
+ 0.02 5 1 : each row contains ACOL(i), INDA(i), ICOL (= column index)
+ 0.03 3 1 : The row indices may be in any order. In this example
+ 1.00 1 1 : row 8 defines the linear objective term transpose(C)*X.
+ 0.70 6 1
+ 0.02 4 1
+ 0.15 2 1
+ -200.00 8 1
+ 0.06 7 2
+ 0.75 6 2
+ 0.03 5 2
+ 0.04 4 2
+ 0.05 3 2
+ 0.04 2 2
+ 1.00 1 2
+-2000.00 8 2
+ 0.02 2 3
+ 1.00 1 3
+ 0.01 4 3
+ 0.08 3 3
+ 0.08 7 3
+ 0.80 6 3
+-2000.00 8 3
+ 1.00 1 4
+ 0.12 7 4
+ 0.02 3 4
+ 0.02 4 4
+ 0.75 6 4
+ 0.04 2 4
+-2000.00 8 4
+ 0.01 5 5
+ 0.80 6 5
+ 0.02 7 5
+ 1.00 1 5
+ 0.02 2 5
+ 0.06 3 5
+ 0.02 4 5
+-2000.00 8 5
+ 1.00 1 6
+ 0.01 2 6
+ 0.01 3 6
+ 0.97 6 6
+ 0.01 7 6
+ 400.00 8 6
+ 0.97 7 7
+ 0.03 2 7
+ 1.00 1 7
+ 400.00 8 7 : End of matrix A
+
+ 0.0 0.0 4.0E+02 1.0E+02 0.0 0.0
+ 0.0 2.0E+03 -1.0E+25 -1.0E+25 -1.0E+25 -1.0E+25
+ 1.5E+03 2.5E+02 -1.0E+25 : End of lower bounds array BL
+
+ 2.0E+02 2.5E+03 8.0E+02 7.0E+02 1.5E+03 1.0E+25
+ 1.0E+25 2.0E+03 6.0E+01 1.0E+02 4.0E+01 3.0E+01
+ 1.0E+25 3.0E+02 1.0E+25 : End of upper bounds array BU
+
+ 0 0 0 0 0 0 0 : Initial array HS
+ 0.0 0.0 0.0 0.0 0.0 0.0 0.0 : Initial vector X
diff --git a/simple_examples/data/e04rsje.d b/simple_examples/data/e04rsje.d
new file mode 100644
index 0000000..9540ce2
--- /dev/null
+++ b/simple_examples/data/e04rsje.d
@@ -0,0 +1,13 @@
+E04RSJ Example Program Data
+ 3 6 6 : n, nnzq1, nnzq2
+ 1 1 1 2 2 3 : irowq0
+ 1 2 3 2 3 3 : icolq0
+ 0.493 0.382 0.270 0.475 0.448 0.515 : q0
+ 1 1 1 2 2 3 : irowq1
+ 1 2 3 2 3 3 : icolq1
+ 0.737 0.453 1.002 0.316 0.635 1.590 : q1
+ 1 2 3 : idxr0
+ 0.847 0.08 0.505 : r0
+ 1 2 3 : idxr1
+ 0.065 0.428 0.097 : r1
+ 1.276 : s
diff --git a/simple_examples/data/e04rtje.d b/simple_examples/data/e04rtje.d
new file mode 100644
index 0000000..f6f5896
--- /dev/null
+++ b/simple_examples/data/e04rtje.d
@@ -0,0 +1,8 @@
+E04RTJ Example Program Data
+ 3 2 4 : n, m, nnza
+ 1 1 2 2 : irowa
+ 1 2 2 3 : icola
+ 0.493 0.382 0.270 0.475 : a
+ 0.2 0.4 : b
+ -1.0 -1.0 -1.0 : xl
+ 1.0 1.0 1.0 : xu
diff --git a/simple_examples/data/e04saje.opt b/simple_examples/data/e04saje.opt
new file mode 100644
index 0000000..098dd78
--- /dev/null
+++ b/simple_examples/data/e04saje.opt
@@ -0,0 +1,30 @@
+NAME E04SAJE
+OBJSENSE
+ MIN
+ROWS
+ N obj
+ L g1
+ G g2
+COLUMNS
+ x1 obj 10.0
+ x1 g1 -0.1
+ x1 g2 -0.06
+ x2 obj 20.0
+ x2 g1 -0.1
+ x2 g2 1.0
+ x3 obj 1.0
+ x3 g1 1.0
+ x3 g2 1.0
+RHS
+ UVEC g1 1.5
+ UVEC g2 1.0
+BOUNDS
+ LO bound x1 -2.0
+ UP bound x1 2.0
+ LO bound x2 -2.0
+ UP bound x2 2.0
+CSECTION k1 0 QUAD
+ x3
+ x1
+ x2
+ENDATA
diff --git a/simple_examples/data/e04tcje.d b/simple_examples/data/e04tcje.d
new file mode 100644
index 0000000..0d7c25f
--- /dev/null
+++ b/simple_examples/data/e04tcje.d
@@ -0,0 +1,22 @@
+E04TCJ Example Program Data
+30 : nres
+-1.0000000000000000E+00 -9.3103448275862066E-01 -8.6206896551724133E-01
+-7.9310344827586210E-01 -7.2413793103448276E-01 -6.5517241379310343E-01
+-5.8620689655172420E-01 -5.1724137931034486E-01 -4.4827586206896552E-01
+-3.7931034482758619E-01 -3.1034482758620685E-01 -2.4137931034482762E-01
+-1.7241379310344829E-01 -1.0344827586206895E-01 -3.4482758620689724E-02
+ 3.4482758620689724E-02 1.0344827586206895E-01 1.7241379310344818E-01
+ 2.4137931034482762E-01 3.1034482758620685E-01 3.7931034482758630E-01
+ 4.4827586206896552E-01 5.1724137931034475E-01 5.8620689655172420E-01
+ 6.5517241379310343E-01 7.2413793103448265E-01 7.9310344827586210E-01
+ 8.6206896551724133E-01 9.3103448275862055E-01 1.0000000000000000E+00 : x
+-4.7355262950125371E-01 -5.4938194860076961E-01 -3.9825239170869919E-01
+-3.8856020837234490E-01 -5.5342876546898057E-01 -4.9096203345353551E-01
+-5.3572741683518588E-01 -4.7612745760879621E-01 -5.3500371923553647E-01
+ 6.0158102095753345E-01 -5.8735647599146978E-01 -4.4672492128166008E-01
+-2.8302528479868733E-01 -3.0311152621895832E-01 -4.1648482978955480E-02
+ 3.7631282343379285E-02 1.6504195889737350E-01 5.1964885199180544E-01
+ 5.4702301251386876E-01 -4.4537928919142311E-01 5.9042453784268267E-01
+ 6.9016702395652996E-01 6.9143394337665087E-01 7.8263998594593021E-01
+ 8.1261679746103432E-01 7.5887968830904762E-01 9.5316846217349571E-01
+ 1.1014159319048389E+00 1.0675894279571976E+00 1.1538027971634699E+00 : obs
diff --git a/simple_examples/data/f03baje.d b/simple_examples/data/f03baje.d
new file mode 100644
index 0000000..8c792dc
--- /dev/null
+++ b/simple_examples/data/f03baje.d
@@ -0,0 +1,5 @@
+F03BAF Example Program Data
+ 3 : N
+ 33 16 72
+ -24 -10 -57
+ -8 -4 -17 : A
diff --git a/simple_examples/data/f04amje.d b/simple_examples/data/f04amje.d
new file mode 100644
index 0000000..dc69386
--- /dev/null
+++ b/simple_examples/data/f04amje.d
@@ -0,0 +1,5 @@
+F04AMF Example Program Data
+ 3 2 : m, n
+ 1.1 0.9 2.2
+ 1.2 1.0 2.3
+ 1.0 1.0 2.1 : matrices A and B
diff --git a/simple_examples/data/f04baje.d b/simple_examples/data/f04baje.d
new file mode 100644
index 0000000..b1df19b
--- /dev/null
+++ b/simple_examples/data/f04baje.d
@@ -0,0 +1,13 @@
+F04BAF Example Program Data
+
+ 4 2 : n, nrhs
+
+ 1.80 2.88 2.05 -0.89
+ 5.25 -2.95 -0.95 -3.80
+ 1.58 -2.69 -2.90 -1.04
+ -1.11 -0.66 -0.59 0.80 : matrix A
+
+ 9.52 18.47
+ 24.35 2.25
+ 0.77 -13.28
+ -6.22 -6.21 : matrix B
diff --git a/simple_examples/data/f05aaje.d b/simple_examples/data/f05aaje.d
new file mode 100644
index 0000000..cafb7ea
--- /dev/null
+++ b/simple_examples/data/f05aaje.d
@@ -0,0 +1,6 @@
+F05AAF Example Program Data
+ 4 2 4
+ 1 -2 3 1
+-2 1 -2 -1
+ 3 -2 1 5
+ 4 1 5 3
\ No newline at end of file
diff --git a/simple_examples/data/f08btje.d b/simple_examples/data/f08btje.d
new file mode 100644
index 0000000..bea5bf4
--- /dev/null
+++ b/simple_examples/data/f08btje.d
@@ -0,0 +1,15 @@
+F08BTF Example Program Data
+
+ 5 4 2 :Values of M, N and NRHS
+
+ ( 0.47,-0.34) (-0.40, 0.54) ( 0.60, 0.01) ( 0.80,-1.02)
+ (-0.32,-0.23) (-0.05, 0.20) (-0.26,-0.44) (-0.43, 0.17)
+ ( 0.35,-0.60) (-0.52,-0.34) ( 0.87,-0.11) (-0.34,-0.09)
+ ( 0.89, 0.71) (-0.45,-0.45) (-0.02,-0.57) ( 1.14,-0.78)
+ (-0.19, 0.06) ( 0.11,-0.85) ( 1.44, 0.80) ( 0.07, 1.14) :End of matrix A
+
+ (-1.08,-2.59) ( 2.22, 2.35)
+ (-2.61,-1.49) ( 1.62,-1.48)
+ ( 3.13,-3.61) ( 1.65, 3.43)
+ ( 7.33,-8.01) (-0.98, 3.08)
+ ( 9.12, 7.63) (-2.84, 2.78) :End of matrix B
diff --git a/simple_examples/data/f08xpje.d b/simple_examples/data/f08xpje.d
new file mode 100644
index 0000000..39b5c87
--- /dev/null
+++ b/simple_examples/data/f08xpje.d
@@ -0,0 +1,10 @@
+F08XPJ Example Program Data
+4 : Value of N
+(-21.10,-22.50) ( 53.50,-50.50) (-34.50,127.50) ( 7.50, 0.50)
+( -0.46, -7.78) ( -3.50,-37.50) (-15.50, 58.50) (-10.50, -1.50)
+( 4.30, -5.50) ( 39.70,-17.10) (-68.50, 12.50) ( -7.50, -3.50)
+( 5.50, 4.40) ( 14.40, 43.30) (-32.50,-46.00) (-19.00,-32.50) : End of A
+( 1.00, -5.00) ( 1.60, 1.20) ( -3.00, 0.00) ( 0.00, -1.00)
+( 0.80, -0.60) ( 3.00, -5.00) ( -4.00, 3.00) ( -2.40, -3.20)
+( 1.00, 0.00) ( 2.40, 1.80) ( -4.00, -5.00) ( 0.00, -3.00)
+( 0.00, 1.00) ( -1.80, 2.40) ( 0.00, -4.00) ( 4.00, -5.00) : End of B
diff --git a/simple_examples/data/g02bjje.d b/simple_examples/data/g02bjje.d
new file mode 100644
index 0000000..eaa8921
--- /dev/null
+++ b/simple_examples/data/g02bjje.d
@@ -0,0 +1,10 @@
+G02BJF Example Program Data
+5 4 3 :: N, M, NVARS
+ 3.0 3.0 1.0 2.0
+ 6.0 4.0 -1.0 4.0
+ 9.0 0.0 5.0 9.0
+12.0 2.0 0.0 0.0
+-1.0 5.0 4.0 12.0 :: End of X
+ 1 1 0 1 :: MISS
+-1.0 0.0 0.0 0.0 :: XMISS
+4 1 2 :: KVAR
diff --git a/simple_examples/data/g02daje.d b/simple_examples/data/g02daje.d
new file mode 100644
index 0000000..4e844ac
--- /dev/null
+++ b/simple_examples/data/g02daje.d
@@ -0,0 +1,15 @@
+G02DAJ Example Program Data
+12 4 'U' 'M'
+1.0 0.0 0.0 0.0 33.63
+0.0 0.0 0.0 1.0 39.62
+0.0 1.0 0.0 0.0 38.18
+0.0 0.0 1.0 0.0 41.46
+0.0 0.0 0.0 1.0 38.02
+0.0 1.0 0.0 0.0 35.83
+0.0 0.0 0.0 1.0 35.99
+1.0 0.0 0.0 0.0 36.58
+0.0 0.0 1.0 0.0 42.92
+1.0 0.0 0.0 0.0 37.80
+0.0 0.0 1.0 0.0 40.43
+0.0 1.0 0.0 0.0 37.89
+1 1 1 1
diff --git a/simple_examples/data/g02eeje.d b/simple_examples/data/g02eeje.d
new file mode 100644
index 0000000..b0c03a7
--- /dev/null
+++ b/simple_examples/data/g02eeje.d
@@ -0,0 +1,24 @@
+G02EEF Example Program Data
+ 20 6 'M' 'U' 2.0 :: N,M,MEAN,WEIGHT,FIN
+ 0.0 1125.0 232.0 7160.0 85.9 8905.0 1.5563
+ 7.0 920.0 268.0 8804.0 86.5 7388.0 0.8976
+ 15.0 835.0 271.0 8108.0 85.2 5348.0 0.7482
+ 22.0 1000.0 237.0 6370.0 83.8 8056.0 0.7160
+ 29.0 1150.0 192.0 6441.0 82.1 6960.0 0.3010
+ 37.0 990.0 202.0 5154.0 79.2 5690.0 0.3617
+ 44.0 840.0 184.0 5896.0 81.2 6932.0 0.1139
+ 58.0 650.0 200.0 5336.0 80.6 5400.0 0.1139
+ 65.0 640.0 180.0 5041.0 78.4 3177.0 -0.2218
+ 72.0 583.0 165.0 5012.0 79.3 4461.0 -0.1549
+ 80.0 570.0 151.0 4825.0 78.7 3901.0 0.0000
+ 86.0 570.0 171.0 4391.0 78.0 5002.0 0.0000
+ 93.0 510.0 243.0 4320.0 72.3 4665.0 -0.0969
+ 100.0 555.0 147.0 3709.0 74.9 4642.0 -0.2218
+ 107.0 460.0 286.0 3969.0 74.4 4840.0 -0.3979
+ 122.0 275.0 198.0 3558.0 72.5 4479.0 -0.1549
+ 129.0 510.0 196.0 4361.0 57.7 4200.0 -0.2218
+ 151.0 165.0 210.0 3301.0 71.8 3410.0 -0.3979
+ 171.0 244.0 327.0 2964.0 72.5 3360.0 -0.5229
+ 220.0 79.0 334.0 2777.0 71.9 2599.0 -0.0458 :: End of X,Y
+ 0 1 1 1 1 2 :: ISX
+ 'DAY' 'BOD' 'TKN' 'TS ' 'TVS' 'COD' :: VNAME
diff --git a/simple_examples/data/g02maje.d b/simple_examples/data/g02maje.d
new file mode 100644
index 0000000..b21e21c
--- /dev/null
+++ b/simple_examples/data/g02maje.d
@@ -0,0 +1,23 @@
+G02MAJ Example Program Data
+20 6 :: N,M
+1 3 1 6 0 :: MTYPE,PRED,PREY,MNSTEP,LISX
+10.28 1.77 9.69 15.58 8.23 10.44 -46.47
+9.08 8.99 11.53 6.57 15.89 12.58 -35.80
+17.98 13.10 1.04 10.45 10.12 16.68 -129.22
+14.82 13.79 12.23 7.00 8.14 7.79 -42.44
+17.53 9.41 6.24 3.75 13.12 17.08 -73.51
+7.78 10.38 9.83 2.58 10.13 4.25 -26.61
+11.95 21.71 8.83 11.00 12.59 10.52 -63.90
+14.60 10.09 -2.70 9.89 14.67 6.49 -76.73
+3.63 9.07 12.59 14.09 9.06 8.19 -32.64
+6.35 9.79 9.40 12.79 8.38 16.79 -83.29
+4.66 3.55 16.82 13.83 21.39 13.88 -16.31
+8.32 14.04 17.17 7.93 7.39 -1.09 -5.82
+10.86 13.68 5.75 10.44 10.36 10.06 -47.75
+4.76 4.92 17.83 2.90 7.58 11.97 18.38
+5.05 10.41 9.89 9.04 7.90 13.12 -54.71
+5.41 9.32 5.27 15.53 5.06 19.84 -55.62
+9.77 2.37 9.54 20.23 9.33 8.82 -45.28
+14.28 4.34 14.23 14.95 18.16 11.03 -22.76
+10.17 6.80 3.17 8.57 16.07 15.93 -104.32
+5.39 2.67 6.37 13.56 10.68 7.35 -55.94 :: End of D, Y
diff --git a/simple_examples/data/g03gaje.d b/simple_examples/data/g03gaje.d
new file mode 100644
index 0000000..ca1c97f
--- /dev/null
+++ b/simple_examples/data/g03gaje.d
@@ -0,0 +1,56 @@
+G03GAF Example Program Data
+25 4 4 : N M IP
+2 : NG
+2 : SOPT
+2 : POPT
+15 : NITER
+2.7 3.2 4.5 4.8
+3.9 3.8 5.9 6.2
+4.8 4.1 6.8 5.5
+3.1 3.5 4.3 4.6
+3.4 3.7 5.1 5.6
+3.1 3.4 4.1 4.7
+4.6 4.4 6.6 6.1
+3.1 3.3 4.0 4.9
+3.8 3.7 4.7 4.9
+5.2 4.9 8.2 6.9
+3.9 3.8 5.2 5.4
+4.1 4.0 5.6 5.6
+5.7 5.1 7.0 6.3
+3.0 3.2 4.5 5.0
+2.9 3.3 4.5 5.1
+3.4 3.3 4.4 5.0
+4.0 4.2 5.2 5.4
+3.0 3.0 4.6 5.0
+4.0 4.1 5.9 5.8
+3.0 3.2 4.4 5.1
+3.6 3.6 5.3 5.4
+3.1 3.2 4.6 5.0
+3.2 3.3 5.4 5.3
+3.0 3.4 4.2 4.7
+3.8 4.0 6.9 6.7 : X
+1.0 0.0
+1.0 0.0
+1.0 0.0
+1.0 0.0
+1.0 0.0
+1.0 0.0
+1.0 0.0
+1.0 0.0
+1.0 0.0
+1.0 0.0
+1.0 0.0
+1.0 0.0
+0.0 1.0
+0.0 1.0
+0.0 1.0
+0.0 1.0
+0.0 1.0
+0.0 1.0
+0.0 1.0
+0.0 1.0
+0.0 1.0
+0.0 1.0
+0.0 1.0
+0.0 1.0
+0.0 1.0 : P
diff --git a/simple_examples/data/g05kfje.d b/simple_examples/data/g05kfje.d
new file mode 100644
index 0000000..b55cba0
--- /dev/null
+++ b/simple_examples/data/g05kfje.d
@@ -0,0 +1,3 @@
+G05KFF Example Program Data
+1 1 1762543 :: GENID,SUBID,SEED(1)
+5 :: N
diff --git a/simple_examples/data/g13naje.d b/simple_examples/data/g13naje.d
new file mode 100644
index 0000000..4da5b32
--- /dev/null
+++ b/simple_examples/data/g13naje.d
@@ -0,0 +1,14 @@
+G13NAJ Example Program Data
+100 :: N
+0.00 0.78 -0.02 0.17 0.04 -1.23 0.24 1.70 0.77 0.06
+0.67 0.94 1.99 2.64 2.26 3.72 3.14 2.28 3.78 0.83
+2.80 1.66 1.93 2.71 2.97 3.04 2.29 3.71 1.69 2.76
+1.96 3.17 1.04 1.50 1.12 1.11 1.00 1.84 1.78 2.39
+1.85 0.62 2.16 0.78 1.70 0.63 1.79 1.21 2.20 -1.34
+0.04 -0.14 2.78 1.83 0.98 0.19 0.57 -1.41 2.05 1.17
+0.44 2.32 0.67 0.73 1.17 -0.34 2.95 1.08 2.16 2.27
+-0.14 -0.24 0.27 1.71 -0.04 -1.03 -0.12 -0.67 1.15 -1.10
+-1.37 0.59 0.44 0.63 -0.06 -0.62 0.39 -2.63 -1.63 -0.42
+-0.73 0.85 0.26 0.48 -0.26 -1.77 -1.53 -1.39 1.68 0.43 :: End of Y
+1 1 4.6 2 :: CTYPE,IPARAM,BETA,MINSS
+1.0 :: PARAM(1)
diff --git a/simple_examples/data/m01ccje.d b/simple_examples/data/m01ccje.d
new file mode 100644
index 0000000..3a946ab
--- /dev/null
+++ b/simple_examples/data/m01ccje.d
@@ -0,0 +1,13 @@
+M01CCF Example Program Data
+11
+A02AAF 289
+A02ABF 523
+A02ACF 531
+C02ADF 169
+C02AEF 599
+C05AUF 1351
+C05AVF 240
+C05AWF 136
+C05AXF 211
+C05AYF 183
+C05AZF 2181
diff --git a/simple_examples/data/s14abje.d b/simple_examples/data/s14abje.d
new file mode 100644
index 0000000..083a4f4
--- /dev/null
+++ b/simple_examples/data/s14abje.d
@@ -0,0 +1,10 @@
+S14ABF Example Program Data
+ 1.0
+ 1.25
+ 1.5
+ 1.75
+ 2.0
+ 5.0
+ 10.0
+ 20.0
+ 1000.0
diff --git a/simple_examples/data/s14acje.d b/simple_examples/data/s14acje.d
new file mode 100644
index 0000000..64a16c9
--- /dev/null
+++ b/simple_examples/data/s14acje.d
@@ -0,0 +1,5 @@
+S14ACJ Example Program Data
+0.1
+0.5
+3.6
+8.0
diff --git a/simple_examples/data/s14afje.d b/simple_examples/data/s14afje.d
new file mode 100644
index 0000000..f658cc5
--- /dev/null
+++ b/simple_examples/data/s14afje.d
@@ -0,0 +1,2 @@
+S14AFJ Example Program Data
+-1.5 2.5 1 : Values of Z and K
diff --git a/simple_examples/data/s17dcje.d b/simple_examples/data/s17dcje.d
new file mode 100644
index 0000000..fa0d57f
--- /dev/null
+++ b/simple_examples/data/s17dcje.d
@@ -0,0 +1,6 @@
+S17DCJ Example Program Data
+0.00 0.3 0.4 'U'
+2.30 2.0 0.0 'U'
+2.12 -1.0 0.0 'U'
+1.58 -2.3 5.6 'U'
+1.58 -2.3 5.6 'S'
diff --git a/simple_examples/data/s17dgje.d b/simple_examples/data/s17dgje.d
new file mode 100644
index 0000000..3e62c29
--- /dev/null
+++ b/simple_examples/data/s17dgje.d
@@ -0,0 +1,6 @@
+S17DGF Example Program Data
+ 'F' ( 0.3, 0.4) 'U'
+ 'F' ( 0.2, 0.0) 'U'
+ 'F' ( 1.1, -6.6) 'U'
+ 'F' ( 1.1, -6.6) 'S'
+ 'D' (-1.0, 0.0) 'U'
diff --git a/simple_examples/data/s30aaje.d b/simple_examples/data/s30aaje.d
new file mode 100644
index 0000000..0248da1
--- /dev/null
+++ b/simple_examples/data/s30aaje.d
@@ -0,0 +1,9 @@
+S30AAJ Example Program Data
+'C' : Call = 'C', Put = 'P'
+55.0 0.3 0.1 0.0 : S, SIGMA, R, Q
+3 2 : M, N
+58.0
+60.0
+62.0 : X(I), I = 1,2,...M
+0.7
+0.8 : T(I), I = 1,2,...N
diff --git a/simple_examples/data/s30acje.d b/simple_examples/data/s30acje.d
new file mode 100644
index 0000000..48117a7
--- /dev/null
+++ b/simple_examples/data/s30acje.d
@@ -0,0 +1,9 @@
+S30ACJ Example Program Data
+'C' : Call = 'C', Put = 'P'
+5 1 : Values of n and mode
+
+4.14 3.89 5.39 5.14 5.04 : p
+268.0 268.0 268.0 268.5 269.0 : k
+267.5 267.5 267.5 267.5 267.5 : s0
+0.00274 0.00274 0.0164 0.0164 0.0164 : t
+0.0166 0.0166 0.0166 0.0166 0.0166 : r
diff --git a/simple_examples/data/x03aaje.d b/simple_examples/data/x03aaje.d
new file mode 100644
index 0000000..1254b78
--- /dev/null
+++ b/simple_examples/data/x03aaje.d
@@ -0,0 +1,5 @@
+X03AAJ Example Program Data
+ -2 -3 7
+ 2 -5 3
+ -9 1 0
+ 8 -4 -2
diff --git a/simple_examples/source/int32/A00AAJE.java b/simple_examples/source/int32/A00AAJE.java
new file mode 100644
index 0000000..65b6c18
--- /dev/null
+++ b/simple_examples/source/int32/A00AAJE.java
@@ -0,0 +1,16 @@
+import com.nag.routines.A00.A00AA;
+
+/**
+ * A00AA example program text.
+ */
+public class A00AAJE {
+
+ public static void main(String[] args) {
+ A00AA a00aa = new A00AA();
+
+ System.out.println(" A00AAJ Example Program Results\n");
+ a00aa.eval();
+
+ }
+
+}
diff --git a/simple_examples/source/int32/A00ACJE.java b/simple_examples/source/int32/A00ACJE.java
new file mode 100644
index 0000000..7f44ba3
--- /dev/null
+++ b/simple_examples/source/int32/A00ACJE.java
@@ -0,0 +1,29 @@
+import com.nag.routines.A00.A00AC;
+
+/**
+ * A00AC example program text.
+ * @author Mo
+ */
+public class A00ACJE {
+
+ public static void main(String[] args) {
+ A00AC a00ac = new A00AC();
+ boolean lmok;
+
+ System.out.println(" A00ACJ Example Program Results\n");
+ System.out.println();
+
+ a00ac.eval();
+
+ lmok = a00ac.eval();
+
+ if (lmok) {
+ System.out.println("A valid licence key is available");
+ }
+ else {
+ System.out.println("No valid licence key was found");
+ }
+
+ }
+
+}
diff --git a/simple_examples/source/int32/A00ADJE.java b/simple_examples/source/int32/A00ADJE.java
new file mode 100644
index 0000000..139c8b9
--- /dev/null
+++ b/simple_examples/source/int32/A00ADJE.java
@@ -0,0 +1,107 @@
+import com.nag.routines.A00.A00AD;
+import com.nag.routines.X05.X05AA;
+import java.util.Arrays;
+
+/**
+ * A00AD example program text.
+ */
+public class A00ADJE {
+
+ public static void main(String[] args) {
+
+ A00AD a00ad = new A00AD();
+ X05AA x05aa = new X05AA();
+ int i, mkmaj, mkmin;
+ boolean licval;
+ String fcomp, hdware, impl, opsys, pcode, prec, vend;
+ int[] itime = new int[7];
+
+ // Instantiate arguments
+ mkmaj = 0;
+ mkmin = 0;
+ licval = false;
+
+ // Strings must be length expected by Fortran
+ fcomp = getBlankString(80);
+ hdware = getBlankString(80);
+ impl = getBlankString(80);
+ opsys = getBlankString(80);
+ pcode = getBlankString(80);
+ prec = getBlankString(80);
+ vend = getBlankString(80);
+
+ System.out.println(" A00ADJ Example Program Results\n");
+
+ a00ad.eval(impl, prec, pcode, mkmaj, mkmin, hdware, opsys, fcomp, vend, licval);
+
+ // Output scalars must be retrieved manually
+ impl = a00ad.getIMPL();
+ prec = a00ad.getPREC();
+ pcode = a00ad.getPCODE();
+ mkmaj = a00ad.getMKMAJ();
+ mkmin = a00ad.getMKMIN();
+ hdware = a00ad.getHDWARE();
+ opsys = a00ad.getOPSYS();
+ fcomp = a00ad.getFCOMP();
+ vend = a00ad.getVEND();
+ licval = a00ad.getLICVAL();
+
+ // Print implementation details
+
+ System.out.println("*** Start of NAG Library implementation details ***");
+ System.out.println();
+ System.out.println("Implementation title: " + impl.trim());
+ System.out.println(" Precision: " + prec.trim());
+ System.out.println(" Product code: " + pcode.trim());
+
+ if (mkmin < 10) {
+ System.out.printf(" Mark: %2d.%1d\n", mkmaj, mkmin);
+ }
+ else {
+ System.out.printf(" Mark: %2d.%2d\n", mkmaj, mkmin);
+ }
+
+ if (vend.trim().equals("(self-contained)")) {
+ System.out.println(" Vendor Library: None");
+ }
+ else {
+ System.out.println(" Vendor Library: " + vend.trim());
+ }
+
+ System.out.println("Applicable to:");
+ System.out.println(" hardware: " + hdware.trim());
+ System.out.println(" operating system: " + opsys.trim());
+ System.out.println(" Fortran compiler: " + fcomp.trim());
+ System.out.println("and compatible systems.");
+
+ if (!licval) {
+ System.out.println(" Licence query: Unsuccessful");
+ }
+ else {
+ System.out.println(" Licence query: Successful");
+ }
+
+ System.out.println();
+ System.out.println("*** End of NAG Library implementation details ***");
+
+ }
+
+ /**
+ * Returns a new String, filled with spaces to the specified length.
+ *
+ * @param len the required length of the String
+ * @return a blank String of the specified length
+ */
+ public static String getBlankString(int len) {
+
+ if (len > 0) {
+ char[] arr = new char[len];
+ Arrays.fill(arr, ' ');
+ return new String(arr);
+ }
+
+ return "";
+
+ }
+
+}
diff --git a/simple_examples/source/int32/C02AAJE.java b/simple_examples/source/int32/C02AAJE.java
new file mode 100644
index 0000000..1abc528
--- /dev/null
+++ b/simple_examples/source/int32/C02AAJE.java
@@ -0,0 +1,174 @@
+import com.nag.routines.C02.C02AA;
+import com.nag.routines.Routine;
+import com.nag.routines.X02.X02AJ;
+import com.nag.routines.X02.X02AL;
+import com.nag.types.NAGComplex;
+import java.util.Arrays;
+
+/**
+ * C02AA example program text.
+ * @author joed
+ * @since 27.1.0.0
+ */
+public class C02AAJE {
+
+ public static void main(String[] args) {
+
+ System.out.println(" C02AAJ Example Program Results");
+
+ Routine.setComplex(new NAGComplex());
+ exampleBasic();
+ examplePolishing();
+
+ System.out.println();
+
+ }
+
+ /** Demonstrate a basic problem. */
+ public static void exampleBasic() {
+
+ C02AA c02aa = new C02AA();
+ int ifail, itmax, n, polish;
+ NAGComplex[] a, z;
+ double[] berr, cond;
+ int[] conv;
+
+ System.out.println();
+ System.out.println("Example 1: Basic Problem");
+ System.out.println();
+
+ // Set polynomial degree and instantiate arrays
+ n = 5;
+ a = new NAGComplex[n+1];
+ berr = new double[n];
+ cond = new double[n];
+ conv = new int[n];
+ z = NAGComplex.createArray(n);
+
+ // Set polynomial coefficients
+ a[0] = new NAGComplex(5.0, 6.0);
+ a[1] = new NAGComplex(30.0, 20.0);
+ a[2] = new NAGComplex(-0.2, -6.0);
+ a[3] = new NAGComplex(50.0, 100000.0);
+ a[4] = new NAGComplex(-2.0, 40.0);
+ a[5] = new NAGComplex(10.0, 1.0);
+
+ // Find roots of the polynomial
+ itmax = 30;
+ polish = 1;
+ ifail = 0;
+ c02aa.eval(a, n, itmax, polish, z, berr, cond, conv, ifail);
+
+ // Print output
+ System.out.println(" i z conv berr cond ");
+ System.out.println(" ---------------------------------------------------");
+ for (int i = 0; i < n; i++) {
+ System.out.printf(" %2d %9.2E, %9.2E %3d %9.2E %9.2E\n", i+1,
+ z[i].getRe(), z[i].getIm(), conv[i], berr[i], cond[i]);
+ }
+
+ }
+
+ /** Compare polishing processes on a Wilkinson-style polynomial. */
+ public static void examplePolishing() {
+
+ C02AA c02aa = new C02AA();
+ X02AJ x02aj = new X02AJ();
+ X02AL x02al = new X02AL();
+ NAGComplex pz;
+ double delta, eps, err, fwderr, maxfwderr, maxrelerr, relerr, rmax;
+ int ifail, itmax, k, n, polish;
+ NAGComplex[] a, z, zact;
+ double[] berr, cond;
+ int[] conv;
+ boolean[] matched;
+
+ System.out.println();
+ System.out.println("Example 2: Polishing Processes");
+ System.out.println();
+
+ // Set polynomial degree and instantiate
+ n = 10;
+ a = new NAGComplex[n+1];
+ berr = new double[n];
+ cond = new double[n];
+ conv = new int[n];
+ matched = new boolean[n];
+ z = new NAGComplex[n];
+ zact = new NAGComplex[n];
+
+ // Set known roots and (instantiate z)
+ for (int i = 0; i < n; i++) {
+ zact[i] = new NAGComplex((double) i+1, 0.0);
+ z[i] = new NAGComplex();
+ }
+
+ // Multiply out (z-1)(z-2)...(z-n) for coefficients
+ for (int i = 0; i < n; i++) {
+ a[i] = new NAGComplex();
+ }
+ a[n] = new NAGComplex(1.0, 0.0);
+ for (int i = 0; i < n; i++) {
+ for (int j = 0; j < n; j++) {
+ a[j] = a[j+1].subtract(a[j].multiply(zact[i]));
+ }
+ a[n] = a[n].negate().multiply(zact[i]);
+ }
+
+ System.out.println(" polish relerr fwderr ");
+ System.out.println(" ----------------------------");
+
+ itmax = 30;
+ eps = x02aj.eval();
+ rmax = x02al.eval();
+
+ for (polish = 0; polish <= 2; polish++) {
+
+ // Find roots
+ ifail = 0;
+ c02aa.eval(a, n, itmax, polish, z, berr, cond, conv, ifail);
+
+ /* Calculate the maximum relative errors of the roots, and the maximum
+ * forward error evaluating the polynomial at those roots. Errors are
+ * capped at machine precision. */
+ maxrelerr = maxfwderr = eps;
+ Arrays.fill(matched, false);
+
+ for (int i = 0; i < n; i++) {
+
+ // Evaluate polynomial at this root
+ pz = a[0].clone();
+ for (int j = 1; j <= n; j++) {
+ pz = z[i].multiply(pz).add(a[j]);
+ }
+
+ // Match to an expected root
+ k = 0;
+ err = rmax;
+ for (int j = 0; j < n; j++) {
+ if (!matched[j]) {
+ delta = z[i].subtract(zact[j]).abs();
+ if (delta <= err) {
+ err = delta;
+ k = j;
+ }
+ }
+ }
+
+ // Mark as matched and update max errors
+ matched[k] = true;
+ relerr = err/zact[k].abs();
+ fwderr = pz.abs();
+ maxrelerr = Math.max(maxrelerr, relerr);
+ maxfwderr = Math.max(maxfwderr, fwderr);
+
+ }
+
+ // Print output
+ System.out.printf(" %2d %10.2E%10.2E\n", polish, maxrelerr, maxfwderr);
+
+ }
+
+ }
+
+}
diff --git a/simple_examples/source/int32/C02ABJE.java b/simple_examples/source/int32/C02ABJE.java
new file mode 100644
index 0000000..fad5ebb
--- /dev/null
+++ b/simple_examples/source/int32/C02ABJE.java
@@ -0,0 +1,217 @@
+import com.nag.routines.C02.C02AB;
+import com.nag.routines.X02.X02AJ;
+import com.nag.routines.X02.X02AL;
+import com.nag.routines.Routine;
+import com.nag.types.NAGComplex;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Arrays;
+
+/**
+ * C02AB
+ */
+public class C02ABJE {
+
+ public static void main(String[] args) {
+
+ final boolean polish_example = false;
+
+ Routine.setComplex(new NAGComplex());
+
+ System.out.println(" C02ABJ Example Program Results");
+
+ ex1_basic(args);
+ if (polish_example) {
+ ex2_polishing(args);
+ }
+ }
+
+ public static void ex1_basic(String[] args) {
+
+ int i, ifail, itmax, n = 0, polish;
+
+ NAGComplex[] z = null;
+ double[] a = null, berr = null, cond = null;
+ int[] conv = null;
+
+ System.out.println("\n Basic Problem\n");
+
+ // Specify path to data file
+ if (args.length != 1) {
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+
+ // Skip heading in data file
+ String line = reader.readLine();
+ line = reader.readLine();
+ line = reader.readLine();
+
+ // Read polynomial degree and allocate
+ line = reader.readLine();
+ String[] sVal = line.trim().split("\\s+");
+ n = Integer.parseInt(sVal[0]);
+ a = new double[n + 1];
+ berr = new double[n];
+ cond = new double[n];
+ conv = new int[n];
+ z = NAGComplex.createArray(n);
+
+ // Read polynomial coefficients
+ for (i = 0; i <= n; i++) {
+ line = reader.readLine();
+ sVal = line.trim().split("\\s+");
+ a[i] = Double.parseDouble(sVal[0]);
+ }
+
+ } catch (FileNotFoundException e) {
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ } catch (IOException e) {
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+
+ // Find roots of the polynomial
+ itmax = 30;
+ polish = 1;
+ ifail = 0;
+ C02AB c02ab = new C02AB();
+ c02ab.eval(a ,n, itmax, polish, z, berr, cond, conv, ifail);
+
+ // Print output
+ System.out.println(" i z conv berr cond");
+ System.out.println(" -----------------------------------------------------");
+ for (i = 0; i < n; i++) {
+ System.out.printf(" %2d (%10.2E, %9.2E) %3d %9.2E %9.2E\n", i+1, z[i].getRe(), z[i].getIm(), conv[i], berr[i], cond[i]);
+ }
+ }
+
+ public static void ex2_polishing(String[] args) {
+ NAGComplex pz = new NAGComplex();
+ double delta, eps, err, fwderr, maxfwderr, maxrelerr, relerr, rmax;
+ int i, ifail, itmax, j, k, n = 0, polish;
+
+ NAGComplex[] z = null, zact = null;
+ double[] a = null, berr = null, cond = null;
+ int[] conv = null;
+ boolean[] matched = null;
+
+ System.out.println("\n Polishing Processes\n");
+
+ // Specify path to data file
+ if (args.length != 1) {
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+
+ // Skip heading and previous example in data file
+ for (i = 0; i <= 12; i++) {
+ reader.readLine();
+ }
+
+ // Read polynomial degree and allocate
+ String line = reader.readLine();
+ String[] sVal = line.trim().split("\\s+");
+ n = Integer.parseInt(sVal[0]);
+
+ a = new double[n + 1];
+ berr = new double[n];
+ cond = new double[n];
+ conv = new int[n];
+ matched = new boolean[n];
+ z = NAGComplex.createArray(n);
+ zact = NAGComplex.createArray(n);
+
+ } catch (FileNotFoundException e) {
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ } catch (IOException e) {
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+
+ // Set known roots
+ for (i = 0; i < n; i++) {
+ zact[i] = new NAGComplex((double) (i + 1), 0.0);
+ }
+
+ // Multiply out (z-1)(z-2)...(z-n) for coefficients
+ for (i = 0; i < n; i++) {
+ a[i] = 0.0;
+ }
+ a[n] = 1.0;
+ for (i = 0; i < n; i++) {
+ for (j = 0; j < n; j++) {
+ a[j] = a[j + 1] - a[j] * zact[i].getRe();
+ }
+ a[n] = -a[n] * zact[i].getRe();
+ }
+
+ System.out.println(" polish relerr fwderr");
+ System.out.println(" ----------------------------");
+
+ // Use different polish modes
+ X02AJ x02aj = new X02AJ();
+ X02AL x02al = new X02AL();
+ for (polish = 0; polish <= 2; polish++) {
+
+ itmax = 30;
+ eps = x02aj.eval();
+ rmax = x02al.eval();
+
+ // Find roots
+ ifail = 0;
+ C02AB c02ab = new C02AB();
+ c02ab.eval(a, n , itmax, polish, z, berr, cond, conv, ifail);
+
+ // Calculate the maximum relative errors of the roots, and the maximum
+ // forward error evaluating the polynomial at those roots. Errors are
+ // capped at machine precision.
+ maxrelerr = eps;
+ maxfwderr = eps;
+ Arrays.fill(matched, false);
+
+ for (i = 0; i < n; i++) {
+ // Evaluate polynomial at this root
+ pz = new NAGComplex(a[0], 0.0);
+ for (j = 1; j <= n; j++) {
+ pz = z[i].multiply(pz).add(new NAGComplex(a[j], 0.0));
+ }
+
+ // Match to an expected root
+ k = 0;
+ err = rmax;
+ for (j = 0; j < n; j++) {
+ if (!matched[j]) {
+ delta = z[i].subtract(zact[j]).abs();
+ if (delta <= err) {
+ err = delta;
+ k = j;
+ }
+ }
+ }
+
+ // Mark as matched and update max errors
+ matched[k] = true;
+ relerr = err/zact[k].abs();
+ fwderr = pz.abs();
+ maxrelerr = Math.max(maxrelerr, relerr);
+ maxfwderr = Math.max(maxfwderr, fwderr);
+ }
+
+ // Print output
+ System.out.printf(" %2d %10.2E%10.2E\n", polish, maxrelerr, maxfwderr);
+
+ }
+ }
+}
diff --git a/simple_examples/source/int32/C02AFJE.java b/simple_examples/source/int32/C02AFJE.java
new file mode 100644
index 0000000..6043be7
--- /dev/null
+++ b/simple_examples/source/int32/C02AFJE.java
@@ -0,0 +1,271 @@
+import com.nag.routines.C02.C02AF;
+import com.nag.routines.A02.A02AB;
+import com.nag.routines.X02.X02AJ;
+import com.nag.routines.X02.X02AL;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Arrays;
+
+/**
+ * C02AF
+ */
+public class C02AFJE {
+
+ public static final boolean scal = true;
+
+ public static void main(String[] args) {
+
+ System.out.println(" C02AFJ Example Program Results");
+
+ ex1(args);
+
+ ex2(args);
+ }
+
+ public static void ex1(String[] args) {
+
+ int i, ifail, n = 0;
+
+ double[][] a = null, z = null;
+ double[] w = null;
+
+ System.out.println("\n\n Example 1");
+
+ // Specify path to data file
+ if (args.length != 1) {
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+
+ // Skip heading in data file
+ reader.readLine();
+ reader.readLine();
+ reader.readLine();
+
+ String line = reader.readLine();
+ String[] sVal = line.trim().split("\\s+");
+ n = Integer.parseInt(sVal[0]);
+
+ a = new double[2][n + 1];
+ w = new double[4 * (n + 1)];
+ z = new double[2][n];
+
+ for (i = 0; i <= n; i++) {
+ line = reader.readLine();
+ sVal = line.trim().split("\\s+");
+ a[0][i] = Double.parseDouble(sVal[0]);
+ a[1][i] = Double.parseDouble(sVal[1]);
+ }
+
+ } catch (FileNotFoundException e) {
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ } catch (IOException e) {
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+
+ ifail = 0;
+ C02AF c02af = new C02AF();
+ double[] a1d = convert2DTo1D(a);
+ double[] z1d = convert2DTo1D(z);
+ c02af.eval(a1d, n, scal, z1d, w, ifail);
+
+ z = convert1DTo2D(z1d, 2);
+
+ System.out.println();
+ System.out.printf(" Degree of polynomial = %4d\n", n);
+ System.out.println();
+ System.out.println(" Computed roots of polynomial");
+ System.out.println();
+
+ for (i = 0; i < n; i++) {
+ System.out.printf(" z = %12.4E%+12.4E*i\n", z[0][i], z[1][i]);
+ }
+
+ }
+
+ public static void ex2(String[] args) {
+
+ double deltac, deltai, di, eps, epsbar, f, r1, r2, r3, rmax;
+ int i, ifail, j, jmin = 0, n = 0;
+
+ double[][] a = null, abar = null, z = null, zbar = null;
+ double[] r = null, w = null;
+ int[] m = null;
+
+ System.out.println("\n\n Example 2");
+
+ // Specify path to data file
+ if (args.length != 1) {
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+
+ // Skip heading and previous example in data file
+ for (i = 0; i < 12; i++) {
+ reader.readLine();
+ }
+
+ String line = reader.readLine();
+ String[] sVal = line.trim().split("\\s+");
+ n = Integer.parseInt(sVal[0]);
+ a = new double[2][n + 1];
+ abar = new double[2][n + 1];
+ r = new double[n];
+ w = new double[4 * (n + 1)];
+ z = new double[2][n];
+ zbar = new double[2][n];
+ m = new int[n];
+
+ // Read in the coefficients of the original polynomial.
+ for (i = 0; i <= n; i++) {
+ line = reader.readLine();
+ sVal = line.trim().split("\\s+");
+ a[0][i] = Double.parseDouble(sVal[0]);
+ a[1][i] = Double.parseDouble(sVal[1]);
+ }
+
+ } catch (FileNotFoundException e) {
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ } catch (IOException e) {
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+
+ // Compute the roots of the original polynomial.
+ ifail = 0;
+ C02AF c02af = new C02AF();
+ double[] a1d = convert2DTo1D(a);
+ double[] z1d = convert2DTo1D(z);
+ c02af.eval(a1d, n, scal, z1d, w, ifail);
+
+ z = convert1DTo2D(z1d, 2);
+
+ // Form the coefficients of the perturbed polynomial.
+ X02AJ x02aj = new X02AJ();
+ eps = x02aj.eval();
+ epsbar = 3.0 * eps;
+
+ for (i = 0; i <= n; i++) {
+ if (a[0][i] != 0.0E0) {
+ f = 1.0E0 + epsbar;
+ epsbar = -epsbar;
+ abar[0][i] = f * a[0][i];
+
+ if (a[1][i] != 0.0E0) {
+ abar[1][i] = f * a[1][i];
+ } else {
+ abar[1][i] = 0.0E0;
+ }
+
+ } else {
+
+ if (a[1][i] != 0.0E0) {
+ f = 1.0E0 + epsbar;
+ epsbar = -epsbar;
+ abar[1][i] = f * a[1][i];
+ } else {
+ abar[1][i] = 0.0E0;
+ }
+ }
+ }
+
+ // Compute the roots of the perturbed polynomial.
+ ifail = 0;
+ double[] abar1d = convert2DTo1D(abar);
+ double[] zbar1d = convert2DTo1D(zbar);
+ c02af.eval(abar1d, n, scal, zbar1d, w, ifail);
+
+ zbar = convert1DTo2D(zbar1d, 2);
+
+ // Perform error analysis.
+
+ // Initialize markers to 0 (unmarked).
+ Arrays.fill(m, 0);
+ X02AL x02al = new X02AL();
+ rmax = x02al.eval();
+
+ // Loop over all unperturbed roots (stored in Z).
+ A02AB a02ab = new A02AB();
+ for (i = 0; i < n; i++) {
+ deltai = rmax;
+ r1 = a02ab.eval(z[0][i], z[1][i]);
+
+ // Loop over all perturbed roots (stored in ZBAR).
+ for (j = 0; j < n; j++) {
+ // Compare the current unperturbed root to all unmarked
+ // perturbed roots.
+
+ if (m[j] == 0) {
+ r2 = a02ab.eval(zbar[0][j], zbar[1][j]);
+ deltac = Math.abs(r1 - r2);
+
+ if (deltac < deltai) {
+ deltai = deltac;
+ jmin = j;
+ }
+ }
+ }
+
+ // Mark the selected perturbed root.
+ m[jmin] = 1;
+
+ // Compute the relative error.
+ if (r1 != 0.0E0) {
+ r3 = a02ab.eval(zbar[0][jmin], zbar[1][jmin]);
+ di = Math.min(r1, r3);
+ r[i] = Math.max(deltai / Math.max(di, deltai / rmax), eps);
+ } else {
+ r[i] = 0.0E0;
+ }
+ }
+
+ System.out.println();
+ System.out.printf(" Degree of polynomial = %4d\n", n);
+ System.out.println();
+ System.out.println(" Computed roots of polynomial Error estimates");
+ System.out.println(" (machine-dependent)");
+ System.out.println();
+
+ for (i = 0; i < n; i++) {
+ System.out.printf(" z = %12.4E%+12.4E*i %9.1E\n", z[0][i], z[1][i], r[i]);
+ }
+
+ }
+
+ public static double[] convert2DTo1D(double[][] a) {
+ double[] b = new double[a.length * a[0].length];
+ int n = a.length;
+
+ for (int i = 0; i < a.length; i++) {
+ for (int j = 0; j < a[0].length; j++) {
+ b[i + j*n] = a[i][j];
+ }
+ }
+
+ return b;
+ }
+
+ public static double[][] convert1DTo2D(double[] a, int n) {
+ double[][] b = new double[n][a.length / n];
+
+ for (int i = 0; i < b.length; i++) {
+ for (int j = 0; j < b[0].length; j++) {
+ b[i][j] = a[i + j*n];
+ }
+ }
+
+ return b;
+ }
+}
diff --git a/simple_examples/source/int32/C02AGJE.java b/simple_examples/source/int32/C02AGJE.java
new file mode 100644
index 0000000..c58e524
--- /dev/null
+++ b/simple_examples/source/int32/C02AGJE.java
@@ -0,0 +1,262 @@
+import com.nag.routines.C02.C02AG;
+import com.nag.routines.A02.A02AB;
+import com.nag.routines.X02.X02AJ;
+import com.nag.routines.X02.X02AL;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Arrays;
+
+/**
+ * C02AG
+ */
+public class C02AGJE {
+
+ public static final boolean scal = true;
+
+ public static void main(String[] args) {
+
+ System.out.println(" C02AGJ Example Program Results");
+
+ ex1(args);
+
+ ex2(args);
+ }
+
+ public static void ex1(String[] args) {
+ double zi, zr;
+ int i, ifail, n = 0, nroot;
+
+ double[] a = null, w = null;
+ double[][] z = null;
+
+ System.out.println("\n\n Example 1\n");
+
+ // Specify path to data file
+ if (args.length != 1) {
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+
+ // Skip heading in data file
+ reader.readLine();
+ reader.readLine();
+ reader.readLine();
+
+ String line = reader.readLine();
+ String[] sVal = line.trim().split("\\s+");
+ n = Integer.parseInt(sVal[0]);
+ a = new double[n + 1];
+ w = new double[2 * (n + 1)];
+ z = new double[2][n];
+
+ line = reader.readLine();
+ sVal = line.trim().split("\\s+");
+ for (i = 0; i <= n; i++) {
+ a[i] = Double.parseDouble(sVal[i]);
+ }
+
+ } catch (FileNotFoundException e) {
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ } catch (IOException e) {
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+
+ System.out.println();
+ System.out.printf(" Degree of polynomial = %4d\n", n);
+ System.out.println();
+
+ ifail = 0;
+ C02AG c02ag = new C02AG();
+ double[] z1d = convert2DTo1D(z);
+ c02ag.eval(a, n, scal, z1d, w, ifail);
+
+ z = convert1DTo2D(z1d, 2);
+
+ System.out.println(" Computed roots of polynomial");
+ System.out.println();
+
+ nroot = 0;
+
+ while (nroot < n) {
+ zr = z[0][nroot];
+ zi = z[1][nroot];
+ if (zi == 0.0E0) {
+ System.out.printf(" z = %12.4E\n", zr);
+ nroot += 1;
+ } else {
+ System.out.printf(" z = %12.4E +/- %12.4E*i\n", zr, Math.abs(zi));
+ nroot += 2;
+ }
+ }
+ }
+
+ public static void ex2(String[] args) {
+
+ double deltac, deltai, di, eps, epsbar, f, r1, r2, r3, rmax;
+ int i, ifail, j, jmin = 0, n = 0;
+
+ double[] a = null, abar = null, r = null, w = null;
+ double[][] z = null, zbar = null;
+ int[] m = null;
+
+ System.out.println("\n\n Example 2");
+
+ // Specify path to data file
+ if (args.length != 1) {
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+
+ // Skip heading and previous example in data file
+ for (i = 0; i < 7; i++) {
+ reader.readLine();
+ }
+
+ String line = reader.readLine();
+ String[] sVal = line.trim().split("\\s+");
+ n = Integer.parseInt(sVal[0]);
+
+ a = new double[n+1];
+ abar = new double[n+1];
+ r = new double[n];
+ w = new double[2 * (n+1)];
+ z = new double[2][n];
+ zbar = new double[2][n];
+ m = new int[n];
+
+ // Read in the coefficients of the original polynomial.
+ line = reader.readLine();
+ sVal = line.trim().split("\\s+");
+ for (i = 0; i <= n; i++) {
+ a[i] = Double.parseDouble(sVal[i]);
+ }
+
+ } catch (FileNotFoundException e) {
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ } catch (IOException e) {
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+
+ // Compute the roots of the original polynomial.
+ ifail = 0;
+ C02AG c02ag = new C02AG();
+ double[] z1d = convert2DTo1D(z);
+ c02ag.eval(a, n, scal, z1d ,w, ifail);
+
+ z = convert1DTo2D(z1d, 2);
+
+ // Form the coefficients of the perturbed polynomial.
+ X02AJ x02aj = new X02AJ();
+ eps = x02aj.eval();
+ epsbar= 3.0 * eps;
+
+ for (i = 0; i <= n; i++) {
+ if (a[i] != 0.0) {
+ f = 1.0 + epsbar;
+ epsbar = -epsbar;
+ abar[i] = f * a[i];
+ } else {
+ abar[i] = 0.0E0;
+ }
+ }
+
+ // Compute the roots of the perturbed polynomial.
+ ifail = 0;
+ double[] zbar1d = convert2DTo1D(zbar);
+ c02ag.eval(abar, n, scal, zbar1d, w, ifail);
+
+ zbar = convert1DTo2D(zbar1d, 2);
+
+ // Perform error analysis.
+
+ // Initialize markers to 0 (unmarked).
+ Arrays.fill(m, 0);
+
+ X02AL x02al = new X02AL();
+ rmax = x02al.eval();
+
+ // Loop over all unperturbed roots (stored in Z).
+ A02AB a02ab = new A02AB();
+ for (i = 0; i < n; i++) {
+ deltai = rmax;
+ r1 = a02ab.eval(z[0][i], z[1][i]);
+
+ // Loop over all perturbed roots (stored in ZBAR).
+ for (j = 0; j < n; j++) {
+ // Compare the current unperturbed root to all unmarked
+ // perturbed roots.
+
+ if (m[j] == 0) {
+ r2 = a02ab.eval(zbar[0][i], zbar[1][i]);
+ deltac = Math.abs(r1-r2);
+
+ if (deltac < deltai) {
+ deltai = deltac;
+ jmin = j;
+ }
+ }
+ }
+
+ // Mark the selected perturbed root.
+ m[jmin] = 1;
+
+ // Compute the relative error.
+ if (r1 != 0.0E0) {
+ r3 = a02ab.eval(zbar[0][jmin], zbar[1][jmin]);
+ di = Math.min(r1, r3);
+ r[i] = Math.max(deltai / Math.max(di, deltai / rmax), eps);
+ } else {
+ r[i] = 0.0;
+ }
+ }
+
+ System.out.println();
+ System.out.printf(" Degree of polynomial = %4d\n", n);
+ System.out.println();
+ System.out.println(" Computed roots of polynomial Error estimates");
+ System.out.println(" (machine-dependent)");
+ System.out.println();
+
+ for (i = 0; i < n; i++) {
+ System.out.printf(" z = %12.4E%+12.4E*i %9.1E\n", z[0][i], z[1][i], r[i]);
+ }
+ }
+
+ public static double[] convert2DTo1D(double[][] a) {
+ double[] b = new double[a.length * a[0].length];
+ int n = a.length;
+
+ for (int i = 0; i < a.length; i++) {
+ for (int j = 0; j < a[0].length; j++) {
+ b[i + j * n] = a[i][j];
+ }
+ }
+
+ return b;
+ }
+
+ public static double[][] convert1DTo2D(double[] a, int n) {
+ double[][] b = new double[n][a.length / n];
+
+ for (int i = 0; i < b.length; i++) {
+ for (int j = 0; j < b[0].length; j++) {
+ b[i][j] = a[i + j * n];
+ }
+ }
+
+ return b;
+ }
+}
diff --git a/simple_examples/source/int32/C02AHJE.java b/simple_examples/source/int32/C02AHJE.java
new file mode 100644
index 0000000..b1e12cd
--- /dev/null
+++ b/simple_examples/source/int32/C02AHJE.java
@@ -0,0 +1,61 @@
+import com.nag.routines.C02.C02AH;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+/**
+ * C02AH
+ */
+public class C02AHJE {
+
+ public static void main(String[] args) {
+
+ double ai = 0, ar = 0, bi = 0, br = 0, ci = 0, cr = 0;
+ int ifail;
+
+ double[] zlg = new double[2];
+ double[] zsm = new double[2];
+
+ System.out.println(" C02AHJ Example Program Results");
+
+ // Specify path to data file
+ if (args.length != 1) {
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+ reader.readLine(); // Skip heading in data file
+
+ String line = reader.readLine();
+ String[] sVal = line.trim().split("\\s+");
+ ar = Double.parseDouble(sVal[0]);
+ ai = Double.parseDouble(sVal[1]);
+ br = Double.parseDouble(sVal[2]);
+ bi = Double.parseDouble(sVal[3]);
+ cr = Double.parseDouble(sVal[4]);
+ ci = Double.parseDouble(sVal[5]);
+
+ } catch (FileNotFoundException e) {
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ } catch (IOException e) {
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+
+ ifail = -1;
+ C02AH c02ah = new C02AH();
+ c02ah.eval(ar, ai, br, bi, cr, ci, zsm, zlg, ifail);
+ ifail = c02ah.getIFAIL();
+
+ if (ifail == 0) {
+ System.out.println("\n Roots of quadratic equation\n");
+ System.out.printf(" z = %12.4E%+14.4E*i\n", zsm[0], zsm[1]);
+ System.out.printf(" z = %12.4E%+14.4E*i\n", zlg[0], zlg[1]);
+ }
+ }
+}
diff --git a/simple_examples/source/int32/C02AJJE.java b/simple_examples/source/int32/C02AJJE.java
new file mode 100644
index 0000000..64e3a5e
--- /dev/null
+++ b/simple_examples/source/int32/C02AJJE.java
@@ -0,0 +1,65 @@
+import com.nag.routines.C02.C02AJ;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+/**
+ * C02AJ
+ */
+public class C02AJJE {
+
+ public static void main(String[] args) {
+
+ double a = 0, b = 0, c = 0;
+ int ifail;
+
+ double[] zlg = new double[2];
+ double[] zsm = new double[2];
+
+ System.out.println(" C02AJJ Example Program Results");
+
+ // Specify path to data file
+ if (args.length != 1) {
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+ reader.readLine(); // Skip heading in data file
+
+ String line = reader.readLine();
+ String[] sVal = line.trim().split("\\s+");
+ a = Double.parseDouble(sVal[0]);
+ b = Double.parseDouble(sVal[1]);
+ c = Double.parseDouble(sVal[2]);
+
+ } catch (FileNotFoundException e) {
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ } catch (IOException e) {
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+
+ ifail = -1;
+ C02AJ c02aj = new C02AJ();
+ c02aj.eval(a, b, c, zsm, zlg, ifail);
+ ifail = c02aj.getIFAIL();
+
+ if (ifail == 0) {
+ System.out.println("\n Roots of quadratic equation\n");
+
+ if (zsm[1] == 0.0E0) {
+ // 2 real roots.
+ System.out.printf(" z = %12.4E\n", zsm[0]);
+ System.out.printf(" z = %12.4E\n", zlg[0]);
+ } else {
+ // 2 complex roots.
+ System.out.printf(" z = %12.4E +/- %12.4E*i", zsm[0], Math.abs(zsm[1]));
+ }
+ }
+ }
+}
diff --git a/simple_examples/source/int32/C02AKJE.java b/simple_examples/source/int32/C02AKJE.java
new file mode 100644
index 0000000..4a0579f
--- /dev/null
+++ b/simple_examples/source/int32/C02AKJE.java
@@ -0,0 +1,62 @@
+import com.nag.routines.C02.C02AK;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+/**
+ * C02AK
+ */
+public class C02AKJE {
+
+ public static void main(String[] args) {
+
+ double r = 0, s = 0, t = 0, u = 0;
+ int i, ifail;
+
+ double[] errest = new double[3];
+ double[] zeroi = new double[3];
+ double[] zeror = new double[3];
+
+ System.out.println(" C02AKJ Example Program Results");
+
+ // Specify path to data file
+ if (args.length != 1) {
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+ reader.readLine(); // Skip heading in data file
+
+ String line = reader.readLine();
+ String[] sVal = line.trim().split("\\s+");
+ u = Double.parseDouble(sVal[0]);
+ r = Double.parseDouble(sVal[1]);
+ s = Double.parseDouble(sVal[2]);
+ t = Double.parseDouble(sVal[3]);
+
+ } catch (FileNotFoundException e) {
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ } catch (IOException e) {
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+
+ ifail = 0;
+ C02AK c02ak = new C02AK();
+ c02ak.eval(u, r, s, t, zeror, zeroi, errest, ifail);
+
+ System.out.println();
+ System.out.println(" Roots of cubic equation Error estimates");
+ System.out.println(" (machine-dependent)");
+ System.out.println();
+
+ for (i = 0; i < 3; i++) {
+ System.out.printf(" z = %12.4E%+12.4E*i %9.1E\n", zeror[i], zeroi[i], errest[i]);
+ }
+ }
+}
diff --git a/simple_examples/source/int32/C02ALJE.java b/simple_examples/source/int32/C02ALJE.java
new file mode 100644
index 0000000..4f9eac9
--- /dev/null
+++ b/simple_examples/source/int32/C02ALJE.java
@@ -0,0 +1,64 @@
+import com.nag.routines.C02.C02AL;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+/**
+ * C02AL
+ */
+public class C02ALJE {
+
+ public static void main(String[] args) {
+
+ double a = 0, b = 0, c = 0, d = 0, e = 0;
+ int i, ifail;
+
+ double[] errest = new double[4];
+ double[] zeroi = new double[4];
+ double[] zeror = new double[4];
+
+ System.out.println(" C02ALJ Example Program Results");
+
+ // Specify path to data file
+ if (args.length != 1) {
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+ reader.readLine(); // Skip heading in data file
+
+ String line = reader.readLine();
+ String[] sVal = line.trim().split("\\s+");
+ e = Double.parseDouble(sVal[0]);
+ a = Double.parseDouble(sVal[1]);
+ b = Double.parseDouble(sVal[2]);
+ c = Double.parseDouble(sVal[3]);
+ d = Double.parseDouble(sVal[4]);
+
+ } catch (FileNotFoundException e_exception) {
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ } catch (IOException e_exception) {
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e_exception.getMessage());
+ }
+
+ ifail = 0;
+ C02AL c02al = new C02AL();
+ c02al.eval(e, a, b, c, d, zeror, zeroi, errest, ifail);
+ ifail = c02al.getIFAIL();
+
+ System.out.println();
+ System.out.println(" Roots of quartic equation Error estimates");
+ System.out.println(" (machine-dependent)");
+ System.out.println();
+
+ for (i = 0; i < 4; i++) {
+ System.out.printf(" z = %12.4E%+12.4E*i %9.1E\n", zeror[i], zeroi[i], errest[i]);
+ }
+ }
+}
diff --git a/simple_examples/source/int32/C02AMJE.java b/simple_examples/source/int32/C02AMJE.java
new file mode 100644
index 0000000..f1fffa4
--- /dev/null
+++ b/simple_examples/source/int32/C02AMJE.java
@@ -0,0 +1,75 @@
+import com.nag.routines.C02.C02AM;
+import com.nag.routines.Routine;
+import com.nag.types.NAGComplex;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+/**
+ * C02AM
+ */
+public class C02AMJE {
+
+ public static void main(String[] args) {
+
+ Routine.setComplex(new NAGComplex());
+
+ NAGComplex r = null, s = null, t = null, u = null;
+ int i, ifail;
+
+ double[] errest = new double[3];
+ double[] zeroi = new double[3];
+ double[] zeror = new double[3];
+
+ System.out.println(" C02AMJ Example Program Results");
+
+ // Specify path to data file
+ if (args.length != 1) {
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+ reader.readLine(); // Skip heading in data file
+
+ String line = reader.readLine().replaceAll("[(),]", "");
+ String[] sVal = line.trim().split("\\s+");
+ u = new NAGComplex(Double.parseDouble(sVal[0]), Double.parseDouble(sVal[1]));
+
+ line = reader.readLine().replaceAll("[(),]", "");
+ sVal = line.trim().split("\\s+");
+ r = new NAGComplex(Double.parseDouble(sVal[0]), Double.parseDouble(sVal[1]));
+
+ line = reader.readLine().replaceAll("[(),]", "");
+ sVal = line.trim().split("\\s+");
+ s = new NAGComplex(Double.parseDouble(sVal[0]), Double.parseDouble(sVal[1]));
+
+ line = reader.readLine().replaceAll("[(),]", "");
+ sVal = line.trim().split("\\s+");
+ t = new NAGComplex(Double.parseDouble(sVal[0]), Double.parseDouble(sVal[1]));
+
+ } catch (FileNotFoundException e) {
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ } catch (IOException e) {
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+
+ ifail = 0;
+ C02AM c02am = new C02AM();
+ c02am.eval(u, r, s, t, zeror, zeroi, errest, ifail);
+
+ System.out.println();
+ System.out.println(" Roots of cubic equation Error estimates");
+ System.out.println(" (machine-dependent)");
+ System.out.println();
+
+ for (i = 0; i < 3; i++) {
+ System.out.printf(" z = %12.4E%+12.4E*i %9.1E\n", zeror[i], zeroi[i], errest[i]);
+ }
+ }
+}
diff --git a/simple_examples/source/int32/C02ANJE.java b/simple_examples/source/int32/C02ANJE.java
new file mode 100644
index 0000000..dc865e2
--- /dev/null
+++ b/simple_examples/source/int32/C02ANJE.java
@@ -0,0 +1,80 @@
+import com.nag.routines.C02.C02AN;
+import com.nag.routines.Routine;
+import com.nag.types.NAGComplex;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+/**
+ * C02AN
+ */
+public class C02ANJE {
+
+ public static void main(String[] args) {
+
+ Routine.setComplex(new NAGComplex());
+
+ NAGComplex a = null, b = null, c = null, d = null, e = null;
+ int i, ifail;
+
+ double[] errest = new double[4];
+ double[] zeroi = new double[4];
+ double[] zeror = new double[4];
+
+ System.out.println(" C02ANJ Example Program Results");
+
+ // Specify path to data file
+ if (args.length != 1) {
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+ reader.readLine(); // Skip heading in data file
+
+ String line = reader.readLine().replaceAll("[(),]", "");
+ String[] sVal = line.trim().split("\\s+");
+ e = new NAGComplex(Double.parseDouble(sVal[0]), Double.parseDouble(sVal[1]));
+
+ line = reader.readLine().replaceAll("[(),]", "");
+ sVal = line.trim().split("\\s+");
+ a = new NAGComplex(Double.parseDouble(sVal[0]), Double.parseDouble(sVal[1]));
+
+ line = reader.readLine().replaceAll("[(),]", "");
+ sVal = line.trim().split("\\s+");
+ b = new NAGComplex(Double.parseDouble(sVal[0]), Double.parseDouble(sVal[1]));
+
+ line = reader.readLine().replaceAll("[(),]", "");
+ sVal = line.trim().split("\\s+");
+ c = new NAGComplex(Double.parseDouble(sVal[0]), Double.parseDouble(sVal[1]));
+
+ line = reader.readLine().replaceAll("[(),]", "");
+ sVal = line.trim().split("\\s+");
+ d = new NAGComplex(Double.parseDouble(sVal[0]), Double.parseDouble(sVal[1]));
+
+ } catch (FileNotFoundException e_exception) {
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ } catch (IOException e_exception) {
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e_exception.getMessage());
+ }
+
+ ifail = 0;
+ C02AN c02an = new C02AN();
+ c02an.eval(e, a, b, c, d, zeror, zeroi, errest, ifail);
+ ifail = c02an.getIFAIL();
+
+ System.out.println();
+ System.out.println(" Roots of quartic equation Error estimates");
+ System.out.println(" (machine-dependent)");
+ System.out.println();
+
+ for (i = 0; i < 4; i++) {
+ System.out.printf(" z = %12.4E%+12.4E*i %9.1E\n", zeror[i], zeroi[i], errest[i]);
+ }
+ }
+}
diff --git a/simple_examples/source/int32/C05AUJE.java b/simple_examples/source/int32/C05AUJE.java
new file mode 100644
index 0000000..d2b09b1
--- /dev/null
+++ b/simple_examples/source/int32/C05AUJE.java
@@ -0,0 +1,67 @@
+import com.nag.routines.C05.C05AU;
+
+/**
+ * C05AUJ example program text.
+ * @author willa
+ * @since 27.1.0.0
+ */
+public class C05AUJE{
+
+ /**
+ * C05AUJ main program
+ */
+ public static void main(String[] args){
+ double a = 0, b = 0, eps, eta, h, x; //placeholders
+ int ifail;
+ double[] ruser;
+ int[] iuser;
+
+ ruser = new double[1]; //need to initialise before passing to wrapper
+ iuser = new int[1];
+
+ System.out.println("C05AUJ Example Program Results");
+
+ x = 1;
+ h = 0.1;
+ eps = 0.00001;
+ eta = 0;
+
+ //Instance of class f to pass to wrapper
+ f f1 = new f();
+
+ ifail = -1;
+ C05AU c05au = new C05AU(x, h, eps, eta, f1, a, b, iuser, ruser, ifail);
+ c05au.eval();
+
+ //update values
+ x = c05au.getX();
+ a = c05au.getA();
+ b = c05au.getB();
+ ifail = c05au.getIFAIL();
+
+ System.out.println();
+
+ switch(ifail){
+ case 0:
+ System.out.printf("Root is : \t%.5f\n", x);
+ System.out.printf("Interval searched is : \t[ %.5f, %.5f]\n", a, b);
+ break;
+ case 3:
+ case 4:
+ System.out.printf("Final value = %.5f\n", x);
+ break;
+ }
+ }
+
+ /**
+ * Extends abstract class C05AU.Abstract_C05AU_F. eval() returns the value of the function at a given x.
+ * eval() must be implemented by the user.
+ * @return x - e^x
+ */
+ public static class f extends C05AU.Abstract_C05AU_F{
+ public double eval(){
+ return(this.X - Math.exp(-this.X));
+ }
+ }
+}
+
diff --git a/simple_examples/source/int32/C05AWJE.java b/simple_examples/source/int32/C05AWJE.java
new file mode 100644
index 0000000..6ea3c9f
--- /dev/null
+++ b/simple_examples/source/int32/C05AWJE.java
@@ -0,0 +1,59 @@
+import com.nag.routines.C05.C05AW;
+
+public class C05AWJE{
+
+ public static void main(String[] args){
+ double eps, eta, x;
+ int ifail, nfmax;
+ double[] ruser;
+ int[] iuser;
+
+ ruser = new double[1];
+ iuser = new int[1];
+
+ System.out.println("C05AWJ Example Program Results");
+ System.out.println();
+
+ boolean finished = false;
+ for(int i = 3; i <= 4; i++){
+ eps = Math.pow(10, -i);
+ x = 1;
+ eta = 0;
+ nfmax = 200;
+
+ ifail = -1;
+ f f1 = new f();
+ C05AW c05aw = new C05AW(x, eps, eta, f1, nfmax, iuser, ruser, ifail);
+ c05aw.eval();
+
+ ifail = c05aw.getIFAIL();
+ x = c05aw.getX();
+ eps = c05aw.getEPS();
+
+ switch(ifail){
+ case(0):
+ System.out.printf("With eps = %.2e root = %.5f\n", eps, x);
+ break;
+ case(-1):
+ //exit loop
+ finished = true;
+ break;
+ case(3):
+ case(4):
+ System.out.printf("With eps = %.2e root = %.5f\n", eps, x);
+ break;
+ }
+ if(finished){
+ break;
+ }
+ }
+ }
+
+ public static class f extends C05AW.Abstract_C05AW_F{
+ public double eval(){
+ return(Math.exp(-X) - X);
+ }
+ }
+}
+
+
diff --git a/simple_examples/source/int32/C05AYJE.java b/simple_examples/source/int32/C05AYJE.java
new file mode 100644
index 0000000..c9ee43b
--- /dev/null
+++ b/simple_examples/source/int32/C05AYJE.java
@@ -0,0 +1,44 @@
+import com.nag.routines.C05.C05AY;
+
+/**
+ * C05AY example program text.
+ */
+public class C05AYJE {
+
+ public static void main(String[] args) {
+
+ C05AY c05ay = new C05AY();
+ OBJFUN f = new OBJFUN();
+ double a = 0.0, b = 1.0, eps = 1.0e-5, eta = 0.0, x = 0.0;
+ int ifail = 0;
+ int[] iuser = new int[1];
+ double[] ruser = new double[1];
+
+ System.out.println("C05AYJ Example Program Results");
+ System.out.println();
+
+ c05ay.eval(a, b, eps, eta, f, x, iuser, ruser, ifail);
+ x = c05ay.getX();
+
+ switch (ifail) {
+ case 0:
+ System.out.printf("Zero at x = %12.5f\n", x);
+ break;
+ case 2: case 3:
+ System.out.printf("Final point = %12.5f\n", x);
+ break;
+ default:
+ System.out.println("Unexpected ifail = " + ifail);
+ }
+
+ }
+
+ private static class OBJFUN extends C05AY.Abstract_C05AY_F {
+
+ public double eval() {
+ return Math.exp(-X) - X;
+ }
+
+ }
+
+}
diff --git a/simple_examples/source/int32/C05AZJE.java b/simple_examples/source/int32/C05AZJE.java
new file mode 100644
index 0000000..7c3e27e
--- /dev/null
+++ b/simple_examples/source/int32/C05AZJE.java
@@ -0,0 +1,65 @@
+import com.nag.routines.C05.C05AZ;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * C05AZ example program text.
+ */
+public class C05AZJE {
+
+ public static void main(String[] args) {
+ double tolx = 0.00001, x = 0.0, y = 1.0, fx;
+ int ir = 0, ind = 1, ifail = -1;
+ double[] c = new double[17];
+ boolean keepOn = true;
+
+
+ C05AZ c05az = new C05AZ();
+ fx = fun(x);
+ int ite = 0;
+
+ System.out.println(" C05AZJ Example Program Results\n");
+ System.out.println(" Iterations\n");
+
+ while (keepOn) {
+ ++ite;
+
+ c05az.eval(x,y,fx,tolx,ir,c,ind,ifail);
+
+ x = c05az.getX();
+ y = c05az.getY();
+ tolx = c05az.getTOLX();
+ ir = c05az.getIR();
+ ind = c05az.getIND();
+ ifail = c05az.getIFAIL();
+ if (ind == 0) {
+ keepOn = false;
+ }
+ else {
+ fx = fun(x);
+ System.out.printf(" X = %7.5f FX = %11.4E IND = %1d\n", x, fx, ind);
+ }
+
+ }
+
+ switch (ifail) {
+ case 0:
+ System.out.println("\n Solution\n");
+ System.out.printf(" X = %8.5f Y = %8.5f\n",x,y);
+ break;
+ case 4:
+ case 5:
+ System.out.printf(" X = %8.5f Y = %8.5f\n",x,y);
+ break;
+ default:
+ System.out.printf("Unexpected error ifail=%d\n",ifail);
+ }
+
+ }
+
+ private static double fun(double x) {
+ double res = (Math.expm1(-x) + 1) - x;
+ return res;
+ }
+
+}
diff --git a/simple_examples/source/int32/C05BBJE.java b/simple_examples/source/int32/C05BBJE.java
new file mode 100644
index 0000000..4723773
--- /dev/null
+++ b/simple_examples/source/int32/C05BBJE.java
@@ -0,0 +1,89 @@
+import com.nag.routines.C05.C05BB;
+import com.nag.types.NAGComplex;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+/**
+ * C05BBJ Example program text.
+ * @author willa
+ * @since 27.1.0.0
+ */
+public class C05BBJE{
+
+ /**
+ * C05BBJE main program text
+ */
+ public static void main(String[] args){
+ NAGComplex w, z;
+ double resid = 0;
+ int branch = 0, ifail = 0; //placeholder
+ boolean offset = false; //placeholder
+
+ //need to initialise first
+ z = new NAGComplex();
+ w = new NAGComplex();
+
+ System.out.println("C05BBJ Example Program Results");
+
+ if(args.length != 1){
+ System.out.println("Please specify path to data file as input");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try{
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+ String line = reader.readLine(); //skip header
+
+ line = reader.readLine();
+ String[] sVal = line.split("\\s+");
+ branch = Integer.parseInt(sVal[0]);
+
+ line = reader.readLine();
+ sVal = line.split("\\s+");
+ offset = Boolean.parseBoolean(sVal[0]);
+
+ System.out.printf("Branch = %d\n", branch);
+ System.out.printf("Offset = %b\n", offset);
+
+ System.out.println();
+ System.out.printf("\t\tZ\t\t\tW(Z)\t\t\t\tRESID\tIFAIL\n");
+ System.out.println();
+
+ while(true){
+ line = reader.readLine();
+ if(line == null){
+ break;
+ }
+ sVal = line.split("\\s+");
+
+ z.setRe(Double.parseDouble(sVal[0]));
+ z.setIm(Double.parseDouble(sVal[1]));
+
+ ifail = -1;
+ C05BB c05bb = new C05BB(branch, offset, z, w, resid, ifail);
+ c05bb.eval();
+
+ z = (NAGComplex) c05bb.getZ();
+ w = (NAGComplex) c05bb.getW();
+ resid = c05bb.getRESID();
+ ifail = c05bb.getIFAIL();
+
+ if(ifail < 0){
+ break;
+ }
+
+ System.out.printf("(%.5e, %.5e)\t (%.5e, %.5e)\t %.5e\t %d\n", z.getRe(), z.getIm(), w.getRe(), w.getIm(), resid, ifail);
+ }
+ }
+ catch(FileNotFoundException e){
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ }
+ catch(IOException e){
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+ }
+}
diff --git a/simple_examples/source/int32/C05MBJE.java b/simple_examples/source/int32/C05MBJE.java
new file mode 100644
index 0000000..9b46ff5
--- /dev/null
+++ b/simple_examples/source/int32/C05MBJE.java
@@ -0,0 +1,95 @@
+import com.nag.routines.C05.C05MB;
+import com.nag.routines.F06.DNRM2;
+import com.nag.routines.X02.X02AJ;
+
+/**
+ * C05MBJ example program text.
+ *
+ * @author joed
+ * @since 27.0.0.0
+ *
+ */
+public class C05MBJE {
+
+ private static final int n = 4;
+
+ private static class FCN extends C05MB.Abstract_C05MB_FCN {
+
+ public void eval() {
+
+ FVEC[0] = Math.cos(X[2]) - X[0];
+ FVEC[1] = Math.sqrt(1.0 - Math.pow(X[3],2)) - X[1];
+ FVEC[2] = Math.sin(X[0]) - X[2];
+ FVEC[3] = Math.pow(X[1], 2) - X[3];
+
+ // Set iflag negative to terminate execution for any reason
+ IFLAG = 0;
+
+ return;
+
+ }
+
+ }
+
+ /**
+ * C05MBJ example main program.
+ */
+ public static void main(String[] args) {
+
+ C05MB c05mb = new C05MB();
+ DNRM2 dnrm2 = new DNRM2();
+ X02AJ x02aj = new X02AJ();
+ FCN fcn = new FCN();
+ long cpuser;
+ double atol, cndtol, fnorm, machpr, rtol;
+ int astart, i, ifail, m;
+ double[] fvec, x;
+ double[] ruser = new double[1];
+ int[] iuser = new int[1];
+
+ System.out.println("C05MBJ Example Program Results\n");
+
+ // Get machine precision from X02AJ
+ machpr = (new X02AJ()).eval();
+
+ fvec = new double[n];
+ x = new double[n];
+
+ // The following starting values provide a rough solution
+ x = new double[]{2.0, 0.5, 2.0, 0.5};
+
+ m = 2;
+ atol = Math.sqrt(machpr);
+ rtol = Math.sqrt(machpr);
+ cndtol = 0.0;
+ astart = 0;
+ cpuser = 0;
+
+ ifail = -1;
+ c05mb.eval(fcn, n, x, fvec, atol, rtol, m, cndtol, astart, iuser, ruser,
+ cpuser, ifail);
+ ifail = c05mb.getIFAIL();
+
+ if (ifail == 0 || ifail == 8 || ifail == 9) {
+ if (ifail == 0) {
+ // The NAG name equivalent of dnrm2 is f06ej
+ fnorm = dnrm2.eval(n, fvec, 1);
+ System.out.println();
+ System.out.printf("Final 2-norm of the residuals = %12.4e\n", fnorm);
+ System.out.println();
+ System.out.println("Final approximate solution");
+ }
+ else {
+ System.out.println();
+ System.out.println("Approximate solution");
+ }
+ System.out.println();
+ for (i = 1; i <= n; i++) {
+ System.out.printf("%12.4f", x[i-1]);
+ }
+ System.out.printf("\n");
+ }
+
+ }
+
+}
diff --git a/simple_examples/source/int32/C05QBJE.java b/simple_examples/source/int32/C05QBJE.java
new file mode 100644
index 0000000..4b93405
--- /dev/null
+++ b/simple_examples/source/int32/C05QBJE.java
@@ -0,0 +1,167 @@
+import com.nag.routines.C05.C05QB;
+import com.nag.routines.F06.DNRM2;
+import com.nag.routines.X02.X02AJ;
+
+/**
+ * C05QB example program text.
+ * @author ludovic
+ */
+public class C05QBJE {
+
+ public static void main(String[] args) {
+
+ C05QB c05qb = new C05QB();
+
+ System.out.println(" C05QBJ Example Program Results");
+
+ int n = 9, ifail = -1;
+
+ double xtol, fnorm;
+
+ int[] IUSER = new int[1];
+ double[] fvec = new double[n];
+ double[] x = new double[n];
+ double[] RUSER = new double[1];
+
+
+ FCN fcn = new FCN();
+
+ for (int i = 0; i < n; ++i) {
+ x[i] = -1.0;
+ }
+ xtol = Math.sqrt((new X02AJ()).eval());
+
+ c05qb.eval(fcn, n, x, fvec, xtol, IUSER, RUSER, ifail);
+
+ ifail = c05qb.getIFAIL();
+
+ switch (ifail) {
+ case (0):
+ fnorm = (new DNRM2(n, fvec, 1)).eval();
+ System.out.println();
+ System.out.printf(" Final 2-norm of the residuals = %11.4E\n", fnorm);
+ System.out.println();
+ System.out.println(" Final approximate solution");
+ int count = 0;
+ for (int i = 0; i < n; ++i) {
+ System.out.printf(" %12.4f", x[i]);
+ ++count;
+ if (count == 3) {
+ System.out.println();
+ count = 0;
+ }
+ }
+ break;
+ case (2):
+ case (3):
+ case (4):
+ System.out.println("Approximate solution");
+ count = 0;
+ for (int i = 0; i < n; ++i) {
+ System.out.printf(" %12.4f", x[i]);
+ ++count;
+ if (count == 3) {
+ System.out.println();
+ count = 0;
+ }
+ }
+ break;
+ }
+
+ }
+
+ public static class FCN implements C05QB.C05QB_FCN {
+
+ private int N, IFLAG;
+ private double[] X, FVEC, RUSER;
+ private int[] IUSER;
+
+ @Override
+ public void setN(int N) {
+ this.N = N;
+ }
+
+ @Override
+ public int getN() {
+ return N;
+ }
+
+ @Override
+ public void setX(double[] X) {
+ this.X = X;
+ }
+
+ @Override
+ public double[] getX() {
+ return X;
+ }
+
+ @Override
+ public void setFVEC(double[] FVEC) {
+ this.FVEC = FVEC;
+ }
+
+ @Override
+ public double[] getFVEC() {
+ return FVEC;
+ }
+
+ @Override
+ public void setIUSER(int[] IUSER) {
+ this.IUSER = IUSER;
+ }
+
+ @Override
+ public int[] getIUSER() {
+ return IUSER;
+ }
+
+ @Override
+ public void setRUSER(double[] RUSER) {
+ this.RUSER = RUSER;
+ }
+
+ @Override
+ public double[] getRUSER() {
+ return RUSER;
+ }
+
+ @Override
+ public void setIFLAG(int IFLAG) {
+ this.IFLAG = IFLAG;
+ }
+
+ @Override
+ public int getIFLAG() {
+ return IFLAG;
+ }
+
+ @Override
+ public void eval(int N, double[] X, double[] FVEC, int[] IUSER, double[] RUSER, int IFLAG) {
+
+ /*
+ * fvec(1:n) = (3.0_nag_wp-2.0_nag_wp*x(1:n))*x(1:n) + 1.0_nag_wp
+ * fvec(2:n) = fvec(2:n) - x(1:(n-1))
+ * fvec(1:(n-1)) = fvec(1:(n-1)) - 2.0_nag_wp*x(2:n)
+ */
+ for (int i = 0; i < N; ++i) {
+ FVEC[i] = (3.0 - 2.0 * X[i]) * X[i] + 1.0;
+ /*if (i >= 1) {
+ FVEC[i] = FVEC[i] - X[i - 1];
+ }
+ if (i < N - 1) {
+ FVEC[i] = FVEC[i] - 2.0 * X[i + 1];
+ }*/
+ }
+ for (int i = 1; i < N; ++i) {
+ FVEC[i] = FVEC[i] - X[i - 1];
+ }
+ for (int i = 0; i < N-1; ++i) {
+ FVEC[i] = FVEC[i] - 2.0 * X[i + 1];
+ }
+
+ }
+
+ }
+
+}
diff --git a/simple_examples/source/int32/C06BAJE.java b/simple_examples/source/int32/C06BAJE.java
new file mode 100644
index 0000000..541d4d3
--- /dev/null
+++ b/simple_examples/source/int32/C06BAJE.java
@@ -0,0 +1,56 @@
+import com.nag.routines.C06.C06BA;
+import com.nag.routines.X01.X01AA;
+
+/**
+ * C06BAJ example program text.
+ * @author willa
+ */
+public class C06BAJE{
+
+ public static void main(String[] args){
+ int lwork = 16, nout = 6;
+ int ifail, ncall;
+ double abserr = 0.0, ans, error, pi = 0.0, r, result = 0.0, seqn, sig;
+ double[] work;
+
+ C06BA c06ba = new C06BA();
+ work = new double[lwork];
+
+ System.out.println("C06BAJ Example Program Results");
+ System.out.println();
+
+ X01AA x01aa = new X01AA(pi);
+ pi = x01aa.eval();
+
+ ans = Math.pow(pi, 2)/12.0;
+ ncall = 0;
+ sig = 1.0;
+ seqn = 0.0;
+ System.out.println("\t\t\t Estimated\t Actual");
+ System.out.println("I\t SEQN \t RESULT\t abs error\t error");
+ System.out.println();
+
+ for(int i = 0; i < 10; i++){
+ r = (double) i + 1;
+ seqn = seqn + sig/Math.pow(r, 2);
+
+ ifail = 0;
+ c06ba.eval(seqn, ncall, result, abserr, work, lwork, ifail);
+
+ //update variables
+ ncall = c06ba.getNCALL();
+ result = c06ba.getRESULT();
+ abserr = c06ba.getABSERR();
+
+ error = result - ans;
+ sig = -sig;
+
+ if(i <= 2){
+ System.out.printf("%d\t %.4f\t %.4f\t -\t\t %.2e\n", (i + 1), seqn, result, error);
+ }
+ else{
+ System.out.printf("%d\t %.4f\t %.4f\t %.2e\t %.2e\n", (i + 1), seqn, result, abserr, error);
+ }
+ }
+ }
+}
diff --git a/simple_examples/source/int32/C06FKJE.java b/simple_examples/source/int32/C06FKJE.java
new file mode 100644
index 0000000..58db62f
--- /dev/null
+++ b/simple_examples/source/int32/C06FKJE.java
@@ -0,0 +1,91 @@
+import com.nag.routines.C06.C06FK;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+/**
+ * C06FKJ example program text
+ * @author willa
+ * @since 27.1.0.0
+ */
+public class C06FKJE{
+
+ /**
+ * C06FKJE main program
+ */
+ public static void main(String[] args){
+ int ifail = 0, n = 0; //placeholder
+ double[] work, xa, xb, ya, yb;
+
+ work = new double[0];
+ xa = new double[0];
+ xb = new double[0];
+ ya = new double[0];
+ yb = new double[0]; //placeholders
+
+ System.out.println("C06FKJ Example Program Results");
+ System.out.println();
+
+ //Supply file path as argument
+ if(args.length != 1){
+ System.out.println("Please specify path to data file");
+ System.exit(-1);
+ }
+
+ String filename = args[0];
+ try{
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+ String line = reader.readLine(); //skip header
+
+ //Loop until break...
+ while(true){
+ line = reader.readLine();
+ //Break when the end of the file is reached
+ if(line == null){
+ break;
+ }
+ String[] sVal = line.split("\\s+");
+ n = Integer.parseInt(sVal[0]);
+
+ work = new double[n];
+ xa = new double[n];
+ xb = new double[n];
+ ya = new double[n];
+ yb = new double[n];
+
+ for(int i = 0; i < n; i++){
+ line = reader.readLine();
+ sVal = line.split("\\s+");
+ xa[i] = Double.parseDouble(sVal[0]);
+ xb[i] = xa[i];
+ ya[i] = Double.parseDouble(sVal[1]);
+ yb[i] = ya[i];
+ }
+
+ ifail = 0;
+
+ C06FK c06fk1 = new C06FK(1, xa, ya, n, work, ifail);
+ c06fk1.eval();
+ xa = c06fk1.getX();
+ C06FK c06fk2 = new C06FK(2, xb, yb, n, work, ifail);
+ c06fk2.eval();
+ xb = c06fk2.getX();
+
+ System.out.printf("\tCovolution \tCorrelation\n");
+ System.out.println();
+
+ for(int i = 0; i < n; i++){
+ System.out.printf("%d\t%.5f\t\t%.5f\n", i, xa[i], xb[i]);
+ }
+ }
+ }
+ catch(FileNotFoundException e){
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ }
+ catch(IOException e){
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+ }
+}
diff --git a/simple_examples/source/int32/C09AAJE.java b/simple_examples/source/int32/C09AAJE.java
new file mode 100644
index 0000000..48c38b6
--- /dev/null
+++ b/simple_examples/source/int32/C09AAJE.java
@@ -0,0 +1,158 @@
+import com.nag.routines.C09.C09AA;
+import com.nag.routines.C09.C09CC;
+import com.nag.routines.C09.C09CD;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+/**
+ * C09AAJ example program text.
+ * @author willa
+ * @since 27.1.0.0
+ */
+public class C09AAJE{
+
+ /**
+ * C09AAJ example main program
+ */
+ public static void main(String[] args){
+ int ifail, lenc = 0, n = 0, nf = 0, nnz, nwc = 0, nwlmax = 0, ny; //placeholders
+ String mode = "", wavnam = "", wtrans; //placeholders
+ int[] dwtlev, icomm;
+ double[] c, x, y;
+
+ x = new double[0]; y = new double[0]; //placeholders
+
+ //print error message if no data file given
+ if(args.length != 1){
+ C09AAJE.usage();
+ }
+
+ icomm = new int[100];
+
+ System.out.println("C09AAJ Example Program Results");
+ System.out.println();
+
+ String filename = args[0];
+ try{
+ BufferedReader reader = new BufferedReader(new FileReader(filename));
+ String line = reader.readLine(); //skip header
+
+ line = reader.readLine();
+ String[] sVal = line.split("\\s+");
+ n = Integer.parseInt(sVal[1]);
+
+ line = reader.readLine();
+ sVal = line.split("\\s+");
+ wavnam = sVal[1];
+ mode = sVal[2];
+
+ x = new double[n];
+ y = new double[n];
+
+ System.out.printf("Parameters read from file :: \n \tWavelet : %s \tEnd mode : %s \t N = %d\n", wavnam, mode, n);
+
+ System.out.println("Input data \tX : ");
+ for(int i = 0; i < n; i++){
+ line = reader.readLine();
+ //Avoid errors with data file format and negative numbers
+ line = " " + line;
+ sVal = line.split("\\s+");
+ x[i] = Double.parseDouble(sVal[1]);
+ System.out.printf("%.3f\t", x[i]);
+ }
+ System.out.printf("\n");
+ }
+ catch(FileNotFoundException e){
+ System.err.println("***FATAL: Can't find " + filename);
+ System.exit(-2);
+ }
+ catch(IOException e){
+ System.err.println("***FATAL: Can't read " + filename + "\n" + e.getMessage());
+ }
+
+ //Query wavelet filter dimensions
+ //For Multi-Resolution analysis ,decomposition, wrtrans = 'M'
+ wtrans = "Multilevel";
+
+ //ifail: behaviour on error exit
+ // =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
+ ifail = 0;
+ C09AA c09aa = new C09AA(wavnam, wtrans, mode, n, nwlmax, nf, nwc, icomm, ifail);
+ c09aa.eval();
+
+ nwc = c09aa.getNWC();
+ nwlmax = c09aa.getNWLMAX();
+ lenc = nwc;
+ c = new double[lenc];
+ dwtlev = new int[nwlmax + 1];
+
+ icomm = c09aa.getICOMM();
+ ifail = 0;
+ //Perform discrete wavelet transform
+ C09CC c09cc = new C09CC(n, x, lenc, c, nwlmax, dwtlev, icomm, ifail);
+ c09cc.eval();
+
+ nf = c09aa.getNF();
+ nwlmax = c09cc.getNWL();
+ dwtlev = c09cc.getDWTLEV();
+ c = c09cc.getC();
+
+ System.out.println();
+ System.out.printf("Length of wavelet filter : \t%d\n", nf);
+ System.out.printf("Number of Levels : \t%d\n", nwlmax);
+ System.out.printf("Number of coefficients in each level: \n\t\t");
+ for(int i = 0; i <= nwlmax; i++){
+ System.out.printf("%d\t ", dwtlev[i]);
+ }
+ System.out.printf("\n");
+ System.out.printf("Total number of wavelength coefficients : %d\n", nwc);
+ nnz = arraySum(dwtlev);
+ System.out.println();
+ System.out.println("Wavelet coefficients C:");
+ for(int i = 0; i < nnz; i++){
+ System.out.printf("%.3f ", c[i]);
+ }
+ System.out.printf("\n");
+
+ //Reconstruct original data
+ ny = n;
+
+ ifail = 0;
+ lenc = c09cc.getLENC();
+ icomm = c09cc.getICOMM();
+ C09CD c09cd = new C09CD(nwlmax, lenc, c, ny, y, icomm, ifail);
+ c09cd.eval();
+
+ y = c09cd.getY();
+ System.out.println();
+ System.out.printf("Reconstruction \tY : \n");
+ for(int i = 0; i < ny; i++){
+ System.out.printf("%.3f ", y[i]);
+ }
+ System.out.printf("\n");
+ }
+
+ /**
+ * Finds the sum of all integers in an array
+ * @param a
+ * Array to sum
+ * @return total
+ */
+ private static int arraySum(int[] a){
+ int tot = 0;
+ for(int i = 0; i < a.length; i++){
+ tot += a[i];
+ }
+ return tot;
+ }
+
+ /**
+ * No arguments supplied when exmaple runs
+ */
+ private static void usage(){
+ System.err.println("Please specify the path to the data file.");
+ System.exit(-1);
+ }
+}
diff --git a/simple_examples/source/int32/D01BDJE.java b/simple_examples/source/int32/D01BDJE.java
new file mode 100644
index 0000000..8659cc4
--- /dev/null
+++ b/simple_examples/source/int32/D01BDJE.java
@@ -0,0 +1,58 @@
+import com.nag.routines.D01.D01BD;
+
+/**
+ * D01BD example program text.
+ */
+public class D01BDJE {
+
+ public static void main(String[] args) {
+
+ double a = 0.0, b = 1.0;
+ double epsabs = 0.0, epsrel = 0.0001;
+ double result = Double.NaN;
+ double abserr = Double.NaN;
+ FUN fun = new FUN();
+ D01BD d01bd = new D01BD(fun, a, b, epsabs, epsrel, result, abserr);
+
+ d01bd.eval();
+ result = d01bd.getRESULT();
+ abserr = d01bd.getABSERR();
+
+ System.out.println(" D01BDJ Example Program Results");
+
+ System.out.println();
+ System.out.printf(" A - lower limit of integration = %10.4f\n",a);
+ System.out.printf(" B - upper limit of integration = %10.4f\n",b);
+ System.out.printf(" EPSABS - absolute accuracy requested = %9.2E\n",epsabs);
+ System.out.printf(" EPSREL - relative accuracy requested = %9.2E\n",epsrel);
+ System.out.println();
+ System.out.printf(" RESULT - approximation to the integral = %9.5f\n",result);
+ System.out.printf(" ABSERR - estimate to the absolute error = %9.2E\n",abserr);
+ System.out.println();
+
+ if (abserr > Math.max(epsabs,epsrel*Math.abs(result))) {
+ System.out.println("Warning - requested accuracy may not have been achieved");
+ }
+
+ }
+
+
+ public static class FUN implements D01BD.D01BD_F {
+
+ private double x;
+
+ public double eval(double x) {
+ return (x * x * Math.sin(10.0 * Math.PI * x));
+ }
+
+ public double getX() {
+ return x;
+ }
+
+ public void setX(double d) {
+ x = d;
+ }
+
+ }
+
+}
diff --git a/simple_examples/source/int32/D01RJJE.java b/simple_examples/source/int32/D01RJJE.java
new file mode 100644
index 0000000..9eee98a
--- /dev/null
+++ b/simple_examples/source/int32/D01RJJE.java
@@ -0,0 +1,184 @@
+import com.nag.routines.D01.D01RJ;
+import com.nag.routines.X01.X01AA;
+import java.util.Arrays;
+
+/**
+ * D01RJ example program text.
+ * @author Mo
+ */
+public class D01RJJE {
+
+ public static void main(String[] args) {
+
+ double pi = 0.0;
+ double a, b, epsabs, epsrel;
+ double result = Double.NaN;
+ double abserr = Double.NaN;
+ double[] rinfo, ruser;
+ int [] iinfo, iuser;
+ int ifail, liinfo, lrinfo, maxsub;
+ long cpuser; // c_ptr
+ F f = new F();
+
+ /* Header */
+ System.out.println(" D01RJJ Example Program Results");
+
+ X01AA x01aa = new X01AA(pi);
+ pi = x01aa.eval();
+ a = 0.0;
+ b = 2.0*pi;
+ epsabs = 0.0;
+ epsrel = 0.0001;
+ maxsub = 20;
+ lrinfo = 4*maxsub;
+ liinfo = Math.max(maxsub,4);
+
+ rinfo = new double[lrinfo];
+ iinfo = new int[liinfo];
+ iuser = new int[0];
+ ruser = new double[0];
+
+ iuser = new int[] {0};
+ /* pass constant to f through ruser */
+ ruser = new double[] {4.0*Math.pow(pi,2)};
+ cpuser = 0L;
+
+ D01RJ d01rj = new D01RJ();
+ ifail = -1;
+ d01rj.eval(f, a, b, epsabs, epsrel, maxsub, result, abserr,
+ rinfo, iinfo, iuser, ruser, cpuser, ifail);
+ result = d01rj.getRESULT();
+ abserr = d01rj.getABSERR();
+ ifail = d01rj.getIFAIL();
+
+ if (ifail >= 0) {
+ System.out.println();
+ System.out.printf(" A - lower limit of integration = %9.4f\n",a);
+ System.out.printf(" B - upper limit of integration = %9.4f\n",b);
+ System.out.printf(" EPSABS - absolute accuracy requested = %9.2E\n",epsabs);
+ System.out.printf(" EPSREL - relative accuracy requested = %9.2E\n",epsrel);
+ System.out.printf(" MAXSUB - maximum number of subintervals = %4d\n",maxsub);
+ System.out.println();
+ if (ifail <= 5) {
+ System.out.printf(" RESULT - approximation to the integral = %9.5f\n",result);
+ System.out.printf(" ABSERR - estimate to the absolute error = %9.2E\n",abserr);
+ System.out.printf(" IINFO(1) - number of subintervals used = %4d\n",iinfo[0]);
+ System.out.println();
+ }
+ else if (ifail == -1) {
+ /* User requested exit */
+ System.out.printf(" Exit requested from F with IFLAG %4d\n",iuser[0]);
+ System.out.println();
+ }
+
+ }
+
+ }
+
+ public static class F implements D01RJ.D01RJ_F {
+
+ private int NX, IFLAG;
+ private double[] X, FV, RUSER;
+ private int[] IUSER;
+ private long CPUSER;
+
+ @Override
+ public void setX(double[] X) {
+ this.X = X;
+ }
+
+ @Override
+ public double[] getX() {
+ return X;
+ }
+
+ @Override
+ public void setNX(int NX) {
+ this.NX = NX;
+ }
+
+ @Override
+ public int getNX() {
+ return NX;
+ }
+
+ @Override
+ public void setFV(double[] FV) {
+ this.FV = FV;
+ }
+
+ @Override
+ public double[] getFV() {
+ return FV;
+ }
+
+ @Override
+ public void setIFLAG(int IFLAG) {
+ this.IFLAG = IFLAG;
+ }
+
+ @Override
+ public int getIFLAG() {
+ return IFLAG;
+ }
+
+ @Override
+ public void setIUSER(int[] IUSER) {
+ this.IUSER = IUSER;
+ }
+
+ @Override
+ public int[] getIUSER() {
+ return IUSER;
+ }
+
+ @Override
+ public void setRUSER(double[] RUSER) {
+ this.RUSER = RUSER;
+ }
+
+ @Override
+ public double[] getRUSER() {
+ return RUSER;
+ }
+
+ @Override
+ public void setCPUSER(long CPUSER) {
+ this.CPUSER = CPUSER;
+ }
+
+ @Override
+ public long getCPUSER() {
+ return CPUSER;
+ }
+
+ @Override
+ public void eval(double[] X, int NX, double[] FV, int IFLAG,
+ int[] IUSER, double[] RUSER, long CPUSER) {
+
+ for (int i = 0; i < NX; i++) {
+ FV[i] = 0.0;
+ }
+
+ for (int i = 0; i < NX; i++) {
+ if (X[i] == 1.0) {
+ /* An undefined result will be generated. */
+ /* Set iflag to force an immediate exit */
+ IFLAG = -1;
+ /* Store chosen value of iflag in iuser */
+ IUSER[0] = IFLAG;
+ }
+ }
+ if (IFLAG != -1) {
+ for (int j = 0; j < NX; j++) {
+ FV[j] = X[j] * Math.sin(30.0 * X[j])/
+ Math.sqrt(1.0 - Math.pow(X[j],2)/RUSER[0]);
+ }
+ }
+ return;
+
+ }
+
+ }
+
+}
diff --git a/simple_examples/source/int32/D01RKJE.java b/simple_examples/source/int32/D01RKJE.java
new file mode 100644
index 0000000..20c0501
--- /dev/null
+++ b/simple_examples/source/int32/D01RKJE.java
@@ -0,0 +1,173 @@
+import com.nag.routines.D01.D01RK;
+import com.nag.routines.X01.X01AA;
+import java.util.Arrays;
+
+/**
+ * D01RK example program text.
+ * @author Mo
+ */
+public class D01RKJE {
+
+ public static void main(String[] args) {
+
+ double pi = 0.0;
+ double a, b, epsabs, epsrel;
+ double result = Double.NaN;
+ double abserr = Double.NaN;
+ double[] rinfo, ruser;
+ int [] iinfo, iuser;
+ int ifail, key, liinfo, lrinfo, maxsub;
+ long cpuser; // c_ptr
+ F f = new F();
+
+ /* Header */
+ System.out.println(" D01RKJ Example Program Results");
+
+ key = 6;
+ X01AA x01aa = new X01AA(pi);
+ pi = x01aa.eval();
+ a = 0.0;
+ b = 2.0*pi;
+ epsabs = 0.0;
+ epsrel = 0.0001;
+ maxsub = 20;
+ lrinfo = 4*maxsub;
+ liinfo = Math.max(maxsub,4);
+
+ rinfo = new double[lrinfo];
+ iinfo = new int[liinfo];
+ iuser = new int[0];
+ ruser = new double[0];
+
+ iuser = new int[] {0};
+ ruser = new double[] {4.0*Math.pow(pi,2)};
+ cpuser = 0L;
+
+ D01RK d01rk = new D01RK();
+ ifail = -1;
+ d01rk.eval(f, a, b, key, epsabs, epsrel, maxsub, result, abserr,
+ rinfo, iinfo, iuser, ruser, cpuser, ifail);
+ result = d01rk.getRESULT();
+ abserr = d01rk.getABSERR();
+ ifail = d01rk.getIFAIL();
+
+ if (ifail >= 0) {
+ System.out.println();
+ System.out.printf(" A - lower limit of integration = %9.4f\n",a);
+ System.out.printf(" B - upper limit of integration = %9.4f\n",b);
+ System.out.printf(" KEY - choice of Gaussian rule = %4d\n",key);
+ System.out.printf(" EPSABS - absolute accuracy requested = %9.2E\n",epsabs);
+ System.out.printf(" EPSREL - relative accuracy requested = %9.2E\n",epsrel);
+ System.out.printf(" MAXSUB - maximum number of subintervals = %4d\n",maxsub);
+ System.out.println();
+ if (ifail <= 5) {
+ System.out.printf(" RESULT - approximation to the integral = %9.5f\n",result);
+ System.out.printf(" ABSERR - estimate to the absolute error = %9.2E\n",abserr);
+ System.out.printf(" IINFO(1) - number of subintervals used = %4d\n",iinfo[0]);
+ System.out.println();
+ }
+ else if (ifail == -1) {
+ /* User requested exit */
+ System.out.printf(" Exit requested from F \n");
+ System.out.println();
+ }
+
+ }
+
+ }
+
+ public static class F implements D01RK.D01RK_F {
+
+ private int NX, IFLAG;
+ private double[] X, FV, RUSER;
+ private int[] IUSER;
+ private long CPUSER;
+
+ @Override
+ public void setX(double[] X) {
+ this.X = X;
+ }
+
+ @Override
+ public double[] getX() {
+ return X;
+ }
+
+ @Override
+ public void setNX(int NX) {
+ this.NX = NX;
+ }
+
+ @Override
+ public int getNX() {
+ return NX;
+ }
+
+ @Override
+ public void setFV(double[] FV) {
+ this.FV = FV;
+ }
+
+ @Override
+ public double[] getFV() {
+ return FV;
+ }
+
+ @Override
+ public void setIFLAG(int IFLAG) {
+ this.IFLAG = IFLAG;
+ }
+
+ @Override
+ public int getIFLAG() {
+ return IFLAG;
+ }
+
+ @Override
+ public void setIUSER(int[] IUSER) {
+ this.IUSER = IUSER;
+ }
+
+ @Override
+ public int[] getIUSER() {
+ return IUSER;
+ }
+
+ @Override
+ public void setRUSER(double[] RUSER) {
+ this.RUSER = RUSER;
+ }
+
+ @Override
+ public double[] getRUSER() {
+ return RUSER;
+ }
+
+ @Override
+ public void setCPUSER(long CPUSER) {
+ this.CPUSER = CPUSER;
+ }
+
+ @Override
+ public long getCPUSER() {
+ return CPUSER;
+ }
+
+ @Override
+ public void eval(double[] X, int NX, double[] FV, int IFLAG,
+ int[] IUSER, double[] RUSER, long CPUSER) {
+
+ for (int i = 0; i < NX; i++) {
+ FV[i] = 0.0;
+ }
+
+ for (int j = 0; j < NX; j++) {
+ FV[j] = X[j] * Math.sin(30.0 * X[j]) * Math.cos(X[j]);
+ }
+ return;
+
+ }
+
+ }
+
+}
diff --git a/simple_examples/source/int32/D01RLJE.java b/simple_examples/source/int32/D01RLJE.java
new file mode 100644
index 0000000..c8a6d0e
--- /dev/null
+++ b/simple_examples/source/int32/D01RLJE.java
@@ -0,0 +1,196 @@
+import com.nag.routines.D01.D01RL;
+import java.util.Arrays;
+
+/**
+ * D01RL example program text.
+ * @author Mo
+ */
+public class D01RLJE {
+
+ public static void main(String[] args) {
+
+ double a, b, epsabs, epsrel;
+ double result = Double.NaN;
+ double abserr = Double.NaN;
+ double[] points, rinfo, ruser;
+ int [] iinfo, iuser;
+ int ifail, liinfo, lrinfo, maxsub, npts;
+ long cpuser; // c_ptr
+ F f = new F();
+
+ /* Header */
+ System.out.println(" D01RLJ Example Program Results");
+
+ epsabs = 0.0;
+ epsrel = 0.0001;
+ a = 0.0;
+ b = 1.0;
+ npts = 1;
+ maxsub = 20;
+ liinfo = 2*Math.max(maxsub,npts) + npts + 4;
+ lrinfo = 4*Math.max(maxsub,npts) + npts + 6;
+
+ points = new double[npts];
+ rinfo = new double[lrinfo];
+ iinfo = new int[liinfo];
+ iuser = new int[0];
+ ruser = new double[21];
+
+ points[0] = 1.0/7.0;
+ iuser = new int[] {0};
+ ruser = new double[] {0.0};
+ cpuser = 0L;
+
+ D01RL d01rl = new D01RL();
+ ifail = -1;
+ d01rl.eval(f, a, b, npts, points, epsabs, epsrel, maxsub, result, abserr,
+ rinfo, iinfo, iuser, ruser, cpuser, ifail);
+ points = d01rl.getPOINTS();
+ result = d01rl.getRESULT();
+ abserr = d01rl.getABSERR();
+ ifail = d01rl.getIFAIL();
+
+ if (ifail >= 0) {
+ System.out.println();
+ System.out.printf(" A - lower limit of integration = %9.4f\n",a);
+ System.out.printf(" B - upper limit of integration = %9.4f\n",b);
+ System.out.printf(" POINT(1) - given break-point = %9.4f\n",points[0]);
+ System.out.printf(" EPSABS - absolute accuracy requested = %9.2E\n",epsabs);
+ System.out.printf(" EPSREL - relative accuracy requested = %9.2E\n",epsrel);
+ System.out.printf(" MAXSUB - maximum number of subintervals = %4d\n",maxsub);
+ System.out.println();
+ if (ifail <= 5) {
+ System.out.printf(" RESULT - approximation to the integral = %9.5f\n",result);
+ System.out.printf(" ABSERR - estimate to the absolute error = %9.2E\n",abserr);
+ System.out.printf(" IINFO(1) - number of subintervals used = %4d\n",iinfo[0]);
+ System.out.println();
+ }
+ else if (ifail == -1) {
+ /* User requested exit */
+ System.out.printf(" Exit requested from F");
+ System.out.println();
+ }
+
+ }
+
+ }
+
+ public static class F implements D01RL.D01RL_F {
+
+ private int NX, IFLAG;
+ private double[] X, FV, RUSER;
+ private int[] IUSER;
+ private long CPUSER;
+
+ @Override
+ public void setX(double[] X) {
+ this.X = X;
+ }
+
+ @Override
+ public double[] getX() {
+ return X;
+ }
+
+ @Override
+ public void setNX(int NX) {
+ this.NX = NX;
+ }
+
+ @Override
+ public int getNX() {
+ return NX;
+ }
+
+ @Override
+ public void setFV(double[] FV) {
+ this.FV = FV;
+ }
+
+ @Override
+ public double[] getFV() {
+ return FV;
+ }
+
+ @Override
+ public void setIFLAG(int IFLAG) {
+ this.IFLAG = IFLAG;
+ }
+
+ @Override
+ public int getIFLAG() {
+ return IFLAG;
+ }
+
+ @Override
+ public void setIUSER(int[] IUSER) {
+ this.IUSER = IUSER;
+ }
+
+ @Override
+ public int[] getIUSER() {
+ return IUSER;
+ }
+
+ @Override
+ public void setRUSER(double[] RUSER) {
+ this.RUSER = RUSER;
+ }
+
+ @Override
+ public double[] getRUSER() {
+ return RUSER;
+ }
+
+ @Override
+ public void setCPUSER(long CPUSER) {
+ this.CPUSER = CPUSER;
+ }
+
+ @Override
+ public long getCPUSER() {
+ return CPUSER;
+ }
+
+ @Override
+ public void eval(double[] X, int NX, double[] FV, int IFLAG,
+ int[] IUSER, double[] RUSER, long CPUSER) {
+
+ /*for (int i = 0; i < NX; i++) {*/
+ /*FV[i] = 0.0;*/
+ /*}*/
+
+ for (int i = 0; i < NX; i++) {
+ FV[i] = Math.abs(X[i] - 1.0/7.0);
+ }
+
+ for (int i = 0; i < NX; i++) {
+ if (FV[i] == 0.0) {
+ /* A singular point will be hit. */
+ /* Record offending abscissae and abort computation. */
+ IFLAG = 0;
+ for (int k = 0; k < NX; k++) {
+ if (FV[k] == 0.0) {
+ IFLAG = IFLAG + 1;
+ RUSER[IFLAG-1] = X[k];
+ }
+ }
+ /* Store value of iflag in iuser */
+ IUSER[0] = IFLAG;
+ /* signal abort by setting iflag<0 */
+ IFLAG = -IFLAG;
+ }
+ }
+ if (IFLAG == 0) {
+ /* Safe to evaluate. */
+ for (int j = 0; j < NX; j++) {
+ FV[j] = 1.0/Math.sqrt(FV[j]);
+ }
+ }
+ return;
+
+ }
+
+ }
+
+}
diff --git a/simple_examples/source/int32/D01RMJE.java b/simple_examples/source/int32/D01RMJE.java
new file mode 100644
index 0000000..6e80b2b
--- /dev/null
+++ b/simple_examples/source/int32/D01RMJE.java
@@ -0,0 +1,163 @@
+import com.nag.routines.D01.D01RM;
+import java.util.Arrays;
+
+/**
+ * D01RM example program text.
+ * @author Mo
+ */
+public class D01RMJE {
+
+ public static void main(String[] args) {
+
+ double bound, epsabs, epsrel;
+ double result = Double.NaN;
+ double abserr = Double.NaN;
+ double[] rinfo, ruser;
+ int [] iinfo, iuser;
+ int ifail, inf, liinfo, lrinfo, maxsub;
+ long cpuser; // c_ptr
+ F f = new F();
+
+ /* Header */
+ System.out.println(" D01RMJ Example Program Results");
+
+ bound = 0.0;
+ inf = 1;
+ epsabs = 0.0;
+ epsrel = 0.0001;
+ maxsub = 20;
+ lrinfo = 4*maxsub;
+ liinfo = Math.max(maxsub,4);
+
+ rinfo = new double[lrinfo];
+ iinfo = new int[liinfo];
+ iuser = new int[0];
+ ruser = new double[0];
+
+ iuser = new int[] {0};
+ ruser = new double[] {0.0};
+ cpuser = 0L;
+
+ D01RM d01rm = new D01RM();
+ ifail = -1;
+ d01rm.eval(f, bound, inf, epsabs, epsrel, maxsub, result, abserr,
+ rinfo, iinfo, iuser, ruser, cpuser, ifail);
+ result = d01rm.getRESULT();
+ abserr = d01rm.getABSERR();
+ ifail = d01rm.getIFAIL();
+
+ if (ifail >= 0) {
+ System.out.println();
+ System.out.printf(" A - lower limit of integration = %9.4f\n",bound);
+ System.out.println(" B - upper limit of integration = infinity\n");
+ System.out.printf(" EPSABS - absolute accuracy requested = %9.2E\n",epsabs);
+ System.out.printf(" EPSREL - relative accuracy requested = %9.2E\n",epsrel);
+ System.out.printf(" MAXSUB - maximum number of subintervals = %4d\n",maxsub);
+ System.out.println();
+ if (ifail <= 5) {
+ System.out.printf(" RESULT - approximation to the integral = %9.5f\n",result);
+ System.out.printf(" ABSERR - estimate to the absolute error = %9.2E\n",abserr);
+ System.out.printf(" IINFO(1) - number of subintervals used = %4d\n",iinfo[0]);
+ System.out.println();
+ }
+ else if (ifail == -1) {
+ /* User requested exit */
+ System.out.printf(" Exit requested from F \n");
+ System.out.println();
+ }
+
+ }
+
+ }
+
+ public static class F implements D01RM.D01RM_F {
+
+ private int NX, IFLAG;
+ private double[] X, FV, RUSER;
+ private int[] IUSER;
+ private long CPUSER;
+
+ @Override
+ public void setX(double[] X) {
+ this.X = X;
+ }
+
+ @Override
+ public double[] getX() {
+ return X;
+ }
+
+ @Override
+ public void setNX(int NX) {
+ this.NX = NX;
+ }
+
+ @Override
+ public int getNX() {
+ return NX;
+ }
+
+ @Override
+ public void setFV(double[] FV) {
+ this.FV = FV;
+ }
+
+ @Override
+ public double[] getFV() {
+ return FV;
+ }
+
+ @Override
+ public void setIFLAG(int IFLAG) {
+ this.IFLAG = IFLAG;
+ }
+
+ @Override
+ public int getIFLAG() {
+ return IFLAG;
+ }
+
+ @Override
+ public void setIUSER(int[] IUSER) {
+ this.IUSER = IUSER;
+ }
+
+ @Override
+ public int[] getIUSER() {
+ return IUSER;
+ }
+
+ @Override
+ public void setRUSER(double[] RUSER) {
+ this.RUSER = RUSER;
+ }
+
+ @Override
+ public double[] getRUSER() {
+ return RUSER;
+ }
+
+ @Override
+ public void setCPUSER(long CPUSER) {
+ this.CPUSER = CPUSER;
+ }
+
+ @Override
+ public long getCPUSER() {
+ return CPUSER;
+ }
+
+ @Override
+ public void eval(double[] X, int NX, double[] FV, int IFLAG,
+ int[] IUSER, double[] RUSER, long CPUSER) {
+
+ for (int j = 0; j < NX; j++) {
+ FV[j] = 1.0/((X[j] + 1.0) * Math.sqrt(X[j]));
+ }
+ return;
+
+ }
+
+ }
+
+}
diff --git a/simple_examples/source/int32/D01TCJE.java b/simple_examples/source/int32/D01TCJE.java
new file mode 100644
index 0000000..cde8428
--- /dev/null
+++ b/simple_examples/source/int32/D01TCJE.java
@@ -0,0 +1,45 @@
+import com.nag.routines.D01.D01TC;
+import java.util.Arrays;
+
+/**
+ * D01TC example program text.
+ * @author Mo
+ */
+public class D01TCJE {
+
+ public static void main(String[] args) {
+
+ double a, b, c, d;
+ double[] abscis, weight;
+ int n, ifail, itype;
+
+ /* Header */
+ System.out.println(" D01TCJ Example Program Results");
+
+ n = 7;
+ a = 0.0;
+ b = 1.0;
+ c = 0.0;
+ d = 0.0;
+ itype = -3;
+
+ abscis = new double[n];
+ weight = new double[n];
+
+ D01TC d01tc = new D01TC();
+ ifail = 0;
+ d01tc.eval(itype, a, b, c, d, n, weight, abscis, ifail);
+ abscis= d01tc.getABSCIS();
+ weight = d01tc.getWEIGHT();
+
+ System.out.println();
+ System.out.printf(" Laguerre formula, %2d points\n",n);
+ System.out.println();
+ System.out.println(" Abscissae Weights\n");
+ for (int j = 0; j < n; j++) {
+ System.out.printf("%15.5E %15.5E\n", abscis[j], weight[j]);
+ }
+
+ }
+
+}
diff --git a/simple_examples/source/int32/D02NEJE.java b/simple_examples/source/int32/D02NEJE.java
new file mode 100644
index 0000000..34a5b25
--- /dev/null
+++ b/simple_examples/source/int32/D02NEJE.java
@@ -0,0 +1,388 @@
+import com.nag.routines.D02.D02MC;
+import com.nag.routines.D02.D02MW;
+import com.nag.routines.D02.D02NE;
+import com.nag.routines.D02.D02NEZ;
+import com.nag.routines.D02.D02NP;
+import java.util.Arrays;
+
+/**
+ * D02NE example program text.
+ * @author joed
+ */
+public class D02NEJE {
+
+ public static final double ALPHA = 0.04;
+ public static final double BETA = 1.0E4;
+ public static final double GAMMA = 3.0E7;
+ public static final int ML = 1;
+ public static final int MU = 2;
+ public static final int NEQ1 = 3;
+ public static final int NEQ2 = 1;
+
+ public static JAC1 jac1 = new JAC1();
+ public static JAC2 jac2 = new JAC2();
+ public static RES1 res1 = new RES1();
+ public static RES2 res2 = new RES2();
+
+ public static void main(String[] args) {
+
+ System.out.println(" D02NEJ Example Program Results");
+
+ ex1();
+ ex2();
+
+ }
+
+ private static void ex1() {
+
+ D02MC d02mc = new D02MC();
+ D02MW d02mw = new D02MW();
+ D02NE d02ne = new D02NE();
+ D02NP d02np = new D02NP();
+ double h0, hmax, t, tout;
+ int ifail, ijac, itask, itol, lcom, licom, maxord, neq;
+ String jceval; // length 8
+ double[] atol, com, rtol, y, ydot, ruser;
+ int[] icom, iuser;
+
+ ruser = new double[1];
+ iuser = new int[3];
+
+ System.out.println();
+ System.out.println(" D02NEF Example 1");
+ System.out.println();
+
+ maxord = 5;
+
+ neq = NEQ1;
+ lcom = 40 + (maxord + 4) * neq + (2 * ML + MU + 1) * neq
+ + 2 * (neq / (ML + MU + 1) + 1);
+ licom = 50 + neq;
+
+ atol = new double[neq];
+ com = new double[lcom];
+ rtol = new double[neq];
+ y = new double[neq];
+ ydot = new double[neq];
+ icom = new int[licom];
+
+ ijac = 1;
+ itol = 1;
+ Arrays.fill(rtol, 1.0E-3);
+ Arrays.fill(atol, 1.0E-6);
+ Arrays.fill(ydot, 0.0);
+
+ // String length = 8
+ jceval = (ijac == 1) ? "Analytic" : "Numeric ";
+
+ // Set initial values
+ y[0] = 1.0;
+ y[1] = 0.0;
+ y[2] = 0.0;
+
+ // Initialize the problem, specifying that the Jacobian is to be
+ // evaluated analytically using the provided routine jac.
+ hmax = 0.0;
+ h0 = 0.0;
+ t = 0.0;
+ tout = 0.02;
+ ifail = 0;
+ d02mw.eval(
+ neq, maxord, jceval, hmax, h0, itol, icom, licom, com, lcom, ifail
+ );
+ ifail = d02mw.getIFAIL();
+
+ // Specify that the Jacobian is banded.
+ ifail = 0;
+ d02np.eval(neq, ML, MU, icom, licom, ifail);
+ ifail = d02np.getIFAIL();
+
+ // Use the iuser array to pass the band dimensions through to jac.
+ // An alternative would be to hard code values for ml and mu in jac.
+ iuser[0] = ML;
+ iuser[1] = MU;
+ iuser[2] = ijac;
+
+ System.out.printf(" t ");
+ for (int i = 1; i <= neq; i++) {
+ System.out.printf(" Y(%1d) ", i);
+ }
+ System.out.println();
+ System.out.printf(" %8.4f ", t);
+ for (int i = 0; i < neq; i++) {
+ System.out.printf("%12.6f", y[i]);
+ }
+ System.out.println();
+
+ itask = 0;
+
+ // Obtain the solution at 5 equally spaced values of T.
+ for (int j = 0; j < 5; j++) {
+ ifail = -1;
+ d02ne.eval(
+ neq, t, tout, y, ydot, rtol, atol, itask, res1, jac1, icom,
+ com, lcom, iuser, ruser, ifail
+ );
+ itask = d02ne.getITASK();
+ ifail = d02ne.getIFAIL();
+ t = d02ne.getT();
+
+ System.out.printf(" %8.4f ", t);
+ for (int i = 0; i < neq; i++) {
+ System.out.printf("%12.6f", y[i]);
+ }
+ System.out.println();
+
+ if (ifail != 0) {
+ System.out.printf(
+ " ** D02NEF returned with IFAIL = %5d\n", ifail
+ );
+ break;
+ }
+
+ tout += 0.02;
+ d02mc.eval(icom);
+
+ }
+
+ System.out.println();
+ System.out.printf(
+ " The integrator completed task, ITASK = %4d\n", itask
+ );
+
+ }
+
+ private static void ex2() {
+ D02MC d02mc = new D02MC();
+ D02MW d02mw = new D02MW();
+ D02NE d02ne = new D02NE();
+ double h0, hmax, t, tout;
+ int ifail, ijac, itask, itol, lcom, licom, maxord, neq;
+ String jceval; // length 8
+ double[] atol, com, rtol, y, ydot, ruser;
+ int[] icom, iuser;
+
+ ruser = new double[1];
+ iuser = new int[1];
+
+ System.out.println();
+ System.out.println(" D02NEF Example 2");
+ System.out.println();
+
+ maxord = 5;
+ neq = NEQ2;
+ lcom = 40 + (maxord + 4) * neq + neq * neq;
+ licom = 50 + neq;
+
+ atol = new double[neq];
+ com = new double[lcom];
+ rtol = new double[neq];
+ y = new double[neq];
+ ydot = new double[neq];
+ icom = new int[licom];
+
+ ijac = 1;
+ itol = 1;
+ rtol[0] = 0.0;
+ atol[0] = 1.0E-8;
+ ydot[0] = 0.0;
+
+ // String length = 8
+ jceval = (ijac == 1) ? "Analytic" : "Numeric ";
+
+ // Initialize the problem, specifying that the Jacobian is to be
+ // evaluated analytically using the provided routine jac.
+ y[0] = 2.0;
+ hmax = 0.0;
+ h0 = 0.0;
+ t = 0.0;
+ tout = 0.2;
+
+ ifail = 0;
+ d02mw.eval(
+ neq, maxord, jceval, hmax, h0, itol, icom, licom, com, lcom, ifail
+ );
+ ifail = d02mw.getIFAIL();
+
+ // Use the iuser array to pass whether numerical or analytic Jacobian
+ // is to be used.
+ iuser[0] = ijac;
+
+ System.out.printf(" t ");
+ for (int i = 1; i <= neq; i++) {
+ System.out.printf(" y(%1d) ", i);
+ }
+ System.out.println();
+ System.out.printf(" %8.4f ", t);
+ for (int i = 0; i < neq; i++) {
+ System.out.printf("%12.6f", y[i]);
+ }
+ System.out.println();
+
+ itask = 0;
+
+ for (int j = 0; j < 5; j++) {
+ ifail = -1;
+ d02ne.eval(
+ neq, t, tout, y, ydot, rtol, atol, itask, res2, jac2, icom,
+ com, lcom, iuser, ruser, ifail
+ );
+ itask = d02ne.getITASK();
+ ifail = d02ne.getIFAIL();
+ t = d02ne.getT();
+
+ System.out.printf(" %8.4f ", t);
+ for (int i = 0; i < neq; i++) {
+ System.out.printf("%12.6f", y[i]);
+ }
+ System.out.println();
+
+ if (ifail != 0) {
+ System.out.printf(
+ " ** D02NEF returned with IFAIL = %5d\n", ifail
+ );
+ break;
+ }
+
+ tout += 0.2;
+ d02mc.eval(icom);
+
+ }
+
+ System.out.println();
+ System.out.printf(
+ " The integrator completed task, ITASK = %4d\n", itask
+ );
+
+ }
+
+ /**
+ * Converts a 2D, 1-based Fortran index to its corresponding 1D, 0-based
+ * Java index.
+ *
+ *
Fortran array definition:
+ * a(dimX, *)
+ *
+ *
Conversion:
+ * a(x, y) --> A[result]
+ */
+ private static int getIdx(int x, int y, int dimX) {
+ return ((y-1) * dimX) + (x-1);
+ }
+
+ public static class RES1 extends D02NE.Abstract_D02NE_RES {
+
+ public void eval() {
+
+ this.R[0] = -(ALPHA * this.Y[0]) + (BETA * this.Y[1] * this.Y[2])
+ - this.YDOT[0];
+ this.R[1] = (ALPHA * this.Y[0]) - (BETA * this.Y[1] * this.Y[2])
+ - (GAMMA * this.Y[1] * this.Y[1]) - this.YDOT[1];
+ this.R[2] = (GAMMA * this.Y[1] * this.Y[1]) - this.YDOT[2];
+
+ }
+
+ }
+
+ public static class JAC1 extends D02NE.Abstract_D02NE_JAC {
+
+ private double[] myjac1(
+ int neq, int ml, int mu, double t, double[] y, double[] ydot,
+ double[] pd, double cj
+ ) {
+
+ int md, ms, pdDim1;
+
+ pdDim1 = (2 * ml) + mu + 1;
+
+ // Main diagonal pdfull(i,i), i=1, neq
+ md = mu + ml + 1;
+ pd[getIdx(md, 1, pdDim1)] = -ALPHA - cj;
+ pd[getIdx(md, 2, pdDim1)] = (-BETA * y[2]) - (2.0 * GAMMA * y[1])
+ - cj;
+ pd[getIdx(md, 3, pdDim1)] = -cj;
+
+ // 1 subdiagonal pdfull(i-1,i), i=2, neq
+ ms = md + 1;
+ pd[getIdx(ms, 1, pdDim1)] = ALPHA;
+ pd[getIdx(ms, 2, pdDim1)] = 2.0 * GAMMA * y[1];
+
+ // First superdiagonal pdfull(i-1,i), i=2, neq
+ ms = md - 1;
+ pd[getIdx(ms, 2, pdDim1)] = BETA * y[2];
+ pd[getIdx(ms, 3, pdDim1)] = -BETA * y[1];
+
+ // Second superdiagonal pdfull(i-2,i), i=3, neq
+ ms = md - 2;
+ pd[getIdx(ms, 3, pdDim1)] = BETA * y[1];
+
+ return pd;
+
+ }
+
+ public void eval() {
+ D02NEZ d02nez = new D02NEZ();
+ int ijac, ml, mu;
+
+ ml = this.IUSER[0];
+ mu = this.IUSER[1];
+ ijac = this.IUSER[2];
+
+ if (ijac == 1) {
+ myjac1(
+ this.NEQ, ml, mu, this.T, this.Y, this.YDOT, this.PD,
+ this.CJ
+ );
+ }
+ else {
+ d02nez.eval(
+ this.NEQ, this.T, this.Y, this.YDOT, this.PD, this.CJ,
+ this.IUSER, this.RUSER
+ );
+ }
+
+ }
+
+ }
+
+ public static class RES2 extends D02NE.Abstract_D02NE_RES {
+
+ public void eval() {
+ this.R[0] = 4.0 - Math.pow(this.Y[0], 2.0)
+ + (this.T * 0.1E0 * Math.exp(this.Y[0]));
+ }
+
+ }
+
+ public static class JAC2 extends D02NE.Abstract_D02NE_JAC {
+
+ private void myjac2(
+ int neq, double t, double[] y, double[] ydot, double[] pd,
+ double cj
+ ) {
+
+ pd[0] = -(2.0 * y[0]) + (0.1E0 * t * y[0] * Math.exp(y[0]));
+
+ }
+
+ public void eval() {
+ D02NEZ d02nez = new D02NEZ();
+ int ijac;
+
+ ijac = this.IUSER[0];
+
+ if (ijac == 1) {
+ myjac2(this.NEQ, this.T, this.Y, this.YDOT, this.PD, this.CJ);
+ }
+ else {
+ d02nez.eval(
+ this.NEQ, this.T, this.Y, this.YDOT, this.PD, this.CJ,
+ this.IUSER, this.RUSER
+ );
+ }
+
+ }
+
+ }
+
+}
diff --git a/simple_examples/source/int32/D02TLJE.java b/simple_examples/source/int32/D02TLJE.java
new file mode 100644
index 0000000..601b3ce
--- /dev/null
+++ b/simple_examples/source/int32/D02TLJE.java
@@ -0,0 +1,290 @@
+import com.nag.routines.D02.D02TL;
+import com.nag.routines.D02.D02TV;
+import com.nag.routines.D02.D02TX;
+import com.nag.routines.D02.D02TY;
+import com.nag.routines.D02.D02TZ;
+import java.util.Arrays;
+
+/**
+ * D02TL example program text.
+ * @author joed
+ */
+public class D02TLJE {
+
+ public static final int MMAX = 3, NEQ = 3, NLBC = 3, NRBC = 3;
+
+ public static double omega, sqrofr;
+ public static int[] m = {1, 3, 2};
+
+ public static FFUN ffun = new FFUN();
+ public static FJAC fjac = new FJAC();
+ public static GAFUN gafun = new GAFUN();
+ public static GAJAC gajac = new GAJAC();
+ public static GBFUN gbfun = new GBFUN();
+ public static GBJAC gbjac = new GBJAC();
+ public static GUESS guess = new GUESS();
+
+ public static void main(String[] args) {
+
+ D02TL d02tl = new D02TL();
+ D02TV d02tv = new D02TV();
+ D02TX d02tx = new D02TX();
+ D02TY d02ty = new D02TY();
+ D02TZ d02tz = new D02TZ();
+ double dx, ermx, r;
+ int iermx, ifail, ijermx, licomm, lrcomm, mxmesh, ncol, ncont,
+ nmesh;
+ double[] mesh, rcomm, tol, y, ruser = new double[1];
+ int[] icomm, ipmesh, iuser = new int[2];
+
+ System.out.println(" D02TLJ Example Program Results");
+ System.out.println();
+
+ ncol = 7;
+ nmesh = 11;
+ mxmesh = 51;
+
+ mesh = new double[mxmesh];
+ tol = new double[NEQ];
+ y = new double[NEQ * MMAX];
+ ipmesh = new int[mxmesh];
+
+ omega = 1.0;
+ Arrays.fill(tol, 1.0E-4);
+
+ dx = 1.0 / ((double) nmesh - 1);
+
+ mesh[0] = 0.0;
+ for (int i = 1; i < nmesh - 1; i++) {
+ mesh[i] = mesh[i - 1] + dx;
+ }
+ mesh[nmesh - 1] = 1.0;
+
+ ipmesh[0] = 1;
+ Arrays.fill(ipmesh, 1, nmesh - 1, 2);
+ ipmesh[nmesh - 1] = 1;
+
+ // Workspace query to get size of rcomm and icomm
+ ifail = 0;
+ d02tv.eval(
+ NEQ, m, NLBC, NRBC, ncol, tol, mxmesh, nmesh, mesh, ipmesh, ruser,
+ 0, iuser, 2, ifail
+ );
+ ifail = d02tv.getIFAIL();
+ lrcomm = iuser[0];
+ licomm = iuser[1];
+ rcomm = new double[lrcomm];
+ icomm = new int[licomm];
+
+ // Initialise integrator for given problem
+ ifail = 0;
+ d02tv.eval(
+ NEQ, m, NLBC, NRBC, ncol, tol, mxmesh, nmesh, mesh, ipmesh, rcomm,
+ lrcomm, icomm, licomm, ifail
+ );
+ ifail = d02tv.getIFAIL();
+
+ ncont = 3;
+ r = 1.0E6;
+
+ sqrofr = Math.sqrt(r);
+
+ ermx = 0.0;
+ iermx = 0;
+ ijermx = 0;
+
+ for (int j = 0; j < ncont; j++) {
+ System.out.printf("\n Tolerance = %8.1E R = %10.3E\n", tol[0], r);
+
+ // Solve problem
+ ifail = -1;
+ d02tl.eval(
+ ffun, fjac, gafun, gbfun, gajac, gbjac, guess, rcomm, icomm,
+ iuser, ruser, ifail
+ );
+ ifail = d02tl.getIFAIL();
+ if (ifail != 0) {
+ System.err.println("D02TL failed with error code " + ifail);
+ }
+
+ // Extract mesh
+ ifail = -1;
+ d02tz.eval(
+ mxmesh, nmesh, mesh, ipmesh, ermx, iermx, ijermx, rcomm, icomm,
+ ifail
+ );
+ nmesh = d02tz.getNMESH();
+ iermx = d02tz.getIERMX();
+ ijermx = d02tz.getIJERMX();
+ ermx = d02tz.getERMX();
+ ifail = d02tz.getIFAIL();
+ if (ifail == 1) {
+ break;
+ }
+
+ // Print mesh, error stats
+ System.out.printf(
+ "\n"
+ + " Used a mesh of %4d points\n"
+ + " Maximum error = %10.2E in interval %4d for component %4d\n"
+ + "\n",
+ nmesh, ermx, iermx, ijermx
+ );
+ System.out.printf("\n Mesh points:\n");
+ for (int i = 0; i < nmesh; i++) {
+ System.out.printf("%4d(%1d)%10.3E", i+1, ipmesh[i], mesh[i]);
+ if ((i+1) % 4 == 0) {
+ System.out.printf("\n");
+ }
+ }
+ System.out.printf("\n");
+
+ // Print solution components on mesh
+ System.out.printf("\n x f f\' g\n");
+ for (int i = 0; i < nmesh; i++) {
+ ifail = 0;
+ d02ty.eval(mesh[i], y, NEQ, MMAX, rcomm, icomm, ifail);
+ ifail = d02ty.getIFAIL();
+ System.out.printf(
+ " %8.3f %9.4f%9.4f%9.4f\n", mesh[i], y[getIdx(1, 0, NEQ)],
+ y[getIdx(2, 0, NEQ)], y[getIdx(3, 0, NEQ)]
+ );
+ }
+
+ if (j == ncont - 1) {
+ break;
+ }
+
+ // Modify continuation parameter
+ r = 100.0 * r;
+ sqrofr = Math.sqrt(r);
+
+ // Select mesh for continuation
+ Arrays.fill(ipmesh, 1, nmesh - 1, 2);
+
+ // Call continuation primer routine
+ ifail = 0;
+ d02tx.eval(mxmesh, nmesh, mesh, ipmesh, rcomm, icomm, ifail);
+ mxmesh = d02tx.getMXMESH();
+ nmesh = d02tx.getNMESH();
+ ifail = d02tx.getIFAIL();
+
+ }
+
+ }
+
+ /**
+ * Converts a 2D Fortran index to the 1D index for its corresponding Java
+ * array. Assumes y is already zero-based.
+ *
+ *
Conversion:
+ * a(x, y) --> A[result]
+ */
+ private static int getIdx(int x, int y, int dimX) {
+ return (y * dimX) + (x-1);
+ }
+
+ /**
+ * Converts a 3D Fortran index to the 1D index for its corresponding Java
+ * array. Assumes z is already zero-based.
+ *
+ *