From f3d6bb8c8373e47dc7f79067d36d11c8247cb177 Mon Sep 17 00:00:00 2001 From: Giovanni La Mura <giovanni.lamura@inaf.it> Date: Tue, 18 Mar 2025 18:14:37 +0100 Subject: [PATCH] Fix wrong definition of VINTS pointer matrix in ParticleDescriptorSphere --- src/libnptm/Commons.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libnptm/Commons.cpp b/src/libnptm/Commons.cpp index 4a29057c..29bf18b6 100644 --- a/src/libnptm/Commons.cpp +++ b/src/libnptm/Commons.cpp @@ -1222,8 +1222,8 @@ ParticleDescriptorInclusion::ParticleDescriptorInclusion(const mixMPI *mpidata) // >>> ParticleDescriptorSphere class implementation. <<< // ParticleDescriptorSphere::ParticleDescriptorSphere(GeometryConfiguration *gconf, ScattererConfiguration *sconf) : ParticleDescriptor(gconf, sconf) { _class_type = SPHERE_TYPE; - vec_sas = new dcomplex[4 * (_nsph + 1)](); - vec_vints = new dcomplex[16 * (_nsph + 1)](); + vec_sas = new dcomplex[4 * _nsph](); + vec_vints = new dcomplex[16 * _nsph](); fsas = new dcomplex[_nsph]; sscs = new double[_nsph](); @@ -1236,7 +1236,7 @@ ParticleDescriptorSphere::ParticleDescriptorSphere(GeometryConfiguration *gconf, sas = new dcomplex**[_nsph]; vints = new dcomplex*[_nsph]; for (int vi = 0; vi < _nsph; vi++) { - vints[vi] = vec_vints + (16 * _nsph); + vints[vi] = vec_vints + (16 * vi); sas[vi] = new dcomplex*[2]; sas[vi][0] = vec_sas + (4 * vi); sas[vi][1] = vec_sas + (4 * vi) + 2; @@ -1249,6 +1249,14 @@ ParticleDescriptorSphere::ParticleDescriptorSphere(const ParticleDescriptorSpher for (int vsi = 0; vsi < 4 * _nsph; vsi++) vec_sas[vsi] = rhs.vec_sas[vsi]; vec_vints = new dcomplex[16 * _nsph]; for (int vvi = 0; vvi < 16 * _nsph; vvi++) vec_vints[vvi] = rhs.vec_vints[vvi]; + sas = new dcomplex**[_nsph]; + vints = new dcomplex*[_nsph]; + for (int vi = 0; vi < _nsph; vi++) { + vints[vi] = vec_vints + (16 * vi); + sas[vi] = new dcomplex*[2]; + sas[vi][0] = vec_sas + (4 * vi); + sas[vi][1] = vec_sas + (4 * vi) + 2; + } fsas = new dcomplex[_nsph]; sscs = new double[_nsph]; @@ -1268,14 +1276,6 @@ ParticleDescriptorSphere::ParticleDescriptorSphere(const ParticleDescriptorSpher sqabs[gi] = rhs.sqabs[gi]; gcsv[gi] = rhs.gcsv[gi]; } - sas = new dcomplex**[_nsph]; - vints = new dcomplex*[_nsph]; - for (int vi = 0; vi < nsph; vi++) { - vints[vi] = vec_vints + (16 * nsph); - sas[vi] = new dcomplex*[2]; - sas[vi][0] = vec_sas + (4 * vi); - sas[vi][1] = vec_sas + (4 * vi) + 2; - } } #ifdef MPI_VERSION @@ -1305,7 +1305,7 @@ ParticleDescriptorSphere::ParticleDescriptorSphere(const mixMPI *mpidata) : Part sas = new dcomplex**[_nsph]; vints = new dcomplex*[_nsph]; for (int vi = 0; vi < nsph; vi++) { - vints[vi] = vec_vints + (16 * nsph); + vints[vi] = vec_vints + (16 * vi); sas[vi] = new dcomplex*[2]; sas[vi][0] = vec_sas + (4 * vi); sas[vi][1] = vec_sas + (4 * vi) + 2; -- GitLab