COPASI API  4.16.103
dbnorm.cpp
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/odepack++/dbnorm.cpp,v $
3  $Revision: 1.4 $
4  $Name: $
5  $Author: ssahle $
6  $Date: 2012/04/22 14:54:53 $
7  End CVS Header */
8 
9 // Copyright (C) 2012 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc. and EML Research, gGmbH.
16 // All rights reserved.
17 
18 //
19 // This C++ code is based on an f2c conversion of the Fortran
20 // library ODEPACK available at: http://www.netlib.org/odepack/
21 
22 #include <cmath>
23 
24 #include <algorithm>
25 
26 #include "copasi.h"
27 
28 #include "dbnorm.h"
29 
30 /* DECK DBNORM */
31 double dbnorm_(C_INT *n, double *a, C_INT *nra, C_INT *ml,
32  C_INT *mu, double *w)
33 {
34  /* System generated locals */
35  C_INT a_dim1, a_offset, i__1, i__2;
36  double ret_val, d__1, d__2;
37 
38  /* Local variables */
39  C_INT i__, j, i1;
40  double an;
41  C_INT jhi, jlo;
42  double sum;
43 
44  /* ----------------------------------------------------------------------- */
45  /* This function computes the norm of a banded N by N matrix, */
46  /* stored in the array A, that is consistent with the weighted max-norm */
47  /* on vectors, with weights stored in the array W. */
48  /* ML and MU are the lower and upper half-bandwidths of the matrix. */
49  /* NRA is the first dimension of the A array, NRA .ge. ML+MU+1. */
50  /* In terms of the matrix elements a(i,j), the norm is given by: */
51  /* DBNORM = MAX(i=1,...,N) (W(i) * Sum(j=1,...,N) ABS(a(i,j))/W(j)) */
52  /* ----------------------------------------------------------------------- */
53  /* Parameter adjustments */
54  --w;
55  a_dim1 = *nra;
56  a_offset = 1 + a_dim1;
57  a -= a_offset;
58 
59  /* Function Body */
60  an = 0.;
61  i__1 = *n;
62 
63  for (i__ = 1; i__ <= i__1; ++i__)
64  {
65  sum = 0.;
66  i1 = i__ + *mu + 1;
67  /* Computing MAX */
68  i__2 = i__ - *ml;
69  jlo = std::max(i__2, (C_INT)1);
70  /* Computing MIN */
71  i__2 = i__ + *mu;
72  jhi = std::min(i__2, *n);
73  i__2 = jhi;
74 
75  for (j = jlo; j <= i__2; ++j)
76  {
77  /* L10: */
78  sum += (d__1 = a[i1 - j + j * a_dim1], fabs(d__1)) / w[j];
79  }
80 
81  /* Computing MAX */
82  d__1 = an, d__2 = sum * w[i__];
83  an = std::max(d__1, d__2);
84  /* L20: */
85  }
86 
87  ret_val = an;
88  return ret_val;
89  /* ----------------------- End of Function DBNORM ------------------------ */
90 } /* dbnorm_ */
#define C_INT
Definition: copasi.h:115
double dbnorm_(C_INT *n, double *a, C_INT *nra, C_INT *ml, C_INT *mu, double *w)
Definition: dbnorm.cpp:31
#define min(a, b)
Definition: f2c.h:175
#define max(a, b)
Definition: f2c.h:176