本文整理汇总了C++中mtl::lazy方法的典型用法代码示例。如果您正苦于以下问题:C++ mtl::lazy方法的具体用法?C++ mtl::lazy怎么用?C++ mtl::lazy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mtl
的用法示例。
在下文中一共展示了mtl::lazy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int, char**)
{
using namespace std;
using mtl::lazy; using mtl::io::tout;
typedef mtl::dense_vector<double> vt;
vt v(60);
iota(v);
tout << "v is " << v << endl;
mtl::mat::identity2D I(60);
vt w1(I * v);
tout << "I * v is " << w1 << endl;
if (one_norm(vt(w1 - v)) > 0.001) throw "Wrong result with square identity";
w1-= I * v;
tout << "w1-= I * v is " << w1 << endl;
if (one_norm(w1) > 0.001) throw "Wrong result";
w1+= I * v;
tout << "w1+= I * v is " << w1 << endl;
if (one_norm(vt(w1 - v)) > 0.001) throw "Wrong result with square identity";
vt w2( w1 - I * v );
double alpha;
(lazy(w2)= I * v) || (lazy(alpha)= lazy_dot(w2, v));
vt w3(30), w4(90);
mtl::mat::identity2D I3(30, 60), I4(90, 60);
w3= I3 * v;
tout << "I3 * v is " << w3 << endl;
if (one_norm(vt(w3 - v[mtl::irange(30)])) > 0.001) throw "Wrong result with broad identity";
w4= I4 * v;
tout << "I4 * v is " << w4 << endl;
if (one_norm(vt(w4[mtl::irange(60)] - v)) > 0.001) throw "Wrong result with long identity";
if (one_norm(w4[mtl::irange(60, 90)]) > 0.001) throw "Wrong result with long identity";
#if 0
mtl::dense2D<double> A(60,60);
A=2;
A+= A*I;
std::cout<< "A=\n" << A << "\n";
#endif
return 0;
}
示例2: main
int main(int, char**)
{
using namespace std;
using mtl::lazy;
using mtl::io::tout;
typedef mtl::vector::dense_vector<double> vt;
mtl::compressed2D<double> A0;
laplacian_setup(A0, 4, 15);
tout << "A0 is\n" << A0 << endl;
vt v(60);
iota(v);
tout << "v is " << v << endl;
vt w1(A0 * v);
tout << "A0 * v is " << w1 << endl;
mtl::matrix::poisson2D_dirichlet A(4, 15);
vt w2(60);
w2= A * v;
tout << "A * v is " << w2 << endl;
if (one_norm(vt(w1 - w2)) > 0.001) throw "Wrong result";
w2+= A * v;
tout << "w2+= A * v is " << w2 << endl;
if (one_norm(vt(w1 + w1 - w2)) > 0.001) throw "Wrong result";
w2-= A * v;
tout << "w2-= A * v is " << w2 << endl;
if (one_norm(vt(w1 - w2)) > 0.001) throw "Wrong result";
vt w3( w2 - A * v );
double alpha;
(lazy(w3)= A * v) || (lazy(alpha)= lazy_dot(w3, v));
return 0;
}