diff --git a/src/scf/driver/scf_loop.cpp b/src/scf/driver/scf_loop.cpp index c798765..efd4d04 100644 --- a/src/scf/driver/scf_loop.cpp +++ b/src/scf/driver/scf_loop.cpp @@ -26,7 +26,7 @@ struct Kernel { auto run(const tensorwrapper::buffer::BufferBase& a, double tol) { tensorwrapper::allocator::Eigen allocator(m_rv); const auto& eigen_a = allocator.rebind(a); - return tensorwrapper::types::fabs(eigen_a.at()) < FloatType(tol); + return tensorwrapper::types::fabs(eigen_a.get_data(0)) < FloatType(tol); } parallelzone::runtime::RuntimeView m_rv; @@ -251,9 +251,9 @@ MODULE_RUN(SCFLoop) { if(ualloc.can_rebind(e_old.buffer())) { simde::type::tensor temp(e_old); - auto val = dalloc.rebind(e_nuclear.buffer()).at(); - ualloc.rebind(temp.buffer()).at() = val; - e_nuclear = temp; + auto val = dalloc.rebind(e_nuclear.buffer()).get_data(0); + ualloc.rebind(temp.buffer()).set_data(0, val); + e_nuclear = temp; } e_total("") = e_old("") + e_nuclear(""); diff --git a/src/scf/eigen_solver/eigen_generalized.cpp b/src/scf/eigen_solver/eigen_generalized.cpp index 31014dc..1016537 100644 --- a/src/scf/eigen_solver/eigen_generalized.cpp +++ b/src/scf/eigen_solver/eigen_generalized.cpp @@ -32,8 +32,8 @@ struct Kernel { const auto& eigen_B = allocator.rebind(B); // Wrap the tensors in Eigen::Map objects to avoid copy - const auto* pA = eigen_A.data(); - const auto* pB = eigen_B.data(); + const auto* pA = eigen_A.get_immutable_data(); + const auto* pB = eigen_B.get_immutable_data(); const auto& shape_A = eigen_A.layout().shape().as_smooth(); auto rows = shape_A.extent(0); auto cols = shape_A.extent(1); @@ -60,10 +60,10 @@ struct Kernel { auto pvalues_buffer = allocator.allocate(vector_layout); auto pvectors_buffer = allocator.allocate(matrix_layout); - for(auto i = 0; i < rows; ++i) { - pvalues_buffer->at(i) = eigen_values(i); - for(auto j = 0; j < cols; ++j) { - pvectors_buffer->at(i, j) = eigen_vectors(i, j); + for(decltype(rows) i = 0; i < rows; ++i) { + pvalues_buffer->set_elem({i}, eigen_values(i)); + for(decltype(cols) j = 0; j < cols; ++j) { + pvectors_buffer->set_elem({i, j}, eigen_vectors(i, j)); } } diff --git a/src/scf/matrix_builder/density_matrix.cpp b/src/scf/matrix_builder/density_matrix.cpp index e9a4461..2bd823f 100644 --- a/src/scf/matrix_builder/density_matrix.cpp +++ b/src/scf/matrix_builder/density_matrix.cpp @@ -31,7 +31,6 @@ struct Kernel { constexpr auto edynam = Eigen::Dynamic; using allocator_type = tensorwrapper::allocator::Eigen; using tensor_type = Eigen::Matrix; - using map_type = Eigen::Map; using const_map_type = Eigen::Map; auto rv = c.allocator().runtime(); allocator_type alloc(rv); @@ -43,13 +42,16 @@ struct Kernel { // Step 2: Grab the orbitals in the ensemble auto& c_buffer = alloc.rebind(c); - const_map_type c_eigen(c_buffer.data(), n_aos, n_aos); - map_type p_eigen(pp_buffer->data(), n_aos, n_aos); + const_map_type c_eigen(c_buffer.get_immutable_data(), n_aos, n_aos); auto slice = c_eigen.block(0, 0, n_aos, n_occ); // Step 3: CC_dagger - p_eigen = slice * slice.transpose(); - + tensor_type p_eigen = slice * slice.transpose(); + for(std::size_t i = 0; i < n_aos; ++i) { + for(std::size_t j = 0; j < n_aos; ++j) { + pp_buffer->set_elem({i, j}, p_eigen(i, j)); + } + } return simde::type::tensor(p_shape, std::move(pp_buffer)); } }; diff --git a/tests/cxx/integration_tests/coulombs_law.cpp b/tests/cxx/integration_tests/coulombs_law.cpp index d8c73fd..46e3503 100644 --- a/tests/cxx/integration_tests/coulombs_law.cpp +++ b/tests/cxx/integration_tests/coulombs_law.cpp @@ -37,7 +37,7 @@ TEMPLATE_LIST_TEST_CASE("CoulombsLaw", "", test_scf::float_types) { auto e_nuclear = mod.run_as(qs, qs); - pcorr->at() = 0.71510297482837526; + pcorr->set_elem({}, 0.71510297482837526); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); REQUIRE(approximately_equal(corr, e_nuclear, 1E-6)); } \ No newline at end of file diff --git a/tests/cxx/integration_tests/driver/scf_driver.cpp b/tests/cxx/integration_tests/driver/scf_driver.cpp index d6d5348..3d6bfd3 100644 --- a/tests/cxx/integration_tests/driver/scf_driver.cpp +++ b/tests/cxx/integration_tests/driver/scf_driver.cpp @@ -28,7 +28,7 @@ TEMPLATE_LIST_TEST_CASE("SCFDriver", "", test_scf::float_types) { tensorwrapper::shape::Smooth shape_corr{}; auto pcorr = alloc.allocate(tensorwrapper::layout::Physical(shape_corr)); using tensorwrapper::operations::approximately_equal; - pcorr->at() = -1.1167592336; + pcorr->set_elem({}, -1.1167592336); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); const auto e = mm.template run_as("SCF Driver", aos, h2); @@ -45,7 +45,7 @@ TEMPLATE_LIST_TEST_CASE("SCFDriver", "", test_scf::float_types) { simde::type::chemical_system h2_dimer_sys(h2_dimer_mol); const auto e = mm.template run_as("SCF Driver", ao_bs, h2_dimer_sys); - alloc.rebind(corr.buffer()).at() = -2.2260535919670001; + alloc.rebind(corr.buffer()).set_elem({}, -2.2260535919670001); REQUIRE(approximately_equal(corr, e, 1E-6)); } } \ No newline at end of file diff --git a/tests/cxx/integration_tests/driver/scf_loop.cpp b/tests/cxx/integration_tests/driver/scf_loop.cpp index dd86b3f..e7d2473 100644 --- a/tests/cxx/integration_tests/driver/scf_loop.cpp +++ b/tests/cxx/integration_tests/driver/scf_loop.cpp @@ -44,7 +44,7 @@ TEMPLATE_LIST_TEST_CASE("SCFLoop", "", test_scf::float_types) { chemist::braket::BraKet H_00(psi0, H, psi0); const auto& [e, psi] = mod.template run_as>(H_00, psi0); - pcorr->at() = -1.1167592336; + pcorr->set_elem({}, -1.1167592336); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); REQUIRE(approximately_equal(corr, e, 1E-6)); } @@ -57,7 +57,7 @@ TEMPLATE_LIST_TEST_CASE("SCFLoop", "", test_scf::float_types) { chemist::braket::BraKet H_00(psi0, H, psi0); const auto& [e, psi] = mod.template run_as>(H_00, psi0); - pcorr->at() = -2.807783957539; + pcorr->set_elem({}, -2.807783957539); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); REQUIRE(approximately_equal(corr, e, 1E-6)); } diff --git a/tests/cxx/integration_tests/matrix_builder/determinant_driver.cpp b/tests/cxx/integration_tests/matrix_builder/determinant_driver.cpp index cc9a1cc..7768d78 100644 --- a/tests/cxx/integration_tests/matrix_builder/determinant_driver.cpp +++ b/tests/cxx/integration_tests/matrix_builder/determinant_driver.cpp @@ -48,7 +48,7 @@ TEMPLATE_LIST_TEST_CASE("DeterminantDriver", "", test_scf::float_types) { erased_type copy_braket(braket); const auto& T = mod.template run_as>(copy_braket); - pcorr->at() = 0.637692; + pcorr->set_elem({}, 0.637692); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); REQUIRE(approximately_equal(corr, T, 1E-6)); } @@ -60,7 +60,7 @@ TEMPLATE_LIST_TEST_CASE("DeterminantDriver", "", test_scf::float_types) { erased_type copy_braket(braket); const auto& V = mod.template run_as>(copy_braket); - pcorr->at() = -1.96830777255516853; + pcorr->set_elem({}, -1.96830777255516853); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); REQUIRE(approximately_equal(corr, V, 1E-6)); } @@ -72,7 +72,7 @@ TEMPLATE_LIST_TEST_CASE("DeterminantDriver", "", test_scf::float_types) { erased_type copy_braket(braket); const auto& J = mod.template run_as>(copy_braket); - pcorr->at() = 0.76056339681664897; + pcorr->set_elem({}, 0.76056339681664897); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); REQUIRE(approximately_equal(corr, J, 1E-6)); } @@ -84,7 +84,7 @@ TEMPLATE_LIST_TEST_CASE("DeterminantDriver", "", test_scf::float_types) { erased_type copy_braket(braket); const auto& K = mod.template run_as>(copy_braket); - pcorr->at() = 0.76056339681664897; + pcorr->set_elem({}, 0.76056339681664897); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); REQUIRE(approximately_equal(corr, K, 1E-6)); } diff --git a/tests/cxx/integration_tests/matrix_builder/electronic_energy.cpp b/tests/cxx/integration_tests/matrix_builder/electronic_energy.cpp index 88b81ac..8f869a3 100644 --- a/tests/cxx/integration_tests/matrix_builder/electronic_energy.cpp +++ b/tests/cxx/integration_tests/matrix_builder/electronic_energy.cpp @@ -51,7 +51,7 @@ TEMPLATE_LIST_TEST_CASE("ElectronicEnergy", "", test_scf::float_types) { const auto& E_elec = mod.template run_as>(braket); - pcorr->at() = -1.90066758625308307; + pcorr->set_elem({}, -1.90066758625308307); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); REQUIRE(approximately_equal(corr, E_elec, 1E-6)); } \ No newline at end of file diff --git a/tests/cxx/integration_tests/matrix_builder/fock.cpp b/tests/cxx/integration_tests/matrix_builder/fock.cpp index b228c7d..7378ec3 100644 --- a/tests/cxx/integration_tests/matrix_builder/fock.cpp +++ b/tests/cxx/integration_tests/matrix_builder/fock.cpp @@ -44,10 +44,10 @@ TEMPLATE_LIST_TEST_CASE("Fock Matrix Builder", "", test_scf::float_types) { chemist::braket::BraKet f_mn(aos, f_e, aos); const auto& F = mod.template run_as(f_mn); - pcorr->at(0, 0) = -1.120958; - pcorr->at(0, 1) = -0.959374; - pcorr->at(1, 0) = -0.959374; - pcorr->at(1, 1) = -1.120958; + pcorr->set_elem({0, 0}, -1.120958); + pcorr->set_elem({0, 1}, -0.959374); + pcorr->set_elem({1, 0}, -0.959374); + pcorr->set_elem({1, 1}, -1.120958); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); @@ -59,10 +59,10 @@ TEMPLATE_LIST_TEST_CASE("Fock Matrix Builder", "", test_scf::float_types) { chemist::braket::BraKet f_mn(aos, f_e, aos); const auto& F = mod.template run_as(f_mn); - pcorr->at(0, 0) = -0.319459; - pcorr->at(0, 1) = -0.571781; - pcorr->at(1, 0) = -0.571781; - pcorr->at(1, 1) = -0.319459; + pcorr->set_elem({0, 0}, -0.319459); + pcorr->set_elem({0, 1}, -0.571781); + pcorr->set_elem({1, 0}, -0.571781); + pcorr->set_elem({1, 1}, -0.319459); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); diff --git a/tests/cxx/test_scf.hpp b/tests/cxx/test_scf.hpp index 22dbb07..5507f63 100644 --- a/tests/cxx/test_scf.hpp +++ b/tests/cxx/test_scf.hpp @@ -167,11 +167,11 @@ inline auto h2_mos() { allocator_type alloc(parallelzone::runtime::RuntimeView{}); tensorwrapper::shape::Smooth shape{2, 2}; tensorwrapper::layout::Physical l(shape); - auto c_buffer = alloc.allocate(l); - c_buffer->at(0, 0) = -0.565516; - c_buffer->at(0, 1) = -1.07019; - c_buffer->at(1, 0) = -0.565516; - c_buffer->at(1, 1) = 1.07019; + auto c_buffer = alloc.allocate(l); + c_buffer->set_elem({0, 0}, -0.565516); + c_buffer->set_elem({0, 1}, -1.07019); + c_buffer->set_elem({1, 0}, -0.565516); + c_buffer->set_elem({1, 1}, 1.07019); tensor_type t(shape, std::move(c_buffer)); return mos_type(h2_aos(), std::move(t)); } @@ -184,8 +184,8 @@ inline auto he_mos() { allocator_type alloc(parallelzone::runtime::RuntimeView{}); tensorwrapper::shape::Smooth shape{1, 1}; tensorwrapper::layout::Physical l(shape); - auto c_buffer = alloc.allocate(l); - c_buffer->at(0, 0) = 1.0000; + auto c_buffer = alloc.allocate(l); + c_buffer->set_elem({0, 0}, 1.0000); tensor_type t(shape, std::move(c_buffer)); return mos_type(he_aos(), std::move(t)); } @@ -198,9 +198,9 @@ inline auto h2_cmos() { allocator_type alloc(parallelzone::runtime::RuntimeView{}); tensorwrapper::shape::Smooth shape{2}; tensorwrapper::layout::Physical l(shape); - auto e_buffer = alloc.allocate(l); - e_buffer->at(0) = -1.25330893; - e_buffer->at(1) = -0.47506974; + auto e_buffer = alloc.allocate(l); + e_buffer->set_elem({0}, -1.25330893); + e_buffer->set_elem({1}, -0.47506974); tensor_type e(shape, std::move(e_buffer)); return cmos_type(std::move(e), h2_aos(), h2_mos().transform()); } @@ -213,8 +213,8 @@ inline auto he_cmos() { allocator_type alloc(parallelzone::runtime::RuntimeView{}); tensorwrapper::shape::Smooth shape{1}; tensorwrapper::layout::Physical l(shape); - auto e_buffer = alloc.allocate(l); - e_buffer->at(0) = -0.876036; + auto e_buffer = alloc.allocate(l); + e_buffer->set_elem({0}, -0.876036); tensor_type e(shape, std::move(e_buffer)); return cmos_type(std::move(e), he_aos(), he_mos().transform()); } diff --git a/tests/cxx/unit_tests/coulombs_law.cpp b/tests/cxx/unit_tests/coulombs_law.cpp index 9300d26..fe75251 100644 --- a/tests/cxx/unit_tests/coulombs_law.cpp +++ b/tests/cxx/unit_tests/coulombs_law.cpp @@ -42,22 +42,22 @@ TEST_CASE("CoulombsLaw") { simde::type::charges qs{q0, q1, q2}; SECTION("empty points") { - auto e = mod.run_as(empty, empty); - pcorr->at() = 0.0; + auto e = mod.run_as(empty, empty); + pcorr->set_elem({}, 0.0); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); REQUIRE(approximately_equal(corr, e, 1E-6)); } SECTION("charges w/ itself") { - auto e = mod.run_as(qs, qs); - pcorr->at() = -1.0103629710818451; + auto e = mod.run_as(qs, qs); + pcorr->set_elem({}, -1.0103629710818451); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); REQUIRE(approximately_equal(corr, e, 1E-6)); } SECTION("charges w/ empty") { - auto e = mod.run_as(qs, empty); - pcorr->at() = 0.0; + auto e = mod.run_as(qs, empty); + pcorr->set_elem({}, 0.0); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); REQUIRE(approximately_equal(corr, e, 1E-6)); } @@ -65,8 +65,8 @@ TEST_CASE("CoulombsLaw") { SECTION("charges w/ different charges") { simde::type::charges qs0{q0}; simde::type::charges qs12{q1, q2}; - auto e = mod.run_as(qs0, qs12); - pcorr->at() = -0.1443375672974065; + auto e = mod.run_as(qs0, qs12); + pcorr->set_elem({}, -0.1443375672974065); tensorwrapper::Tensor corr(shape_corr, std::move(pcorr)); REQUIRE(approximately_equal(corr, e, 1E-6)); } diff --git a/tests/cxx/unit_tests/eigen_solver/eigen_generalized.cpp b/tests/cxx/unit_tests/eigen_solver/eigen_generalized.cpp index 366e5c5..4281693 100644 --- a/tests/cxx/unit_tests/eigen_solver/eigen_generalized.cpp +++ b/tests/cxx/unit_tests/eigen_solver/eigen_generalized.cpp @@ -30,17 +30,17 @@ TEMPLATE_LIST_TEST_CASE("EigenGeneralized", "", test_scf::float_types) { tensorwrapper::allocator::Eigen alloc(mm.get_runtime()); tensorwrapper::shape::Smooth shape{2, 2}; tensorwrapper::layout::Physical l(shape); - auto A_buffer = alloc.allocate(l); - A_buffer->at(0, 0) = 1.0; - A_buffer->at(0, 1) = 2.0; - A_buffer->at(1, 0) = 2.0; - A_buffer->at(1, 1) = 3.0; - - auto B_buffer = alloc.allocate(l); - B_buffer->at(0, 0) = 1.0; - B_buffer->at(0, 1) = 0.0; - B_buffer->at(1, 0) = 0.0; - B_buffer->at(1, 1) = 1.0; + auto A_buffer = alloc.allocate(l); + A_buffer->set_elem({0, 0}, 1.0); + A_buffer->set_elem({0, 1}, 2.0); + A_buffer->set_elem({1, 0}, 2.0); + A_buffer->set_elem({1, 1}, 3.0); + + auto B_buffer = alloc.allocate(l); + B_buffer->set_elem({0, 0}, 1.0); + B_buffer->set_elem({0, 1}, 0.0); + B_buffer->set_elem({1, 0}, 0.0); + B_buffer->set_elem({1, 1}, 1.0); simde::type::tensor A(shape, std::move(A_buffer)); simde::type::tensor B(shape, std::move(B_buffer));