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 * * File : cvdense.c *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, and * * Programmers : Scott D. Cohen, Alan C. Hindmarsh, and *
* Radu Serban @ LLNL * * Radu Serban @ LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/cvode/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the implementation file for the CVODE dense linear * * This is the implementation file for the CVODE dense linear *
* solver, CVDENSE. * * 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> #include <stdio.h>
@ -32,7 +76,7 @@
#define MACHENV machEnv->phreeqc_ptr-> #define MACHENV machEnv->phreeqc_ptr->
#define CVMEM cv_mem->cv_machenv->phreeqc_ptr-> #define CVMEM cv_mem->cv_machenv->phreeqc_ptr->
#define MACHENV_MALLOC MACHENV #define MACHENV_MALLOC MACHENV
#define CVMEM_MALLOC CVMEM #define CVMEM_MALLOC CVMEM
#include "phqalloc.h" #include "phqalloc.h"
/* WARNING don`t include any headers below here */ /* WARNING don`t include any headers below here */
@ -56,7 +100,7 @@
/****************************************************************** /******************************************************************
* * * *
* Types : CVDenseMemRec, CVDenseMem * * Types : CVDenseMemRec, CVDenseMem *
*----------------------------------------------------------------* *----------------------------------------------------------------*
* The type CVDenseMem is pointer to a CVDenseMemRec. This * * 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 address of this structure. It sets setupNonNull in (*cvode_mem) to
TRUE, the d_J_data field in CVDenseMemRec to be the input TRUE, the d_J_data field in CVDenseMemRec to be the input
parameter jac_data, and the d_jac field to be: parameter jac_data, and the d_jac field to be:
(1) the input parameter djac if djac != NULL or (1) the input parameter djac if djac != NULL or
(2) CVDenseDQJac if djac == NULL. (2) CVDenseDQJac if djac == NULL.
Finally, it allocates memory for M, savedJ, and pivots. Finally, it allocates memory for M, savedJ, and pivots.
The return value is SUCCESS = 0, or LMEM_FAIL = -1. The return value is SUCCESS = 0, or LMEM_FAIL = -1.
NOTE: The dense linear solver assumes a serial implementation 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 test for compatible a compatible N_Vector internal
representation by checking (1) the machine environment representation by checking (1) the machine environment
ID tag and (2) that the functions N_VMake, N_VDispose, 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. This routine does the setup operations for the dense linear solver.
It makes a decision whether or not to call the Jacobian evaluation It makes a decision whether or not to call the Jacobian evaluation
routine based on various state variables, and if not it uses the routine based on various state variables, and if not it uses the
saved copy. In any case, it constructs the Newton matrix saved copy. In any case, it constructs the Newton matrix
M = I - gamma*J, updates counters, and calls the dense LU M = I - gamma*J, updates counters, and calls the dense LU
factorization routine. factorization routine.
**********************************************************************/ **********************************************************************/

View File

@ -1,24 +1,68 @@
#ifndef _INC_CVDENSE_H #ifndef _INC_CVDENSE_H
#define _INC_CVDENSE_H #define _INC_CVDENSE_H
/******************************************************************* /**************************************************************************
* * * *
* File : cvdense.h * * File : cvdense.h *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, and * * Programmers : Scott D. Cohen, Alan C. Hindmarsh, and *
* Radu Serban @ LLNL * * Radu Serban @ LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/cvode/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the header file for the CVODE dense linear solver, * * This is the header file for the CVODE dense linear solver, *
* CVDENSE. * * CVDENSE. *
* * * *
* Note: The type integertype must be large enough to store the * * Note: The type integertype must be large enough to store the *
* value of the linear system size N. * * 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 #ifndef _cvdense_h
#define _cvdense_h #define _cvdense_h
@ -74,7 +118,7 @@
/****************************************************************** /******************************************************************
* * * *
* Type : CVDenseJacFn * * Type : CVDenseJacFn *
*----------------------------------------------------------------* *----------------------------------------------------------------*
* A dense Jacobian approximation function Jac must have the * * A dense Jacobian approximation function Jac must have the *
@ -96,7 +140,7 @@
* col_j[i] = J_ij; * * col_j[i] = J_ij; *
* } * * } *
* } * * } *
* * * *
* (2) (without macros - explicit data structure references) * * (2) (without macros - explicit data structure references) *
* for (j=0; j < N; j++) { * * for (j=0; j < N; j++) { *
* col_j = (J->data)[j]; * * col_j = (J->data)[j]; *

206
cvode.cpp
View File

@ -1,21 +1,65 @@
/*#define DEBUG_CVODE*/ /*#define DEBUG_CVODE*/
/******************************************************************* /**************************************************************************
* * * *
* File : cvode.c * * File : cvode.c *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, Radu Serban, * * Programmers : Scott D. Cohen, Alan C. Hindmarsh, Radu Serban, *
* and Dan Shumaker @ LLNL * * and Dan Shumaker @ LLNL *
* Version of : 24 July 2002 * * Version of : 24 July 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/cvode/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the implementation file for the main CVODE integrator. * * This is the implementation file for the main CVODE integrator. *
* It is independent of the CVODE linear solver in use. * * It is independent of the CVODE linear solver in use. *
* * * *
*******************************************************************/ *------------------------------------------------------------------------*
#include "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 "nvector_serial.h"
#define Ith(v,i) NV_Ith_S(v,i-1) #define Ith(v,i) NV_Ith_S(v,i-1)
/************************************************************/ /************************************************************/
/******************* BEGIN Imports **************************/ /******************* BEGIN Imports **************************/
@ -32,7 +76,7 @@
#define MACHENV machEnv->phreeqc_ptr-> #define MACHENV machEnv->phreeqc_ptr->
#define CVMEM cv_mem->cv_machenv->phreeqc_ptr-> #define CVMEM cv_mem->cv_machenv->phreeqc_ptr->
#define MACHENV_MALLOC MACHENV #define MACHENV_MALLOC MACHENV
#define CVMEM_MALLOC CVMEM #define CVMEM_MALLOC CVMEM
#include "phqalloc.h" #include "phqalloc.h"
/* WARNING don`t include any headers below here */ /* 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 error occurs during initialization, it is reported to the file
whose file pointer is errfp and NULL is returned. Otherwise, the whose file pointer is errfp and NULL is returned. Otherwise, the
pointer to successfully initialized problem memory is returned. pointer to successfully initialized problem memory is returned.
*****************************************************************/ *****************************************************************/
void * void *
@ -782,7 +826,7 @@ CVodeMalloc(integertype N, RhsFn f, realtype t0, N_Vector y0,
file whose file pointer is errfp. file whose file pointer is errfp.
The return value is SUCCESS = 0 if no errors occurred, or The return value is SUCCESS = 0 if no errors occurred, or
a negative value otherwise. a negative value otherwise.
*****************************************************************/ *****************************************************************/
int int
@ -1047,7 +1091,7 @@ CVReInit(void *cvode_mem, RhsFn f, realtype t0, N_Vector y0,
/********************* CVode **************************************** /********************* 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 It integrates over a time interval defined by the user, by calling
CVStep to do internal time steps. 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 */ 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_rate_sim_time = CVMEM cvode_rate_sim_time_start + tn;
CVMEM cvode_step_fraction = 0; 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 This routine computes the k-th derivative of the interpolating
polynomial at the time t and stores the result in the vector dky. polynomial at the time t and stores the result in the vector dky.
The formula is: The formula is:
q q
dky = SUM c(j,k) * (t - tn)^(j-k) * h^(-j) * zn[j] , dky = SUM c(j,k) * (t - tn)^(j-k) * h^(-j) * zn[j] ,
j=k j=k
where c(j,k) = j*(j-1)*...*(j-k+1), q is the current order, and 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. 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 ********************************* /***************** CVFreeVectors *********************************
This routine frees the CVODE vectors allocated in CVAllocVectors. This routine frees the CVODE vectors allocated in CVAllocVectors.
******************************************************************/ ******************************************************************/
@ -1585,7 +1629,7 @@ CVFreeVectors(CVodeMem cv_mem, int maxord)
} }
/*********************** CVEwtSet ************************************** /*********************** CVEwtSet **************************************
This routine is responsible for setting the error weight vector ewt, This routine is responsible for setting the error weight vector ewt,
according to tol_type, as follows: according to tol_type, as follows:
@ -1599,7 +1643,7 @@ CVFreeVectors(CVodeMem cv_mem, int maxord)
considered undefined after the FALSE return from CVEwtSet. considered undefined after the FALSE return from CVEwtSet.
All the real work is done in the routines CVEwtSetSS, CVEwtSetSV. All the real work is done in the routines CVEwtSetSS, CVEwtSetSV.
***********************************************************************/ ***********************************************************************/
static booleantype static booleantype
@ -1666,13 +1710,13 @@ CVEwtSetSV(CVodeMem cv_mem, N_Vector ycur)
/******************* CVHin *************************************** /******************* 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 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. value h0 and returns TRUE.
The algorithm used seeks to find h0 as a solution of 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. where ydd = estimated second derivative of y.
*****************************************************************/ *****************************************************************/
@ -1695,9 +1739,9 @@ CVHin(CVodeMem cv_mem, realtype tout)
if (tdist < TWO * tround) if (tdist < TWO * tround)
return (FALSE); 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 */ Exit with this value if the bounds cross each other */
hlb = HLB_FACTOR * tround; hlb = HLB_FACTOR * tround;
hub = CVUpperBoundH0(cv_mem, tdist); hub = CVUpperBoundH0(cv_mem, tdist);
hg = RSqrt(hlb * hub); hg = RSqrt(hlb * hub);
@ -1828,7 +1872,7 @@ CVYddNorm(CVodeMem cv_mem, realtype hg)
} }
/********************* CVStep ************************************** /********************* CVStep **************************************
This routine performs one internal cvode step, from tn to tn + h. This routine performs one internal cvode step, from tn to tn + h.
It calls other routines to do all the work. It calls other routines to do all the work.
@ -2088,7 +2132,7 @@ CVStep(CVodeMem cv_mem)
#endif #endif
etamax = (nst <= SMALL_NST) ? ETAMX2 : ETAMX3; 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. */ estimated local error vector. */
N_VScale(ONE / tq[2], acor, acor); 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 /* 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), coefficients of the polynomial x*x*(x+xi_1)*...*(x+xi_j),
integrated, where xi_j = [t_n - t_(n-j)]/h. */ integrated, where xi_j = [t_n - t_(n-j)]/h. */
@ -2195,8 +2239,8 @@ CVAdjustAdams(CVodeMem cv_mem, int deltaq)
/********************** CVAdjustBDF ******************************* /********************** CVAdjustBDF *******************************
This is a high level routine which handles adjustments to the This is a high level routine which handles adjustments to the
history array on a change of order by deltaq in the case that history array on a change of order by deltaq in the case that
lmm == BDF. CVAdjustBDF calls CVIncreaseBDF if deltaq = +1 and lmm == BDF. CVAdjustBDF calls CVIncreaseBDF if deltaq = +1 and
CVDecreaseBDF if deltaq = -1 to do the actual work. CVDecreaseBDF if deltaq = -1 to do the actual work.
******************************************************************/ ******************************************************************/
@ -2217,11 +2261,11 @@ CVAdjustBDF(CVodeMem cv_mem, int deltaq)
/******************** CVIncreaseBDF ********************************** /******************** CVIncreaseBDF **********************************
This routine adjusts the history array on an increase in the This routine adjusts the history array on an increase in the
order q in the case that lmm == BDF. order q in the case that lmm == BDF.
A new column zn[q+1] is set equal to a multiple of the saved 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 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)), coefficients of the polynomial x*x*(x+xi_1)*...*(x+xi_(q-1)),
where xi_j = [t_n - t_(n-j)]/h. where xi_j = [t_n - t_(n-j)]/h.
@ -2262,8 +2306,8 @@ CVIncreaseBDF(CVodeMem cv_mem)
/********************* CVDecreaseBDF ****************************** /********************* CVDecreaseBDF ******************************
This routine adjusts the history array on a decrease in the This routine adjusts the history array on a decrease in the
order q in the case that lmm == BDF. order q in the case that lmm == BDF.
Each zn[j] is adjusted by a multiple of zn[q]. The coefficients Each zn[j] is adjusted by a multiple of zn[q]. The coefficients
in the adjustment are the coefficients of the polynomial 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. 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 ********************************* /************************** CVSet *********************************
This routine is a high level routine which calls CVSetAdams or 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. 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 This routine generates in m[] the coefficients of the product
polynomial needed for the Adams l and tq coefficients for q > 1. polynomial needed for the Adams l and tq coefficients for q > 1.
******************************************************************/ ******************************************************************/
static realtype static realtype
@ -2471,7 +2515,7 @@ CVAdamsFinish(CVodeMem cv_mem, realtype m[], realtype M[], realtype hsum)
} }
/****************** CVAltSum ************************************** /****************** CVAltSum **************************************
CVAltSum returns the value of the alternating sum CVAltSum returns the value of the alternating sum
sum (i= 0 ... iend) [ (-1)^i * (a[i] / (i + k)) ]. sum (i= 0 ... iend) [ (-1)^i * (a[i] / (i + k)) ].
If iend < 0 then CVAltSum returns 0. 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 This routine computes the coefficients l and tq in the case
lmm == BDF. CVSetBDF calls CVSetTqBDF to set the test 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 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 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 ******************************** /***************** CVnlsFunctional ********************************
This routine attempts to solve the nonlinear system using This routine attempts to solve the nonlinear system using
functional iteration (no matrices involved). functional iteration (no matrices involved).
******************************************************************/ ******************************************************************/
@ -2695,8 +2739,8 @@ CVnlsFunctional(CVodeMem cv_mem)
/*********************** CVnlsNewton ********************************** /*********************** CVnlsNewton **********************************
This routine handles the Newton iteration. It calls lsetup if This routine handles the Newton iteration. It calls lsetup if
indicated, calls CVNewtonIteration to perform the iteration, and indicated, calls CVNewtonIteration to perform the iteration, and
retries a failed attempt at Newton iteration if that is indicated. retries a failed attempt at Newton iteration if that is indicated.
See return values at top of this file. See return values at top of this file.
@ -2800,7 +2844,7 @@ CVnlsNewton(CVodeMem cv_mem, int nflag)
ier)); ier));
#endif #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 data appears not to be current, loop again with a call to lsetup
in which convfail=FAIL_BAD_J. Otherwise return. */ in which convfail=FAIL_BAD_J. Otherwise return. */
if (ier != TRY_AGAIN_CVODE) if (ier != TRY_AGAIN_CVODE)
@ -2813,11 +2857,11 @@ CVnlsNewton(CVodeMem cv_mem, int nflag)
/********************** CVNewtonIteration **************************** /********************** CVNewtonIteration ****************************
This routine performs the Newton iteration. If the iteration succeeds, 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 routine to call lsetup again and reattempt the iteration, by
returning the value TRY_AGAIN_CVODE. (In this case, CVnlsNewton must set returning the value TRY_AGAIN_CVODE. (In this case, CVnlsNewton must set
convfail to FAIL_BAD_J before calling setup again). convfail to FAIL_BAD_J before calling setup again).
Otherwise, this routine returns one of the appropriate values Otherwise, this routine returns one of the appropriate values
SOLVE_FAIL_UNREC or CONV_FAIL back to CVnlsNewton. SOLVE_FAIL_UNREC or CONV_FAIL back to CVnlsNewton.
*********************************************************************/ *********************************************************************/
@ -2895,7 +2939,7 @@ CVNewtonIteration(CVodeMem cv_mem)
mnewt = ++m; mnewt = ++m;
/* Stop at maxcor iterations or if iter. seems to be diverging. /* 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 */ signal to try the solution again */
if ((m == maxcor) || ((m >= 2) && (del > RDIV * delp))) 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 This routine takes action on the return value nflag = *nflagPtr
returned by CVnls, as follows: returned by CVnls, as follows:
If CVnls succeeded in solving the nonlinear system, then If CVnls succeeded in solving the nonlinear system, then
CVHandleNFlag returns the constant DO_ERROR_TEST, which tells CVStep CVHandleNFlag returns the constant DO_ERROR_TEST, which tells CVStep
to perform the error test. 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 If it failed due to an unrecoverable failure in solve, then we return
the value SOLVE_FAILED. the value SOLVE_FAILED.
Otherwise, a recoverable failure occurred when solving the Otherwise, a recoverable failure occurred when solving the
nonlinear system (CVnls returned nflag == CONV_FAIL). nonlinear system (CVnls returned nflag == CONV_FAIL).
In this case, we return the value REP_CONV_FAIL if ncf is now 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 If not, we set *nflagPtr = PREV_CONV_FAIL and return the value
PREDICT_AGAIN, telling CVStep to reattempt the step. PREDICT_AGAIN, telling CVStep to reattempt the step.
@ -3008,14 +3052,14 @@ CVRestore(CVodeMem cv_mem, realtype saved_t)
/******************* CVDoErrorTest ******************************** /******************* CVDoErrorTest ********************************
This routine performs the local error test. This routine performs the local error test.
The weighted local error norm dsm is loaded into *dsmPtr, and The weighted local error norm dsm is loaded into *dsmPtr, and
the test dsm ?<= 1 is made. 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), If the test fails, we undo the step just taken (call CVRestore),
set *nflagPtr to PREV_ERR_FAIL, and return FALSE. set *nflagPtr to PREV_ERR_FAIL, and return FALSE.
If MXNEF error test failures have occurred or if ABS(h) = hmin, If MXNEF error test failures have occurred or if ABS(h) = hmin,
we set *kflagPtr = REP_ERR_FAIL. (Otherwise *kflagPtr has the we set *kflagPtr = REP_ERR_FAIL. (Otherwise *kflagPtr has the
@ -3102,7 +3146,7 @@ CVDoErrorTest(CVodeMem cv_mem, int *nflagPtr, int *kflagPtr,
/*************** CVCompleteStep ********************************** /*************** CVCompleteStep **********************************
This routine performs various update operations when the solution 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, We increment the step counter nst, record the values hu and qu,
update the tau array, and apply the corrections to the zn array. 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. 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 This routine handles the setting of stepsize and order for the
next step -- hprime and qprime. Along with hprime, it sets the next step -- hprime and qprime. Along with hprime, it sets the
ratio eta = hprime/h. It also updates other state variables ratio eta = hprime/h. It also updates other state variables
related to a change of step size or order. related to a change of step size or order.
******************************************************************/ ******************************************************************/
@ -3171,7 +3215,7 @@ CVPrepareNextStep(CVodeMem cv_mem, realtype dsm)
return; 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. the ratios of new to old h at orders q-1 and q+1, respectively.
CVChooseEta selects the largest; CVSetEta adjusts eta and acor */ CVChooseEta selects the largest; CVSetEta adjusts eta and acor */
qwait = 2; qwait = 2;
@ -3259,7 +3303,7 @@ CVComputeEtaqp1(CVodeMem cv_mem)
/******************* CVChooseEta ********************************** /******************* CVChooseEta **********************************
Given etaqm1, etaq, etaqp1 (the values of eta for qprime = 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 maximum eta value, sets eta to that value, and sets qprime to the
corresponding value of q. If there is a tie, the preference corresponding value of q. If there is a tie, the preference
order is to (1) keep the same order, then (2) decrease the order, 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); return (SETUP_FAILURE);
case SOLVE_FAILED: case SOLVE_FAILED:
{ {
char * error_string = CVMEM sformatf(MSG_SOLVE_FAILED, (double) tn); char * error_string = CVMEM sformatf(MSG_SOLVE_FAILED, (double) tn);
CVMEM warning_msg(error_string); CVMEM warning_msg(error_string);
} }
@ -3415,21 +3459,21 @@ CVBDFStab(CVodeMem cv_mem)
} }
else else
{ {
/* Otherwise, let order increase happen, and /* Otherwise, let order increase happen, and
reset stability limit counter, nscon. */ reset stability limit counter, nscon. */
nscon = 0; nscon = 0;
} }
} }
/********************* CVsldet ************************************ /********************* 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 derivatives data. CVsldet returns the magnitude of the
dominate characteristic root, rr. The presents of a stability 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 and a positive kflag. This routine should only be called if
order is greater than or equal to 3, and data has been collected order is greater than or equal to 3, and data has been collected
for 5 time steps. for 5 time steps.
Returned values: Returned values:
kflag = 1 -> Found stable characteristic root, normal matrix case kflag = 1 -> Found stable characteristic root, normal matrix case
kflag = 2 -> Found stable characteristic root, quartic solution kflag = 2 -> Found stable characteristic root, quartic solution
@ -3440,14 +3484,14 @@ CVBDFStab(CVodeMem cv_mem)
kflag = 6 -> Found stability violation, quartic solution, kflag = 6 -> Found stability violation, quartic solution,
with Newton correction with Newton correction
kflag < 0 -> No stability limitation, kflag < 0 -> No stability limitation,
or could not compute limitation. or could not compute limitation.
kflag = -1 -> Min/max ratio of ssdat too small. kflag = -1 -> Min/max ratio of ssdat too small.
kflag = -2 -> For normal matrix case, vmax > vrrt2*vrrt2 kflag = -2 -> For normal matrix case, vmax > vrrt2*vrrt2
kflag = -3 -> For normal matrix case, The three ratios kflag = -3 -> For normal matrix case, The three ratios
are inconsistent. 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 = -5 -> R value from quartics not consistent.
kflag = -6 -> No corrected root passes test on qk values kflag = -6 -> No corrected root passes test on qk values
kflag = -7 -> Trouble solving for sigsq. kflag = -7 -> Trouble solving for sigsq.
@ -3532,8 +3576,8 @@ CVsldet(CVodeMem cv_mem)
} /* End of k loop */ } /* End of k loop */
/* Isolate normal or nearly-normal matrix case. Three quartic will /* Isolate normal or nearly-normal matrix case. Three quartic will
have common or nearly-common roots in this case. have common or nearly-common roots in this case.
Return a kflag = 1 if this procedure works. If three root Return a kflag = 1 if this procedure works. If three root
differ more than vrrt2, return error kflag = -3. */ differ more than vrrt2, return error kflag = -3. */
vmin = MIN(vrat[1], MIN(vrat[2], vrat[3])); vmin = MIN(vrat[1], MIN(vrat[2], vrat[3]));

88
cvode.h
View File

@ -1,20 +1,64 @@
#ifndef _INC_CVODE_H #ifndef _INC_CVODE_H
#define _INC_CVODE_H #define _INC_CVODE_H
/******************************************************************* /**************************************************************************
* * * *
* File : cvode.h * * File : cvode.h *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, Radu Serban * * Programmers : Scott D. Cohen, Alan C. Hindmarsh, Radu Serban *
* and Dan Shumaker @ LLNL * * and Dan Shumaker @ LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/cvode/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the interface file for the main CVODE integrator. * * 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 #ifndef _cvode_h
#define _cvode_h #define _cvode_h
@ -95,11 +139,11 @@
/****************************************************************** /******************************************************************
* * * *
* Type : RhsFn * * Type : RhsFn *
*----------------------------------------------------------------* *----------------------------------------------------------------*
* The f function which defines the right hand side of the ODE * * The f function which defines the right hand side of the ODE *
* system y' = f(t,y) must have type RhsFn. * * system y' = f(t,y) must have type RhsFn. *
* f takes as input the problem size N, the independent variable * * 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 * * result of f(t,y) in the vector ydot. The y and ydot arguments *
* are of type N_Vector. * * are of type N_Vector. *
* (Allocation of memory for ydot is handled within CVODE.) * * (Allocation of memory for ydot is handled within CVODE.) *
@ -124,7 +168,7 @@
* * * *
* N is the number of equations in the ODE system. * * 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. * * t0 is the initial value of t. *
* * * *
@ -195,7 +239,7 @@
* (*reltol) and either (*abstol), for a scalar absolute * * (*reltol) and either (*abstol), for a scalar absolute *
* tolerance, or the components of abstol, for a vector * * tolerance, or the components of abstol, for a vector *
* absolute tolerance. * * absolute tolerance. *
* * * *
* If successful, CVodeMalloc returns a pointer to initialized * * If successful, CVodeMalloc returns a pointer to initialized *
* problem memory. This pointer should be passed to CVode. If * * problem memory. This pointer should be passed to CVode. If *
* an initialization error occurs, CVodeMalloc prints an error * * an initialization error occurs, CVodeMalloc prints an error *
@ -401,7 +445,7 @@
* BAD_DKY : The dky argument was NULL. * * BAD_DKY : The dky argument was NULL. *
* * * *
* DKY_NO_MEM : The cvode_mem argument was NULL. * * DKY_NO_MEM : The cvode_mem argument was NULL. *
* * * *
******************************************************************/ ******************************************************************/
@ -452,7 +496,7 @@
* the solver in its attempt to reach tout. * * the solver in its attempt to reach tout. *
* Optional input. (Default = 500). * * 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.* * solver that t + h = t on the next internal step.*
* A value of -1 means no such messages are issued.* * A value of -1 means no such messages are issued.*
* Optional input. (Default = 10). * * Optional input. (Default = 10). *
@ -760,7 +804,7 @@
* NO_FAILURES : Either this is the first cv_setup call for this * * NO_FAILURES : Either this is the first cv_setup call for this *
* step, or the local error test failed on the * * step, or the local error test failed on the *
* previous attempt at this step (but the Newton * * previous attempt at this step (but the Newton *
* iteration converged). * * iteration converged). *
* * * *
* FAIL_BAD_J : This value is passed to cv_lsetup if * * FAIL_BAD_J : This value is passed to cv_lsetup if *
* * * *

View File

@ -1,19 +1,63 @@
/******************************************************************* /**************************************************************************
* * * *
* File : dense.c * * File : dense.c *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, and * * Programmers : Scott D. Cohen, Alan C. Hindmarsh, and *
* Radu Serban @ LLNL * * Radu Serban @ LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/shared/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the implementation file for a generic DENSE linear * * This is the implementation file for a generic DENSE linear *
* solver package. * * 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 <stdio.h>
#include <stdlib.h> #include <stdlib.h>

124
dense.h
View File

@ -1,42 +1,86 @@
#ifndef _INC_DENSE_H #ifndef _INC_DENSE_H
#define _INC_DENSE_H #define _INC_DENSE_H
/******************************************************************* /**************************************************************************
* * * *
* File : dense.h * * File : dense.h *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, and * * Programmers : Scott D. Cohen, Alan C. Hindmarsh, and *
* Radu Serban @ LLNL * * Radu Serban @ LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/shared/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the header file for a generic DENSE linear solver * * This is the header file for a generic DENSE linear solver *
* package. The routines listed in this file all use type * * package. The routines listed in this file all use type *
* DenseMat, defined below, for matrices. These routines in turn * * DenseMat, defined below, for matrices. These routines in turn *
* call routines in the smalldense.h/smalldense.c module, which * * call routines in the smalldense.h/smalldense.c module, which *
* use the type realtype** for matrices. This separation allows * * use the type realtype** for matrices. This separation allows *
* for possible modifications in which matrices of type DenseMat * * for possible modifications in which matrices of type DenseMat *
* may not be stored contiguously, while small matrices can still * * may not be stored contiguously, while small matrices can still *
* be treated with the routines in smalldense. * * be treated with the routines in smalldense. *
* * * *
* Routines that work with the type DenseMat begin with "Dense". * * Routines that work with the type DenseMat begin with "Dense". *
* The DenseAllocMat function allocates a dense matrix for use in * * The DenseAllocMat function allocates a dense matrix for use in *
* the other DenseMat routines listed in this file. Matrix * * the other DenseMat routines listed in this file. Matrix *
* storage details are given in the documentation for the type * * storage details are given in the documentation for the type *
* DenseMat. The DenseAllocPiv function allocates memory for * * DenseMat. The DenseAllocPiv function allocates memory for *
* pivot information. The storage allocated by DenseAllocMat and * * pivot information. The storage allocated by DenseAllocMat and *
* DenseAllocPiv is deallocated by the routines DenseFreeMat and * * DenseAllocPiv is deallocated by the routines DenseFreeMat and *
* DenseFreePiv, respectively. The DenseFactor and DenseBacksolve * * DenseFreePiv, respectively. The DenseFactor and DenseBacksolve *
* routines perform the actual solution of a dense linear system. * * routines perform the actual solution of a dense linear system. *
* * * *
* Routines that work with realtype** begin with "den" (except for * * Routines that work with realtype** begin with "den" (except for *
* the factor and solve routines which are called gefa and gesl, * * the factor and solve routines which are called gefa and gesl, *
* respectively). The underlying matrix storage is described in * * respectively). The underlying matrix storage is described in *
* the documentation for denalloc in smalldense.h * * 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 #ifndef _dense_h
#define _dense_h #define _dense_h
@ -121,8 +165,8 @@
* returns the storage allocated (type DenseMat). DenseAllocMat * * returns the storage allocated (type DenseMat). DenseAllocMat *
* returns NULL if the request for matrix storage cannot be * * returns NULL if the request for matrix storage cannot be *
* satisfied. See the above documentation for the type DenseMat * * satisfied. See the above documentation for the type DenseMat *
* for matrix storage details. * * for matrix storage details. *
* * * *
******************************************************************/ ******************************************************************/
DenseMat DenseAllocMat(integertype N); DenseMat DenseAllocMat(integertype N);
@ -140,7 +184,7 @@
* information is an array of N integers and this routine returns * * information is an array of N integers and this routine returns *
* the pointer to the memory it allocates. If the request for * * the pointer to the memory it allocates. If the request for *
* pivot storage cannot be satisfied, DenseAllocPiv returns NULL. * * pivot storage cannot be satisfied, DenseAllocPiv returns NULL. *
* * * *
******************************************************************/ ******************************************************************/
integertype *DenseAllocPiv(integertype N); integertype *DenseAllocPiv(integertype N);

View File

@ -1,19 +1,63 @@
/******************************************************************* /**************************************************************************
* * * *
* File : nvector.c * * File : nvector.c *
* Programmers : Radu Serban, LLNL * * Programmers : Radu Serban, LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/shared/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the implementation file for a generic NVECTOR * * This is the implementation file for a generic NVECTOR *
* package. It contains the implementation of the N_Vector * * package. It contains the implementation of the N_Vector *
* kernels listed in nvector.h. * * 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 */ #include "nvector.h" /* generic M_Env and N_Vector */

130
nvector.h
View File

@ -1,44 +1,88 @@
/******************************************************************* /**************************************************************************
* * * *
* File : nvector.h * * File : nvector.h *
* Programmers : Radu Serban, LLNL * * Programmers : Radu Serban, LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/shared/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the header file for a generic NVECTOR package. * * This is the header file for a generic NVECTOR package. *
* It defines the N_Vector and M_Env structures: * * It defines the N_Vector and M_Env structures: *
* M_Env has an implementation-dependent 'content' field * * M_Env has an implementation-dependent 'content' field *
* which contains the data needed to generate a new * * which contains the data needed to generate a new *
* nvector in that implementation and an 'ops' filed * * nvector in that implementation and an 'ops' filed *
* which is a structure listing operations acting on * * which is a structure listing operations acting on *
* such nvectors. * * such nvectors. *
* N_Vector has an implementation-dependent 'content' field * * N_Vector has an implementation-dependent 'content' field *
* which contains the description and actual data of * * which contains the description and actual data of *
* the nvector and a 'menv' field which points to the * * the nvector and a 'menv' field which points to the *
* M_Env structure used in creating the nvector. * * M_Env structure used in creating the nvector. *
* * * *
* Part I of this file contains type declarations for the * * Part I of this file contains type declarations for the *
* the following structures: _generic_M_Env, _generic_N_Vector, * * the following structures: _generic_M_Env, _generic_N_Vector, *
* and _generic_N_Vector_Ops, as well as references to pointers * * and _generic_N_Vector_Ops, as well as references to pointers *
* to such structures (M_Env and N_Vector). * * to such structures (M_Env and N_Vector). *
* * * *
* Part II of this file contains the prototypes for the vector * * Part II of this file contains the prototypes for the vector *
* kernels which operate on N_Vector. * * kernels which operate on N_Vector. *
* * * *
* A particular implementation of an NVECTOR package must then * * A particular implementation of an NVECTOR package must then *
* specify the 'content' fields of M_Env and N_Vector, define * * specify the 'content' fields of M_Env and N_Vector, define *
* the propotypes for kernel operations on those N_Vectors * * the propotypes for kernel operations on those N_Vectors *
* (NOTE: kernel routine names must be unique to that * * (NOTE: kernel routine names must be unique to that *
* implementation), and finally provide an initialization * * implementation), and finally provide an initialization *
* routine (which generates an M_Env with that particular * * routine (which generates an M_Env with that particular *
* 'content' field and links the defined vector kernel routines * * 'content' field and links the defined vector kernel routines *
* into the 'ops' field). * * 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; class Phreeqc;
#ifndef included_nvector_h #ifndef included_nvector_h
@ -99,7 +143,7 @@ class Phreeqc;
/* A machine environment is a structure with an implementation /* A machine environment is a structure with an implementation
dependent 'content' representation (used to generate a new vector 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 */ structure, and an ID tag */
struct _generic_M_Env struct _generic_M_Env
{ {
@ -110,7 +154,7 @@ class Phreeqc;
}; };
/* A vector is a structure with an implementation dependent content /* 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 */ corresponding to that implementation */
struct _generic_N_Vector struct _generic_N_Vector
{ {

View File

@ -1,23 +1,66 @@
/******************************************************************* /**************************************************************************
* * * *
* File : nvector_serial.c * * File : nvector_serial.c *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, * * Programmers : Scott D. Cohen, Alan C. Hindmarsh, *
* Radu Serban, and Allan G. Taylor, LLNL * * Radu Serban, and Allan G. Taylor, LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/shared/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the implementation file for a serial implementation * * This is the implementation file for a serial implementation *
* of the NVECTOR package. It contains the implementation of * * of the NVECTOR package. It contains the implementation of *
* the serial machine environment intialization and free * * the serial machine environment intialization and free *
* routines (and of the Fortran callable interfaces to them) * * routines (and of the Fortran callable interfaces to them) *
* and of the N_Vector kernels listed in nvector_serial.h. * * 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 <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -57,7 +100,7 @@ static void VScaleBy_Serial(realtype a, N_Vector x);
/********************* Exported Functions ************************/ /********************* Exported Functions ************************/
/* Serial implementation of the machine environment /* Serial implementation of the machine environment
initialization routine */ initialization routine */
M_Env 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 */ free routine */
void void

View File

@ -1,59 +1,103 @@
#ifndef _INC_NVECTOR_SERIAL_H #ifndef _INC_NVECTOR_SERIAL_H
#define _INC_NVECTOR_SERIAL_H #define _INC_NVECTOR_SERIAL_H
/******************************************************************* /**************************************************************************
* * * *
* File : nvector_serial.h * * File : nvector_serial.h *
* Programmers : Scott D. Cohen, Alan C. Hindmarsh, * * Programmers : Scott D. Cohen, Alan C. Hindmarsh, *
* : Radu Serban, and Allan G. Taylor, LLNL * * : Radu Serban, and Allan G. Taylor, LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/shared/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the header file for a serial implementation of the * * This is the header file for a serial implementation of the *
* NVECTOR package. * * NVECTOR package. *
* * * *
* Part I of this file contains declarations which are specific * * Part I of this file contains declarations which are specific *
* to the particular machine environment in which this version * * to the particular machine environment in which this version *
* of the vector package is to be used. This includes the * * of the vector package is to be used. This includes the *
* typedef for the 'content' fields of the structures M_Env and * * typedef for the 'content' fields of the structures M_Env and *
* N_Vector (M_EnvSerialContent and N_VectorSerialContent, * * N_Vector (M_EnvSerialContent and N_VectorSerialContent, *
* respectively). * * respectively). *
* * * *
* Part II of this file defines accessor macros that allow the * * Part II of this file defines accessor macros that allow the *
* user to use efficiently the type N_Vector without making * * user to use efficiently the type N_Vector without making *
* explicit references to its underlying representation. * * explicit references to its underlying representation. *
* * * *
* Part III of this file contains the prototype for the * * Part III of this file contains the prototype for the *
* initialization routine specific to this implementation * * initialization routine specific to this implementation *
* (M_EnvInit_Serial) as well as prototypes for the vector * * (M_EnvInit_Serial) as well as prototypes for the vector *
* kernels which operate on the serial N_Vector. These * * kernels which operate on the serial N_Vector. These *
* prototypes are unique to this particular implementation of * * prototypes are unique to this particular implementation of *
* the vector package. * * the vector package. *
* * * *
* NOTES: * * NOTES: *
* * * *
* The definitions of the generic M_Env and N_Vector structures * * The definitions of the generic M_Env and N_Vector structures *
* are in the header file nvector.h. * * are in the header file nvector.h. *
* * * *
* The definitions of the types realtype and integertype are in * * The definitions of the types realtype and integertype are in *
* the header file sundialstypes.h and these may be changed * * the header file sundialstypes.h and these may be changed *
* according to the user's needs. The sundialstypes.h file also * * according to the user's needs. The sundialstypes.h file also *
* contains the definition for the type booleantype. * * contains the definition for the type booleantype. *
* * * *
* N_Vector arguments to arithmetic kernels need not be * * N_Vector arguments to arithmetic kernels need not be *
* distinct. Thus, for example, the call * * distinct. Thus, for example, the call *
* N_VLinearSum_Serial(a,x,b,y,y); y <- ax+by * * N_VLinearSum_Serial(a,x,b,y,y); y <- ax+by *
* is legal. * * is legal. *
* * * *
* This version of nvector is for the ordinary sequential * * This version of nvector is for the ordinary sequential *
* machine environment. In the documentation given below, N is * * machine environment. In the documentation given below, N is *
* the length of all N_Vector parameters and x[i] denotes the * * the length of all N_Vector parameters and x[i] denotes the *
* ith component of the N_Vector x, where 0 <= i <= N-1. * * 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 #ifndef included_nvector_serial_h
#define included_nvector_serial_h #define included_nvector_serial_h
@ -66,7 +110,7 @@
* Serial implementaion of M_Env and N_Vector * * 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' */ ID tag 'serial' */
#define ID_TAG_S "serial" #define ID_TAG_S "serial"
@ -80,8 +124,8 @@
typedef struct _M_EnvSerialContent *M_EnvSerialContent; typedef struct _M_EnvSerialContent *M_EnvSerialContent;
/* The serial implementation of the N_Vector 'content' /* The serial implementation of the N_Vector 'content'
structure contains the length of the vector and a pointer structure contains the length of the vector and a pointer
to an array of realtype components */ to an array of realtype components */
struct _N_VectorSerialContent struct _N_VectorSerialContent
@ -148,11 +192,11 @@
* (3) ME_CONTENT_S, NV_CONTENT_S * * (3) ME_CONTENT_S, NV_CONTENT_S *
* * * *
* These routines give access to the contents of the serial * * 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 * * The assignment m_cont = ME_CONTENT_S(machenv) sets *
* m_cont to be a pointer to the serial machine * * 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 * * The assignment v_cont = NV_CONTENT_S(v) sets *
* v_cont to be a pointer to the serial N_Vector content * * 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 * * The assignment v_data=NV_DATA_S(v) sets v_data to be *
* a pointer to the first component of v. The assignment * * a pointer to the first component of v. The assignment *
* NV_DATA_S(v)=v_data sets the component array of v to * * 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 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 * * the length of v. The call NV_LENGTH_S(v)=len_v sets *
@ -277,7 +321,7 @@
void M_EnvFree_Serial(M_Env machenv); 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 * * For a complete description of each of the following routines *
* see the header file nvector.h * * see the header file nvector.h *

View File

@ -1,18 +1,62 @@
/******************************************************************* /**************************************************************************
* * * *
* File : smalldense.c * * File : smalldense.c *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL * * Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/shared/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the implementation file for a generic DENSE linear * * This is the implementation file for a generic DENSE linear *
* solver package, intended for small dense matrices. * * 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 <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,24 +1,68 @@
/******************************************************************* /**************************************************************************
* * * *
* File : smalldense.h * * File : smalldense.h *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL * * Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *----------------------------------------------------------------- *
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/shared/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *----------------------------------------------------------------- *
* This is the header file for a generic DENSE linear solver * * This is the header file for a generic DENSE linear solver *
* package, intended for small dense matrices. These routines * * package, intended for small dense matrices. These routines *
* use the type realtype** for dense matrix arguments. * * use the type realtype** for dense matrix arguments. *
* * * *
* These routines begin with "den" (except for the factor and * * These routines begin with "den" (except for the factor and *
* solve routines which are called gefa and gesl, respectively). * * solve routines which are called gefa and gesl, respectively). *
* The underlying matrix storage is described in the * * The underlying matrix storage is described in the *
* documentation for denalloc. * * 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 #ifndef _smalldense_h
#define _smalldense_h #define _smalldense_h
@ -88,7 +132,7 @@
* triangular matrix, then the upper triangular part of a * * triangular matrix, then the upper triangular part of a *
* (including its diagonal) contains U and the strictly lower * * (including its diagonal) contains U and the strictly lower *
* triangular part of a contains the multipliers, I-L. * * triangular part of a contains the multipliers, I-L. *
* * * *
* gefa returns 0 if successful. Otherwise it encountered a zero * * gefa returns 0 if successful. Otherwise it encountered a zero *
* diagonal element during the factorization. In this case it * * diagonal element during the factorization. In this case it *
* returns the column index (numbered from one) at which it * * returns the column index (numbered from one) at which it *

View File

@ -1,17 +1,61 @@
/******************************************************************* /**************************************************************************
* * * *
* File : sundialsmath.c * * File : sundialsmath.c *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL * * Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/shared/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the implementation file for a C math library. * * 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> #include <stdio.h>

View File

@ -1,27 +1,71 @@
/******************************************************************* /**************************************************************************
* * * *
* File : sundialsmath.h * * File : sundialsmath.h *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL * * Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/shared/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This is the header file for a C math library. The routines * * This is the header file for a C math library. The routines *
* listed here work with the type realtype as defined in * * listed here work with the type realtype as defined in *
* sundialstypes.h. * * sundialstypes.h. *
* To do single precision floating point arithmetic, set the type * * To do single precision floating point arithmetic, set the type *
* realtype to be float. To do double precision arithmetic, set * * realtype to be float. To do double precision arithmetic, set *
* the type realtype to be double. The default implementations * * the type realtype to be double. The default implementations *
* for RPowerR and RSqrt call standard math library functions * * for RPowerR and RSqrt call standard math library functions *
* which do double precision arithmetic. If this is unacceptable * * which do double precision arithmetic. If this is unacceptable *
* when realtype is float, then the user should re-implement * * when realtype is float, then the user should re-implement *
* these two routines by calling single precision routines * * these two routines by calling single precision routines *
* available on his/her machine. * * 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 #ifndef _sundialsmath_h
#define _sundialsmath_h #define _sundialsmath_h

View File

@ -4,69 +4,113 @@
#include "phrqtype.h" #include "phrqtype.h"
#ifndef _INC_SUNDIALSTYPES_H #ifndef _INC_SUNDIALSTYPES_H
#define _INC_SUNDIALSTYPES_H #define _INC_SUNDIALSTYPES_H
/******************************************************************* /**************************************************************************
* * * *
* File : sundialstypes.h * * File : sundialstypes.h *
* Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL * * Programmers : Scott D. Cohen and Alan C. Hindmarsh @ LLNL *
* Version of : 26 June 2002 * * Version of : 26 June 2002 *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* Copyright (c) 2002, The Regents of the University of California * * Copyright (c) 2002, The Regents of the University of California *
* Produced at the Lawrence Livermore National Laboratory * * Produced at the Lawrence Livermore National Laboratory *
* All rights reserved * * All rights reserved *
* For details, see sundials/shared/LICENSE * * For details, see LICENSE below *
*-----------------------------------------------------------------* *------------------------------------------------------------------------*
* This header file exports three types: realtype, integertype, * * This header file exports three types: realtype, integertype, *
* and booleantype, as well as the constants TRUE and FALSE. * * and booleantype, as well as the constants TRUE and FALSE. *
* * * *
* Users should #include "sundialstypes.h" in any file that * * Users should #include "sundialstypes.h" in any file that *
* shhould be easily modifiable to work with different real or * * shhould be easily modifiable to work with different real or *
* integer types and use the exported names realtype and * * integer types and use the exported names realtype and *
* integertype within such a file. * * integertype within such a file. *
* The types for realtype and integertype below have been set to * * The types for realtype and integertype below have been set to *
* double and long int, respectively. A user should modify these * * double and long int, respectively. A user should modify these *
* type declarations as he/she sees fit. For example, if a user * * type declarations as he/she sees fit. For example, if a user *
* wants the work with type float because double precision * * wants the work with type float because double precision *
* floating point arithmetic is too expensive on the user's * * floating point arithmetic is too expensive on the user's *
* machine, then the definition below should be changed to: * * machine, then the definition below should be changed to: *
* * * *
* typedef float realtype; * * typedef float realtype; *
* * * *
* Similarly, if a user does not need to work with extremely large * * Similarly, if a user does not need to work with extremely large *
* integers (see the system header file <limits.h> for the limits * * integers (see the system header file <limits.h> for the limits *
* on type int and long int on your machine), then the user * * on type int and long int on your machine), then the user *
* should change the definition below to: * * should change the definition below to: *
* * * *
* typedef int integertype; * * typedef int integertype; *
* * * *
* The constants SUNDIALS_FLOAT, SUNDIALS_DOUBLE, SUNDIALS_INT, * * The constants SUNDIALS_FLOAT, SUNDIALS_DOUBLE, SUNDIALS_INT, *
* SUNDIALS_LONG indicate the underlying types for realtype and * * SUNDIALS_LONG indicate the underlying types for realtype and *
* integertype. They should be set as follows: * * integertype. They should be set as follows: *
* * * *
* (1) #define SUNDIALS_FLOAT 1 * * (1) #define SUNDIALS_FLOAT 1 *
* #define SUNDIALS_DOUBLE 0 (real is float) * * #define SUNDIALS_DOUBLE 0 (real is float) *
* * * *
* (2) #define SUNDIALS_FLOAT 0 * * (2) #define SUNDIALS_FLOAT 0 *
* #define SUNDIALS_DOUBLE 1 (real is double) * * #define SUNDIALS_DOUBLE 1 (real is double) *
* * * *
* (3) #define SUNDIALS_INT 1 * * (3) #define SUNDIALS_INT 1 *
* #define SUNDIALS_LONG 0 (integer is int) * * #define SUNDIALS_LONG 0 (integer is int) *
* * * *
* (4) #define SUNDIALS_INT 0 * * (4) #define SUNDIALS_INT 0 *
* #define SUNDIALS_LONG 1 (integer is long int) * * #define SUNDIALS_LONG 1 (integer is long int) *
* * * *
* Thus the legal types for realtype are float and double, while * * Thus the legal types for realtype are float and double, while *
* the legal types for integertype are int and long int. * * the legal types for integertype are int and long int. *
* The macro RCONST gives a user a convenient way to define real * * The macro RCONST gives a user a convenient way to define real *
* constants. To use the real constant 1.0, for example, the * * constants. To use the real constant 1.0, for example, the *
* user should write * * user should write *
* * * *
* #define ONE RCONST(1.0) * * #define ONE RCONST(1.0) *
* * * *
* If realtype is double, then RCONST(1.0) expands to 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. * * If realtype is float, then RCONST(1.0) expands to 1.0F. *
* There is never a need to explicitly cast 1.0 to (realtype). * * 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 #ifndef _sundialstypes_h
#define _sundialstypes_h #define _sundialstypes_h