COPASI API  4.16.103
dfnorm.cpp
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/odepack++/dfnorm.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 "dfnorm.h"
29 
30 /* DECK DFNORM */
31 double dfnorm_(C_INT *n, double *a, double *w)
32 {
33  /* System generated locals */
34  C_INT a_dim1, a_offset, i__1, i__2;
35  double ret_val, d__1, d__2;
36 
37  /* Local variables */
38  C_INT i__, j;
39  double an, sum;
40 
41  /* ----------------------------------------------------------------------- */
42  /* This function computes the norm of a full N by N matrix, */
43  /* stored in the array A, that is consistent with the weighted max-norm */
44  /* on vectors, with weights stored in the array W: */
45  /* DFNORM = MAX(i=1,...,N) (W(i) * Sum(j=1,...,N) ABS(a(i,j))/W(j)) */
46  /* ----------------------------------------------------------------------- */
47  /* Parameter adjustments */
48  --w;
49  a_dim1 = *n;
50  a_offset = 1 + a_dim1;
51  a -= a_offset;
52 
53  /* Function Body */
54  an = 0.;
55  i__1 = *n;
56 
57  for (i__ = 1; i__ <= i__1; ++i__)
58  {
59  sum = 0.;
60  i__2 = *n;
61 
62  for (j = 1; j <= i__2; ++j)
63  {
64  /* L10: */
65  sum += (d__1 = a[i__ + j * a_dim1], fabs(d__1)) / w[j];
66  }
67 
68  /* Computing MAX */
69  d__1 = an, d__2 = sum * w[i__];
70  an = std::max(d__1, d__2);
71  /* L20: */
72  }
73 
74  ret_val = an;
75  return ret_val;
76  /* ----------------------- End of Function DFNORM ------------------------ */
77 } /* dfnorm_ */
#define C_INT
Definition: copasi.h:115
double dfnorm_(C_INT *n, double *a, double *w)
Definition: dfnorm.cpp:31
#define max(a, b)
Definition: f2c.h:176