06-20-2024, 05:40 PM
CoPilot says it can REDim a 3 Dim array into a $ dim array and preserve the values from the original array. Here is it's suggestion.
Certainly! To redimension a 3D array to a 4D array while preserving all values in QB64pe, you can follow these steps:
I'll have to see if Gemini can do it.
Certainly! To redimension a 3D array to a 4D array while preserving all values in QB64pe, you can follow these steps:
- Let’s assume you have a 3D array called
with the shapeCode: (Select All)arr
.Code: (Select All)(n_bands, y_pixels, x_pixels)
- First, swap the
axis to the end:Code: (Select All)n_bands
Code: (Select All)DIM SHARED arr(1 TO n_bands, 1 TO y_pixels, 1 TO x_pixels)
DIM SHARED arr4d(1 TO 1, 1 TO y_pixels, 1 TO x_pixels, 1 TO n_bands)
FOR x = 1 TO x_pixels
FOR y = 1 TO y_pixels
FOR z = 1 TO n_bands
arr4d(1, y, x, z) = arr(z, y, x)
NEXT z
NEXT y
NEXT x - Now you have a 4D array
with the desired shapeCode: (Select All)arr4d
, preserving all values. ?Code: (Select All)(1, y_pixels, x_pixels, n_bands)
I'll have to see if Gemini can do it.