Skip to content

Commit

Permalink
Merge pull request #18 from talassio/master
Browse files Browse the repository at this point in the history
Miscelaneous updates (second batch)
  • Loading branch information
tyronerees authored May 8, 2019
2 parents ddbea68 + 9f33fbc commit 2cbb17c
Show file tree
Hide file tree
Showing 26 changed files with 2,692 additions and 2,182 deletions.
3 changes: 2 additions & 1 deletion libRALFit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,-export-dynamic")

# Set the source files that we're going to compile
set ( SRC_FILES
src/ral_nlls_double.f90
src/ral_nlls_double.f90
src/ral_nlls_internal.f90
src/ral_nlls_dtrs_double.f90
src/ral_nlls_symbols.f90
src/ral_nlls_ciface.f90
src/ral_nlls_workspaces.f90
src/ral_nlls_printing.f90
)

# Support for CMAKE_BUILD_TYPE={Debug,Release,Profile}
Expand Down
20 changes: 16 additions & 4 deletions libRALFit/doc/C/howtouse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,6 @@ The derived data type for holding options
**Printing Controls**
.. c:member:: int error
|error|
Default is 6.
.. c:member:: int out
|out|
Expand All @@ -255,6 +251,18 @@ The derived data type for holding options
.. include:: ../common/options_print_level.txt
Default is 0.
.. c:member:: bool print_options
|print_options|
Default is false.
.. c:member:: int print_header
|print_header|
Default is 30.
**Choice of Algorithm**
Expand Down Expand Up @@ -580,6 +588,10 @@ The derived data type for holding information
.. c:member:: character external_name(81)
|external_name|
.. c:member:: double step
|step|
The workspace derived data type
Expand Down
14 changes: 10 additions & 4 deletions libRALFit/doc/Fortran/howtouse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,17 +308,21 @@ The derived data type for holding options
This is used to hold controlling data. The components are automatically given default values in the definition of the type.

**Printing Controls**

:f integer error [default=6]: |error|

:f integer out [default=6]: |out|

:f integer print_level [default=0]: |print_level|

.. include:: ../common/options_print_level.txt

:f logical print_options [default=false]: |print_options|

:f integer print_header [default=30]: |print_header|

**Choice of Algorithm**

:f integer model [default=3]: |model|

.. include:: ../common/options_model.txt

:f integer type_of_method [default=1]: |type_of_method|
Expand Down Expand Up @@ -476,6 +480,8 @@ The derived data type for holding information
:f integer external_return: |external_return|

:f character external_name(80): |external_name|

:f real step: |step|


The workspace derived data type
Expand Down
20 changes: 15 additions & 5 deletions libRALFit/doc/Python/howtouse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ Controlling data is sent to the subroutine using a Python dictionary. A descrip

**Printing Controls**

* error (int)

|error|
Default is 6.

* out (int)

|out|
Expand All @@ -100,6 +95,18 @@ Controlling data is sent to the subroutine using a Python dictionary. A descrip
.. include:: ../common/options_print_level.txt

Default is 0.

* print_options (bool)

|print_options|

Default is false.

* print_header (int)

|print_header|

Default is 30.

**Choice of Algorithm**

Expand Down Expand Up @@ -393,3 +400,6 @@ This is used to hold information about the progress of the algorithm.

|scaled_g|

* step (float)
|step|

12 changes: 10 additions & 2 deletions libRALFit/doc/common/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ Possible values are:
* - -13
- Error accessing pre-allocated workspace.
* - -14
- Unsupported value in type_of_method
- Unsupported value in ``type_of_method``.
* - -15
- Unsupported value of ``inner_method`` passed in options.
* - -101
- Unsupported model in dogleg (``nlls_method = 1``).
- Unsupported model in dogleg (``nlls_method=1``).
* - -201
- All eigenvalues are imaginary (``nlls_method=2``).
* - -202
Expand All @@ -44,3 +46,9 @@ Possible values are:
- No progress being made in ``more_sorensen`` subroutine (``nlls_method=3``).
* - -401
- ``model = 4`` selected, but ``exact_second_derivatives`` is set to ``false``.
* - -900
- Illegal value of ``print_level`` in options array. Valid range is 0 to 5.
* - -950
- Combination of method/regularization options not yet implemented
* - -999
- Unexpected error occured
4 changes: 3 additions & 1 deletion libRALFit/doc/common/inform.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@

.. |norm_g| replace:: holds the gradient of the objective function at the best estimate of the solution determined by the package.

.. |scaled_g| replace:: holds the gradient of the objective function at the best estimate of the solution determined by the package.
.. |scaled_g| replace:: holds a scaled version of the gradient of the objective function at the best estimate of the solution determined by the package.

.. |external_return| replace:: gives the error code that was returned by a call to an external routine.

.. |external_name| replace:: holds the name of the external code that flagged an error.

.. |step| replace:: holds the size of the last step taken.
20 changes: 13 additions & 7 deletions libRALFit/doc/common/options.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
.. |error| replace:: the Fortran unit number for error messages. If it is negative, these messages will be suppressed.

.. |out| replace:: the Fortran unit number for general messages. If it is negative, these messages will be suppressed.

.. |print_level| replace:: controls the level of output required. Options are:

.. !+----+------------------------------------------------------------------------+
.. !| <1 | No informational output will occur. |
.. !| 0 | No informational output will occur. |
.. !+----+------------------------------------------------------------------------+
.. !| 1 | Prints a brief summary when finished. |
.. !+----+------------------------------------------------------------------------+
.. !| 2 | Gives a one-line summary for each iteration. |
.. !+----+------------------------------------------------------------------------+
.. !| 1 | Gives a one-line summary for each iteration. |
.. ! +----+------------------------------------------------------------------------+
.. !| 2 | As 1, plus gives a summary of the inner iteration for each iteration. |
.. !| 3 | As 2, but with more details. |
.. !+----+------------------------------------------------------------------------+
.. !| 3 | As 2, plus gives more verbose (debugging) output. |
.. !| 4 | As 3, plus gives a summary of the inner iteration for each iteration. |
.. !+----+------------------------------------------------------------------------+
.. !| 5 | As 4, plus gives more verbose (debugging) output. |
.. !+----+------------------------------------------------------------------------+
.. |print_options| replace:: determines whether to print a list of all options and their values at the beggining of the solve.

.. |print_header| replace:: prints the column header every ``print_header`` iterations when ``print_level > 1``.

.. |maxit| replace:: gives the number of iterations the algorithm is allowed to take before being stopped. This is not accessed if |nlls_iterate| is used.

Expand Down
16 changes: 10 additions & 6 deletions libRALFit/doc/common/options_print_level.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
.. list-table::

* - < 1
* - 0
- No informational output will occur.
* - 1
* - 1
- Prints a brief summary when finished.
* - 2
- Gives a one-line summary for each iteration.
* - 2
- As 1, plus gives a summary of the inner iteration for each iteration.
* - 3
- As 2, plus gives more verbose (debugging) output.
* - 3
- As 2, but with more details.
* - 4
- As 3, plus gives a summary of the inner iteration for each iteration.
* - 5
- As 4, plus gives more verbose (debugging) output.
7 changes: 5 additions & 2 deletions libRALFit/doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,23 @@
#####################################################
# add LaTeX macros

f = file('common/RALFit_header.sty')
f = open('common/RALFit_header.sty', 'r')
flines = f.readlines()


try:
imgmath_latex_preamble # check whether this is already defined
except NameError:
imgmath_latex_preamble = ""

for macro in f:
for macro in flines:
# used when building latex and pdf versions
latex_elements['preamble'] += macro + '\n'
# used when building html version
imgmath_latex_preamble += macro + '\n'
# (from http://stackoverflow.com/questions/9728292/creating-latex-math-macros-within-sphinx)

f.close()
#####################################################

# Grouping the document tree into LaTeX files. List of tuples
Expand Down
1 change: 1 addition & 0 deletions libRALFit/doc/info_type.tex
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
\scalarreal{scaled\_g} that holds the gradient of the objective function at the best estimate of the solution determined by the package.
\scalarinteger{external\_return} that gives the error code that was returned by a call to an external routine.
\scalarcharacter{external\_name}{80} that holds the name of the external code that flagged an error.
\scalarreal{step} holds the size of the last step taken.
\end{description}


Expand Down
10 changes: 6 additions & 4 deletions libRALFit/doc/options_type.tex
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
\noindent {\bf Components that control printing}
\begin{description}

\scalarinteger{error}
with default value {\tt 6} that is used as the \conly{Fortran }unit number for error messages.
If it is negative, these messages will be suppressed.

\scalarinteger{out}
with default value {\tt 6} that is used as the \conly{Fortran }unit number for general messages. If it is negative, these messages will be suppressed.

Expand All @@ -34,6 +30,12 @@
The default is {\tt print\_level} $=$ 0.
\end{description}

\scalarlogical{print_options}
with default value {\tt false}, determines whether to print a list of all options and their values at the beggining of the solve.

\scalarinteger{print_header}
with default value {\tt 30}, it will print the column header every 30 iterations when {\tt print\_level} is greater than 1.

\noindent {\bf Components that control the main iteration}.

\begin{description}
Expand Down
9 changes: 4 additions & 5 deletions libRALFit/example/Fortran/Lanczos.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ subroutine eval_r(status, n, m, x, r, params)
r(1:m) = params%y(:) &
- x(1)*exp(-x(2)*params%t(:)) &
- x(3)*exp(-x(4)*params%t(:)) &
- x(5)*exp(-x(6)*params%t(:))
- x(5)*exp(-x(n)*params%t(:))
end select

status = 0 ! success
Expand All @@ -50,7 +50,7 @@ subroutine eval_J(status, n, m, x, J, params)
J(2*m+1:3*m) = -exp(-x(4)*params%t(1:m)) ! J_i3
J(3*m+1:4*m) = +params%t(1:m) * x(3) * exp(-x(4)*params%t(1:m))! J_i4
J(4*m+1:5*m) = -exp(-x(6)*params%t(1:m)) ! J_i5
J(5*m+1:6*m) = +params%t(1:m) * x(5) * exp(-x(6)*params%t(1:m))! J_i6
J(5*m+1:6*m) = +params%t(1:m) * x(5) * exp(-x(n)*params%t(1:m))! J_i6
end select


Expand Down Expand Up @@ -93,7 +93,7 @@ subroutine eval_HP(status, n, m, x, y, HP, params)
class(params_base_type), intent(inout) :: params

integer :: i

status = 0
HP(1:n*m) = 0.0
select type(params)
type is (params_type)
Expand Down Expand Up @@ -130,7 +130,6 @@ program lanczos
integer :: m,n
real(wp), allocatable :: x(:)
type(params_type) :: params
integer :: inner_method
real(wp) :: tic, toc

! data to be fitted
Expand Down Expand Up @@ -191,7 +190,7 @@ program lanczos
allocate(x(n))
x = (/ 1.2, 0.3, 5.6, 5.5, 6.5, 7.6 /) ! SP 1

options%print_level = 1
options%print_level = 4
options%exact_second_derivatives = .true.
options%model = 4
options%nlls_method = 3
Expand Down
4 changes: 2 additions & 2 deletions libRALFit/example/Fortran/nlls_example.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ subroutine eval_r(status, n, m, x, r, params)
real(wp) :: x1, x2

x1 = x(1)
x2 = x(2)
x2 = x(n)
select type(params)
type is(params_type)
r(1:m) = x1 * exp(x2*params%t(:)) - params%y(:)
Expand All @@ -48,7 +48,7 @@ subroutine eval_J(status, n, m, x, J, params)
real(wp) :: x1, x2

x1 = x(1)
x2 = x(2)
x2 = x(n)
select type(params)
type is(params_type)
J( 1: m) = exp(x2*params%t(1:m)) ! J_i1
Expand Down
10 changes: 4 additions & 6 deletions libRALFit/example/Fortran/nlls_example2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ subroutine eval_r(status, n, m, x, r, params)
real(wp) :: x1, x2

x1 = x(1)
x2 = x(2)
x2 = x(n)
select type(params)
type is(params_type)
r(1:m) = x1 * exp(x2*params%t(:)) - params%y(:)
Expand All @@ -48,7 +48,7 @@ subroutine eval_J(status, n, m, x, J, params)
real(wp) :: x1, x2

x1 = x(1)
x2 = x(2)
x2 = x(n)
select type(params)
type is(params_type)
J( 1: m) = exp(x2*params%t(1:m)) ! J_i1
Expand Down Expand Up @@ -125,7 +125,6 @@ program nlls_example2
real(wp), allocatable :: x(:)
type(params_type) :: params
integer :: inner_method

! Data to be fitted
m = 5
allocate(params%t(m), params%y(m))
Expand All @@ -137,12 +136,11 @@ program nlls_example2
allocate(x(n))

options%model = 4
options%type_of_method = 3
options%type_of_method = 2
options%nlls_method = 4
options%exact_second_derivatives = .true.
options%maxit = 50

options%print_level = 1
options%print_level = 4

do inner_method = 1,3

Expand Down
4 changes: 3 additions & 1 deletion libRALFit/include/ral_nlls.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ typedef double ral_nllspkgtype_d_;
struct ral_nlls_options_d {
int f_arrays; /* Use 1-based indexing if true(!=0) else 0-based */

int error; /* Fortran output stream for error messages */
int out; /* Fortran output stream for general messages */
int print_level; /* levels of print output */
bool print_options; /* print all options? */
int print_header; /*=k; print one-liner header every k-th iteration */
int maxit; /* maximum number of iterations */
int model; /* what model to use? */
int type_of_method; /* what method to use? */
Expand Down Expand Up @@ -101,6 +102,7 @@ struct ral_nlls_inform_d {
ral_nllspkgtype_d_ scaled_g;
int external_return;
char external_name[81];
ral_nllspkgtype_d_ step;
};

/* Set default values of options */
Expand Down
Loading

0 comments on commit 2cbb17c

Please sign in to comment.