COPASI API  4.16.103
Functions
dbnorm.cpp File Reference
#include <cmath>
#include <algorithm>
#include "copasi.h"
#include "dbnorm.h"
Include dependency graph for dbnorm.cpp:

Go to the source code of this file.

Functions

double dbnorm_ (C_INT *n, double *a, C_INT *nra, C_INT *ml, C_INT *mu, double *w)
 

Function Documentation

double dbnorm_ ( C_INT n,
double *  a,
C_INT nra,
C_INT ml,
C_INT mu,
double *  w 
)

Definition at line 31 of file dbnorm.cpp.

References C_INT, max, and min.

Referenced by CInternalSolver::dprja_().

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
#define min(a, b)
Definition: f2c.h:175
#define max(a, b)
Definition: f2c.h:176