Revision 1293 trunk/src/linad99/fvar_m15.cpp

fvar_m15.cpp (revision 1293)
23 23
\param b An integer
24 24
\return A integer \f$ z = \min(a,b)\f$
25 25
*/
26
int min(int a,int b)
26
int min(const int a, const int b)
27 27
{
28
  if (a>b) return b;
29
  return a;
28
  return a <= b ? a : b;
30 29
}
31 30

  
32 31
/** Inverse of a varaiable matrix.
......
38 37
*/
39 38
dvar_matrix inv(const dvar_matrix& aa)
40 39
{
41
  int i,imax,j,k,n;
42
  n=aa.colsize();
40
  int imax = 0;
41
  int n = aa.colsize();
43 42
  int lb=aa.colmin();
44 43
  int ub=aa.colmax();
45 44
  dvar_matrix vc(lb,ub,lb,ub);
......
66 65
  dvector vv(lb,ub);
67 66

  
68 67
  d=1.0;
69
  for (i=lb;i<=ub;i++)
68
  for (int i=lb;i<=ub;i++)
70 69
  {
71 70
    big=0.0;
72
    for (j=lb;j<=ub;j++)
71
    for (int j=lb;j<=ub;j++)
73 72
    {
74 73
      temp=fabs(bb.elem(i,j));
75 74
      if (temp > big)
......
85 84
    vv[i]=1.0/big;
86 85
  }
87 86

  
88
  for (j=lb;j<=ub;j++)
87
  for (int j=lb;j<=ub;j++)
89 88
  {
90
    for (i=lb;i<j;i++)
89
    for (int i=lb;i<j;i++)
91 90
    {
92 91
      sum=bb.elem(i,j);
93
      for (k=lb;k<i;k++)
92
      for (int k=lb;k<i;k++)
94 93
      {
95 94
        sum = sum - bb.elem(i,k)*bb.elem(k,j);
96 95
      }
......
98 97
      bb.elem(i,j)=sum;
99 98
    }
100 99
    big=0.0;
101
    for (i=j;i<=ub;i++)
100
    for (int i=j;i<=ub;i++)
102 101
    {
103 102
      sum=bb.elem(i,j);
104
      for (k=lb;k<j;k++)
103
      for (int k=lb;k<j;k++)
105 104
      {
106 105
        sum = sum - bb.elem(i,k)*bb.elem(k,j);
107 106
      }
......
115 114
    }
116 115
    if (j != imax)
117 116
    {
118
      for (k=lb;k<=ub;k++)
117
      for (int k=lb;k<=ub;k++)
119 118
      {
120 119
        dum=bb.elem(imax,k);
121 120
        bb.elem(imax,k)=bb.elem(j,k);
......
141 140
    if (j != n)
142 141
    {
143 142
      dum=1.0/bb.elem(j,j);
144
      for (i=j+1;i<=ub;i++)
143
      for (int i=j+1;i<=ub;i++)
145 144
      {
146 145
        bb.elem(i,j) = bb.elem(i,j) * dum;
147 146
      }
......
154 153
  //int ub=rowmax;
155 154
  dmatrix& b=bb;
156 155
  ivector indxinv(lb,ub);
157
  for (i=lb;i<=ub;i++)
156
  for (int i=lb;i<=ub;i++)
158 157
  {
159 158
    indxinv(indx.elem(i))=i;
160 159
  }
......
179 178
      }
180 179
      y.elem(i)=sum;
181 180
    }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff