本文整理汇总了C++中ivector::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ ivector::resize方法的具体用法?C++ ivector::resize怎么用?C++ ivector::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ivector
的用法示例。
在下文中一共展示了ivector::resize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ludcmp
int ludcmp(struct soap *soap, matrix &a, ivector &indx, double &d)
{ int i, imax = 0, j, k, n;
double big, dum, sum, temp;
n = a.size();
vector vv(soap);
vv.resize(n);
indx.resize(n);
d = 1.0;
for (i = 1; i <= n; i++)
{ big = 0.0;
a[i].resize(n);
for (j = 1; j <= n; j++)
if ((temp = fabs(a[i][j])) > big)
big = temp;
if (big == 0.0)
return -1;
vv[i] = 1.0/big;
}
for (j = 1; j <= n; j++)
{ for (i = 1; i < j; i++)
{ sum = a[i][j];
for (k = 1; k < i; k++)
sum -= a[i][k]*a[k][j];
a[i][j] = sum;
}
big = 0.0;
for (i = j; i <= n; i++)
{ sum = a[i][j];
for (k = 1; k < j; k++)
sum -= a[i][k]*a[k][j];
a[i][j] = sum;
if ((dum = vv[i]*fabs(sum)) >= big)
{ big = dum;
imax = i;
}
}
if (j != imax)
{ for (k = 1; k <= n; k++)
{ dum = a[imax][k];
a[imax][k] = a[j][k];
a[j][k] = dum;
}
d = -d;
vv[imax] = vv[j];
}
indx[j] = imax;
if (a[j][j] == 0.0)
a[j][j] = 1.0e-20;
if (j != n)
{ dum = 1.0/a[j][j];
for (i = j+1; i <= n; i++)
a[i][j] *= dum;
}
}
for (i = 1; i <= n; i++)
{ for (j = 1; j <= n; j++)
if (fabs(a[i][j]) > 1.0e-15)
break;
for (k = n; k > j; k--)
if (fabs(a[i][k]) > 1.0e-15)
break;
a[i].resize(j, k);
}
return 0;
}