Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/scf/driver/scf_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct Kernel {
auto run(const tensorwrapper::buffer::BufferBase& a, double tol) {
tensorwrapper::allocator::Eigen<FloatType> 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;
Expand Down Expand Up @@ -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("");

Expand Down
12 changes: 6 additions & 6 deletions src/scf/eigen_solver/eigen_generalized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/scf/matrix_builder/density_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,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));
}
};
Expand Down
2 changes: 1 addition & 1 deletion tests/cxx/integration_tests/coulombs_law.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ TEMPLATE_LIST_TEST_CASE("CoulombsLaw", "", test_scf::float_types) {

auto e_nuclear = mod.run_as<pt>(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));
}
4 changes: 2 additions & 2 deletions tests/cxx/integration_tests/driver/scf_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<pt>("SCF Driver", aos, h2);
Expand All @@ -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<pt>("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));
}
}
4 changes: 2 additions & 2 deletions tests/cxx/integration_tests/driver/scf_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<pt<wf_type>>(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));
}
Expand All @@ -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<pt<wf_type>>(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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ TEMPLATE_LIST_TEST_CASE("DeterminantDriver", "", test_scf::float_types) {
erased_type<wf_type> copy_braket(braket);
const auto& T = mod.template run_as<pt<wf_type>>(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));
}
Expand All @@ -60,7 +60,7 @@ TEMPLATE_LIST_TEST_CASE("DeterminantDriver", "", test_scf::float_types) {
erased_type<wf_type> copy_braket(braket);
const auto& V = mod.template run_as<pt<wf_type>>(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));
}
Expand All @@ -72,7 +72,7 @@ TEMPLATE_LIST_TEST_CASE("DeterminantDriver", "", test_scf::float_types) {
erased_type<wf_type> copy_braket(braket);
const auto& J = mod.template run_as<pt<wf_type>>(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));
}
Expand All @@ -84,7 +84,7 @@ TEMPLATE_LIST_TEST_CASE("DeterminantDriver", "", test_scf::float_types) {
erased_type<wf_type> copy_braket(braket);
const auto& K = mod.template run_as<pt<wf_type>>(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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ TEMPLATE_LIST_TEST_CASE("ElectronicEnergy", "", test_scf::float_types) {

const auto& E_elec = mod.template run_as<pt<wf_type>>(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));
}
16 changes: 8 additions & 8 deletions tests/cxx/integration_tests/matrix_builder/fock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<pt>(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));

Expand All @@ -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<pt>(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));

Expand Down
24 changes: 12 additions & 12 deletions tests/cxx/test_scf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand All @@ -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<FloatType>().transform());
}
Expand All @@ -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<FloatType>().transform());
}
Expand Down
16 changes: 8 additions & 8 deletions tests/cxx/unit_tests/coulombs_law.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,31 @@ TEST_CASE("CoulombsLaw") {
simde::type::charges qs{q0, q1, q2};

SECTION("empty points") {
auto e = mod.run_as<pt>(empty, empty);
pcorr->at() = 0.0;
auto e = mod.run_as<pt>(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<pt>(qs, qs);
pcorr->at() = -1.0103629710818451;
auto e = mod.run_as<pt>(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<pt>(qs, empty);
pcorr->at() = 0.0;
auto e = mod.run_as<pt>(qs, empty);
pcorr->set_elem({}, 0.0);
tensorwrapper::Tensor corr(shape_corr, std::move(pcorr));
REQUIRE(approximately_equal(corr, e, 1E-6));
}

SECTION("charges w/ different charges") {
simde::type::charges qs0{q0};
simde::type::charges qs12{q1, q2};
auto e = mod.run_as<pt>(qs0, qs12);
pcorr->at() = -0.1443375672974065;
auto e = mod.run_as<pt>(qs0, qs12);
pcorr->set_elem({}, -0.1443375672974065);
tensorwrapper::Tensor corr(shape_corr, std::move(pcorr));
REQUIRE(approximately_equal(corr, e, 1E-6));
}
Expand Down
22 changes: 11 additions & 11 deletions tests/cxx/unit_tests/eigen_solver/eigen_generalized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ TEMPLATE_LIST_TEST_CASE("EigenGeneralized", "", test_scf::float_types) {
tensorwrapper::allocator::Eigen<float_type> 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));
Expand Down
Loading