added LICENSE to cvode files

git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/trunk@8727 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
Scott R Charlton 2014-05-08 02:23:14 +00:00
parent 8e81c17eb2
commit 48ec1a3837
15 changed files with 1143 additions and 484 deletions

View File

@ -1,19 +1,63 @@
/*******************************************************************
* *
* File : cvdense.c *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, and *
* Radu Serban @ LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/cvode/LICENSE *
*-----------------------------------------------------------------*
* This is the implementation file for the CVODE dense linear *
* solver, CVDENSE. *
* *
*******************************************************************/
/**************************************************************************
* *
* File : cvdense.c *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, and *
* Radu Serban @ LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the implementation file for the CVODE dense linear *
* solver, CVDENSE. *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#include <stdio.h>
@ -32,7 +76,7 @@
#define MACHENV machEnv->phreeqc_ptr->
#define CVMEM cv_mem->cv_machenv->phreeqc_ptr->
#define MACHENV_MALLOC MACHENV
#define CVMEM_MALLOC CVMEM
#define CVMEM_MALLOC CVMEM
#include "phqalloc.h"
/* WARNING don`t include any headers below here */
@ -56,7 +100,7 @@
/******************************************************************
* *
* *
* Types : CVDenseMemRec, CVDenseMem *
*----------------------------------------------------------------*
* The type CVDenseMem is pointer to a CVDenseMemRec. This *
@ -215,13 +259,13 @@ CVDenseDQJac(integertype N, DenseMat J, RhsFn f, void *f_data,
address of this structure. It sets setupNonNull in (*cvode_mem) to
TRUE, the d_J_data field in CVDenseMemRec to be the input
parameter jac_data, and the d_jac field to be:
(1) the input parameter djac if djac != NULL or
(2) CVDenseDQJac if djac == NULL.
(1) the input parameter djac if djac != NULL or
(2) CVDenseDQJac if djac == NULL.
Finally, it allocates memory for M, savedJ, and pivots.
The return value is SUCCESS = 0, or LMEM_FAIL = -1.
NOTE: The dense linear solver assumes a serial implementation
of the NVECTOR package. Therefore, CVDense will first
of the NVECTOR package. Therefore, CVDense will first
test for compatible a compatible N_Vector internal
representation by checking (1) the machine environment
ID tag and (2) that the functions N_VMake, N_VDispose,
@ -396,9 +440,9 @@ CVDenseInit(CVodeMem cv_mem)
This routine does the setup operations for the dense linear solver.
It makes a decision whether or not to call the Jacobian evaluation
routine based on various state variables, and if not it uses the
saved copy. In any case, it constructs the Newton matrix
M = I - gamma*J, updates counters, and calls the dense LU
routine based on various state variables, and if not it uses the
saved copy. In any case, it constructs the Newton matrix
M = I - gamma*J, updates counters, and calls the dense LU
factorization routine.
**********************************************************************/

View File

@ -1,24 +1,68 @@
#ifndef _INC_CVDENSE_H
#define _INC_CVDENSE_H
/*******************************************************************
* *
* File : cvdense.h *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, and *
* Radu Serban @ LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/cvode/LICENSE *
*-----------------------------------------------------------------*
* This is the header file for the CVODE dense linear solver, *
* CVDENSE. *
* *
* Note: The type integertype must be large enough to store the *
* value of the linear system size N. *
* *
*******************************************************************/
/**************************************************************************
* *
* File : cvdense.h *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, and *
* Radu Serban @ LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the header file for the CVODE dense linear solver, *
* CVDENSE. *
* *
* Note: The type integertype must be large enough to store the *
* value of the linear system size N. *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#ifndef _cvdense_h
#define _cvdense_h
@ -74,7 +118,7 @@
/******************************************************************
* *
* *
* Type : CVDenseJacFn *
*----------------------------------------------------------------*
* A dense Jacobian approximation function Jac must have the *
@ -96,7 +140,7 @@
* col_j[i] = J_ij; *
* } *
* } *
* *
* *
* (2) (without macros - explicit data structure references) *
* for (j=0; j < N; j++) { *
* col_j = (J->data)[j]; *

206
cvode.cpp
View File

@ -1,21 +1,65 @@
/*#define DEBUG_CVODE*/
/*******************************************************************
* *
* File : cvode.c *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, Radu Serban, *
* and Dan Shumaker @ LLNL *
* Version of : 24 July 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/cvode/LICENSE *
*-----------------------------------------------------------------*
* This is the implementation file for the main CVODE integrator. *
* It is independent of the CVODE linear solver in use. *
* *
*******************************************************************/
#include "nvector_serial.h"
/**************************************************************************
* *
* File : cvode.c *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, Radu Serban, *
* and Dan Shumaker @ LLNL *
* Version of : 24 July 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the implementation file for the main CVODE integrator. *
* It is independent of the CVODE linear solver in use. *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#include "nvector_serial.h"
#define Ith(v,i) NV_Ith_S(v,i-1)
/************************************************************/
/******************* BEGIN Imports **************************/
@ -32,7 +76,7 @@
#define MACHENV machEnv->phreeqc_ptr->
#define CVMEM cv_mem->cv_machenv->phreeqc_ptr->
#define MACHENV_MALLOC MACHENV
#define CVMEM_MALLOC CVMEM
#define CVMEM_MALLOC CVMEM
#include "phqalloc.h"
/* WARNING don`t include any headers below here */
@ -503,7 +547,7 @@ static int CVHandleFailure(CVodeMem cv_mem, int kflag);
error occurs during initialization, it is reported to the file
whose file pointer is errfp and NULL is returned. Otherwise, the
pointer to successfully initialized problem memory is returned.
*****************************************************************/
void *
@ -782,7 +826,7 @@ CVodeMalloc(integertype N, RhsFn f, realtype t0, N_Vector y0,
file whose file pointer is errfp.
The return value is SUCCESS = 0 if no errors occurred, or
a negative value otherwise.
*****************************************************************/
int
@ -1047,7 +1091,7 @@ CVReInit(void *cvode_mem, RhsFn f, realtype t0, N_Vector y0,
/********************* CVode ****************************************
This routine is the main driver of the CVODE package.
This routine is the main driver of the CVODE package.
It integrates over a time interval defined by the user, by calling
CVStep to do internal time steps.
@ -1148,7 +1192,7 @@ CVode(void *cvode_mem, realtype tout, N_Vector yout, realtype * t, int itask)
}
}
/* On the first call, call f at (t0,y0), set zn[1] = y'(t0),
/* On the first call, call f at (t0,y0), set zn[1] = y'(t0),
set initial h (from H0 or CVHin), and scale zn[1] by h */
CVMEM cvode_rate_sim_time = CVMEM cvode_rate_sim_time_start + tn;
CVMEM cvode_step_fraction = 0;
@ -1380,9 +1424,9 @@ CVode(void *cvode_mem, realtype tout, N_Vector yout, realtype * t, int itask)
This routine computes the k-th derivative of the interpolating
polynomial at the time t and stores the result in the vector dky.
The formula is:
q
dky = SUM c(j,k) * (t - tn)^(j-k) * h^(-j) * zn[j] ,
j=k
q
dky = SUM c(j,k) * (t - tn)^(j-k) * h^(-j) * zn[j] ,
j=k
where c(j,k) = j*(j-1)*...*(j-k+1), q is the current order, and
zn[j] is the j-th column of the Nordsieck history array.
@ -1566,7 +1610,7 @@ CVAllocVectors(CVodeMem cv_mem, integertype neq, int maxord, M_Env machEnv)
}
/***************** CVFreeVectors *********************************
This routine frees the CVODE vectors allocated in CVAllocVectors.
******************************************************************/
@ -1585,7 +1629,7 @@ CVFreeVectors(CVodeMem cv_mem, int maxord)
}
/*********************** CVEwtSet **************************************
This routine is responsible for setting the error weight vector ewt,
according to tol_type, as follows:
@ -1599,7 +1643,7 @@ CVFreeVectors(CVodeMem cv_mem, int maxord)
considered undefined after the FALSE return from CVEwtSet.
All the real work is done in the routines CVEwtSetSS, CVEwtSetSV.
***********************************************************************/
static booleantype
@ -1666,13 +1710,13 @@ CVEwtSetSV(CVodeMem cv_mem, N_Vector ycur)
/******************* CVHin ***************************************
This routine computes a tentative initial step size h0.
This routine computes a tentative initial step size h0.
If tout is too close to tn (= t0), then CVHin returns FALSE and
h remains uninitialized. Otherwise, CVHin sets h to the chosen
h remains uninitialized. Otherwise, CVHin sets h to the chosen
value h0 and returns TRUE.
The algorithm used seeks to find h0 as a solution of
(WRMS norm of (h0^2 ydd / 2)) = 1,
(WRMS norm of (h0^2 ydd / 2)) = 1,
where ydd = estimated second derivative of y.
*****************************************************************/
@ -1695,9 +1739,9 @@ CVHin(CVodeMem cv_mem, realtype tout)
if (tdist < TWO * tround)
return (FALSE);
/* Set lower and upper bounds on h0, and take geometric mean
/* Set lower and upper bounds on h0, and take geometric mean
Exit with this value if the bounds cross each other */
hlb = HLB_FACTOR * tround;
hub = CVUpperBoundH0(cv_mem, tdist);
hg = RSqrt(hlb * hub);
@ -1828,7 +1872,7 @@ CVYddNorm(CVodeMem cv_mem, realtype hg)
}
/********************* CVStep **************************************
This routine performs one internal cvode step, from tn to tn + h.
It calls other routines to do all the work.
@ -2088,7 +2132,7 @@ CVStep(CVodeMem cv_mem)
#endif
etamax = (nst <= SMALL_NST) ? ETAMX2 : ETAMX3;
/* Finally, we rescale the acor array to be the
/* Finally, we rescale the acor array to be the
estimated local error vector. */
N_VScale(ONE / tq[2], acor, acor);
@ -2169,7 +2213,7 @@ CVAdjustAdams(CVodeMem cv_mem, int deltaq)
}
/* On an order decrease, each zn[j] is adjusted by a multiple
of zn[q]. The coefficients in the adjustment are the
of zn[q]. The coefficients in the adjustment are the
coefficients of the polynomial x*x*(x+xi_1)*...*(x+xi_j),
integrated, where xi_j = [t_n - t_(n-j)]/h. */
@ -2195,8 +2239,8 @@ CVAdjustAdams(CVodeMem cv_mem, int deltaq)
/********************** CVAdjustBDF *******************************
This is a high level routine which handles adjustments to the
history array on a change of order by deltaq in the case that
lmm == BDF. CVAdjustBDF calls CVIncreaseBDF if deltaq = +1 and
history array on a change of order by deltaq in the case that
lmm == BDF. CVAdjustBDF calls CVIncreaseBDF if deltaq = +1 and
CVDecreaseBDF if deltaq = -1 to do the actual work.
******************************************************************/
@ -2217,11 +2261,11 @@ CVAdjustBDF(CVodeMem cv_mem, int deltaq)
/******************** CVIncreaseBDF **********************************
This routine adjusts the history array on an increase in the
order q in the case that lmm == BDF.
A new column zn[q+1] is set equal to a multiple of the saved
This routine adjusts the history array on an increase in the
order q in the case that lmm == BDF.
A new column zn[q+1] is set equal to a multiple of the saved
vector (= acor) in zn[qmax]. Then each zn[j] is adjusted by
a multiple of zn[q+1]. The coefficients in the adjustment are the
a multiple of zn[q+1]. The coefficients in the adjustment are the
coefficients of the polynomial x*x*(x+xi_1)*...*(x+xi_(q-1)),
where xi_j = [t_n - t_(n-j)]/h.
@ -2262,8 +2306,8 @@ CVIncreaseBDF(CVodeMem cv_mem)
/********************* CVDecreaseBDF ******************************
This routine adjusts the history array on a decrease in the
order q in the case that lmm == BDF.
This routine adjusts the history array on a decrease in the
order q in the case that lmm == BDF.
Each zn[j] is adjusted by a multiple of zn[q]. The coefficients
in the adjustment are the coefficients of the polynomial
x*x*(x+xi_1)*...*(x+xi_(q-2)), where xi_j = [t_n - t_(n-j)]/h.
@ -2339,7 +2383,7 @@ CVPredict(CVodeMem cv_mem)
/************************** CVSet *********************************
This routine is a high level routine which calls CVSetAdams or
CVSetBDF to set the polynomial l, the test quantity array tq,
CVSetBDF to set the polynomial l, the test quantity array tq,
and the related variables rl1, gamma, and gamrat.
******************************************************************/
@ -2407,7 +2451,7 @@ CVSetAdams(CVodeMem cv_mem)
This routine generates in m[] the coefficients of the product
polynomial needed for the Adams l and tq coefficients for q > 1.
******************************************************************/
static realtype
@ -2471,7 +2515,7 @@ CVAdamsFinish(CVodeMem cv_mem, realtype m[], realtype M[], realtype hsum)
}
/****************** CVAltSum **************************************
CVAltSum returns the value of the alternating sum
sum (i= 0 ... iend) [ (-1)^i * (a[i] / (i + k)) ].
If iend < 0 then CVAltSum returns 0.
@ -2503,7 +2547,7 @@ CVAltSum(int iend, realtype a[], int k)
This routine computes the coefficients l and tq in the case
lmm == BDF. CVSetBDF calls CVSetTqBDF to set the test
quantity array tq.
quantity array tq.
The components of the array l are the coefficients of a
polynomial Lambda(x) = l_0 + l_1 x + ... + l_q x^q, given by
@ -2612,7 +2656,7 @@ CVnls(CVodeMem cv_mem, int nflag)
/***************** CVnlsFunctional ********************************
This routine attempts to solve the nonlinear system using
This routine attempts to solve the nonlinear system using
functional iteration (no matrices involved).
******************************************************************/
@ -2695,8 +2739,8 @@ CVnlsFunctional(CVodeMem cv_mem)
/*********************** CVnlsNewton **********************************
This routine handles the Newton iteration. It calls lsetup if
indicated, calls CVNewtonIteration to perform the iteration, and
This routine handles the Newton iteration. It calls lsetup if
indicated, calls CVNewtonIteration to perform the iteration, and
retries a failed attempt at Newton iteration if that is indicated.
See return values at top of this file.
@ -2800,7 +2844,7 @@ CVnlsNewton(CVodeMem cv_mem, int nflag)
ier));
#endif
}
/* If there is a convergence failure and the Jacobian-related
/* If there is a convergence failure and the Jacobian-related
data appears not to be current, loop again with a call to lsetup
in which convfail=FAIL_BAD_J. Otherwise return. */
if (ier != TRY_AGAIN_CVODE)
@ -2813,11 +2857,11 @@ CVnlsNewton(CVodeMem cv_mem, int nflag)
/********************** CVNewtonIteration ****************************
This routine performs the Newton iteration. If the iteration succeeds,
it returns the value SOLVED. If not, it may signal the CVnlsNewton
it returns the value SOLVED. If not, it may signal the CVnlsNewton
routine to call lsetup again and reattempt the iteration, by
returning the value TRY_AGAIN_CVODE. (In this case, CVnlsNewton must set
convfail to FAIL_BAD_J before calling setup again).
Otherwise, this routine returns one of the appropriate values
returning the value TRY_AGAIN_CVODE. (In this case, CVnlsNewton must set
convfail to FAIL_BAD_J before calling setup again).
Otherwise, this routine returns one of the appropriate values
SOLVE_FAIL_UNREC or CONV_FAIL back to CVnlsNewton.
*********************************************************************/
@ -2895,7 +2939,7 @@ CVNewtonIteration(CVodeMem cv_mem)
mnewt = ++m;
/* Stop at maxcor iterations or if iter. seems to be diverging.
If still not converged and Jacobian data is not current,
If still not converged and Jacobian data is not current,
signal to try the solution again */
if ((m == maxcor) || ((m >= 2) && (del > RDIV * delp)))
{
@ -2929,7 +2973,7 @@ CVNewtonIteration(CVodeMem cv_mem)
This routine takes action on the return value nflag = *nflagPtr
returned by CVnls, as follows:
If CVnls succeeded in solving the nonlinear system, then
CVHandleNFlag returns the constant DO_ERROR_TEST, which tells CVStep
to perform the error test.
@ -2943,10 +2987,10 @@ CVNewtonIteration(CVodeMem cv_mem)
If it failed due to an unrecoverable failure in solve, then we return
the value SOLVE_FAILED.
Otherwise, a recoverable failure occurred when solving the
nonlinear system (CVnls returned nflag == CONV_FAIL).
Otherwise, a recoverable failure occurred when solving the
nonlinear system (CVnls returned nflag == CONV_FAIL).
In this case, we return the value REP_CONV_FAIL if ncf is now
equal to MXNCF or |h| = hmin.
equal to MXNCF or |h| = hmin.
If not, we set *nflagPtr = PREV_CONV_FAIL and return the value
PREDICT_AGAIN, telling CVStep to reattempt the step.
@ -3008,14 +3052,14 @@ CVRestore(CVodeMem cv_mem, realtype saved_t)
/******************* CVDoErrorTest ********************************
This routine performs the local error test.
The weighted local error norm dsm is loaded into *dsmPtr, and
This routine performs the local error test.
The weighted local error norm dsm is loaded into *dsmPtr, and
the test dsm ?<= 1 is made.
If the test passes, CVDoErrorTest returns TRUE.
If the test passes, CVDoErrorTest returns TRUE.
If the test fails, we undo the step just taken (call CVRestore),
set *nflagPtr to PREV_ERR_FAIL, and return FALSE.
If the test fails, we undo the step just taken (call CVRestore),
set *nflagPtr to PREV_ERR_FAIL, and return FALSE.
If MXNEF error test failures have occurred or if ABS(h) = hmin,
we set *kflagPtr = REP_ERR_FAIL. (Otherwise *kflagPtr has the
@ -3102,7 +3146,7 @@ CVDoErrorTest(CVodeMem cv_mem, int *nflagPtr, int *kflagPtr,
/*************** CVCompleteStep **********************************
This routine performs various update operations when the solution
to the nonlinear system has passed the local error test.
to the nonlinear system has passed the local error test.
We increment the step counter nst, record the values hu and qu,
update the tau array, and apply the corrections to the zn array.
The tau[i] are the last q values of h, with tau[1] the most recent.
@ -3141,8 +3185,8 @@ CVCompleteStep(CVodeMem cv_mem)
This routine handles the setting of stepsize and order for the
next step -- hprime and qprime. Along with hprime, it sets the
ratio eta = hprime/h. It also updates other state variables
related to a change of step size or order.
ratio eta = hprime/h. It also updates other state variables
related to a change of step size or order.
******************************************************************/
@ -3171,7 +3215,7 @@ CVPrepareNextStep(CVodeMem cv_mem, realtype dsm)
return;
}
/* If qwait = 0, consider an order change. etaqm1 and etaqp1 are
/* If qwait = 0, consider an order change. etaqm1 and etaqp1 are
the ratios of new to old h at orders q-1 and q+1, respectively.
CVChooseEta selects the largest; CVSetEta adjusts eta and acor */
qwait = 2;
@ -3259,7 +3303,7 @@ CVComputeEtaqp1(CVodeMem cv_mem)
/******************* CVChooseEta **********************************
Given etaqm1, etaq, etaqp1 (the values of eta for qprime =
q - 1, q, or q + 1, respectively), this routine chooses the
q - 1, q, or q + 1, respectively), this routine chooses the
maximum eta value, sets eta to that value, and sets qprime to the
corresponding value of q. If there is a tie, the preference
order is to (1) keep the same order, then (2) decrease the order,
@ -3340,7 +3384,7 @@ CVHandleFailure(CVodeMem cv_mem, int kflag)
}
return (SETUP_FAILURE);
case SOLVE_FAILED:
{
{
char * error_string = CVMEM sformatf(MSG_SOLVE_FAILED, (double) tn);
CVMEM warning_msg(error_string);
}
@ -3415,21 +3459,21 @@ CVBDFStab(CVodeMem cv_mem)
}
else
{
/* Otherwise, let order increase happen, and
/* Otherwise, let order increase happen, and
reset stability limit counter, nscon. */
nscon = 0;
}
}
/********************* CVsldet ************************************
This routine detects stability limitation using stored scaled
This routine detects stability limitation using stored scaled
derivatives data. CVsldet returns the magnitude of the
dominate characteristic root, rr. The presents of a stability
limit is indicated by rr > "something a little less then 1.0",
limit is indicated by rr > "something a little less then 1.0",
and a positive kflag. This routine should only be called if
order is greater than or equal to 3, and data has been collected
for 5 time steps.
for 5 time steps.
Returned values:
kflag = 1 -> Found stable characteristic root, normal matrix case
kflag = 2 -> Found stable characteristic root, quartic solution
@ -3440,14 +3484,14 @@ CVBDFStab(CVodeMem cv_mem)
kflag = 6 -> Found stability violation, quartic solution,
with Newton correction
kflag < 0 -> No stability limitation,
kflag < 0 -> No stability limitation,
or could not compute limitation.
kflag = -1 -> Min/max ratio of ssdat too small.
kflag = -2 -> For normal matrix case, vmax > vrrt2*vrrt2
kflag = -3 -> For normal matrix case, The three ratios
are inconsistent.
kflag = -4 -> Small coefficient prevents elimination of quartics.
kflag = -4 -> Small coefficient prevents elimination of quartics.
kflag = -5 -> R value from quartics not consistent.
kflag = -6 -> No corrected root passes test on qk values
kflag = -7 -> Trouble solving for sigsq.
@ -3532,8 +3576,8 @@ CVsldet(CVodeMem cv_mem)
} /* End of k loop */
/* Isolate normal or nearly-normal matrix case. Three quartic will
have common or nearly-common roots in this case.
Return a kflag = 1 if this procedure works. If three root
have common or nearly-common roots in this case.
Return a kflag = 1 if this procedure works. If three root
differ more than vrrt2, return error kflag = -3. */
vmin = MIN(vrat[1], MIN(vrat[2], vrat[3]));

88
cvode.h
View File

@ -1,20 +1,64 @@
#ifndef _INC_CVODE_H
#define _INC_CVODE_H
/*******************************************************************
* *
* File : cvode.h *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, Radu Serban *
* and Dan Shumaker @ LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/cvode/LICENSE *
*-----------------------------------------------------------------*
* This is the interface file for the main CVODE integrator. *
* *
*******************************************************************/
/**************************************************************************
* *
* File : cvode.h *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, Radu Serban *
* and Dan Shumaker @ LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the interface file for the main CVODE integrator. *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#ifndef _cvode_h
#define _cvode_h
@ -95,11 +139,11 @@
/******************************************************************
* *
* Type : RhsFn *
*----------------------------------------------------------------*
*----------------------------------------------------------------*
* The f function which defines the right hand side of the ODE *
* system y' = f(t,y) must have type RhsFn. *
* f takes as input the problem size N, the independent variable *
* value t, and the dependent variable vector y. It stores the *
* value t, and the dependent variable vector y. It stores the *
* result of f(t,y) in the vector ydot. The y and ydot arguments *
* are of type N_Vector. *
* (Allocation of memory for ydot is handled within CVODE.) *
@ -124,7 +168,7 @@
* *
* N is the number of equations in the ODE system. *
* *
* f is the right hand side function in y' = f(t,y). *
* f is the right hand side function in y' = f(t,y). *
* *
* t0 is the initial value of t. *
* *
@ -195,7 +239,7 @@
* (*reltol) and either (*abstol), for a scalar absolute *
* tolerance, or the components of abstol, for a vector *
* absolute tolerance. *
* *
* *
* If successful, CVodeMalloc returns a pointer to initialized *
* problem memory. This pointer should be passed to CVode. If *
* an initialization error occurs, CVodeMalloc prints an error *
@ -401,7 +445,7 @@
* BAD_DKY : The dky argument was NULL. *
* *
* DKY_NO_MEM : The cvode_mem argument was NULL. *
* *
* *
******************************************************************/
@ -452,7 +496,7 @@
* the solver in its attempt to reach tout. *
* Optional input. (Default = 500). *
* *
* iopt[MXHNIL] : maximum number of warning messages issued by the*
* iopt[MXHNIL] : maximum number of warning messages issued by the*
* solver that t + h = t on the next internal step.*
* A value of -1 means no such messages are issued.*
* Optional input. (Default = 10). *
@ -760,7 +804,7 @@
* NO_FAILURES : Either this is the first cv_setup call for this *
* step, or the local error test failed on the *
* previous attempt at this step (but the Newton *
* iteration converged). *
* iteration converged). *
* *
* FAIL_BAD_J : This value is passed to cv_lsetup if *
* *

View File

@ -1,19 +1,63 @@
/*******************************************************************
* *
* File : dense.c *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, and *
* Radu Serban @ LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/shared/LICENSE *
*-----------------------------------------------------------------*
* This is the implementation file for a generic DENSE linear *
* solver package. *
* *
*******************************************************************/
/**************************************************************************
* *
* File : dense.c *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, and *
* Radu Serban @ LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the implementation file for a generic DENSE linear *
* solver package. *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#include <stdio.h>
#include <stdlib.h>

124
dense.h
View File

@ -1,42 +1,86 @@
#ifndef _INC_DENSE_H
#define _INC_DENSE_H
/*******************************************************************
* *
* File : dense.h *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, and *
* Radu Serban @ LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/shared/LICENSE *
*-----------------------------------------------------------------*
* This is the header file for a generic DENSE linear solver *
* package. The routines listed in this file all use type *
* DenseMat, defined below, for matrices. These routines in turn *
* call routines in the smalldense.h/smalldense.c module, which *
* use the type realtype** for matrices. This separation allows *
* for possible modifications in which matrices of type DenseMat *
* may not be stored contiguously, while small matrices can still *
* be treated with the routines in smalldense. *
* *
* Routines that work with the type DenseMat begin with "Dense". *
* The DenseAllocMat function allocates a dense matrix for use in *
* the other DenseMat routines listed in this file. Matrix *
* storage details are given in the documentation for the type *
* DenseMat. The DenseAllocPiv function allocates memory for *
* pivot information. The storage allocated by DenseAllocMat and *
* DenseAllocPiv is deallocated by the routines DenseFreeMat and *
* DenseFreePiv, respectively. The DenseFactor and DenseBacksolve *
* routines perform the actual solution of a dense linear system. *
* *
* Routines that work with realtype** begin with "den" (except for *
* the factor and solve routines which are called gefa and gesl, *
* respectively). The underlying matrix storage is described in *
* the documentation for denalloc in smalldense.h *
* *
*******************************************************************/
/**************************************************************************
* *
* File : dense.h *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, and *
* Radu Serban @ LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the header file for a generic DENSE linear solver *
* package. The routines listed in this file all use type *
* DenseMat, defined below, for matrices. These routines in turn *
* call routines in the smalldense.h/smalldense.c module, which *
* use the type realtype** for matrices. This separation allows *
* for possible modifications in which matrices of type DenseMat *
* may not be stored contiguously, while small matrices can still *
* be treated with the routines in smalldense. *
* *
* Routines that work with the type DenseMat begin with "Dense". *
* The DenseAllocMat function allocates a dense matrix for use in *
* the other DenseMat routines listed in this file. Matrix *
* storage details are given in the documentation for the type *
* DenseMat. The DenseAllocPiv function allocates memory for *
* pivot information. The storage allocated by DenseAllocMat and *
* DenseAllocPiv is deallocated by the routines DenseFreeMat and *
* DenseFreePiv, respectively. The DenseFactor and DenseBacksolve *
* routines perform the actual solution of a dense linear system. *
* *
* Routines that work with realtype** begin with "den" (except for *
* the factor and solve routines which are called gefa and gesl, *
* respectively). The underlying matrix storage is described in *
* the documentation for denalloc in smalldense.h *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#ifndef _dense_h
#define _dense_h
@ -121,8 +165,8 @@
* returns the storage allocated (type DenseMat). DenseAllocMat *
* returns NULL if the request for matrix storage cannot be *
* satisfied. See the above documentation for the type DenseMat *
* for matrix storage details. *
* *
* for matrix storage details. *
* *
******************************************************************/
DenseMat DenseAllocMat(integertype N);
@ -140,7 +184,7 @@
* information is an array of N integers and this routine returns *
* the pointer to the memory it allocates. If the request for *
* pivot storage cannot be satisfied, DenseAllocPiv returns NULL. *
* *
* *
******************************************************************/
integertype *DenseAllocPiv(integertype N);

View File

@ -1,19 +1,63 @@
/*******************************************************************
* *
* File : nvector.c *
* Programmers : Radu Serban, LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/shared/LICENSE *
*-----------------------------------------------------------------*
* This is the implementation file for a generic NVECTOR *
* package. It contains the implementation of the N_Vector *
* kernels listed in nvector.h. *
* *
*******************************************************************/
/**************************************************************************
* *
* File : nvector.c *
* Programmers : Radu Serban, LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the implementation file for a generic NVECTOR *
* package. It contains the implementation of the N_Vector *
* kernels listed in nvector.h. *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#include "nvector.h" /* generic M_Env and N_Vector */

130
nvector.h
View File

@ -1,44 +1,88 @@
/*******************************************************************
* *
* File : nvector.h *
* Programmers : Radu Serban, LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/shared/LICENSE *
*-----------------------------------------------------------------*
* This is the header file for a generic NVECTOR package. *
* It defines the N_Vector and M_Env structures: *
* M_Env has an implementation-dependent 'content' field *
* which contains the data needed to generate a new *
* nvector in that implementation and an 'ops' filed *
* which is a structure listing operations acting on *
* such nvectors. *
* N_Vector has an implementation-dependent 'content' field *
* which contains the description and actual data of *
* the nvector and a 'menv' field which points to the *
* M_Env structure used in creating the nvector. *
* *
* Part I of this file contains type declarations for the *
* the following structures: _generic_M_Env, _generic_N_Vector, *
* and _generic_N_Vector_Ops, as well as references to pointers *
* to such structures (M_Env and N_Vector). *
* *
* Part II of this file contains the prototypes for the vector *
* kernels which operate on N_Vector. *
* *
* A particular implementation of an NVECTOR package must then *
* specify the 'content' fields of M_Env and N_Vector, define *
* the propotypes for kernel operations on those N_Vectors *
* (NOTE: kernel routine names must be unique to that *
* implementation), and finally provide an initialization *
* routine (which generates an M_Env with that particular *
* 'content' field and links the defined vector kernel routines *
* into the 'ops' field). *
* *
*******************************************************************/
/**************************************************************************
* *
* File : nvector.h *
* Programmers : Radu Serban, LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the header file for a generic NVECTOR package. *
* It defines the N_Vector and M_Env structures: *
* M_Env has an implementation-dependent 'content' field *
* which contains the data needed to generate a new *
* nvector in that implementation and an 'ops' filed *
* which is a structure listing operations acting on *
* such nvectors. *
* N_Vector has an implementation-dependent 'content' field *
* which contains the description and actual data of *
* the nvector and a 'menv' field which points to the *
* M_Env structure used in creating the nvector. *
* *
* Part I of this file contains type declarations for the *
* the following structures: _generic_M_Env, _generic_N_Vector, *
* and _generic_N_Vector_Ops, as well as references to pointers *
* to such structures (M_Env and N_Vector). *
* *
* Part II of this file contains the prototypes for the vector *
* kernels which operate on N_Vector. *
* *
* A particular implementation of an NVECTOR package must then *
* specify the 'content' fields of M_Env and N_Vector, define *
* the propotypes for kernel operations on those N_Vectors *
* (NOTE: kernel routine names must be unique to that *
* implementation), and finally provide an initialization *
* routine (which generates an M_Env with that particular *
* 'content' field and links the defined vector kernel routines *
* into the 'ops' field). *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
class Phreeqc;
#ifndef included_nvector_h
@ -99,7 +143,7 @@ class Phreeqc;
/* A machine environment is a structure with an implementation
dependent 'content' representation (used to generate a new vector
in that implementation), a set of operations defined in the above
in that implementation), a set of operations defined in the above
structure, and an ID tag */
struct _generic_M_Env
{
@ -110,7 +154,7 @@ class Phreeqc;
};
/* A vector is a structure with an implementation dependent content
representation and a pointer to the machine environment
representation and a pointer to the machine environment
corresponding to that implementation */
struct _generic_N_Vector
{

View File

@ -1,23 +1,66 @@
/*******************************************************************
* *
* File : nvector_serial.c *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, *
* Radu Serban, and Allan G. Taylor, LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/shared/LICENSE *
*-----------------------------------------------------------------*
* This is the implementation file for a serial implementation *
* of the NVECTOR package. It contains the implementation of *
* the serial machine environment intialization and free *
* routines (and of the Fortran callable interfaces to them) *
* and of the N_Vector kernels listed in nvector_serial.h. *
* *
*******************************************************************/
/**************************************************************************
* *
* File : nvector_serial.c *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, *
* Radu Serban, and Allan G. Taylor, LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the implementation file for a serial implementation *
* of the NVECTOR package. It contains the implementation of *
* the serial machine environment intialization and free *
* routines (and of the Fortran callable interfaces to them) *
* and of the N_Vector kernels listed in nvector_serial.h. *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -57,7 +100,7 @@ static void VScaleBy_Serial(realtype a, N_Vector x);
/********************* Exported Functions ************************/
/* Serial implementation of the machine environment
/* Serial implementation of the machine environment
initialization routine */
M_Env
@ -128,7 +171,7 @@ M_EnvInit_Serial(integertype vec_length)
}
/* Serial implementation of the machine environment
/* Serial implementation of the machine environment
free routine */
void

View File

@ -1,59 +1,103 @@
#ifndef _INC_NVECTOR_SERIAL_H
#define _INC_NVECTOR_SERIAL_H
/*******************************************************************
* *
* File : nvector_serial.h *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, *
* : Radu Serban, and Allan G. Taylor, LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/shared/LICENSE *
*-----------------------------------------------------------------*
* This is the header file for a serial implementation of the *
* NVECTOR package. *
* *
* Part I of this file contains declarations which are specific *
* to the particular machine environment in which this version *
* of the vector package is to be used. This includes the *
* typedef for the 'content' fields of the structures M_Env and *
* N_Vector (M_EnvSerialContent and N_VectorSerialContent, *
* respectively). *
* *
* Part II of this file defines accessor macros that allow the *
* user to use efficiently the type N_Vector without making *
* explicit references to its underlying representation. *
* *
* Part III of this file contains the prototype for the *
* initialization routine specific to this implementation *
* (M_EnvInit_Serial) as well as prototypes for the vector *
* kernels which operate on the serial N_Vector. These *
* prototypes are unique to this particular implementation of *
* the vector package. *
* *
* NOTES: *
* *
* The definitions of the generic M_Env and N_Vector structures *
* are in the header file nvector.h. *
* *
* The definitions of the types realtype and integertype are in *
* the header file sundialstypes.h and these may be changed *
* according to the user's needs. The sundialstypes.h file also *
* contains the definition for the type booleantype. *
* *
* N_Vector arguments to arithmetic kernels need not be *
* distinct. Thus, for example, the call *
* N_VLinearSum_Serial(a,x,b,y,y); y <- ax+by *
* is legal. *
* *
* This version of nvector is for the ordinary sequential *
* machine environment. In the documentation given below, N is *
* the length of all N_Vector parameters and x[i] denotes the *
* ith component of the N_Vector x, where 0 <= i <= N-1. *
* *
*******************************************************************/
/**************************************************************************
* *
* File : nvector_serial.h *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, *
* : Radu Serban, and Allan G. Taylor, LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the header file for a serial implementation of the *
* NVECTOR package. *
* *
* Part I of this file contains declarations which are specific *
* to the particular machine environment in which this version *
* of the vector package is to be used. This includes the *
* typedef for the 'content' fields of the structures M_Env and *
* N_Vector (M_EnvSerialContent and N_VectorSerialContent, *
* respectively). *
* *
* Part II of this file defines accessor macros that allow the *
* user to use efficiently the type N_Vector without making *
* explicit references to its underlying representation. *
* *
* Part III of this file contains the prototype for the *
* initialization routine specific to this implementation *
* (M_EnvInit_Serial) as well as prototypes for the vector *
* kernels which operate on the serial N_Vector. These *
* prototypes are unique to this particular implementation of *
* the vector package. *
* *
* NOTES: *
* *
* The definitions of the generic M_Env and N_Vector structures *
* are in the header file nvector.h. *
* *
* The definitions of the types realtype and integertype are in *
* the header file sundialstypes.h and these may be changed *
* according to the user's needs. The sundialstypes.h file also *
* contains the definition for the type booleantype. *
* *
* N_Vector arguments to arithmetic kernels need not be *
* distinct. Thus, for example, the call *
* N_VLinearSum_Serial(a,x,b,y,y); y <- ax+by *
* is legal. *
* *
* This version of nvector is for the ordinary sequential *
* machine environment. In the documentation given below, N is *
* the length of all N_Vector parameters and x[i] denotes the *
* ith component of the N_Vector x, where 0 <= i <= N-1. *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#ifndef included_nvector_serial_h
#define included_nvector_serial_h
@ -66,7 +110,7 @@
* Serial implementaion of M_Env and N_Vector *
****************************************************************/
/* The serial implementation of the machine environment has
/* The serial implementation of the machine environment has
ID tag 'serial' */
#define ID_TAG_S "serial"
@ -80,8 +124,8 @@
typedef struct _M_EnvSerialContent *M_EnvSerialContent;
/* The serial implementation of the N_Vector 'content'
structure contains the length of the vector and a pointer
/* The serial implementation of the N_Vector 'content'
structure contains the length of the vector and a pointer
to an array of realtype components */
struct _N_VectorSerialContent
@ -148,11 +192,11 @@
* (3) ME_CONTENT_S, NV_CONTENT_S *
* *
* These routines give access to the contents of the serial *
* machine environment and N_Vector, respectively. *
* machine environment and N_Vector, respectively. *
* *
* The assignment m_cont = ME_CONTENT_S(machenv) sets *
* m_cont to be a pointer to the serial machine *
* environment content structure. *
* environment content structure. *
* *
* The assignment v_cont = NV_CONTENT_S(v) sets *
* v_cont to be a pointer to the serial N_Vector content *
@ -166,7 +210,7 @@
* The assignment v_data=NV_DATA_S(v) sets v_data to be *
* a pointer to the first component of v. The assignment *
* NV_DATA_S(v)=v_data sets the component array of v to *
* be v_data by storing the pointer v_data. *
* be v_data by storing the pointer v_data. *
* *
* The assignment v_len=NV_LENGTH_S(v) sets v_len to be *
* the length of v. The call NV_LENGTH_S(v)=len_v sets *
@ -277,7 +321,7 @@
void M_EnvFree_Serial(M_Env machenv);
/*--------------------------------------------------------------*
* Serial implementations of the vector operations *
* Serial implementations of the vector operations *
* *
* For a complete description of each of the following routines *
* see the header file nvector.h *

View File

@ -1,18 +1,62 @@
/*******************************************************************
* *
* File : smalldense.c *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/shared/LICENSE *
*-----------------------------------------------------------------*
* This is the implementation file for a generic DENSE linear *
* solver package, intended for small dense matrices. *
* *
*******************************************************************/
/**************************************************************************
* *
* File : smalldense.c *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the implementation file for a generic DENSE linear *
* solver package, intended for small dense matrices. *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#include <stdio.h>
#include <stdlib.h>

View File

@ -1,24 +1,68 @@
/*******************************************************************
* *
* File : smalldense.h *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/shared/LICENSE *
*-----------------------------------------------------------------*
* This is the header file for a generic DENSE linear solver *
* package, intended for small dense matrices. These routines *
* use the type realtype** for dense matrix arguments. *
* *
* These routines begin with "den" (except for the factor and *
* solve routines which are called gefa and gesl, respectively). *
* The underlying matrix storage is described in the *
* documentation for denalloc. *
* *
*******************************************************************/
/**************************************************************************
* *
* File : smalldense.h *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 *
*----------------------------------------------------------------- *
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*----------------------------------------------------------------- *
* This is the header file for a generic DENSE linear solver *
* package, intended for small dense matrices. These routines *
* use the type realtype** for dense matrix arguments. *
* *
* These routines begin with "den" (except for the factor and *
* solve routines which are called gefa and gesl, respectively). *
* The underlying matrix storage is described in the *
* documentation for denalloc. *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#ifndef _smalldense_h
#define _smalldense_h
@ -88,7 +132,7 @@
* triangular matrix, then the upper triangular part of a *
* (including its diagonal) contains U and the strictly lower *
* triangular part of a contains the multipliers, I-L. *
* *
* *
* gefa returns 0 if successful. Otherwise it encountered a zero *
* diagonal element during the factorization. In this case it *
* returns the column index (numbered from one) at which it *

View File

@ -1,17 +1,61 @@
/*******************************************************************
* *
* File : sundialsmath.c *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/shared/LICENSE *
*-----------------------------------------------------------------*
* This is the implementation file for a C math library. *
* *
*******************************************************************/
/**************************************************************************
* *
* File : sundialsmath.c *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the implementation file for a C math library. *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#include <stdio.h>

View File

@ -1,27 +1,71 @@
/*******************************************************************
* *
* File : sundialsmath.h *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/shared/LICENSE *
*-----------------------------------------------------------------*
* This is the header file for a C math library. The routines *
* listed here work with the type realtype as defined in *
* sundialstypes.h. *
* To do single precision floating point arithmetic, set the type *
* realtype to be float. To do double precision arithmetic, set *
* the type realtype to be double. The default implementations *
* for RPowerR and RSqrt call standard math library functions *
* which do double precision arithmetic. If this is unacceptable *
* when realtype is float, then the user should re-implement *
* these two routines by calling single precision routines *
* available on his/her machine. *
* *
*******************************************************************/
/**************************************************************************
* *
* File : sundialsmath.h *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This is the header file for a C math library. The routines *
* listed here work with the type realtype as defined in *
* sundialstypes.h. *
* To do single precision floating point arithmetic, set the type *
* realtype to be float. To do double precision arithmetic, set *
* the type realtype to be double. The default implementations *
* for RPowerR and RSqrt call standard math library functions *
* which do double precision arithmetic. If this is unacceptable *
* when realtype is float, then the user should re-implement *
* these two routines by calling single precision routines *
* available on his/her machine. *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#ifndef _sundialsmath_h
#define _sundialsmath_h

View File

@ -4,69 +4,113 @@
#include "phrqtype.h"
#ifndef _INC_SUNDIALSTYPES_H
#define _INC_SUNDIALSTYPES_H
/*******************************************************************
* *
* File : sundialstypes.h *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 *
*-----------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see sundials/shared/LICENSE *
*-----------------------------------------------------------------*
* This header file exports three types: realtype, integertype, *
* and booleantype, as well as the constants TRUE and FALSE. *
* *
* Users should #include "sundialstypes.h" in any file that *
* shhould be easily modifiable to work with different real or *
* integer types and use the exported names realtype and *
* integertype within such a file. *
* The types for realtype and integertype below have been set to *
* double and long int, respectively. A user should modify these *
* type declarations as he/she sees fit. For example, if a user *
* wants the work with type float because double precision *
* floating point arithmetic is too expensive on the user's *
* machine, then the definition below should be changed to: *
* *
* typedef float realtype; *
* *
* Similarly, if a user does not need to work with extremely large *
* integers (see the system header file <limits.h> for the limits *
* on type int and long int on your machine), then the user *
* should change the definition below to: *
* *
* typedef int integertype; *
* *
* The constants SUNDIALS_FLOAT, SUNDIALS_DOUBLE, SUNDIALS_INT, *
* SUNDIALS_LONG indicate the underlying types for realtype and *
* integertype. They should be set as follows: *
* *
* (1) #define SUNDIALS_FLOAT 1 *
* #define SUNDIALS_DOUBLE 0 (real is float) *
* *
* (2) #define SUNDIALS_FLOAT 0 *
* #define SUNDIALS_DOUBLE 1 (real is double) *
* *
* (3) #define SUNDIALS_INT 1 *
* #define SUNDIALS_LONG 0 (integer is int) *
* *
* (4) #define SUNDIALS_INT 0 *
* #define SUNDIALS_LONG 1 (integer is long int) *
* *
* Thus the legal types for realtype are float and double, while *
* the legal types for integertype are int and long int. *
* The macro RCONST gives a user a convenient way to define real *
* constants. To use the real constant 1.0, for example, the *
* user should write *
* *
* #define ONE RCONST(1.0) *
* *
* If realtype is double, then RCONST(1.0) expands to 1.0. *
* If realtype is float, then RCONST(1.0) expands to 1.0F. *
* There is never a need to explicitly cast 1.0 to (realtype). *
* *
*******************************************************************/
/**************************************************************************
* *
* File : sundialstypes.h *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory *
* All rights reserved *
* For details, see LICENSE below *
*------------------------------------------------------------------------*
* This header file exports three types: realtype, integertype, *
* and booleantype, as well as the constants TRUE and FALSE. *
* *
* Users should #include "sundialstypes.h" in any file that *
* shhould be easily modifiable to work with different real or *
* integer types and use the exported names realtype and *
* integertype within such a file. *
* The types for realtype and integertype below have been set to *
* double and long int, respectively. A user should modify these *
* type declarations as he/she sees fit. For example, if a user *
* wants the work with type float because double precision *
* floating point arithmetic is too expensive on the user's *
* machine, then the definition below should be changed to: *
* *
* typedef float realtype; *
* *
* Similarly, if a user does not need to work with extremely large *
* integers (see the system header file <limits.h> for the limits *
* on type int and long int on your machine), then the user *
* should change the definition below to: *
* *
* typedef int integertype; *
* *
* The constants SUNDIALS_FLOAT, SUNDIALS_DOUBLE, SUNDIALS_INT, *
* SUNDIALS_LONG indicate the underlying types for realtype and *
* integertype. They should be set as follows: *
* *
* (1) #define SUNDIALS_FLOAT 1 *
* #define SUNDIALS_DOUBLE 0 (real is float) *
* *
* (2) #define SUNDIALS_FLOAT 0 *
* #define SUNDIALS_DOUBLE 1 (real is double) *
* *
* (3) #define SUNDIALS_INT 1 *
* #define SUNDIALS_LONG 0 (integer is int) *
* *
* (4) #define SUNDIALS_INT 0 *
* #define SUNDIALS_LONG 1 (integer is long int) *
* *
* Thus the legal types for realtype are float and double, while *
* the legal types for integertype are int and long int. *
* The macro RCONST gives a user a convenient way to define real *
* constants. To use the real constant 1.0, for example, the *
* user should write *
* *
* #define ONE RCONST(1.0) *
* *
* If realtype is double, then RCONST(1.0) expands to 1.0. *
* If realtype is float, then RCONST(1.0) expands to 1.0F. *
* There is never a need to explicitly cast 1.0 to (realtype). *
* *
*------------------------------------------------------------------------*
* LICENSE *
*------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California. *
* Produced at the Lawrence Livermore National Laboratory. *
* Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, *
* D. Shumaker, and A.G. Taylor. *
* UCRL-CODE-155951 (CVODE) *
* UCRL-CODE-155950 (CVODES) *
* UCRL-CODE-155952 (IDA) *
* UCRL-CODE-237203 (IDAS) *
* UCRL-CODE-155953 (KINSOL) *
* All rights reserved. *
* *
* This file is part of SUNDIALS. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the disclaimer below. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the disclaimer (as noted below) *
* in the documentation and/or other materials provided with the *
* distribution. *
* *
* 3. Neither the name of the UC/LLNL nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
* REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
**************************************************************************/
#ifndef _sundialstypes_h
#define _sundialstypes_h