Csound Csound-dev Csound-tekno Search About

[Cs-dev] ARRAYDAT dimensions

Date2013-07-10 20:45
FromEdward Costello
Subject[Cs-dev] ARRAYDAT dimensions
AttachmentsNone  None  None  None  

Date2013-07-10 21:30
FromSteven Yi
SubjectRe: [Cs-dev] ARRAYDAT dimensions
Hi Ed,

That's mostly right.  The int dimensions is the number of dimensions,
and the sizes are essentially an int array that marks the sizes of
each dimension.  So if you had an array of:

karray1[][][]  init 3, 4, 5

that'd have 3 dimensions, with sizes 3, 4, and 5, and you could index
into the last element using:

karray1[2][3][4]

If you wanted a 2d array with 10 rows, and 3 columns, you could do:

karray1[][] init 10, 3

which would have 2 dimensions, with sizes[0] == 10, and sizes[1] == 3.

So you can use the dimensions member of the struct to check how much
you can index into the sizes array.

Hope that helps!
steven

On Wed, Jul 10, 2013 at 3:45 PM, Edward Costello
 wrote:
> Hi,
>
> I am testing out making some opcodes using arrays and I was just wondering
> if I understand the ARRAYDAT structure correctly. Does the sizes pointer
> give the row and column dimensions? i.e. array->sizes[0] is the rows and
> array->sizes[1] the columns?
>
> If I make a score that has  kArr[][] init 10,11 in it I get 10 for both
> sizes[0] and sizes[1].
>
>
> --
> Edward Costello
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2013-07-10 22:12
FromEdward Costello
SubjectRe: [Cs-dev] ARRAYDAT dimensions
AttachmentsNone  None  None  None  

Date2013-07-11 00:36
FromSteven Yi
SubjectRe: [Cs-dev] ARRAYDAT dimensions
AttachmentsNone  None  

Hey Ed,

Thanks for reporting that. The test CSD used during development used the same sizes for the different dimensions so that issue wasn't caught. I committed a fix we the an updated test. Could you try building from git and seeing if it's working now there?

Thanks!
Steven

P.s. - I think you get the prize for the first bug reported for Csound 6.0. :)

On Jul 10, 2013 5:13 PM, "Edward Costello" <edwardcostello@gmail.com> wrote:
Yeah I thought that was ok. It seems though that both dimensions are being set to the value in the first dimension. This code for instance gives an error:


instr 1, Init

    kArr1[][] init 5,10

    kIndx = 0

    until kIndx == 10 do
        
        kArr1[4][kIndx] = kIndx

        kIndx += 1
    od
    

    turnoff
endin


-- 
Edward Costello

On Wednesday 10 July 2013 at 22:30, Steven Yi wrote:

Hi Ed,

That's mostly right. The int dimensions is the number of dimensions,
and the sizes are essentially an int array that marks the sizes of
each dimension. So if you had an array of:

karray1[][][] init 3, 4, 5

that'd have 3 dimensions, with sizes 3, 4, and 5, and you could index
into the last element using:

karray1[2][3][4]

If you wanted a 2d array with 10 rows, and 3 columns, you could do:

karray1[][] init 10, 3

which would have 2 dimensions, with sizes[0] == 10, and sizes[1] == 3.

So you can use the dimensions member of the struct to check how much
you can index into the sizes array.

Hope that helps!
steven

On Wed, Jul 10, 2013 at 3:45 PM, Edward Costello
Hi,

I am testing out making some opcodes using arrays and I was just wondering
if I understand the ARRAYDAT structure correctly. Does the sizes pointer
give the row and column dimensions? i.e. array->sizes[0] is the rows and
array->sizes[1] the columns?

If I make a score that has kArr[][] init 10,11 in it I get 10 for both
sizes[0] and sizes[1].


--
Edward Costello


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
_______________________________________________
Csound-devel mailing list

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
_______________________________________________
Csound-devel mailing list


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2013-07-11 09:35
FromEdward Costello
SubjectRe: [Cs-dev] ARRAYDAT dimensions
AttachmentsNone  None  None  None  

Date2013-07-11 09:58
FromEdward Costello
SubjectRe: [Cs-dev] ARRAYDAT dimensions
AttachmentsNone  None  None  None  

Date2013-07-11 10:26
Fromjpff@cs.bath.ac.uk
SubjectRe: [Cs-dev] ARRAYDAT dimensions
I am not sure that multidimensonal array add was implemented, although the
code implements it


> For the OENTRY of a 2D array opcode, should you be using [[k] to specify
> the argument as a 2D array?
>
>
> --
> Edward Costello
>
>
> On Thursday 11 July 2013 at 10:35, Edward Costello wrote:
>
>> Hmmm, the opcode I had written that was working doesn't work anymore
>> now, I get a :
>>
>> csound(6990) malloc: *** error for object 0x7fc5934c1020: pointer being
>> freed was not allocated
>> *** set a breakpoint in malloc_error_break to debug
>>
>>
>> Every time I use it now, that wasn't present in earlier builds. I
>> commented every line of code out from my the functions used in the
>> opcode and just left them as skeletons without any processing whatsoever
>> and I still get the same error.
>>
>> Also I tried doing this:
>>
>> instr 1, Init
>>
>>     kArr1[][] init 10, 2
>>     kArr2[][] init 10, 2
>>     kArr3[][] init 10, 2
>>
>>
>>     kArr3 = kArr2 + kArr1
>>     turnoff
>> endin
>>
>>
>> And you get the error:
>>
>> INIT ERROR in instr 1: Dimensions do not match in array arithmetic
>> #k0[] ##add.[] kArr2 kArr1
>>
>>
>> --
>> Edward Costello
>>
>>
>> On Thursday 11 July 2013 at 01:36, Steven Yi wrote:
>>
>> > Hey Ed,
>> > Thanks for reporting that. The test CSD used during development used
>> the same sizes for the different dimensions so that issue wasn't
>> caught. I committed a fix we the an updated test. Could you try
>> building from git and seeing if it's working now there?
>> > Thanks!
>> > Steven
>> > P.s. - I think you get the prize for the first bug reported for Csound
>> 6.0. :)
>> > On Jul 10, 2013 5:13 PM, "Edward Costello" > (mailto:edwardcostello@gmail.com)> wrote:
>> > > Yeah I thought that was ok. It seems though that both dimensions are
>> being set to the value in the first dimension. This code for
>> instance gives an error:
>> > >
>> > >
>> > > instr 1, Init
>> > >
>> > >     kArr1[][] init 5,10
>> > >
>> > >     kIndx = 0
>> > >
>> > >     until kIndx == 10 do
>> > >
>> > >         kArr1[4][kIndx] = kIndx
>> > >
>> > >         kIndx += 1
>> > >     od
>> > >
>> > >
>> > >     turnoff
>> > > endin
>> > >
>> > >
>> > >
>> > > --
>> > > Edward Costello
>> > >
>> > >
>> > > On Wednesday 10 July 2013 at 22:30, Steven Yi wrote:
>> > >
>> > > > Hi Ed,
>> > > >
>> > > > That's mostly right. The int dimensions is the number of
>> dimensions,
>> > > > and the sizes are essentially an int array that marks the sizes of
>> > > > each dimension. So if you had an array of:
>> > > >
>> > > > karray1[][][] init 3, 4, 5
>> > > >
>> > > > that'd have 3 dimensions, with sizes 3, 4, and 5, and you could
>> index
>> > > > into the last element using:
>> > > >
>> > > > karray1[2][3][4]
>> > > >
>> > > > If you wanted a 2d array with 10 rows, and 3 columns, you could
>> do:
>> > > >
>> > > > karray1[][] init 10, 3
>> > > >
>> > > > which would have 2 dimensions, with sizes[0] == 10, and sizes[1]
>> == 3.
>> > > >
>> > > > So you can use the dimensions member of the struct to check how
>> much
>> > > > you can index into the sizes array.
>> > > >
>> > > > Hope that helps!
>> > > > steven
>> > > >
>> > > > On Wed, Jul 10, 2013 at 3:45 PM, Edward Costello
>> > > > 
>> wrote:
>> > > > > Hi,
>> > > > >
>> > > > > I am testing out making some opcodes using arrays and I was just
>> wondering
>> > > > > if I understand the ARRAYDAT structure correctly. Does the sizes
>> pointer
>> > > > > give the row and column dimensions? i.e. array->sizes[0] is the
>> rows and
>> > > > > array->sizes[1] the columns?
>> > > > >
>> > > > > If I make a score that has kArr[][] init 10,11 in it I get 10
>> for both
>> > > > > sizes[0] and sizes[1].
>> > > > >
>> > > > >
>> > > > > --
>> > > > > Edward Costello
>> > > > >
>> > > > >
>> > > > > ------------------------------------------------------------------------------
>> > > > > See everything from the browser to the database with AppDynamics
>> > > > > Get end-to-end visibility with application monitoring from
>> AppDynamics
>> > > > > Isolate bottlenecks and diagnose root cause in seconds.
>> > > > > Start your free trial of AppDynamics Pro today!
>> > > > > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>> > > > > _______________________________________________
>> > > > > Csound-devel mailing list
>> > > > > Csound-devel@lists.sourceforge.net
>> (mailto:Csound-devel@lists.sourceforge.net)
>> > > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> > > > >
>> > > >
>> > > >
>> > > > ------------------------------------------------------------------------------
>> > > > See everything from the browser to the database with AppDynamics
>> > > > Get end-to-end visibility with application monitoring from
>> AppDynamics
>> > > > Isolate bottlenecks and diagnose root cause in seconds.
>> > > > Start your free trial of AppDynamics Pro today!
>> > > > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>> > > > _______________________________________________
>> > > > Csound-devel mailing list
>> > > > Csound-devel@lists.sourceforge.net
>> (mailto:Csound-devel@lists.sourceforge.net)
>> > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> > > >
>> > > >
>> > > >
>> > >
>> > >
>> > >
>> > > ------------------------------------------------------------------------------
>> > > See everything from the browser to the database with AppDynamics
>> > > Get end-to-end visibility with application monitoring from
>> AppDynamics
>> > > Isolate bottlenecks and diagnose root cause in seconds.
>> > > Start your free trial of AppDynamics Pro today!
>> > > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>> > > _______________________________________________
>> > > Csound-devel mailing list
>> > > Csound-devel@lists.sourceforge.net
>> (mailto:Csound-devel@lists.sourceforge.net)
>> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> > >
>> > ------------------------------------------------------------------------------
>> > See everything from the browser to the database with AppDynamics
>> > Get end-to-end visibility with application monitoring from AppDynamics
>> > Isolate bottlenecks and diagnose root cause in seconds.
>> > Start your free trial of AppDynamics Pro today!
>> > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>> >
>> > _______________________________________________
>> > Csound-devel mailing list
>> > Csound-devel@lists.sourceforge.net
>> (mailto:Csound-devel@lists.sourceforge.net)
>> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>> >
>> >
>>
>>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>



------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2013-07-11 17:11
FromSteven Yi
SubjectRe: [Cs-dev] ARRAYDAT dimensions
Hi Ed,

I think there's issues with specifying multiple dimensions.  Actually,
I think the issue is that there was at some point support for array
args of any-dimensions, but I'm now thinking that's a mistake.  I'll
post another email shortly that describes the problem.

As for array syntax, for opcodes, whether UDO or C, the syntax is now:

k[][]

for a two dimensional array.  So you'll need to use that.  (The [[k]
is only used internally within Csound itself.)

As for the malloc error, I think we'd need more information as to what
the code looked like that caused it.  Could you post some code here?

Thanks!
steven

On Thu, Jul 11, 2013 at 4:58 AM, Edward Costello
 wrote:
> For the OENTRY of a 2D array opcode, should you be using [[k] to specify the
> argument as a 2D array?
>
>
> --
> Edward Costello
>
> On Thursday 11 July 2013 at 10:35, Edward Costello wrote:
>
> Hmmm, the opcode I had written that was working doesn't work anymore now, I
> get a :
>
> csound(6990) malloc: *** error for object 0x7fc5934c1020: pointer being
> freed was not allocated
> *** set a breakpoint in malloc_error_break to debug
>
> Every time I use it now, that wasn't present in earlier builds. I commented
> every line of code out from my the functions used in the opcode and just
> left them as skeletons without any processing whatsoever and I still get the
> same error.
>
> Also I tried doing this:
>
> instr 1, Init
>
>     kArr1[][] init 10, 2
>     kArr2[][] init 10, 2
>     kArr3[][] init 10, 2
>
>
>     kArr3 = kArr2 + kArr1
>     turnoff
> endin
>
> And you get the error:
>
> INIT ERROR in instr 1: Dimensions do not match in array arithmetic
> #k0[] ##add.[] kArr2 kArr1
>
> --
> Edward Costello
>
> On Thursday 11 July 2013 at 01:36, Steven Yi wrote:
>
> Hey Ed,
>
> Thanks for reporting that. The test CSD used during development used the
> same sizes for the different dimensions so that issue wasn't caught. I
> committed a fix we the an updated test. Could you try building from git and
> seeing if it's working now there?
>
> Thanks!
> Steven
>
> P.s. - I think you get the prize for the first bug reported for Csound 6.0.
> :)
>
> On Jul 10, 2013 5:13 PM, "Edward Costello"  wrote:
>
> Yeah I thought that was ok. It seems though that both dimensions are being
> set to the value in the first dimension. This code for instance gives an
> error:
>
>
> instr 1, Init
>
>     kArr1[][] init 5,10
>
>     kIndx = 0
>
>     until kIndx == 10 do
>
>         kArr1[4][kIndx] = kIndx
>
>         kIndx += 1
>     od
>
>
>     turnoff
> endin
>
>
> --
> Edward Costello
>
> On Wednesday 10 July 2013 at 22:30, Steven Yi wrote:
>
> Hi Ed,
>
> That's mostly right. The int dimensions is the number of dimensions,
> and the sizes are essentially an int array that marks the sizes of
> each dimension. So if you had an array of:
>
> karray1[][][] init 3, 4, 5
>
> that'd have 3 dimensions, with sizes 3, 4, and 5, and you could index
> into the last element using:
>
> karray1[2][3][4]
>
> If you wanted a 2d array with 10 rows, and 3 columns, you could do:
>
> karray1[][] init 10, 3
>
> which would have 2 dimensions, with sizes[0] == 10, and sizes[1] == 3.
>
> So you can use the dimensions member of the struct to check how much
> you can index into the sizes array.
>
> Hope that helps!
> steven
>
> On Wed, Jul 10, 2013 at 3:45 PM, Edward Costello
>  wrote:
>
> Hi,
>
> I am testing out making some opcodes using arrays and I was just wondering
> if I understand the ARRAYDAT structure correctly. Does the sizes pointer
> give the row and column dimensions? i.e. array->sizes[0] is the rows and
> array->sizes[1] the columns?
>
> If I make a score that has kArr[][] init 10,11 in it I get 10 for both
> sizes[0] and sizes[1].
>
>
> --
> Edward Costello
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2013-07-11 23:17
FromEdward Costello
SubjectRe: [Cs-dev] ARRAYDAT dimensions
AttachmentsNone  None  None  None  

Date2013-07-11 23:27
FromSteven Yi
SubjectRe: [Cs-dev] ARRAYDAT dimensions
Nice, glad that's working out now.

On Thu, Jul 11, 2013 at 6:17 PM, Edward Costello
 wrote:
> Thanks Steven,
>
> I was actually using the wrong string to specify the opcode argument, my
> opcode is working fine now,
>
> --
> Edward Costello
>
> On Thursday 11 July 2013 at 17:11, Steven Yi wrote:
>
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2013-07-12 10:44
FromEdward Costello
SubjectRe: [Cs-dev] ARRAYDAT dimensions
AttachmentsNone  None  None  None  

Date2013-07-12 22:54
FromSteven Yi
SubjectRe: [Cs-dev] ARRAYDAT dimensions
Hi Ed,

You're correct that this won't work, at least with how they are currently.

There are some complications to think through here.  If we modify
array_get to have multiple entries and implement the array changes
regarding dimensions in the other email thread I wrote, we could
probably do it. But what should this do in regards to data sharing?
For example, if I do:

karr1[][] init 2, 4
... initialize the karr1

karr2[] = karr1[0]
karr3[] = karr1[1]

should karr2 and karr3's data point to the same memory as in karr1, or
be copies?  If we do shared memory, then that breaks with how csound
works for other variables, as other variables always copy by value and
do not do assignment by reference.

In C, there's a concept of pointers that makes this possible to reason
about.  For example, in:

#include 
#include 

void doSomething(int vals[]) {
  printf("vals: %d\n", vals[1]);
}

int main(int argc, char** argv) {
  int vals[2][2] = {{1,2}, {3,4}};
  printf("vals: %d\n", vals[1][1]);
  doSomething(vals[1]);
  int *vals2 = vals[0];
}

We're passing a pointer to memory to doSomething, and vals2 is
pointing to memory from vals[0].  In Csound, I'm not sure have a
corresponding concept of pointers or references unless we introduce
it, and I'm not sure that's a good idea.

On the other hand, I can see that writing code to use
multi-dimensional arrays can be sort of a drag if you have to pass it
in with an index, when you just want to work on a sub-dimension of the
array, i.e.

opcode myOp k, k[][]i
karr[][], indx xin
ival = 0
kval = 0
until (ival == 2) do
  kval += karr[indx][ival]
od
xout kval
endop


We could do sub-dimensions with copies such that:

karr2[] = karr1[0]
karr3[] = karr1[1]

have karr2 and karr3 be unique copies of values from karr1[][].

I'm not sure what's the best way forward at the moment.  If anyone has
thoughts on this please chime in.

Thanks!
steven

On Fri, Jul 12, 2013 at 5:44 AM, Edward Costello
 wrote:
> Hi Steven,
>
> Just one more thing, on arrays as they relate to writing opcodes, am I right
> in thinking that if you have a 2D array, and you pass it to an opcode that
> accepts a 1D array using a subscript that it isn't equivalent to passing a
> vector in? For example:
>
>
>     iRows = 10
>     iColumns = 10
>     kArr[][] init iRows,iColumns
>
>     myGreat1DArrayOpcode kArr[0]
>
> It looks like kArr[0] is treated like the first element of the matrix and
> not the beginning of a row. It would be great if something like kArr[0] gave
> you a 'view' of the 2D array that had 1D opcodes treat each row like a 1D
> array.
>
>
> --
> Edward Costello
>
> On Thursday 11 July 2013 at 23:27, Steven Yi wrote:
>
> Nice, glad that's working out now.
>
> On Thu, Jul 11, 2013 at 6:17 PM, Edward Costello
>  wrote:
>
> Thanks Steven,
>
> I was actually using the wrong string to specify the opcode argument, my
> opcode is working fine now,
>
> --
> Edward Costello
>
> On Thursday 11 July 2013 at 17:11, Steven Yi wrote:
>
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2013-07-13 21:46
FromAndres Cabrera
SubjectRe: [Cs-dev] ARRAYDAT dimensions
AttachmentsNone  None  
Hi Steven,

I think you are right that it's not often that many dimensions are needed, but I wonder if it might be possible to leave both. Maybe you want some opcodes that take particular dimensions, but others might be able to accept any numbers of dimensions.

I'm also thinking how this can be documented clearly in the manual. Opcode writers would need to have a clear and consistent way of specifying the valid array dimensions.

Cheers,
Andrés


On Fri, Jul 12, 2013 at 2:54 PM, Steven Yi <stevenyi@gmail.com> wrote:
Hi Ed,

You're correct that this won't work, at least with how they are currently.

There are some complications to think through here.  If we modify
array_get to have multiple entries and implement the array changes
regarding dimensions in the other email thread I wrote, we could
probably do it. But what should this do in regards to data sharing?
For example, if I do:

karr1[][] init 2, 4
... initialize the karr1

karr2[] = karr1[0]
karr3[] = karr1[1]

should karr2 and karr3's data point to the same memory as in karr1, or
be copies?  If we do shared memory, then that breaks with how csound
works for other variables, as other variables always copy by value and
do not do assignment by reference.

In C, there's a concept of pointers that makes this possible to reason
about.  For example, in:

#include <stdlib.h>
#include <stdio.h>

void doSomething(int vals[]) {
  printf("vals: %d\n", vals[1]);
}

int main(int argc, char** argv) {
  int vals[2][2] = {{1,2}, {3,4}};
  printf("vals: %d\n", vals[1][1]);
  doSomething(vals[1]);
  int *vals2 = vals[0];
}

We're passing a pointer to memory to doSomething, and vals2 is
pointing to memory from vals[0].  In Csound, I'm not sure have a
corresponding concept of pointers or references unless we introduce
it, and I'm not sure that's a good idea.

On the other hand, I can see that writing code to use
multi-dimensional arrays can be sort of a drag if you have to pass it
in with an index, when you just want to work on a sub-dimension of the
array, i.e.

opcode myOp k, k[][]i
karr[][], indx xin
ival = 0
kval = 0
until (ival == 2) do
  kval += karr[indx][ival]
od
xout kval
endop


We could do sub-dimensions with copies such that:

karr2[] = karr1[0]
karr3[] = karr1[1]

have karr2 and karr3 be unique copies of values from karr1[][].

I'm not sure what's the best way forward at the moment.  If anyone has
thoughts on this please chime in.

Thanks!
steven

On Fri, Jul 12, 2013 at 5:44 AM, Edward Costello
<edwardcostello@gmail.com> wrote:
> Hi Steven,
>
> Just one more thing, on arrays as they relate to writing opcodes, am I right
> in thinking that if you have a 2D array, and you pass it to an opcode that
> accepts a 1D array using a subscript that it isn't equivalent to passing a
> vector in? For example:
>
>
>     iRows = 10
>     iColumns = 10
>     kArr[][] init iRows,iColumns
>
>     myGreat1DArrayOpcode kArr[0]
>
> It looks like kArr[0] is treated like the first element of the matrix and
> not the beginning of a row. It would be great if something like kArr[0] gave
> you a 'view' of the 2D array that had 1D opcodes treat each row like a 1D
> array.
>
>
> --
> Edward Costello
>
> On Thursday 11 July 2013 at 23:27, Steven Yi wrote:
>
> Nice, glad that's working out now.
>
> On Thu, Jul 11, 2013 at 6:17 PM, Edward Costello
> <edwardcostello@gmail.com> wrote:
>
> Thanks Steven,
>
> I was actually using the wrong string to specify the opcode argument, my
> opcode is working fine now,
>
> --
> Edward Costello
>
> On Thursday 11 July 2013 at 17:11, Steven Yi wrote:
>
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel