From e5f5231d92c301c958ae053779d3d5e1769dcf05 Mon Sep 17 00:00:00 2001 From: Atsushi Togo Date: Fri, 5 Mar 2021 08:05:38 +0900 Subject: [PATCH] Minor refactoring of C part --- c/phono3py.c | 2 +- c/triplet.c | 15 +++------------ c/triplet_kpoint.c | 16 ++++++++++++---- c/triplet_kpoint.h | 4 ++-- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/c/phono3py.c b/c/phono3py.c index 943dc3f5..4633cba3 100644 --- a/c/phono3py.c +++ b/c/phono3py.c @@ -36,12 +36,12 @@ #include "lapack_wrapper.h" #include "phonoc_array.h" +#include "bzgrid.h" #include "collision_matrix.h" #include "fc3.h" #include "interaction.h" #include "imag_self_energy_with_g.h" #include "isotope.h" -#include "bzgrid.h" #include "pp_collision.h" #include "real_self_energy.h" #include "grgrid.h" diff --git a/c/triplet.c b/c/triplet.c index 28206319..37869b28 100644 --- a/c/triplet.c +++ b/c/triplet.c @@ -34,7 +34,6 @@ /* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ -#include "bzgrid.h" #include "grgrid.h" #include "triplet.h" #include "triplet_iw.h" @@ -231,13 +230,7 @@ static long get_triplets_reciprocal_mesh_at_q(long *map_triplets, GRGCONST long (*rotations)[3][3], const long swappable) { - MatLONG *rot_real; - long i, num_ir; - - rot_real = bzg_alloc_MatLONG(num_rot); - for (i = 0; i < num_rot; i++) { - bzg_copy_matrix_l3(rot_real->mat[i], rotations[i]); - } + long num_ir; num_ir = tpk_get_ir_triplets_at_q(map_triplets, map_q, @@ -245,10 +238,8 @@ static long get_triplets_reciprocal_mesh_at_q(long *map_triplets, grid_point, mesh, is_time_reversal, - rot_real, + rotations, + num_rot, swappable); - - bzg_free_MatLONG(rot_real); - return num_ir; } diff --git a/c/triplet_kpoint.c b/c/triplet_kpoint.c index c62a4a32..270c1802 100644 --- a/c/triplet_kpoint.c +++ b/c/triplet_kpoint.c @@ -200,13 +200,20 @@ long tpk_get_ir_triplets_at_q(long *map_triplets, const long grid_point, const long mesh[3], const long is_time_reversal, - const MatLONG * rotations, + GRGCONST long (*rotations)[3][3], + const long num_rot, const long swappable) { - long num_ir; - MatLONG *rot_reciprocal; + long i, num_ir; + MatLONG *rot_real, *rot_reciprocal; + + rot_real = bzg_alloc_MatLONG(num_rot); + for (i = 0; i < num_rot; i++) { + bzg_copy_matrix_l3(rot_real->mat[i], rotations[i]); + } + rot_reciprocal = bzg_get_point_group_reciprocal(rot_real, is_time_reversal); + bzg_free_MatLONG(rot_real); - rot_reciprocal = bzg_get_point_group_reciprocal(rotations, is_time_reversal); num_ir = get_ir_triplets_at_q(map_triplets, map_q, grid_address, @@ -215,6 +222,7 @@ long tpk_get_ir_triplets_at_q(long *map_triplets, rot_reciprocal, swappable); bzg_free_MatLONG(rot_reciprocal); + return num_ir; } diff --git a/c/triplet_kpoint.h b/c/triplet_kpoint.h index 23004153..e01fc72a 100644 --- a/c/triplet_kpoint.h +++ b/c/triplet_kpoint.h @@ -37,7 +37,6 @@ #ifndef __triplet_kpoint_H__ #define __triplet_kpoint_H__ -#include "bzgrid.h" #include "grgrid.h" long tpk_get_ir_triplets_at_q(long *map_triplets, @@ -46,7 +45,8 @@ long tpk_get_ir_triplets_at_q(long *map_triplets, const long grid_point, const long mesh[3], const long is_time_reversal, - const MatLONG * rotations, + GRGCONST long (*rotations)[3][3], + const long num_rot, const long swappable); long tpk_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point,