本文整理汇总了C++中nt2::_方法的典型用法代码示例。如果您正苦于以下问题:C++ nt2::_方法的具体用法?C++ nt2::_怎么用?C++ nt2::_使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nt2
的用法示例。
在下文中一共展示了nt2::_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL( linear, NT2_REAL_TYPES )
{
using nt2::_;
nt2::table<T> x = nt2::linspace(T(1), T(4), 4);
nt2::table<T> y = nt2::linspace(T(2), T(8), 4);
nt2::table<T> xi= nt2::linspace(T(0), T(5), 11);
nt2::table<T> r0 = _(T(0), T(10));
T nan = nt2::Nan<T>();
nt2::table<T> r1 = r0; r1(_(1, 2)) = nan; r1(_(10, 11)) = nan;
nt2::table<T> r2 = r0; r2(_(1, 2)) = T(33);r2(_(10, 11)) = T(33);
NT2_DISPLAY(x);
NT2_DISPLAY(y);
NT2_DISPLAY(xi);
nt2::table<T> yi =nt2::linear(x, y, xi);
std::cout << "extrap " << false << " extrapval " << "-" << std::endl;
NT2_DISPLAY(yi);
NT2_TEST_EQUAL(yi, r1);
yi =nt2::linear(x, y, xi, false);
std::cout << "extrap " << false << " extrapval " << "-" << std::endl;
NT2_DISPLAY(yi);
NT2_TEST_EQUAL(yi, r1);
std::cout << "extrap " << true << " extrapval " << "-" << std::endl;
yi =nt2::linear(x, y, xi, true);
NT2_DISPLAY(yi);
T z = 33;
std::cout << "extrap " << "-" << " extrapval " << "33" << std::endl;
yi =nt2::linear(x, y, xi, z);
NT2_TEST_EQUAL(yi, r2);
NT2_DISPLAY(yi);
std::cout << "extrap " << "-" << " extrapval " << "33" << std::endl;
yi =nt2::linear(x, y, xi, T(33));
NT2_TEST_EQUAL(yi, r2);
NT2_DISPLAY(yi);
}
示例2: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL ( non_square_lu, NT2_REAL_TYPES)
{
using nt2::_;
using nt2::meta::as_;
nt2::table<T> lu, l, u, p;
nt2::table<T> a = nt2::ones(4, 7, as_<T>()) + T(10)*nt2::eye(4, 7, as_<T>());
/// Interface tests
lu = nt2::lu(a);
lu = nt2::lu(a) - a;
nt2::tie(lu) = nt2::lu(a);
lu = nt2::zeros(4, 7, nt2::meta::as_<T>());
nt2::tie(lu(_(2,3),_(2,5))) = nt2::lu( a(_(1,2),_(1,4)) );
// [L,U] = LU(A) <=> A = L*U
nt2::tie(l, u) = nt2::lu(a);
NT2_TEST_ULP_EQUAL( (nt2::mtimes(l, u)), a, 0.5 );
// [L,U,P] = LU(A) <=> P*A = L*U
nt2::tie(l, u, p) = nt2::lu(a);
NT2_TEST_EQUAL ( p , (nt2::eye(4, nt2::meta::as_<T>())) );
NT2_TEST_ULP_EQUAL( (nt2::mtimes(p, a)), (nt2::mtimes(l, u)), 0.5 );
}
示例3: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL(trsm_racces2, NT2_REAL_TYPES )
{
using nt2::_;
typedef nt2::table<T> t_t;
t_t a = nt2::cons<T>(nt2::of_size(3,3),2,1,1,1,1,1,1,1,2);
t_t b = nt2::cons<T>(nt2::of_size(3,1),1,2,5);
t_t x = nt2::cons<T>(nt2::of_size(3,1),-1,0,3);
t_t p,y(b);
t_t temp(nt2::of_size(15,1));
nt2::table<T, nt2::upper_triangular_> u ;
nt2::table<T, nt2::lower_triangular_> l ;
nt2::tie(l,u,p) = nt2::lu(a);
temp(_(9,11)) = nt2::trsolve(l,y);
temp(_(6,8)) = nt2::trsolve(u,temp(_(9,11)));
test_is_terminal_shared(nt2::trsolve(l, y).proto_base().child1);
test_is_terminal_shared(nt2::trsolve(u, nt2::trsolve(l, y)).proto_base().child1);
NT2_TEST_EQUAL( temp(_(6,8)), x);
}
示例4: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL(chol_no_2i_sub, NT2_REAL_TYPES )
{
using nt2::_;
using nt2::meta::as_;
int p;
nt2::table<T,nt2::positive_definite_>
a = nt2::cons<T>(nt2::of_size(3,3),2,-1,0,-1,2,-1,0,-1,2);
nt2::table<T> u, l, u1;
u = nt2::ones(6, 3, as_<T>());
l = nt2::ones(6, 3, as_<T>());
std::cout << " u(_(1, 2, 6), _) = chol(a, nt2::upper_) " << std::endl;
u(_(1, 2, 6), _) = nt2::chol(a, nt2::upper_);
NT2_TEST_ULP_EQUAL(a , nt2::mtimes(nt2::trans(u(_(1, 2, 6), _)),u(_(1, 2, 6), _)), T(20) );
std::cout << " tie(l,p) = chol(a, lower_) " << std::endl;
nt2::tie(l(_(1, 2, 6), _),p) = nt2::chol(a, nt2::lower_);
NT2_TEST_EQUAL(p,0);
NT2_TEST_ULP_EQUAL(a, nt2::mtimes(l(_(1, 2, 6), _), nt2::trans(l(_(1, 2, 6), _))), T(20) );
std::cout << " tie(u,p) = chol(a, raw_) " << std::endl;
nt2::tie(u(_(1, 2, 6), _),p) = nt2::chol(a, nt2::raw_);
u1 = triu(u(_(1, 2, 6), _));
NT2_TEST_EQUAL(p,0);
NT2_TEST_ULP_EQUAL(a, nt2::mtimes(nt2::trans(u1),u1), T(20) );
}
示例5: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL( along_write, NT2_REAL_TYPES )
{
using nt2::_;
nt2::table<T> y = zeros( nt2::of_size(3, 4, 2, 3), nt2::meta::as_<T>() );
nt2::table<T> ref = T(3)*ones( nt2::of_size(3, 4, 2, 3), nt2::meta::as_<T>() );
nt2::along(y, _(1,3), 1) = T(3);
nt2::along(y, _(1,4), 2) = T(3);
nt2::along(y, _(1,2), 3) = T(3);
nt2::along(y, _(1,3), 4) = T(3);
NT2_TEST_EQUAL(y, ref );
}
示例6: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL( cumtrapz_mat, NT2_REAL_TYPES )
{
using nt2::table;
using nt2::of_size;
using nt2::cumtrapz;
using nt2::reshape;
using nt2::trans;
using nt2::cons;
using nt2::_;
using nt2::_2D;
using nt2::meta::as_;
table<T> y = reshape(_(T(1), T(15)), 3, 5); // test fails if y is _2D
table<T, _2D> r1= trans(reshape(cons(
T(0 ), T(0 ), T(0 ), T(0 ),T( 0 ),
T(1.5), T(4.5), T(7.5), T(10.5),T( 13.5),
T(4.0), T(10.), T(16.0),T(22.0),T( 28.0)
), 5, 3));
table<T, _2D> r2= trans(reshape(cons(
T(0), T(2.5), T( 8.0), T(16.5), T(28.0),
T(0), T(3.5), T(10.0), T(19.5), T(32.0),
T(0), T(4.5), T(12.0), T(22.5), T(36.0)
), 5, 3));
table<T, _2D> r3 = nt2::zeros(3, 5, as_<T>());
table<T, _2D> v1 = cumtrapz(y, 1);
NT2_TEST_EQUAL(v1, r1);
table<T, _2D> v2 = cumtrapz(y, 2);
NT2_TEST_EQUAL(v2, r2);
table<T, _2D> v3 = cumtrapz(y, 3);
NT2_TEST_EQUAL(v3, r3);
}
示例7: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL(svd_solve_result, NT2_REAL_TYPES)
{
using nt2::_;
// using nt2::tag::solvers::svd_solve_;
typedef typename nt2::meta::as_integer<T, signed>::type itype_t;
typedef nt2::table<T> t_t;
t_t a = nt2::expand(nt2::triu(nt2::ones(4, 4, nt2::meta::as_<T>())), 2, 4);
a(2, 2) = T(0);
t_t b = nt2::expand(T(2)*nt2::eye (4, 4, nt2::meta::as_<T>()), 2, 4);
b(2, 3) = T(1);
t_t c = _(T(4), T(-1), T(3))(_);
t_t d = T(2)*nt2::ones(2, 1, nt2::meta::as_<T>());
nt2::display("a ", a);
nt2::display("b ", b);
nt2::display("c ", c);
nt2::display("d ", d);
nt2_la_int status;
t_t x, residuals;
nt2::tie(x, residuals, status) = nt2::lsq_lse_solve(a, b, c, d);
nt2::display("x", x);
nt2::display("residuals ", residuals);
std::cout << status << std::endl;
t_t z = nt2::mtimes(a, x);
NT2_DISPLAY(z);
NT2_TEST(nt2::isulpequal(z, c, T(1.0)));
}
示例8: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL ( unifpdf_2, NT2_REAL_TYPES)
{
using nt2::unifpdf;
using nt2::tag::unifpdf_;
using nt2::_;
using nt2::meta::as_;
// specific values tests
NT2_TEST_ULP_EQUAL(unifpdf(nt2::Nan<T>(), nt2::Zero<T>(),nt2::One<T>()) , nt2::Nan<T>() , 0);
NT2_TEST_ULP_EQUAL(unifpdf(nt2::One<T>(), nt2::Zero<T>(),nt2::One<T>()) , nt2::One<T>() , 0);
NT2_TEST_ULP_EQUAL(unifpdf(nt2::Half<T>(), nt2::Zero<T>(),nt2::One<T>()) , nt2::One<T>() , 0);
NT2_TEST_ULP_EQUAL(unifpdf(nt2::Zero<T>(), nt2::Zero<T>(),nt2::One<T>()) , nt2::One<T>() , 0);
NT2_TEST_ULP_EQUAL(unifpdf(nt2::Inf<T>(), nt2::Zero<T>(),nt2::One<T>()) , nt2::Zero<T>(), 0);
NT2_TEST_ULP_EQUAL(unifpdf(nt2::Minf<T>(), nt2::Zero<T>(),nt2::One<T>()) , nt2::Zero<T>(), 0);
NT2_TEST_ULP_EQUAL(unifpdf(nt2::Half<T>(), nt2::One<T>(),nt2::Zero<T>()) , nt2::Nan<T>() , 0);
nt2::table<T> a = _(T(-5), T(1), T(5))/T(3);
nt2::table<T> b = nt2::zeros(size(a), as_<T>());
nt2::table<T> c = nt2::ones(size(a), as_<T>());
NT2_DISPLAY(a);
NT2_DISPLAY(unifpdf(a, b, c));
NT2_DISPLAY(unifpdf(a, nt2::zeros(size(a), as_<T>()), nt2::ones(size(a), as_<T>())));
{
nt2::table<T> a = nt2::reshape(nt2::linspace(T(0), T(1), 50), 10, 5);
NT2_DISPLAY(a);
NT2_DISPLAY(unifpdf(a, T(0), T(1)));
}
}
示例9: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL ( unifinv_2, NT2_REAL_TYPES)
{
using nt2::unifinv;
using nt2::tag::unifinv_;
using nt2::_;
using nt2::meta::as_;
// specific values tests
NT2_TEST_ULP_EQUAL(unifinv(nt2::Nan<T>(), nt2::Zero<T>(),nt2::One<T>()) , nt2::Nan<T>() , 0);
NT2_TEST_ULP_EQUAL(unifinv(nt2::One<T>(), nt2::Zero<T>(),nt2::One<T>()) , nt2::One<T>() , 0);
NT2_TEST_ULP_EQUAL(unifinv(nt2::Half<T>(), nt2::Zero<T>(),nt2::One<T>()) , nt2::Half<T>(), 0);
NT2_TEST_ULP_EQUAL(unifinv(nt2::Zero<T>(), nt2::Zero<T>(),nt2::One<T>()) , nt2::Zero<T>(), 0);
NT2_TEST_ULP_EQUAL(unifinv(nt2::Inf<T>(), nt2::Zero<T>(),nt2::One<T>()) , nt2::Nan<T>() , 0);
NT2_TEST_ULP_EQUAL(unifinv(nt2::Minf<T>(), nt2::Zero<T>(),nt2::One<T>()) , nt2::Nan<T>(), 0);
// NT2_TEST_ULP_EQUAL(unifinv(nt2::Half<T>(), nt2::One<T>(),nt2::Zero<T>()) , nt2::Nan<T>() , 0);
nt2::table<T> a = _(T(-5), T(1), T(5))/T(3);
NT2_DISPLAY(a);
NT2_DISPLAY(unifinv(a, nt2::zeros(size(a), as_<T>()), nt2::ones(size(a), as_<T>())));
NT2_DISPLAY(unifinv(a, T(0), T(1)));
nt2::table<T> z = nt2::if_allbits_else(nt2::logical_or(nt2::is_ltz(a), nt2::gt(a, nt2::One<T>())), a);
NT2_DISPLAY(z);
NT2_TEST(nt2::isulpequal(z, unifinv(a)));
} // end of test for floating_
示例10: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL ( exppdf_2, NT2_REAL_TYPES)
{
using nt2::exppdf;
using nt2::tag::exppdf_;
using nt2::_;
// specific values tests
NT2_TEST_ULP_EQUAL(exppdf(nt2::Nan<T>(), nt2::One<T>()), nt2::Nan<T>(), 0);
NT2_TEST_ULP_EQUAL(exppdf(nt2::Zero<T>(), nt2::One<T>() ), nt2::One<T>(), 0);
NT2_TEST_ULP_EQUAL(exppdf(nt2::One<T>(), nt2::One<T>()), nt2::Invexp_1<T>(), 0);
NT2_TEST_ULP_EQUAL(exppdf(nt2::Inf<T>(), nt2::One<T>()), nt2::Zero<T>(), 0);
NT2_TEST_ULP_EQUAL(exppdf(nt2::Minf<T>(), nt2::One<T>()), nt2::Zero<T>(), 0);
nt2::table<T> a = _(T(-5), T(1), T(5));
nt2::table<T> r = nt2::cons<T>( 0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
0.36787944117144233402, 0.13533528323661270232, 0.049787068367863944462,
0.018315638888734178669, 0.0067379469990854670008);
NT2_TEST_ULP_EQUAL(exppdf(a), r, 1);
NT2_TEST_ULP_EQUAL(exppdf(a, nt2::One<T>()), r, 1);
nt2::table<T> r1 = nt2::cons<T>( 0.033689734995427336739, 0.014872513059998150944, 0.0063831737588816135978,
0.0026837010232200948258, 0.0011106882367801159967, 0.00045399929762484844686,
0.00018371870869270226544, 7.3730548239938514289e-05, 2.9384282290753705114e-05,
1.1641402067449950703e-05, 4.5885348075273863649e-06
);
NT2_TEST_ULP_EQUAL(exppdf(nt2::One<T>(), a+T(10)), r1, 1);
a = nt2::reshape(_(T(1), T(16)), 4, 4);
nt2::table<T> z = exppdf(a, a/T(10)+T(0.05));
nt2::table<T> zz = nt2::trans(nt2::cons<T>(nt2::of_size(4, 4),
0.12910619646375867675, 0.035160323663689166396, 0.00018386784458018914446, 3.224523980484168886e-08,
0.15163266492815835607, 0.013157242439772847895, 2.8913271817234518384e-05, 2.2140632307335824579e-09,
0.12247821218890438122, 0.0039356387993860382501, 3.6886941271645263231e-06, 1.238753783407859502e-10,
0.074384499699713946264, 0.00094670887566808208883, 3.8237790062728223237e-07, 5.6507959076111078999e-12
));
NT2_TEST_ULP_EQUAL(z, zz, 5);
a = _(T(-5), T(1), T(5));
nt2::table<T> b = _(T(1), T(1), T(11));
nt2::table<T> rr = nt2::cons<T>( 0.0, 0.0, 0.0, 0.0, 0.0, 6.0,
0.0063831737588816135978, 9.0028139775407293166e-07, 1.6915759348851748341e-11,
4.248354255291588871e-17, 1.4295395675082535051e-23
);
NT2_TEST_ULP_EQUAL(exppdf(a, b), rr, 1);
} // end of test for floating_
示例11: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL(gqr_non_square_complex, NT2_REAL_TYPES )
{
using nt2::_;
typedef std::complex<T> cT;
typedef nt2::table<cT> t_t;
typedef nt2::table<nt2_la_int> t_i;
t_t tau_q3,tau_rf, r_q3, r_rf;
t_i jpvt = nt2::zeros(3,1, nt2::meta::as_<nt2_la_int>());
t_t q = T(10)* nt2::ones (6, 3, nt2::meta::as_<cT>())
- T(4)*nt2::eye (6, 3, nt2::meta::as_<cT>());
t_t q_p3(q);
t_t q_rf(q);
nt2::geqrf( boost::proto::value(q_rf),boost::proto::value(tau_rf));
nt2::geqp3( boost::proto::value(q_p3), boost::proto::value(jpvt)
, boost::proto::value(tau_q3));
r_q3 = nt2::triu ( q_p3( _(1,3), _) );
r_rf = nt2::triu ( q_rf(_(1,3), _) );
nt2::gqr(boost::proto::value(q_rf),boost::proto::value(tau_rf));
nt2::gqr(boost::proto::value(q_p3),boost::proto::value(tau_q3));
t_t qr_q3 = nt2::mtimes(q_p3,r_q3);
t_t qr_rf = nt2::mtimes(q_rf,r_rf);
std::size_t d = nt2::numel(jpvt);
t_t p = nt2::zeros(d, nt2::meta::as_<cT>());
for(std::size_t i = 1; i<= d;++i)
p(jpvt(i),i) = 1;
NT2_TEST_ULP_EQUAL(nt2::mtimes(q,p), qr_q3, T(10));
NT2_TEST_ULP_EQUAL(q, qr_rf , T(10));
}
示例12: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL( adjfun, NT2_TYPES)
{
using nt2::_;
using nt2::end_;
using nt2::isempty;
using nt2::adjfun;
using nt2::functor;
nt2::container::table<T> y( nt2::of_size(5,3) );
for(std::size_t j=1;j <= nt2::size(y, 2);j++)
for(std::size_t i=1;i <= nt2::size(y, 1);i++)
y(i,j) = T(i + j)*T(i+j);
NT2_TEST_EQUAL( adjfun(functor<nt2::tag::is_equal_>(), y)
, y(_(2, end_), _) == y(_(1, end_-1), _)
);
NT2_TEST_EQUAL( adjfun(functor<nt2::tag::minus_>(), y, 1)
, y(_(2, end_), _)-y(_(1, end_-1), _)
);
NT2_TEST_EQUAL( adjfun(functor<nt2::tag::minus_>(), y, 2)
, y(_,_(2, end_), _)-y(_,_(1, end_-1), _)
);
NT2_TEST(isempty( adjfun(functor<nt2::tag::minus_>(), y, 3) ));
}
示例13: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL( idx_linear, NT2_REAL_TYPES )
{
using nt2::_;
nt2::table<T> x = nt2::linspace(T(1), T(4), 4);
nt2::table<T> xi= nt2::linspace(T(0), T(5), 11);
T nan = nt2::Nan<T> ();
nt2::table<T> r0 = nt2::linspace(T(0), T(5), 11);
nt2::table<T> r1 = r0; r1(_(1, 2)) = nan; r1(_(10, 11)) = nan;
nt2::table<T> r2 = r0; r2(_(1, 2)) = T(33), r2(_(10, 11)) = T(33);
nt2::table<T> r3 = r2; r3(_(10, 11)) = T(42);
NT2_DISPLAY(x);
NT2_DISPLAY(xi);
nt2::table<T> yi =nt2::idx_linear(x, xi);
std::cout << "1 extrap " << false << " extrapval " << "-" << std::endl;
NT2_DISPLAY(yi);
NT2_TEST_EQUAL(yi, r1);
yi =nt2::idx_linear(x, xi, false);
std::cout << "2 extrap " << false << " extrapval " << "-" << std::endl;
NT2_DISPLAY(yi);
NT2_TEST_EQUAL(yi, r1);
std::cout << "3 extrap " << true << " extrapval " << "-" << std::endl;
yi =nt2::idx_linear(x, xi, true);
NT2_DISPLAY(yi);
NT2_TEST_EQUAL(yi, r0);
T z = T(33);
std::cout << "4 extrap " << "-" << " extrapval " << "33" << std::endl;
yi =nt2::idx_linear(x, xi, z);
NT2_DISPLAY(yi);
NT2_TEST_EQUAL(yi, r2);
std::cout << "5 extrap " << "-" << " extrapval " << "33" << std::endl;
yi =nt2::idx_linear(x, xi, T(33));
NT2_DISPLAY(yi);
NT2_TEST_EQUAL(yi, r2);
std::cout << "6 extrap " << "-" << " extrapval1 " << "33" << " extrapval1 " << "42"<< std::endl;
yi =nt2::idx_linear(x, xi, T(33), T(42));
NT2_DISPLAY(yi);
NT2_TEST_EQUAL(yi, r3);
}
示例14: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL( nearest, NT2_REAL_TYPES )
{
using nt2::_;
nt2::table<T> x = nt2::linspace(T(1), T(4), 4);
nt2::table<T> y = nt2::linspace(T(2), T(8), 4);
nt2::table<T> xi= nt2::linspace(T(0), T(5), 11);
T tr0[] = {2 ,2 ,2 ,4 ,4 ,6 ,6 ,8 ,8 ,8 ,8};
nt2::table<T> r0(nt2::of_size(1, 11), &tr0[0], &tr0[11]);
T nan = nt2::Nan<T>();
nt2::table<T> r1 = r0; r1(_(1, 2)) = nan; r1(_(10, 11)) = nan;
nt2::table<T> r2 = r0; r2(_(1, 2)) = T(33); r2(_(10, 11))= T(33);
NT2_DISPLAY(x);
NT2_DISPLAY(y);
NT2_DISPLAY(xi);
nt2::table<T> yi =nt2::nearest(x, y, xi);
std::cout << "extrap " << false << " extrapval " << "-" << std::endl;
NT2_DISPLAY(yi);
NT2_TEST_EQUAL(yi, r1);
yi =nt2::nearest(x, y, xi, false);
std::cout << "extrap " << false << " extrapval " << "-" << std::endl;
NT2_DISPLAY(yi);
NT2_TEST_EQUAL(yi, r1);
std::cout << "extrap " << true << " extrapval " << "-" << std::endl;
yi =nt2::nearest(x, y, xi, true);
NT2_DISPLAY(yi);
NT2_TEST_EQUAL(yi, r0);
T z = 33;
std::cout << "extrap " << "-" << " extrapval " << "33" << std::endl;
yi =nt2::nearest(x, y, xi, z);
NT2_TEST_EQUAL(yi, r2);
NT2_DISPLAY(yi);
std::cout << "extrap " << "-" << " extrapval " << "33" << std::endl;
yi =nt2::nearest(x, y, xi, T(33));
NT2_DISPLAY(yi);
NT2_TEST_EQUAL(yi, r2);
}
示例15: NT2_TEST_CASE_TPL
NT2_TEST_CASE_TPL ( option_qr_not_square_m_superior_n, NT2_REAL_TYPES)
{
using nt2::_;
using nt2::meta::as_;
using nt2::pivot_;
using nt2::matrix_;
using nt2::vector_;
using nt2::no_pivot_;
typedef nt2::table<T> t_t;
nt2::table<T> x, q, q1, r, r1, p, p1;
nt2::table<T> a = nt2::rand(9 , 6, as_<T>());
/// Interface tests
// [Q,R] = QR(A,0)
nt2::tie(q, r) = nt2::qr(a,0);
NT2_TEST_ULP_EQUAL( a, nt2::mtimes(q, r), T(200));
x = nt2::qr(a, no_pivot_);
t_t u = triu(x(_(1,6), _ ));
NT2_TEST_ULP_EQUAL( u, r, T(200));
// [Q,R,P] = QR(A,matrix_,vector_,0)
nt2::tie(q, r, p) = nt2::qr(a, matrix_ );
NT2_TEST_ULP_EQUAL( nt2::mtimes(a,p), nt2::mtimes(q, r), T(200));
x = nt2::qr(a, pivot_);
u = triu(x);
NT2_TEST_ULP_EQUAL(u, r, T(200));
x = nt2::qr(a, 0);
u = triu(x);
NT2_TEST_ULP_EQUAL(u, r, T(200));
nt2::tie(q, r, p1) = nt2::qr(a, vector_ );
NT2_TEST_ULP_EQUAL( nt2::mtimes(a,extract_p(p1)), nt2::mtimes(q, r), T(200));
nt2::tie(q1, r1, p1) = nt2::qr(a, 0);
NT2_TEST_ULP_EQUAL( nt2::mtimes(a,extract_p(p1)), nt2::mtimes(q, r), T(200));
}