COPASI API  4.16.103
dmnorm.cpp
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/odepack++/dmnorm.cpp,v $
3  $Revision: 1.6 $
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 /* DECK DMNORM */
29 /* ----------------------------------------------------------------------- */
30 /* This function routine computes the weighted max-norm */
31 /* of the vector of length N contained in the array V, with weights */
32 /* contained in the array w of length N: */
33 /* DMNORM = MAX(i=1,...,N) ABS(V(i))*W(i) */
34 /* ----------------------------------------------------------------------- */
35 double dmnorm_(C_INT *n, double *v, double *w)
36 {
37  double vm = 0.0, tmp;
38  double *tv = v, *tw = w, *end = tv + *n;
39 
40  while (tv != end)
41  if ((tmp = fabs(*tv++) * *tw++) > vm) vm = tmp;
42 
43  return vm;
44 }
45 
46 #ifdef XXXX
47 double dmnorm_(C_INT *n, double *v, double *w)
48 {
49  /* System generated locals */
50  C_INT i__1;
51  double ret_val, d__1, d__2, d__3;
52 
53  /* Local variables */
54  C_INT i__;
55  double vm;
56 
57  /* ----------------------------------------------------------------------- */
58  /* This function routine computes the weighted max-norm */
59  /* of the vector of length N contained in the array V, with weights */
60  /* contained in the array w of length N: */
61  /* DMNORM = MAX(i=1,...,N) ABS(V(i))*W(i) */
62  /* ----------------------------------------------------------------------- */
63  /* Parameter adjustments */
64  --w;
65  --v;
66 
67  /* Function Body */
68  vm = 0.;
69  i__1 = *n;
70 
71  for (i__ = 1; i__ <= i__1; ++i__)
72  {
73  /* L10: */
74  /* Computing MAX */
75  d__2 = vm, d__3 = (d__1 = v[i__], fabs(d__1)) * w[i__];
76  vm = std::max(d__2, d__3);
77  }
78 
79  ret_val = vm;
80  return ret_val;
81  /* ----------------------- End of Function DMNORM ------------------------ */
82 } /* dmnorm_ */
83 #endif // XXXX
#define C_INT
Definition: copasi.h:115
double dmnorm_(C_INT *n, double *v, double *w)
Definition: dmnorm.cpp:35
#define max(a, b)
Definition: f2c.h:176