本文整理汇总了C++中Matrix::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::Clear方法的具体用法?C++ Matrix::Clear怎么用?C++ Matrix::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Pow
Matrix Pow(LL m) {
Matrix ans ; ans.Clear();
ans.n = 1; ans.m = 2;
ans.a[0][0] = ans.a[1][0] = 1;
Matrix s ; s.Clear();
s.n = s.m = 2;
s.a[0][0] = s.a[0][1] = 1;
s.a[1][0] =2; s.a[1][1] = 1;
while(m) {
if(m&1) ans = s*ans;
s = s*s;
m>>=1;
}
return ans;
}
示例2:
Matrix operator * (const Matrix & b) const {
Matrix temp; temp.Clear();
temp.n = n; temp.m = b.m;
for(int i = 0;i<n;i++) {
for(int j = 0 ;j<b.m;j++) {
for(int k = 0 ;k<m;k++) {
temp.a[i][j] = (temp.a[i][j] + (a[i][k] * b.a[k][j])%Mod)%Mod;
}
}
}
return temp;
}
示例3: Pow
Matrix Pow(Matrix m1,LL b)
{
Matrix ans;ans.Clear();
for(int i=0;i<2;i++)
ans.mat[i][i]=1;
while(b)
{
if(b&1)
ans=mult(ans,m1);
b>>=1;
m1=mult(m1,m1);
}
return ans;
}
示例4: SDMax
SDOut SDMax (SDIn& si) {
SDOut so;
Matrix<double>& posh = si.posh;
Matrix<double>& sh = si.sh;
PolyVal<double>& pkx = *(si.pkx);
PolyVal<double>& pky = *(si.pky);
PolyVal<double>& pkz = *(si.pkz);
size_t ssp = size(posh,0);
size_t sss = size(sh ,0);
Matrix<double> dpp (ssp,1);
Matrix<double> dsp (sss,1);
Matrix<double> csp (ssp,3);
for (size_t i = 0; i < ssp-1; i++)
dpp[i] = posh[i+1] - posh[i];
dpp[ssp-1] = dpp[ssp-2];
for (size_t i = 0; i < sss-1; i++)
dsp[i] = sh[i+1] - sh[i];
dsp[ssp-1] = dsp[ssp-2];
printf (".");
fflush (stdout);
for (size_t i = 1; i < ssp-1; i++) {
csp(i,0) = (pkx.Lookup (posh[i] + dpp[i]) - pkx.Lookup (posh[i])) / dsp[i];
csp(i,1) = (pky.Lookup (posh[i] + dpp[i]) - pky.Lookup (posh[i])) / dsp[i];
csp(i,2) = (pkz.Lookup (posh[i] + dpp[i]) - pkz.Lookup (posh[i])) / dsp[i];
}
printf (".");
fflush (stdout);
dpp.Clear();
Matrix<double> dpm (ssp,1);
Matrix<double> dsm (sss,1);
Matrix<double> csm (ssp,3);
for (size_t i = 1; i < ssp; i++)
dpm[i] = posh[i] - posh[i-1];
dpm[0] = dpm[1];
for (size_t i = 1; i < sss; i++)
dsm[i] = sh[i] - sh[i-1];
dsm[0] = dsm[1];
for (size_t i = 1; i < ssp-1; i++) {
csm(i,0) = (pkx.Lookup (posh[i]) - pkx.Lookup (posh[i] - dpm[i])) / dsm[i];
csm(i,1) = (pky.Lookup (posh[i]) - pky.Lookup (posh[i] - dpm[i])) / dsm[i];
csm(i,2) = (pkz.Lookup (posh[i]) - pkz.Lookup (posh[i] - dpm[i])) / dsm[i];
}
dpm.Clear();
Matrix<double> css (ssp,3);
for (size_t i = 1; i < ssp-1; i++) {
css(i,0) = (csp(i,0) - csm(i,0)) / ((dsm[i] + dsp[i]) * 0.5);
css(i,1) = (csp(i,1) - csm(i,1)) / ((dsm[i] + dsp[i]) * 0.5);
css(i,2) = (csp(i,2) - csm(i,2)) / ((dsm[i] + dsp[i]) * 0.5);
}
csp.Clear();
csm.Clear();
dsp.Clear();
dsm.Clear();
printf (". ");
fflush (stdout);
so.k = Matrix<double> (ssp,1);
so.phi = Matrix<double> (ssp,1);
for (size_t i = 1; i < ssp-1; i++)
so.k[i] = sqrt (pow(css(i,0),2) + pow(css(i,1),2) + pow(css(i,2),2));
so.k[0] = so.k[1];
so.k[sss-1] = so.k[sss-2];
css.Clear();
double mgr = GAMMA / 10.0 * si.mgr;
double msr = GAMMA / 10.0 * si.msr;
for (size_t i = 0; i < ssp; i++)
so.phi[i] = MIN (mgr, sqrt(msr/so.k[i]));
return so;
}