本文整理汇总了C++中SparseMat::add_row_coeff方法的典型用法代码示例。如果您正苦于以下问题:C++ SparseMat::add_row_coeff方法的具体用法?C++ SparseMat::add_row_coeff怎么用?C++ SparseMat::add_row_coeff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparseMat
的用法示例。
在下文中一共展示了SparseMat::add_row_coeff方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: allocate_system
/*----------------------------------------------------------------------------*/
System Surface::allocate_system()
{
const int n = 4*w*h;
const int m = w*h;
const long double w2 = (long double)(w)/2.;
const long double h2 = (long double)(h)/2.;
const long double sqrt_L1 = sqrtl(LAMBDA_1);
const long double sqrt_1ML1 = sqrtl(1.-LAMBDA_1);
const long double sqrt_L2 = sqrtl(LAMBDA_2);
// builds B
long double *b = new long double[n];
for(int u=0; u<w; u++)
for(int v=0; v<h; v++)
{
int i = u * h + v;
b[i] = sqrt_L1 * mu(u,v) * depth_map(u,v);
}
for(int i=m; i<n; i++)
b[i] = 0.;
Zvect *B = new Zvect(n, b);
// builds A
SparseMat *A = new SparseMat(n,m);
// part 1
for(int u=0; u<w; u++)
for(int v=0; v<h; v++)
{
int i = u * h + v;
A->add_coeff(i, i, sqrt_L1*mu(u,v));
}
// part 2
long double dx_filter[] = {-1./12., 0. , 1./12.,
-4./12., 0. , 4./12.,
-1./12., 0. , 1./12.};
for(int u=0; u<w; u++)
for(int v=0; v<h; v++)
{
int j = u * h + v;
int i = m + j;
long double x = ((long double)(u)-w2)/fx;
long double y = ((long double)(v)-h2)/fy;
const vec& n = caracs(u,v).n;
long double dx_weight = sqrt_1ML1 * (n[2] - (n[0]*x + n[1]*y));
A->add_row_coeff(i, make_filter(u,v, dx_filter, dx_weight));
A->add_coeff(i, j, -sqrt_1ML1 * n[0] / fx);
}
// part 3
long double dy_filter[] = { 1./12., 4./12. , 1./12.,
0., 0. , 0.,
-1./12., -4./12. , -1./12.,};
for(int u=0; u<w; u++)
for(int v=0; v<h; v++)
{
int j = u * h + v;
int i = 2*m + j;
long double x = ((long double)(u)-w2)/fx;
long double y = ((long double)(v)-h2)/fy;
const vec& n = caracs(u,v).n;
long double dy_weight = sqrt_1ML1 * (n[2] - (n[0]*x + n[1]*y));
A->add_row_coeff(i, make_filter(u,v, dy_filter, dy_weight));
A->add_coeff(i, j, -sqrt_1ML1 * n[1] / fy);
}
// part 4
long double laplacian_filter[] = { -1., -1. , -1.,
-1., 8. , -1.,
-1., -1. , -1.};
for(int u=0; u<w; u++)
for(int v=0; v<h; v++)
{
int i = 3*m + u * h + v;
A->add_row_coeff(i, make_filter(u,v, laplacian_filter, sqrt_L2));
}
return pair<SparseMat*, Zvect*>(A,B);
}