Skip to content

Commit 1d086cb

Browse files
committed
tests: general products with block expressions (block operands; assignment into a block view)
1 parent c04c83c commit 1d086cb

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

tests/general_product.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,48 @@ BOOST_AUTO_TEST_CASE(expression_mixed_t_tot_scaled) {
597597
BOOST_CHECK_SMALL(tot_max_abs_diff(w, w_ref), 1e-10);
598598
}
599599

600+
BOOST_AUTO_TEST_CASE(expression_general_product_block_operands) {
601+
// general product of BLOCK views: C("b,i,k") = A.block * B.block with
602+
// b fused, j contracted, i/k free; the blocks restrict b and i/k
603+
auto& world = TA::get_default_world();
604+
TA::TiledRange tr{{0, 2, 4}, {0, 2, 4}, {0, 2, 4}}; // (b,i,j) / (b,j,k)
605+
auto a = make_patterned_array(world, tr, 1.0);
606+
auto t = make_patterned_array(world, tr, 2.0);
607+
608+
// materialized blocks as the reference operands
609+
TA::TArrayD ab, tb, w_ref, w;
610+
ab("b,i,j") = a("b,i,j").block({0, 0, 0}, {1, 2, 2});
611+
tb("b,j,k") = t("b,j,k").block({0, 0, 0}, {1, 2, 1});
612+
w_ref("b,i,k") = ab("b,i,j") * tb("b,j,k");
613+
614+
BOOST_REQUIRE_NO_THROW(w("b,i,k") = a("b,i,j").block({0, 0, 0}, {1, 2, 2}) *
615+
t("b,j,k").block({0, 0, 0}, {1, 2, 1}));
616+
BOOST_CHECK_SMALL(diff_norm(w, w_ref, "b,i,k"), 1e-10);
617+
}
618+
619+
BOOST_AUTO_TEST_CASE(expression_general_product_into_block) {
620+
// general product assigned INTO a block view of the result:
621+
// W.block = A * B (b fused, j contracted)
622+
auto& world = TA::get_default_world();
623+
TA::TiledRange tr_a{{0, 2}, {0, 2}, {0, 2, 4}}; // b, i, j
624+
TA::TiledRange tr_b{{0, 2}, {0, 2, 4}, {0, 2}}; // b, j, k
625+
TA::TiledRange tr_w{{0, 2, 4}, {0, 2, 4}, {0, 2, 4}};
626+
auto a = make_patterned_array(world, tr_a, 1.0);
627+
auto t = make_patterned_array(world, tr_b, 2.0);
628+
629+
TA::TArrayD prod;
630+
prod("b,i,k") = a("b,i,j") * t("b,j,k");
631+
632+
TA::TArrayD w(world, tr_w), w_ref(world, tr_w);
633+
w.fill(0.0);
634+
w_ref.fill(0.0);
635+
w_ref("b,i,k").block({0, 0, 0}, {1, 1, 1}) = prod("b,i,k");
636+
637+
BOOST_REQUIRE_NO_THROW(w("b,i,k").block({0, 0, 0}, {1, 1, 1}) =
638+
a("b,i,j") * t("b,j,k"));
639+
BOOST_CHECK_SMALL(diff_norm(w, w_ref, "b,i,k"), 1e-10);
640+
}
641+
600642
BOOST_AUTO_TEST_CASE(expression_general_product_tot_inner_outer_product) {
601643
// the PNO-CC PPL building-block shape: ToT x ToT with an EMPTY right
602644
// outer-external set and an inner OUTER-product:

0 commit comments

Comments
 (0)