Skip to content

Commit

Permalink
upgrade alglib to 4.04
Browse files Browse the repository at this point in the history
Signed-off-by: Lamont Granquist <[email protected]>
  • Loading branch information
lamont-granquist committed Mar 5, 2025
1 parent b37d7b3 commit fecb434
Show file tree
Hide file tree
Showing 13 changed files with 7,706 additions and 1,493 deletions.
547 changes: 542 additions & 5 deletions alglib/alglibinternal.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion alglib/alglibmisc.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*************************************************************************
ALGLIB 4.03.0 (source code generated 2024-09-26)
ALGLIB 4.04.0 (source code generated 2024-12-21)
Copyright (c) Sergey Bochkanov (ALGLIB project).
>>> SOURCE LICENSE >>>
Expand Down
31 changes: 30 additions & 1 deletion alglib/ap.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************
ALGLIB 4.03.0 (source code generated 2024-09-26)
ALGLIB 4.04.0 (source code generated 2024-12-21)
Copyright (c) Sergey Bochkanov (ALGLIB project).
>>> SOURCE LICENSE >>>
Expand Down Expand Up @@ -8243,6 +8243,35 @@ static internal ulong ae_get_effective_threading_cbk(xparams p)
}
public partial class alglib
{
/*
* Parts of alglib class that are shared between all ALGLIB editions (free managed, commercial managed, commercial native)
*/
/************************************************************************
returns maximum number of worker threads allowed (either cores count or AE_NWORKERS if defined), >=1
************************************************************************/
public static int get_max_nworkers()
{
int cc = smp.cores_count;
return cc>0 ? cc : 1;
}

/************************************************************************
This function returns index of a current worker thread that calls user
callback during parallel numerical differentiation or batch evaluation:
* a value between 0 and alglib.get_max_nworkers()-1 is returned when
callback parallelism is enabled and when this function is called from a
user callback
* 0 is returned when callback parallelism is NOT enabled, or when called
from outside of a callback.
************************************************************************/
[System.ThreadStatic] internal static int _cbck_worker_idx = 0;
public static int get_callback_worker_idx()
{
return _cbck_worker_idx;
}

/*
* Parts of alglib.smp class that are shared between all ALGLIB editions (free managed, commercial managed, commercial native)
*/
Expand Down
2 changes: 1 addition & 1 deletion alglib/dataanalysis.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*************************************************************************
ALGLIB 4.03.0 (source code generated 2024-09-26)
ALGLIB 4.04.0 (source code generated 2024-12-21)
Copyright (c) Sergey Bochkanov (ALGLIB project).

>>> SOURCE LICENSE >>>
Expand Down
2 changes: 1 addition & 1 deletion alglib/diffequations.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*************************************************************************
ALGLIB 4.03.0 (source code generated 2024-09-26)
ALGLIB 4.04.0 (source code generated 2024-12-21)
Copyright (c) Sergey Bochkanov (ALGLIB project).
>>> SOURCE LICENSE >>>
Expand Down
2 changes: 1 addition & 1 deletion alglib/fasttransforms.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*************************************************************************
ALGLIB 4.03.0 (source code generated 2024-09-26)
ALGLIB 4.04.0 (source code generated 2024-12-21)
Copyright (c) Sergey Bochkanov (ALGLIB project).
>>> SOURCE LICENSE >>>
Expand Down
2 changes: 1 addition & 1 deletion alglib/integration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*************************************************************************
ALGLIB 4.03.0 (source code generated 2024-09-26)
ALGLIB 4.04.0 (source code generated 2024-12-21)
Copyright (c) Sergey Bochkanov (ALGLIB project).
>>> SOURCE LICENSE >>>
Expand Down
137 changes: 120 additions & 17 deletions alglib/interpolation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*************************************************************************
ALGLIB 4.03.0 (source code generated 2024-09-26)
ALGLIB 4.04.0 (source code generated 2024-12-21)
Copyright (c) Sergey Bochkanov (ALGLIB project).

>>> SOURCE LICENSE >>>
Expand Down Expand Up @@ -6174,10 +6174,15 @@ This subroutine uses only f(c,x[i]).
N - number of points, N>1
M - dimension of space
K - number of parameters being fitted
DiffStep- numerical differentiation step;
should not be very small or large;
large = loss of accuracy
small = growth of round-off errors
DiffStep- numerical differentiation step, >0; Obviously, step size
should not be too large in order to get a good numerical
derivative. However, it also should not be too small
because numerical errors are greatly amplified by numerical
differentiation.
By default, symmetric 3-point formula which provides good
accuracy is used. It can be changed to a faster but less
precise 2-point one with minlmsetnumdiff() function.


OUTPUT PARAMETERS:
State - structure which stores algorithm state
Expand Down Expand Up @@ -6269,10 +6274,14 @@ This subroutine uses only f(c,x[i]).
N - number of points, N>1
M - dimension of space
K - number of parameters being fitted
DiffStep- numerical differentiation step;
should not be very small or large;
large = loss of accuracy
small = growth of round-off errors
DiffStep- numerical differentiation step, >0; Obviously, step size
should not be too large in order to get a good numerical
derivative. However, it also should not be too small
because numerical errors are greatly amplified by numerical
differentiation.
By default, symmetric 3-point formula which provides good
accuracy is used. It can be changed to a faster but less
precise 2-point one with minlmsetnumdiff() function.

OUTPUT PARAMETERS:
State - structure which stores algorithm state
Expand Down Expand Up @@ -6565,6 +6574,45 @@ public static void lsfitsetnonmonotonicsteps(lsfitstate state, int cnt, alglib.x
lsfit.lsfitsetnonmonotonicsteps(state.innerobj, cnt, _params);
}

/*************************************************************************
This function sets specific finite difference formula to be used for
numerical differentiation.

It works only for optimizers configured to use numerical differentiation;
in other cases it has no effect.

INPUT PARAMETERS:
State - optimizer
FormulaType - formula type:
* 3 for a 3-point formula, which is also known as a
symmetric difference quotient (the formula actually
uses only two function values per variable: at x+h
and x-h). A good choice for medium-accuracy setups,
a default option.
* 2 for a forward (or backward, depending on variable
bounds) finite difference (f(x+h)-f(x))/h. This
formula has the lowest accuracy. However, it is 4x
faster than the 5-point formula and 2x faster than
the 3-point one because, in addition to the central
value f(x), it needs only one additional function
evaluation per variable.


-- ALGLIB --
Copyright 03.12.2024 by Bochkanov Sergey
*************************************************************************/
public static void lsfitsetnumdiff(lsfitstate state, int formulatype)
{

lsfit.lsfitsetnumdiff(state.innerobj, formulatype, null);
}

public static void lsfitsetnumdiff(lsfitstate state, int formulatype, alglib.xparams _params)
{

lsfit.lsfitsetnumdiff(state.innerobj, formulatype, _params);
}

/*************************************************************************
Stopping conditions for nonlinear least squares fitting.

Expand Down Expand Up @@ -24330,6 +24378,7 @@ Never try to access its fields directly!
public class lsfitstate : apobject
{
public int protocolversion;
public int formulatype;
public int optalgo;
public int m;
public int k;
Expand Down Expand Up @@ -24448,6 +24497,7 @@ public override alglib.apobject make_copy()
{
lsfitstate _result = new lsfitstate();
_result.protocolversion = protocolversion;
_result.formulatype = formulatype;
_result.optalgo = optalgo;
_result.m = m;
_result.k = k;
Expand Down Expand Up @@ -27821,10 +27871,15 @@ This subroutine uses only f(c,x[i]).
N - number of points, N>1
M - dimension of space
K - number of parameters being fitted
DiffStep- numerical differentiation step;
should not be very small or large;
large = loss of accuracy
small = growth of round-off errors
DiffStep- numerical differentiation step, >0; Obviously, step size
should not be too large in order to get a good numerical
derivative. However, it also should not be too small
because numerical errors are greatly amplified by numerical
differentiation.
By default, symmetric 3-point formula which provides good
accuracy is used. It can be changed to a faster but less
precise 2-point one with minlmsetnumdiff() function.


OUTPUT PARAMETERS:
State - structure which stores algorithm state
Expand Down Expand Up @@ -27875,6 +27930,7 @@ public static void lsfitcreatewf(double[,] x,
alglib.ap.assert(math.isfinite(diffstep), "LSFitCreateWF: DiffStep is not finite!");
alglib.ap.assert((double)(diffstep)>(double)(0), "LSFitCreateWF: DiffStep<=0!");
state.protocolversion = 1;
state.formulatype = 0;
state.teststep = 0;
state.diffstep = diffstep;
state.npoints = n;
Expand Down Expand Up @@ -27961,10 +28017,14 @@ This subroutine uses only f(c,x[i]).
N - number of points, N>1
M - dimension of space
K - number of parameters being fitted
DiffStep- numerical differentiation step;
should not be very small or large;
large = loss of accuracy
small = growth of round-off errors
DiffStep- numerical differentiation step, >0; Obviously, step size
should not be too large in order to get a good numerical
derivative. However, it also should not be too small
because numerical errors are greatly amplified by numerical
differentiation.
By default, symmetric 3-point formula which provides good
accuracy is used. It can be changed to a faster but less
precise 2-point one with minlmsetnumdiff() function.

OUTPUT PARAMETERS:
State - structure which stores algorithm state
Expand Down Expand Up @@ -28015,6 +28075,7 @@ public static void lsfitcreatef(double[,] x,
alglib.ap.assert(math.isfinite(diffstep), "LSFitCreateF: DiffStep is not finite!");
alglib.ap.assert((double)(diffstep)>(double)(0), "LSFitCreateF: DiffStep<=0!");
state.protocolversion = 1;
state.formulatype = 0;
state.teststep = 0;
state.diffstep = diffstep;
state.npoints = n;
Expand Down Expand Up @@ -28145,6 +28206,7 @@ public static void lsfitcreatewfg(double[,] x,
alglib.ap.assert(alglib.ap.cols(x)>=m, "LSFitCreateWFG: cols(X)<M!");
alglib.ap.assert(apserv.apservisfinitematrix(x, n, m, _params), "LSFitCreateWFG: X contains infinite or NaN values!");
state.protocolversion = 1;
state.formulatype = 0;
state.teststep = 0;
state.diffstep = 0;
state.npoints = n;
Expand Down Expand Up @@ -28276,6 +28338,7 @@ public static void lsfitcreatefg(double[,] x,
alglib.ap.assert(alglib.ap.cols(x)>=m, "LSFitCreateFG: cols(X)<M!");
alglib.ap.assert(apserv.apservisfinitematrix(x, n, m, _params), "LSFitCreateFG: X contains infinite or NaN values!");
state.protocolversion = 1;
state.formulatype = 0;
state.teststep = 0;
state.diffstep = 0;
state.npoints = n;
Expand Down Expand Up @@ -28373,6 +28436,42 @@ public static void lsfitsetnonmonotonicsteps(lsfitstate state,
}


/*************************************************************************
This function sets specific finite difference formula to be used for
numerical differentiation.

It works only for optimizers configured to use numerical differentiation;
in other cases it has no effect.

INPUT PARAMETERS:
State - optimizer
FormulaType - formula type:
* 3 for a 3-point formula, which is also known as a
symmetric difference quotient (the formula actually
uses only two function values per variable: at x+h
and x-h). A good choice for medium-accuracy setups,
a default option.
* 2 for a forward (or backward, depending on variable
bounds) finite difference (f(x+h)-f(x))/h. This
formula has the lowest accuracy. However, it is 4x
faster than the 5-point formula and 2x faster than
the 3-point one because, in addition to the central
value f(x), it needs only one additional function
evaluation per variable.


-- ALGLIB --
Copyright 03.12.2024 by Bochkanov Sergey
*************************************************************************/
public static void lsfitsetnumdiff(lsfitstate state,
int formulatype,
alglib.xparams _params)
{
alglib.ap.assert(formulatype==2 || formulatype==3, "LSFitSetNumDiff: unexpected formula type");
state.formulatype = formulatype;
}


/*************************************************************************
Stopping conditions for nonlinear least squares fitting.

Expand Down Expand Up @@ -28923,6 +29022,10 @@ public static bool lsfititeration(lsfitstate state,
minlm.minlmsetbc(state.optstate, state.bndl, state.bndu, _params);
minlm.minlmsetlc(state.optstate, state.cleic, state.tmpct, state.nec+state.nic, _params);
minlm.minlmsetnonmonotonicsteps(state.optstate, state.nonmonotoniccnt, _params);
if( state.formulatype!=0 )
{
minlm.minlmsetnumdiff(state.optstate, state.formulatype, _params);
}
state.requesttype = 0;

//
Expand Down
Loading

0 comments on commit fecb434

Please sign in to comment.