Skip to content

Commit

Permalink
c-long was changed to int64_t.
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Jan 26, 2025
1 parent d024ecb commit 942b1f5
Show file tree
Hide file tree
Showing 72 changed files with 2,599 additions and 2,369 deletions.
639 changes: 322 additions & 317 deletions c/_phono3py.cpp

Large diffs are not rendered by default.

37 changes: 19 additions & 18 deletions c/_phononcalc.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <math.h>
#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <stdint.h>

#include "phononcalc.h"

Expand All @@ -16,46 +17,46 @@ void py_get_phonons_at_gridpoints(
double unit_conversion_factor, nb::ndarray<> py_born_effective_charge,
nb::ndarray<> py_dielectric_constant, nb::ndarray<> py_reciprocal_lattice,
nb::ndarray<> py_q_direction, double nac_factor, nb::ndarray<> py_dd_q0,
nb::ndarray<> py_G_list, double lambda, long is_nac, long is_nac_q_zero,
long use_GL_NAC, const char *uplo) {
nb::ndarray<> py_G_list, double lambda, int64_t is_nac,
int64_t is_nac_q_zero, int64_t use_GL_NAC, const char *uplo) {
double(*born)[3][3];
double(*dielectric)[3];
double *q_dir;
double *freqs;
_lapack_complex_double *eigvecs;
char *phonon_done;
long *grid_points;
long(*grid_address)[3];
int64_t *grid_points;
int64_t(*grid_address)[3];
double(*QDinv)[3];
double *fc2;
double(*svecs_fc2)[3];
long(*multi_fc2)[2];
int64_t(*multi_fc2)[2];
double(*positions_fc2)[3];
double *masses_fc2;
long *p2s_fc2;
long *s2p_fc2;
int64_t *p2s_fc2;
int64_t *s2p_fc2;
double(*rec_lat)[3];
double(*dd_q0)[2];
double(*G_list)[3];
long num_patom, num_satom, num_phonons, num_grid_points, num_G_points;
int64_t num_patom, num_satom, num_phonons, num_grid_points, num_G_points;

freqs = (double *)py_frequencies.data();
eigvecs = (_lapack_complex_double *)py_eigenvectors.data();
phonon_done = (char *)py_phonon_done.data();
grid_points = (long *)py_grid_points.data();
grid_address = (long(*)[3])py_grid_address.data();
grid_points = (int64_t *)py_grid_points.data();
grid_address = (int64_t(*)[3])py_grid_address.data();
QDinv = (double(*)[3])py_QDinv.data();
fc2 = (double *)py_fc2.data();
svecs_fc2 = (double(*)[3])py_shortest_vectors_fc2.data();
multi_fc2 = (long(*)[2])py_multiplicity_fc2.data();
multi_fc2 = (int64_t(*)[2])py_multiplicity_fc2.data();
masses_fc2 = (double *)py_masses_fc2.data();
p2s_fc2 = (long *)py_p2s_map_fc2.data();
s2p_fc2 = (long *)py_s2p_map_fc2.data();
p2s_fc2 = (int64_t *)py_p2s_map_fc2.data();
s2p_fc2 = (int64_t *)py_s2p_map_fc2.data();
rec_lat = (double(*)[3])py_reciprocal_lattice.data();
num_patom = (long)py_multiplicity_fc2.shape(1);
num_satom = (long)py_multiplicity_fc2.shape(0);
num_phonons = (long)py_frequencies.shape(0);
num_grid_points = (long)py_grid_points.shape(0);
num_patom = (int64_t)py_multiplicity_fc2.shape(1);
num_satom = (int64_t)py_multiplicity_fc2.shape(0);
num_phonons = (int64_t)py_frequencies.shape(0);
num_grid_points = (int64_t)py_grid_points.shape(0);

if (is_nac) {
born = (double(*)[3][3])py_born_effective_charge.data();
Expand All @@ -78,7 +79,7 @@ void py_get_phonons_at_gridpoints(
if (use_GL_NAC) {
dd_q0 = (double(*)[2])py_dd_q0.data();
G_list = (double(*)[3])py_G_list.data();
num_G_points = (long)py_G_list.shape(0);
num_G_points = (int64_t)py_G_list.shape(0);
positions_fc2 = (double(*)[3])py_positions_fc2.data();
} else {
dd_q0 = NULL;
Expand Down
181 changes: 91 additions & 90 deletions c/_recgrid.cpp
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <stdint.h>

#include "recgrid.h"

namespace nb = nanobind;

long py_get_grid_index_from_address(nb::ndarray<> py_address,
nb::ndarray<> py_D_diag) {
long *address;
long *D_diag;
long gp;
int64_t py_get_grid_index_from_address(nb::ndarray<> py_address,
nb::ndarray<> py_D_diag) {
int64_t *address;
int64_t *D_diag;
int64_t gp;

address = (long *)py_address.data();
D_diag = (long *)py_D_diag.data();
address = (int64_t *)py_address.data();
D_diag = (int64_t *)py_D_diag.data();

gp = recgrid_get_grid_index_from_address(address, D_diag);

return gp;
}

long py_get_ir_grid_map(nb::ndarray<> py_grid_mapping_table,
nb::ndarray<> py_D_diag, nb::ndarray<> py_is_shift,
nb::ndarray<> py_rotations) {
long *D_diag;
long *is_shift;
long(*rot)[3][3];
long num_rot;
int64_t py_get_ir_grid_map(nb::ndarray<> py_grid_mapping_table,
nb::ndarray<> py_D_diag, nb::ndarray<> py_is_shift,
nb::ndarray<> py_rotations) {
int64_t *D_diag;
int64_t *is_shift;
int64_t(*rot)[3][3];
int64_t num_rot;

long *grid_mapping_table;
long num_ir;
int64_t *grid_mapping_table;
int64_t num_ir;

D_diag = (long *)py_D_diag.data();
is_shift = (long *)py_is_shift.data();
rot = (long(*)[3][3])py_rotations.data();
num_rot = (long)py_rotations.shape(0);
grid_mapping_table = (long *)py_grid_mapping_table.data();
D_diag = (int64_t *)py_D_diag.data();
is_shift = (int64_t *)py_is_shift.data();
rot = (int64_t(*)[3][3])py_rotations.data();
num_rot = (int64_t)py_rotations.shape(0);
grid_mapping_table = (int64_t *)py_grid_mapping_table.data();

num_ir = recgrid_get_ir_grid_map(grid_mapping_table, rot, num_rot, D_diag,
is_shift);
Expand All @@ -43,25 +44,25 @@ long py_get_ir_grid_map(nb::ndarray<> py_grid_mapping_table,

void py_get_gr_grid_addresses(nb::ndarray<> py_gr_grid_addresses,
nb::ndarray<> py_D_diag) {
long(*gr_grid_addresses)[3];
long *D_diag;
int64_t(*gr_grid_addresses)[3];
int64_t *D_diag;

gr_grid_addresses = (long(*)[3])py_gr_grid_addresses.data();
D_diag = (long *)py_D_diag.data();
gr_grid_addresses = (int64_t(*)[3])py_gr_grid_addresses.data();
D_diag = (int64_t *)py_D_diag.data();

recgrid_get_all_grid_addresses(gr_grid_addresses, D_diag);
}

long py_get_reciprocal_rotations(nb::ndarray<> py_rec_rotations,
nb::ndarray<> py_rotations,
long is_time_reversal) {
long(*rec_rotations)[3][3];
long(*rotations)[3][3];
long num_rot, num_rec_rot;
int64_t py_get_reciprocal_rotations(nb::ndarray<> py_rec_rotations,
nb::ndarray<> py_rotations,
int64_t is_time_reversal) {
int64_t(*rec_rotations)[3][3];
int64_t(*rotations)[3][3];
int64_t num_rot, num_rec_rot;

rec_rotations = (long(*)[3][3])py_rec_rotations.data();
rotations = (long(*)[3][3])py_rotations.data();
num_rot = (long)py_rotations.shape(0);
rec_rotations = (int64_t(*)[3][3])py_rec_rotations.data();
rotations = (int64_t(*)[3][3])py_rotations.data();
num_rot = (int64_t)py_rotations.shape(0);

num_rec_rot = recgrid_get_reciprocal_point_group(
rec_rotations, rotations, num_rot, is_time_reversal, 1);
Expand All @@ -72,17 +73,17 @@ long py_get_reciprocal_rotations(nb::ndarray<> py_rec_rotations,
bool py_transform_rotations(nb::ndarray<> py_transformed_rotations,
nb::ndarray<> py_rotations, nb::ndarray<> py_D_diag,
nb::ndarray<> py_Q) {
long(*transformed_rotations)[3][3];
long(*rotations)[3][3];
long *D_diag;
long(*Q)[3];
long num_rot, succeeded;

transformed_rotations = (long(*)[3][3])py_transformed_rotations.data();
rotations = (long(*)[3][3])py_rotations.data();
D_diag = (long *)py_D_diag.data();
Q = (long(*)[3])py_Q.data();
num_rot = (long)py_transformed_rotations.shape(0);
int64_t(*transformed_rotations)[3][3];
int64_t(*rotations)[3][3];
int64_t *D_diag;
int64_t(*Q)[3];
int64_t num_rot, succeeded;

transformed_rotations = (int64_t(*)[3][3])py_transformed_rotations.data();
rotations = (int64_t(*)[3][3])py_rotations.data();
D_diag = (int64_t *)py_D_diag.data();
Q = (int64_t(*)[3])py_Q.data();
num_rot = (int64_t)py_transformed_rotations.shape(0);

succeeded = recgrid_transform_rotations(transformed_rotations, rotations,
num_rot, D_diag, Q);
Expand All @@ -95,16 +96,16 @@ bool py_transform_rotations(nb::ndarray<> py_transformed_rotations,

bool py_get_snf3x3(nb::ndarray<> py_D_diag, nb::ndarray<> py_P,
nb::ndarray<> py_Q, nb::ndarray<> py_A) {
long *D_diag;
long(*P)[3];
long(*Q)[3];
long(*A)[3];
long succeeded;
int64_t *D_diag;
int64_t(*P)[3];
int64_t(*Q)[3];
int64_t(*A)[3];
int64_t succeeded;

D_diag = (long *)py_D_diag.data();
P = (long(*)[3])py_P.data();
Q = (long(*)[3])py_Q.data();
A = (long(*)[3])py_A.data();
D_diag = (int64_t *)py_D_diag.data();
P = (int64_t(*)[3])py_P.data();
Q = (int64_t(*)[3])py_Q.data();
A = (int64_t(*)[3])py_A.data();

succeeded = recgrid_get_snf3x3(D_diag, P, Q, A);
if (succeeded) {
Expand All @@ -114,26 +115,25 @@ bool py_get_snf3x3(nb::ndarray<> py_D_diag, nb::ndarray<> py_P,
}
}

long py_get_bz_grid_addresses(nb::ndarray<> py_bz_grid_addresses,
nb::ndarray<> py_bz_map, nb::ndarray<> py_bzg2grg,
nb::ndarray<> py_D_diag, nb::ndarray<> py_Q,
nb::ndarray<> py_PS,
nb::ndarray<> py_reciprocal_lattice, long type) {
long(*bz_grid_addresses)[3];
long *bz_map;
long *bzg2grg;
long *D_diag;
long(*Q)[3];
long *PS;
int64_t py_get_bz_grid_addresses(
nb::ndarray<> py_bz_grid_addresses, nb::ndarray<> py_bz_map,
nb::ndarray<> py_bzg2grg, nb::ndarray<> py_D_diag, nb::ndarray<> py_Q,
nb::ndarray<> py_PS, nb::ndarray<> py_reciprocal_lattice, int64_t type) {
int64_t(*bz_grid_addresses)[3];
int64_t *bz_map;
int64_t *bzg2grg;
int64_t *D_diag;
int64_t(*Q)[3];
int64_t *PS;
double(*reciprocal_lattice)[3];
long num_total_gp;

bz_grid_addresses = (long(*)[3])py_bz_grid_addresses.data();
bz_map = (long *)py_bz_map.data();
bzg2grg = (long *)py_bzg2grg.data();
D_diag = (long *)py_D_diag.data();
Q = (long(*)[3])py_Q.data();
PS = (long *)py_PS.data();
int64_t num_total_gp;

bz_grid_addresses = (int64_t(*)[3])py_bz_grid_addresses.data();
bz_map = (int64_t *)py_bz_map.data();
bzg2grg = (int64_t *)py_bzg2grg.data();
D_diag = (int64_t *)py_D_diag.data();
Q = (int64_t(*)[3])py_Q.data();
PS = (int64_t *)py_PS.data();
reciprocal_lattice = (double(*)[3])py_reciprocal_lattice.data();

num_total_gp =
Expand All @@ -143,23 +143,24 @@ long py_get_bz_grid_addresses(nb::ndarray<> py_bz_grid_addresses,
return num_total_gp;
}

long py_rotate_bz_grid_addresses(long bz_grid_index, nb::ndarray<> py_rotation,
nb::ndarray<> py_bz_grid_addresses,
nb::ndarray<> py_bz_map,
nb::ndarray<> py_D_diag, nb::ndarray<> py_PS,
long type) {
long(*bz_grid_addresses)[3];
long(*rotation)[3];
long *bz_map;
long *D_diag;
long *PS;
long ret_bz_gp;

bz_grid_addresses = (long(*)[3])py_bz_grid_addresses.data();
rotation = (long(*)[3])py_rotation.data();
bz_map = (long *)py_bz_map.data();
D_diag = (long *)py_D_diag.data();
PS = (long *)py_PS.data();
int64_t py_rotate_bz_grid_addresses(int64_t bz_grid_index,
nb::ndarray<> py_rotation,
nb::ndarray<> py_bz_grid_addresses,
nb::ndarray<> py_bz_map,
nb::ndarray<> py_D_diag,
nb::ndarray<> py_PS, int64_t type) {
int64_t(*bz_grid_addresses)[3];
int64_t(*rotation)[3];
int64_t *bz_map;
int64_t *D_diag;
int64_t *PS;
int64_t ret_bz_gp;

bz_grid_addresses = (int64_t(*)[3])py_bz_grid_addresses.data();
rotation = (int64_t(*)[3])py_rotation.data();
bz_map = (int64_t *)py_bz_map.data();
D_diag = (int64_t *)py_D_diag.data();
PS = (int64_t *)py_PS.data();

ret_bz_gp = recgrid_rotate_bz_grid_index(
bz_grid_index, rotation, bz_grid_addresses, bz_map, D_diag, PS, type);
Expand Down
Loading

0 comments on commit 942b1f5

Please sign in to comment.