commit c4ae089becb0de2cd079012dded315775c79f589
parent 9944f8cb2ed045e8a5d4f68cae978269516e08fd
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 25 Jul 2022 17:31:14 +0200
Fix the partition_get_voxel function
Diffstat:
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/rnatm_voxel_partition.c b/src/rnatm_voxel_partition.c
@@ -39,9 +39,9 @@ struct partition {
struct list_node node;
size_t id; /* Unique identifier of the partition */
- /* Offset toward the voxels of a quadrature point in a spectral band. The
- * first dimension corresponds to the spectral bands and the second dimension
- * to the quadrature points in the spectral band */
+ /* Offset in #float toward the voxels of a quadrature point in a spectral
+ * band. The first dimension corresponds to the spectral bands and the second
+ * dimension to the quadrature points in the spectral band */
struct darray_size_t_list cluster_offsets;
/* List of voxels. Use the LUT cluster_offsets to retrieve the list of voxels
@@ -107,6 +107,7 @@ setup_partition_clusters
{
size_t nclusters = 0;
size_t iband = 0;
+ size_t cluster_nfloats = 0;
res_T res = RES_OK;
ASSERT(partition && args);
@@ -119,6 +120,7 @@ setup_partition_clusters
* args->partition_definition;
partition->cluster_size = ALIGN_SIZE
(partition->cluster_nvoxels * NFLOATS_PER_VOXEL * sizeof(float), 64u);
+ cluster_nfloats = partition->cluster_size / sizeof(float);
/* Allocate the list of per band cluster offsets */
res = darray_size_t_list_resize(&partition->cluster_offsets, args->nbands);
@@ -136,8 +138,7 @@ setup_partition_clusters
/* Setup the cluster offsets for the quadrature points of the band */
FOR_EACH(iquad_pt, 0, nquad_pts) {
- darray_size_t_data_get(offsets)[iquad_pt] =
- nclusters * partition->cluster_size;
+ darray_size_t_data_get(offsets)[iquad_pt] = nclusters * cluster_nfloats;
nclusters += 1;
}
}
@@ -281,7 +282,7 @@ partition_get_voxel
ASSERT(iquad_pt < darray_size_t_size_get(band_offsets));
offset = darray_size_t_cdata_get(band_offsets)[iquad_pt];
- return part->voxels + offset + ivoxel;
+ return part->voxels + offset + (ivoxel*NFLOATS_PER_VOXEL);
}
void