Csound Csound-dev Csound-tekno Search About

[Csnd] Problems with 3D array

Date2018-12-11 09:48
FromAndreas Bergsland
Subject[Csnd] Problems with 3D array

Hi

I am using a 3D array to do some ftab admin task, but I am having problems that I can’t see why occur. In this simplified example everything seems to work fine when I write to the array looping through the three dimensions, but when I loop through everything to read out the values, they don’t make sense. Am I missing something here? Or is this a bug?

Best, Andreas

 

Instr       1

ival         =             0

i3D_arr[][][]       init          3, 3, 4

indx1     =             0

while indx1 < 3 do

indx2     =             0

while indx2 < 3 do

indx3     =             0

while indx3 < 4 do

i3D_arr[indx1][indx2][indx3] = ival

print indx1, indx2, indx3, ival

ival  +=  1

indx3     +=           1

od

indx2 +=               1

od

indx1 +=               1

od

 

 

; Debugging printout

indxset = 0

printloop1:

indxlay = 0

printloop2:

indxsnd = 0

printloop3:

printf_i "i3D_arr[%i][%i][%i] = %i\n", 1, indxset, indxlay, indxsnd, i3D_arr[indxset][indxlay][indxsnd]

loop_lt  indxsnd, 1, 4, printloop3

loop_lt  indxlay, 1, 3, printloop2

loop_lt  indxset, 1, 3, printloop1

 

endin

 

-- 

Andreas Bergsland

 

Associate professor - førsteamanuensis

Study Programme Leader - studieprogramleder

Music Technology Programme - Musikkteknologiseksjonen

Department of Music - Institutt for musikk

Olavskvartalet

NTNU (Norwegian University of Science and Technology)

7491 Trondheim, NORWAY

 

Visiting address/besøksadresse: Fjordgt.1 (3.etg.)

e-mail: andreas.bergsland@ntnu.no

Office phone (Skype for business):7359 0096

Mobil: 4566 3316

http://folk.ntnu.no/andbe

https://www.vibra.no/

https://www.ntnu.edu/artec


Date2018-12-25 16:06
FromSteven Yi
SubjectRe: [Csnd] Problems with 3D array
Hi Andreas,

I ran this and got some odd values. Looks like a bug to me, could you
file an issue in the Csound github tracker with this code example?

All best,
Steven

On Tue, Dec 11, 2018 at 4:48 AM Andreas Bergsland
 wrote:
>
> Hi
>
> I am using a 3D array to do some ftab admin task, but I am having problems that I can’t see why occur. In this simplified example everything seems to work fine when I write to the array looping through the three dimensions, but when I loop through everything to read out the values, they don’t make sense. Am I missing something here? Or is this a bug?
>
> Best, Andreas
>
>
>
> Instr       1
>
> ival         =             0
>
> i3D_arr[][][]       init          3, 3, 4
>
> indx1     =             0
>
> while indx1 < 3 do
>
> indx2     =             0
>
> while indx2 < 3 do
>
> indx3     =             0
>
> while indx3 < 4 do
>
> i3D_arr[indx1][indx2][indx3] = ival
>
> print indx1, indx2, indx3, ival
>
> ival  +=  1
>
> indx3     +=           1
>
> od
>
> indx2 +=               1
>
> od
>
> indx1 +=               1
>
> od
>
>
>
>
>
> ; Debugging printout
>
> indxset = 0
>
> printloop1:
>
> indxlay = 0
>
> printloop2:
>
> indxsnd = 0
>
> printloop3:
>
> printf_i "i3D_arr[%i][%i][%i] = %i\n", 1, indxset, indxlay, indxsnd, i3D_arr[indxset][indxlay][indxsnd]
>
> loop_lt  indxsnd, 1, 4, printloop3
>
> loop_lt  indxlay, 1, 3, printloop2
>
> loop_lt  indxset, 1, 3, printloop1
>
>
>
> endin
>
>
>
> --
>
> Andreas Bergsland
>
>
>
> Associate professor - førsteamanuensis
>
> Study Programme Leader - studieprogramleder
>
> Music Technology Programme - Musikkteknologiseksjonen
>
> Department of Music - Institutt for musikk
>
> Olavskvartalet
>
> NTNU (Norwegian University of Science and Technology)
>
> 7491 Trondheim, NORWAY
>
>
>
> Visiting address/besøksadresse: Fjordgt.1 (3.etg.)
>
> e-mail: andreas.bergsland@ntnu.no
>
> Office phone (Skype for business):7359 0096
>
> Mobil: 4566 3316
>
> http://folk.ntnu.no/andbe
>
> https://www.vibra.no/
>
> https://www.ntnu.edu/artec
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here