Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix abs function #275

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/prg_c_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ subroutine prg_build_density_T_fermi_c(ham_bml_c, rho_bml_c, threshold, kbt, ef,
type(bml_matrix_t) :: ham_bml
type(c_ptr), value :: rho_bml_c
type(bml_matrix_t) :: rho_bml
real(c_double), value :: drho
real(c_double), intent(inout) :: drho
ham_bml%ptr = ham_bml_c
rho_bml%ptr = rho_bml_c
call prg_build_density_T_fermi(ham_bml, rho_bml, threshold, kbt, ef, verbose, drho)
Expand Down
2 changes: 1 addition & 1 deletion src/prg_progress_mod.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ extern "C"
double kbt,
double ef,
int verbose,
double drho);
double *drho);

void prg_build_atomic_density(
bml_matrix_t * rhoat_bml,
Expand Down
11 changes: 6 additions & 5 deletions tests/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "bml.h"
#include "prg_progress_mod.h"
#include <stdio.h>
#include <math.h>

int
main(
Expand Down Expand Up @@ -128,7 +129,7 @@ main(
double drho;
double ef = -0.10682896819759;

prg_build_density_T_fermi(ham, rho, threshold, kbt, ef, 1, drho);
prg_build_density_T_fermi(ham, rho, threshold, kbt, ef, 1, &drho);
bml_scale(&scale_factor, rho, rho);

if (idempotency > 1.0e-5)
Expand All @@ -152,11 +153,11 @@ main(
ham =
bml_zero_matrix(matrix_type, precision, norb, norb, distrib_mode);
bml_read_bml_matrix(ham, "hamiltonian_ortho.mtx");
prg_build_density_T_fermi(ham, rho, threshold, kbt, ef, 1, drho);
prg_build_density_T_fermi(ham, rho, threshold, kbt, ef, 1, &drho);

if (abs(drho - drho_ref) > 1.0e-5)
if (fabs(drho - drho_ref) > 1.0e-5)
{
printf("Difference is too high %f %f\n", drho, drho_ref);
printf("Difference is too high %f\n", drho - drho_ref);
exit(EXIT_FAILURE);
}
}
Expand All @@ -182,7 +183,7 @@ main(

rho1 =
bml_zero_matrix(matrix_type, precision, norb, norb, distrib_mode);
prg_build_density_T_fermi(ham, rho, threshold, kbt, ef, 1, drho);
prg_build_density_T_fermi(ham, rho, threshold, kbt, ef, 1, &drho);
prg_build_density_cheb_fermi(ham, rho1, athr, threshold, ncoeffs, kbt,
mu, bndfil, 1, fermitol, 1, npts, 0,
verbose);
Expand Down