Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Value notation for multi-dimensional arrays

Value notation for multi-dimensional arrays 16 Jun 2004 14:32 #6689

Hi,

I would like to come back to an issue that we have touched some time
ago, but never fully settled.

The question is, how values for multi-dimensional arrays should be
written. So for example, should it be:

var integer arr[2][3] := { {1,2,3}, {1,2,3} };

or

var integer arr[2][3] := { {1,2}, {1,2}, {1,2} };

Related to this is the question how array slices should be treated.
Should it be allowed to write:

var integer arr1[3] := arr[0];

or

var integer arr1[2] := arr[0];

Or should these slices be completly disallowed?

The current standard is not explicit in this regards but contains an
example (clause 6.5, example 3) which seems to point at the second
alternative:

var integer MyArray4[1 .. 5][2 .. 3 ];
MyArray4:= {{1, 2, 3, 4, 5}, {11, 12, 13, 14, 15}} ;

Unfortunately, this is exactly contrary to how C does things, and, at
least for me, is more un-intuitive. But that is a matter of taste, I guess.

So, what should it be?

BR

Stephan
--

Stephan Tobies Sr. Research Engineer, Nokia Research Center
~ Mobile Networks Lab, Protocol Engineering Group
E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 01:33 #6692

In a message dated Jun/16/2004 9:32:39 AM Eastern Standard Time, Stephan Tobies
<This email address is being protected from spambots. You need JavaScript enabled to view it.> writes:

>Hi,
>

Hi Stephan,

I had addressed this issue about 2 years ago. Whether multi-dimensional arrays
should be treated in a row-major or column-major
fashion. The conclusion, if I recall correctly is that it does
not matter, but seeing your questions, leads me to conclude that
it does matter.

With respect to how multi-dimensional arrays are stored internally
has always remained an _implementation dependent_ issue.


Colin, Jens, do you remember what the exact details of this issue
wereÉ

Regards,


Claude.

>I would like to come back to an issue that we have touched some time
>ago, but never fully settled.
>
>The question is, how values for multi-dimensional arrays should be
>written. So for example, should it be:
>
>var integer arr[2][3] := { {1,2,3}, {1,2,3} };
>
>or
>
>var integer arr[2][3] := { {1,2}, {1,2}, {1,2} };
>
>Related to this is the question how array slices should be treated.
>Should it be allowed to write:
>
>var integer arr1[3] := arr[0];
>
>or
>
>var integer arr1[2] := arr[0];
>
>Or should these slices be completly disallowed?
>
>The current standard is not explicit in this regards but contains an
>example (clause 6.5, example 3) which seems to point at the second
>alternative:
>
>var integer MyArray4[1 .. 5][2 .. 3 ];
>MyArray4:= {{1, 2, 3, 4, 5}, {11, 12, 13, 14, 15}} ;
>

This points to a row-major representation if I am not mistaken.

>Unfortunately, this is exactly contrary to how C does things, and, at
>least for me, is more un-intuitive. But that is a matter of taste, I guess.
>
>So, what should it be?
>
>BR
>
>Stephan
>--
>
>Stephan Tobies Sr. Research Engineer, Nokia Research Center
>~ Mobile Networks Lab, Protocol Engineering Group
>E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
>


--
Claude Desroches email:CDesroche@aol.com
Conformance Technologies Ltd. phone: +49 30 9606 7986
Solonplatz 3/2 fax: +49 30 9606 7987
13088 Berlin mobile 0174 701 6792
Germany

Claude Desroches phone: +1 705 533 2394
685 Cedar Point Road
Penetanguishene, Ontario
L9M 1R3
Canada
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 05:29 #6695

ext Claude Desroches wrote:

>In a message dated Jun/16/2004 9:32:39 AM Eastern Standard Time, Stephan Tobies
<This email address is being protected from spambots. You need JavaScript enabled to view it.> writes:
>
>
>
>>Hi,
>>
>>
>>
>
>Hi Stephan,
>
>I had addressed this issue about 2 years ago. Whether multi-dimensional arrays
should be treated in a row-major or column-major
>fashion. The conclusion, if I recall correctly is that it does
>not matter, but seeing your questions, leads me to conclude that
>it does matter.
>
>With respect to how multi-dimensional arrays are stored internally
>has always remained an _implementation dependent_ issue.
>
>

That was the conclusion of the discussion as I had found it in the
archives: that it is a implementation dependent matter. Unfortunately,
when it comes to value notation and array slices, it is external
behaviour that is altered depending on the rows-of-columns or
columns-of-rows view. I guess we really do have to settle this issue.

BR

Stephan

--
Stephan Tobies Sr. Research Engineer, Nokia Research Center
~ Mobile Networks Lab, Protocol Engineering Group
E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
Work Phone: +49-234-9842262
Mobile: +49-163-9842405
Fax: +49-234-9843491
Address: NRC Bochum, Meesmannstr. 103, 44807 Bochum, Germany
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 05:48 #6698

In a message dated Jun/17/2004 12:29:04 AM Eastern Standard Time, Stephan Tobies
<This email address is being protected from spambots. You need JavaScript enabled to view it.> writes:


Hi Stephan,

>ext Claude Desroches wrote:
>
>>In a message dated Jun/16/2004 9:32:39 AM Eastern Standard Time, Stephan
Tobies <This email address is being protected from spambots. You need JavaScript enabled to view it.> writes:
>>
>>
>>
>>>Hi,
>>>
>>>
>>>
>>
>>Hi Stephan,
>>
>>I had addressed this issue about 2 years ago. Whether multi-dimensional
arrays should be treated in a row-major or column-major
>>fashion. The conclusion, if I recall correctly is that it does
>>not matter, but seeing your questions, leads me to conclude that
>>it does matter.
>>
>>With respect to how multi-dimensional arrays are stored internally
>>has always remained an _implementation dependent_ issue.
>>
>>
>
>That was the conclusion of the discussion as I had found it in the
>archives: that it is a implementation dependent matter. Unfortunately,
>when it comes to value notation and array slices, it is external
>behaviour that is altered depending on the rows-of-columns or
>columns-of-rows view. I guess we really do have to settle this issue.
>

I feel better already reading your comment. Somehow, I felt that the
issue had not been addressed completely. Row major or column major
array initialization looks different from a notational point of view,
but internally, need not. The most common approach is Row major.
It is for the most part the more intuitive choice, however, others
might see this differently. Comments from the list would be
useful.

Will you submit a CR? :-). Actually, it might be sufficient to
re-visit the original CR I submitted way back when! :-).

Cheers,


Claude.

>BR
>
>Stephan
>
>--
>Stephan Tobies Sr. Research Engineer, Nokia Research Center
>~ Mobile Networks Lab, Protocol Engineering Group
>E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
>Work Phone: +49-234-9842262
>Mobile: +49-163-9842405
>Fax: +49-234-9843491
>Address: NRC Bochum, Meesmannstr. 103, 44807 Bochum, Germany
>


--
Claude Desroches email:CDesroche@aol.com
Conformance Technologies Ltd. phone: +49 30 9606 7986
Solonplatz 3/2 fax: +49 30 9606 7987
13088 Berlin mobile 0174 701 6792
Germany

Claude Desroches phone: +1 705 533 2394
685 Cedar Point Road
Penetanguishene, Ontario
L9M 1R3
Canada
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 07:21 #6701

Hi Claude,

In my opinion it should be C-style as Stephan has pointed out as the most
intuitive to the user. It would be otherwise difficult to explain to the
users why TTCN-3 is doing things in its own non-conventional way that is
different from C, C++, Java and I guess many other commonly used languages
and what is the actual reason for doing so.

Best regards,
Alexey Mednonogov

Software Engineer
OpenTTCN Oy
www.openttcn.com

Claude Desroches wrote:

>I feel better already reading your comment. Somehow, I felt that the
>issue had not been addressed completely. Row major or column major
>array initialization looks different from a notational point of view,
>but internally, need not. The most common approach is Row major.
>It is for the most part the more intuitive choice, however, others
>might see this differently. Comments from the list would be
>useful.
>
>
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 07:47 #6702

  • Antti Hyrkk
  • Antti Hyrkk's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 43
  • Karma: 0
>I feel better already reading your comment. Somehow, I felt that the
>issue had not been addressed completely. Row major or column major
>array initialization looks different from a notational point of view,
>but internally, need not. The most common approach is Row major.
>It is for the most part the more intuitive choice, however, others
>might see this differently. Comments from the list would be
>useful.

If you are familiar with Matlab and matrices, then

var integer arr[2][3] := { {1,2}, {3,4}, {5,6} };

would be the intuitive way to do it. Arr would be interpreted as a matrix
containing three column vectors, each of them being vectors of two
dimensional space.

0. 1. 2.
.
0. |1 3 5
1. |2 4 6

For those who are interested, the below link contains a short example how
matrices are handled in Matlab:


www.ee.columbia.edu/~marios/matlab/Matri...ing%20in%20Matlab.pd
f

The Matlab notation allows to list the rows and columns, or to use ranges,
to specify what is being operated:

arr[1][0,2]

would mean row 1, columns 0 and 1, which
is the matrix:

2 6

so

arr[1][0,2] := {8, 9}

would result in

0. 1. 2.
.
0. |1 3 5
1. |8 4 9

(The above notation was not really matlab notation, but TTCN-3 adapted
matlab
notation. In matlab the proper syntax would be arr([2],[1,3]) (indexing
starts
at 1, not at 0))

It is also possible to use linear indexing with matrices. In that case
the matrix is interpreted as a single column vector.
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 08:18 #6705

ext Antti Hyrkkanen wrote:

>>I feel better already reading your comment. Somehow, I felt that the
>>issue had not been addressed completely. Row major or column major
>>array initialization looks different from a notational point of view,
>>but internally, need not. The most common approach is Row major.
>>It is for the most part the more intuitive choice, however, others
>>might see this differently. Comments from the list would be
>>useful.
>>
>>
>
>If you are familiar with Matlab and matrices, then
>
>var integer arr[2][3] := { {1,2}, {3,4}, {5,6} };
>
>would be the intuitive way to do it. Arr would be interpreted as a matrix
>containing three column vectors, each of them being vectors of two
>dimensional space.
>
> 0. 1. 2.
> .
>0. |1 3 5
>1. |2 4 6
>
>

In a mathematical setting, where the matrix is seens as a row of column
vectors, this does make perfect sense.

In a programming language setting, I personally would prefer the
intuition that a two-dimensional array is a colum of rows. This is how
C, C++, and Java treat things, and I think that this is what we should
use for TTCN-3.

BR

Stephan

--
Stephan Tobies Sr. Research Engineer, Nokia Research Center
~ Mobile Networks Lab, Protocol Engineering Group
E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
Work Phone: +49-234-9842262
Mobile: +49-163-9842405
Fax: +49-234-9843491
Address: NRC Bochum, Meesmannstr. 103, 44807 Bochum, Germany
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 08:31 #6706

Hi,


I agree that initialization of variable arrays should be clarified in more
detail. But except of this row~ or column major implementation of arrays is
really a tool issue.

In the case of
var integer MyArray [5][2] := {{1,2,3,4,5},{11,12,13,14,15}}

it is unimportant if the matrix looks like:

0 1 2 3 4
0 1 2 3 4 5
1 11 12 13 14 15


or like this:

0 1
0 1 11
1 2 12
2 3 13
3 4 14
4 5 15

In both cases MyArray [1][1] will access the element with the value 12 and
MyArray [2][1] the element with the value 13.

What should be avoided is:

0 1 2 3 4
0 1 3 5 12 14
1 2 4 11 13 15

To my opinion the syntax of the declaration in the above example implicitly
excludes this (but an example of a [2][2] array would not) but this point could
be made explicit in the standard.

Gyorgy

>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
> [This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of Antti Hyrkkanen
> Sent: Thursday, June 17, 2004 9:48 AM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Value notation for multi-dimensional arrays
>
>
> >I feel better already reading your comment. Somehow, I felt that the
> >issue had not been addressed completely. Row major or column major
> >array initialization looks different from a notational point of view,
> >but internally, need not. The most common approach is Row major.
> >It is for the most part the more intuitive choice, however, others
> >might see this differently. Comments from the list would be
> >useful.
>
> If you are familiar with Matlab and matrices, then
>
> var integer arr[2][3] := { {1,2}, {3,4}, {5,6} };
>
> would be the intuitive way to do it. Arr would be interpreted
> as a matrix
> containing three column vectors, each of them being vectors of two
> dimensional space.
>
> 0. 1. 2.
> .
> 0. |1 3 5
> 1. |2 4 6
>
> For those who are interested, the below link contains a short
> example how
> matrices are handled in Matlab:
>
>
> www.ee.columbia.edu/~marios/matlab/Matrix%20Indexing%20
> in%20Matlab.pd
> f
>
> The Matlab notation allows to list the rows and columns, or
> to use ranges,
> to specify what is being operated:
>
> arr[1][0,2]
>
> would mean row 1, columns 0 and 1, which
> is the matrix:
>
> 2 6
>
> so
>
> arr[1][0,2] := {8, 9}
>
> would result in
>
> 0. 1. 2.
> .
> 0. |1 3 5
> 1. |8 4 9
>
> (The above notation was not really matlab notation, but TTCN-3 adapted
> matlab
> notation. In matlab the proper syntax would be arr([2],[1,3])
> (indexing
> starts
> at 1, not at 0))
>
> It is also possible to use linear indexing with matrices. In that case
> the matrix is interpreted as a single column vector.
>
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 08:38 #6707

Hi,

It is of course only my personal opinion, but I feel that there are
more users of C, C++ and Java than there are Mathlab users (although
I have been once one of them, true). After all, TTCN-3 is more about
developing test scripts than about doing maths. Moreover, it seems
that Mathlab is a proprietary language of Mathworks (is it?), while
there exist internationally recognized standards on C and C++ to my
knowlegde.

Best regards,
Alexey Mednonogov

Software Engineer
OpenTTCN Oy
www.openttcn.com

Antti Hyrkkanen wrote:

>If you are familiar with Matlab and matrices, then
>
>var integer arr[2][3] := { {1,2}, {3,4}, {5,6} };
>
>would be the intuitive way to do it. Arr would be interpreted as a matrix
>containing three column vectors, each of them being vectors of two
>dimensional space.
>
><...>
>
>(The above notation was not really matlab notation, but TTCN-3 adapted
>matlab notation. In matlab the proper syntax would be arr([2],[1,3])
>
>(indexing starts at 1, not at 0))
>
>It is also possible to use linear indexing with matrices. In that case
>the matrix is interpreted as a single column vector.
>
>
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 09:14 #6708

  • Antti Hyrkk
  • Antti Hyrkk's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 43
  • Karma: 0
Hi

I think you are correct that the M-language of Matlab is a
proprietary language. How about Fortran then? :). Anyway,
I agree that the arrays should work in TTCN-3 as they work
in widely used languages like C, C++ and Java. There is probably
not many telecom systems or other software written originally
in M-language :). I felt that it was counter intuitive to write

>var integer arr[2][3] := { {1,2}, {3,4}, {5,6} };

when I used arrays the first time in TTCN-3.


Original Message
From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
[This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of ext Alexey Mednonogov
Sent: Thursday, June 17, 2004 10:38 AM
To: This email address is being protected from spambots. You need JavaScript enabled to view it.
Subject: Re: Value notation for multi-dimensional arrays


Hi,

It is of course only my personal opinion, but I feel that there are
more users of C, C++ and Java than there are Mathlab users (although
I have been once one of them, true). After all, TTCN-3 is more about
developing test scripts than about doing maths. Moreover, it seems
that Mathlab is a proprietary language of Mathworks (is it?), while
there exist internationally recognized standards on C and C++ to my
knowlegde.

Best regards,
Alexey Mednonogov

Software Engineer
OpenTTCN Oy
www.openttcn.com

Antti Hyrkkanen wrote:

>If you are familiar with Matlab and matrices, then
>
>var integer arr[2][3] := { {1,2}, {3,4}, {5,6} };
>
>would be the intuitive way to do it. Arr would be interpreted as a matrix
>containing three column vectors, each of them being vectors of two
>dimensional space.
>
><...>
>
>(The above notation was not really matlab notation, but TTCN-3 adapted
>matlab notation. In matlab the proper syntax would be arr([2],[1,3])
>
>(indexing starts at 1, not at 0))
>
>It is also possible to use linear indexing with matrices. In that case
>the matrix is interpreted as a single column vector.
>
>
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 09:18 #6709

ext György Réthy (IJ/ETH) wrote:

>Hi,
>
>
>I agree that initialization of variable arrays should be clarified in more detail. But except of this row~ or column major implementation of arrays is really a tool issue.
>
>

Agreed.


>In the case of
>var integer MyArray [5][2] := {{1,2,3,4,5},{11,12,13,14,15}}
>
>it is unimportant if the matrix looks like:
>
> 0 1 2 3 4
>0 1 2 3 4 5
>1 11 12 13 14 15
>
>
>or like this:
>
> 0 1
>0 1 11
>1 2 12
>2 3 13
>3 4 14
>4 5 15
>
>

But it is important if the initialisation should be written like you
have done it, of like this:

var integer MyArray [5][2] := {{1,11}, {2,12}, {3,13}, {4,14}, {5,15}};

We have already seen that there are cases for both solutions, but for me the 'do it like C and Java' approach makes most sense. If nobody comes up with a convincing argument for the Matlab way, then I will write a CR makes this explicit.

What about array slices - should they be allowed:

var integer MyArray2[2] := MyArray[3]; // after this, MyArray2 is {4,14}

BR

Stephan

--
Stephan Tobies Sr. Research Engineer, Nokia Research Center
~ Mobile Networks Lab, Protocol Engineering Group
E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
Work Phone: +49-234-9842262
Mobile: +49-163-9842405
Fax: +49-234-9843491
Address: NRC Bochum, Meesmannstr. 103, 44807 Bochum, Germany
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 09:57 #6710

  • Antti Hyrkk
  • Antti Hyrkk's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 43
  • Karma: 0
>> ext György Réthy (IJ/ETH) wrote:
>> In the case of
>> var integer MyArray [5][2] := {{1,2,3,4,5},{11,12,13,14,15}}
>
> ext Stephan Tobies wrote:
> But it is important if the initialisation should be written like you
> have done it, of like this:
>
> var integer MyArray [5][2] := {{1,11}, {2,12}, {3,13}, {4,14}, {5,15}};
>
> We have already seen that there are cases for both solutions, but for me
> the 'do it like C and Java' approach makes most sense. If nobody comes up
> with a convincing argument for the Matlab way, then I will write a CR
> makes this explicit.
>
> What about array slices - should they be allowed:
>
> var integer MyArray2[2] := MyArray[3]; // after this, MyArray2 is {4,14}
>

I find that as the right way to initialise the multi dimensional array,
which contains five arrays, containing two elements each. Your
array slice usage looks sane with it.

If it was initialised as

var integer MyArrayB [5][2] := {{1, 2, 3, 4, 5}, {11, 12, 13, 14, 15}};

and array slices were allowed, then

// after this MyArray5 is {11, 12, 13, 14, 15}
var integer MyArray5[5] := MyArrayB[1];

or

// after this MyArray5 is {11, 12, 13, 14, 15}
var integer MyArray5[5] := MyArrayB[][1];

would be a bit odd looking, since I have to omit the first index of MyArrayB
to address the elements of the second list. If I am not allowed omit the
first
index, then I cannot address a slice/list in MyArrayB.

So the Stephan's 'C and Java' way looks like the best way to me.

BR
Antti
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 09:57 #6711

Hi,

exactly this is what I'm saying too. It shall be clarified that

var integer MyArray [5][2] := {{1,11}, {2,12}, {3,13}, {4,14}, {5,15}};

is incorrect. But not due to row~ or column major interpretation but because inner value lists shall be related to the first array dimension. Once this is clarified, row or column is unimportant from the language point of view and you can simply draw your matrix as you like.

In a more complex example
var integer MyArray [5][3][2] :=
{ { {1,2,3,4,5}, {11,12,13,14,15}, {21,22,23,24,25} },
// ^ ^ ^ ^ these inner lists shall relate to the first dimension
// ^
relates to the second dimension
^
{ {101,102,103,104,105}, {111,112,113,114,115}, {121,122,123,124,125} } };
// ^
relates to the second dimension
^
//^
relates to the third dimension
^

Gyorgy

>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
> [This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of Stephan Tobies
> Sent: Thursday, June 17, 2004 11:18 AM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Value notation for multi-dimensional arrays
>
>
> ext György Réthy (IJ/ETH) wrote:
>
> >Hi,
> >
> >
> >I agree that initialization of variable arrays should be
> clarified in more detail. But except of this row~ or column
> major implementation of arrays is really a tool issue.
> >
> >
>
> Agreed.
>
>
> >In the case of
> >var integer MyArray [5][2] := {{1,2,3,4,5},{11,12,13,14,15}}
> >
> >it is unimportant if the matrix looks like:
> >
> > 0 1 2 3 4
> >0 1 2 3 4 5
> >1 11 12 13 14 15
> >
> >
> >or like this:
> >
> > 0 1
> >0 1 11
> >1 2 12
> >2 3 13
> >3 4 14
> >4 5 15
> >
> >
>
> But it is important if the initialisation should be written like you
> have done it, of like this:
>
> var integer MyArray [5][2] := {{1,11}, {2,12}, {3,13},
> {4,14}, {5,15}};
>
> We have already seen that there are cases for both solutions,
> but for me the 'do it like C and Java' approach makes most
> sense. If nobody comes up with a convincing argument for the
> Matlab way, then I will write a CR makes this explicit.
>
> What about array slices - should they be allowed:
>
> var integer MyArray2[2] := MyArray[3]; // after this,
> MyArray2 is {4,14}
>
> BR
>
> Stephan
>
> --
> Stephan Tobies Sr. Research Engineer, Nokia Research Center
> ~ Mobile Networks Lab, Protocol Engineering Group
> E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Work Phone: +49-234-9842262
> Mobile: +49-163-9842405
> Fax: +49-234-9843491
> Address: NRC Bochum, Meesmannstr. 103, 44807 Bochum, Germany
>
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 10:42 #6712

  • Antti Hyrkk
  • Antti Hyrkk's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 43
  • Karma: 0
>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
> [This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of ext György Réthy (IJ/ETH)
> Sent: Thursday, June 17, 2004 11:58 AM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Value notation for multi-dimensional arrays
>
>
> Hi,
>
> exactly this is what I'm saying too. It shall be clarified that
>
> var integer MyArray [5][2] := {{1,11}, {2,12}, {3,13}, {4,14}, {5,15}};
>
> is incorrect. But not due to row~ or column major interpretation but
> because inner value lists shall be related to the first array dimension.
> Once this is clarified, row or column is unimportant from the language
> point of view and you can simply draw your matrix as you like

Isn't this contradictory to C and Java, if you say that the above example
is incorrect?

From K&R C Programming language page 111:

static char daytab[2][13] = {
{0, 31, 28, 31, 30, etc..},
{0, 31, 28, 31, 30, etc..}
}

I understood that Stephan meant that

> var integer MyArray [5][2] := {{1,11}, {2,12}, {3,13}, {4,14}, {5,15}};

is the right way which should be used, and

var integer MyArray [5][2] := {{...}, {...}};

is the wrong way.

BR
Antti
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 11:00 #6713

ext György Réthy (IJ/ETH) wrote:

>Hi,
>
>exactly this is what I'm saying too. It shall be clarified that
>
>var integer MyArray [5][2] := {{1,11}, {2,12}, {3,13}, {4,14}, {5,15}};
>
>is incorrect.
>

But that is the _correct_ notation for C. Quoting from K&R (German
edition, page 107):

static char daytab[2][13] = { {0, 31, 28, 31, 30, 31, 30, 31, 31, 30,
31, 30, 31}, {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} };

>But not due to row~ or column major interpretation but because inner value lists shall be related to the first array dimension. Once this is clarified, row or column is unimportant from the language point of view and you can simply draw your matrix as you like.
>
>

The row and column thing is indeed irrelvant. But we do need to fix the
order in which the dimension are interpreted. My proposal would be to
read from left to right, i.e., the left-most dimension is the outer-most
dimension of the array, and so on.

So, to illustrate this with an example:

var integer MayArr[5][3][2] :=
{ /* 5 elements in this level */
{ /* 3 on this */
{ /* 2 on this */ 1,2},
{1,2},
{1,2}
},
{
{1,2},
{1,2},
{1,2}
},
{
{1,2},
{1,2},
{1,2}
},
{
{1,2},
{1,2},
{1,2}
},
{
{1,2},
{1,2},
{1,2}
}
};

This is _not_ what you propose below, but it is the way that C and Java do things, which is why I would propose this also for TTCN-3.


>In a more complex example
>var integer MyArray [5][3][2] :=
> { { {1,2,3,4,5}, {11,12,13,14,15}, {21,22,23,24,25} },
>// ^ ^ ^ ^ these inner lists shall relate to the first dimension
>// ^
relates to the second dimension
^
> { {101,102,103,104,105}, {111,112,113,114,115}, {121,122,123,124,125} } };
>// ^
relates to the second dimension
^
>//^
relates to the third dimension
^
>
>
>
Yes, the C and Java way is to a certain extent counter-intuitive. An array definition

var integer x[2][3]

cannot be read like this

var (integer x[2])[3]

which would somehow be the natural way to read such a definition. But C and Java do things differently - and since I would expect TTCN-3 users to have more background in these languages, I guess we should not confuse them unecessarily.

BR

Stephan

--
Stephan Tobies Sr. Research Engineer, Nokia Research Center
~ Mobile Networks Lab, Protocol Engineering Group
E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
Work Phone: +49-234-9842262
Mobile: +49-163-9842405
Fax: +49-234-9843491
Address: NRC Bochum, Meesmannstr. 103, 44807 Bochum, Germany
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 11:00 #6714

ext Antti Hyrkkanen wrote:

>>
Original Message
>>From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
>>[This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of ext György Réthy (IJ/ETH)
>>Sent: Thursday, June 17, 2004 11:58 AM
>>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
>>Subject: Re: Value notation for multi-dimensional arrays
>>
>>
>>Hi,
>>
>>exactly this is what I'm saying too. It shall be clarified that
>>
>>var integer MyArray [5][2] := {{1,11}, {2,12}, {3,13}, {4,14}, {5,15}};
>>
>>is incorrect. But not due to row~ or column major interpretation but
>>because inner value lists shall be related to the first array dimension.
>>Once this is clarified, row or column is unimportant from the language
>>point of view and you can simply draw your matrix as you like
>>
>>
>
>Isn't this contradictory to C and Java, if you say that the above example
>is incorrect?
>
>>From K&R C Programming language page 111:
>
> static char daytab[2][13] = {
> {0, 31, 28, 31, 30, etc..},
> {0, 31, 28, 31, 30, etc..}
> }
>
>

You are taking the words out of my mouth :-).

>I understood that Stephan meant that
>
>
>
>>var integer MyArray [5][2] := {{1,11}, {2,12}, {3,13}, {4,14}, {5,15}};
>>
>>
>
>
>
Exactly - see my other mail.

>is the right way which should be used, and
>
> var integer MyArray [5][2] := {{...}, {...}};
>
>is the wrong way.
>
>BR
>Antti
>
>
>
BR

Stephan

--
Stephan Tobies Sr. Research Engineer, Nokia Research Center
~ Mobile Networks Lab, Protocol Engineering Group
E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
Work Phone: +49-234-9842262
Mobile: +49-163-9842405
Fax: +49-234-9843491
Address: NRC Bochum, Meesmannstr. 103, 44807 Bochum, Germany
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 11:08 #6715

Hi,

A valid point. What I meant is that once

1) dimension order at initialization and
2) relation of dimension order @ declaration to index order @ value notation are clarified

no sense to argue about rows and columns.

Regarding 2) I think all of us intiutivelly used the same order: i.e. the first index relates to the first dimension at declaration. This was not a question.

My previous example for 1) was simply following the example in the standard. It could also be given to relate the inner list to the outer dimension like:

var integer MyArray [5][3][2] :=
{ { {1,2}, {11,12}, {21,22} },
// ^---^ ^
^ these inner lists relate to the third dimension
// ^
^ relates to the second dimension
{ {101,102}, {111,112}, {121,122} },
// ^-relates to the second dimension-^

...
{ {401,402}, {411,412}, {421,422} } }
//^---relates to the first dimension----^

I agree this is better for slices. The matter here is to specify the way to do initialization. The decision may also be influenced by backward compatibility and by compatibility with record of.

Gyorgy

>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
> [This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of Antti Hyrkkanen
> Sent: Thursday, June 17, 2004 11:58 AM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Value notation for multi-dimensional arrays
>
>
> >> ext György Réthy (IJ/ETH) wrote:
> >> In the case of
> >> var integer MyArray [5][2] := {{1,2,3,4,5},{11,12,13,14,15}}
> >
> > ext Stephan Tobies wrote:
> > But it is important if the initialisation should be written like you
> > have done it, of like this:
> >
> > var integer MyArray [5][2] := {{1,11}, {2,12}, {3,13},
> {4,14}, {5,15}};
> >
> > We have already seen that there are cases for both
> solutions, but for me
> > the 'do it like C and Java' approach makes most sense. If
> nobody comes up
> > with a convincing argument for the Matlab way, then I will
> write a CR
> > makes this explicit.
> >
> > What about array slices - should they be allowed:
> >
> > var integer MyArray2[2] := MyArray[3]; // after this,
> MyArray2 is {4,14}
> >
>
> I find that as the right way to initialise the multi
> dimensional array,
> which contains five arrays, containing two elements each. Your
> array slice usage looks sane with it.
>
> If it was initialised as
>
> var integer MyArrayB [5][2] := {{1, 2, 3, 4, 5}, {11, 12,
> 13, 14, 15}};
>
> and array slices were allowed, then
>
> // after this MyArray5 is {11, 12, 13, 14, 15}
> var integer MyArray5[5] := MyArrayB[1];
>
> or
>
> // after this MyArray5 is {11, 12, 13, 14, 15}
> var integer MyArray5[5] := MyArrayB[][1];
>
> would be a bit odd looking, since I have to omit the first
> index of MyArrayB
> to address the elements of the second list. If I am not
> allowed omit the
> first
> index, then I cannot address a slice/list in MyArrayB.
>
> So the Stephan's 'C and Java' way looks like the best way to me.
>
> BR
> Antti
>
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 11:21 #6716

Hi,

OK, this is a matter of agreement. I think both ways have its pros and cons but I'm not opposing to change the standard and define that the left-most dimension relates to the outer-most value list in the value notation (simply not this is the way suggested by the standard TODAY).

Gyorgy

>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
> [This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of Stephan Tobies
> Sent: Thursday, June 17, 2004 1:00 PM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Value notation for multi-dimensional arrays
>
>
> ext György Réthy (IJ/ETH) wrote:
>
> >Hi,
> >
> >exactly this is what I'm saying too. It shall be clarified that
> >
> >var integer MyArray [5][2] := {{1,11}, {2,12}, {3,13},
> {4,14}, {5,15}};
> >
> >is incorrect.
> >
>
> But that is the _correct_ notation for C. Quoting from K&R (German
> edition, page 107):
>
> static char daytab[2][13] = { {0, 31, 28, 31, 30, 31, 30, 31, 31, 30,
> 31, 30, 31}, {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} };
>
> >But not due to row~ or column major interpretation but
> because inner value lists shall be related to the first array
> dimension. Once this is clarified, row or column is
> unimportant from the language point of view and you can
> simply draw your matrix as you like.
> >
> >
>
> The row and column thing is indeed irrelvant. But we do need
> to fix the
> order in which the dimension are interpreted. My proposal would be to
> read from left to right, i.e., the left-most dimension is the
> outer-most
> dimension of the array, and so on.
>
> So, to illustrate this with an example:
>
> var integer MayArr[5][3][2] :=
> { /* 5 elements in this level */
> { /* 3 on this */
> { /* 2 on this */ 1,2},
> {1,2},
> {1,2}
> },
> {
> {1,2},
> {1,2},
> {1,2}
> },
> {
> {1,2},
> {1,2},
> {1,2}
> },
> {
> {1,2},
> {1,2},
> {1,2}
> },
> {
> {1,2},
> {1,2},
> {1,2}
> }
> };
>
> This is _not_ what you propose below, but it is the way that
> C and Java do things, which is why I would propose this also
> for TTCN-3.
>
>
> >In a more complex example
> >var integer MyArray [5][3][2] :=
> > { { {1,2,3,4,5}, {11,12,13,14,15}, {21,22,23,24,25} },
> >// ^ ^ ^ ^ these inner lists shall
> relate to the first dimension
> >// ^
relates to the second dimension
^
> > { {101,102,103,104,105}, {111,112,113,114,115},
> {121,122,123,124,125} } };
> >// ^
relates to the second
> dimension
^
> >//^
relates to the third
> dimension
^
> >
> >
> >
> Yes, the C and Java way is to a certain extent
> counter-intuitive. An array definition
>
> var integer x[2][3]
>
> cannot be read like this
>
> var (integer x[2])[3]
>
> which would somehow be the natural way to read such a
> definition. But C and Java do things differently - and since
> I would expect TTCN-3 users to have more background in these
> languages, I guess we should not confuse them unecessarily.
>
> BR
>
> Stephan
>
> --
> Stephan Tobies Sr. Research Engineer, Nokia Research Center
> ~ Mobile Networks Lab, Protocol Engineering Group
> E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Work Phone: +49-234-9842262
> Mobile: +49-163-9842405
> Fax: +49-234-9843491
> Address: NRC Bochum, Meesmannstr. 103, 44807 Bochum, Germany
>
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 11:28 #6717

ext György Réthy (IJ/ETH) wrote:

>Hi,
>
>A valid point. What I meant is that once
>
>1) dimension order at initialization and
>2) relation of dimension order @ declaration to index order @ value notation are clarified
>
>no sense to argue about rows and columns.
>
>

Yes indeed - I consider this issue settled.

>Regarding 2) I think all of us intiutivelly used the same order: i.e. the first index relates to the first dimension at declaration. This was not a question.
>
>My previous example for 1) was simply following the example in the standard. It could also be given to relate the inner list to the outer dimension like:
>
>var integer MyArray [5][3][2] :=
> { { {1,2}, {11,12}, {21,22} },
>// ^---^ ^
^ these inner lists relate to the third dimension
>// ^
^ relates to the second dimension
> { {101,102}, {111,112}, {121,122} },
>// ^-relates to the second dimension-^
>
>...
> { {401,402}, {411,412}, {421,422} } }
>//^---relates to the first dimension----^
>
>I agree this is better for slices. The matter here is to specify the way to do initialization. The decision may also be influenced by backward compatibility and by compatibility with record of.
>
>

That is indeed an important aspect. With the 'C and Java' approach, we
would get that, if we define:

type record length (2) of integer Pair;
type record length (3) of Pair Triple;
type record length (5) of Triple Quintuple;

then

var integer x[5][3][2] := ... ;
var Quintuple y := x;

would be a valid assignment.

I can live with that. Shall I write a CR that promotes the 'C and Java'
notation + slices + this type compatibility?

BR

Stephan

--
Stephan Tobies Sr. Research Engineer, Nokia Research Center
~ Mobile Networks Lab, Protocol Engineering Group
E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
Work Phone: +49-234-9842262
Mobile: +49-163-9842405
Fax: +49-234-9843491
Address: NRC Bochum, Meesmannstr. 103, 44807 Bochum, Germany
The administrator has disabled public write access.

Value notation for multi-dimensional arrays 17 Jun 2004 12:57 #6718

Yes, I think so, you could write a CR. As I could not have found text saying that dimension order at declaretion and index order at value notation shall be the same, it would be worth to include as well.

Gyorgy
>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
> [This email address is being protected from spambots. You need JavaScript enabled to view it.]On Behalf Of Stephan Tobies
> Sent: Thursday, June 17, 2004 1:29 PM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: Value notation for multi-dimensional arrays
>
>
> ext György Réthy (IJ/ETH) wrote:
>
> >Hi,
> >
> >A valid point. What I meant is that once
> >
> >1) dimension order at initialization and
> >2) relation of dimension order @ declaration to index order
> @ value notation are clarified
> >
> >no sense to argue about rows and columns.
> >
> >
>
> Yes indeed - I consider this issue settled.
>
> >Regarding 2) I think all of us intiutivelly used the same
> order: i.e. the first index relates to the first dimension at
> declaration. This was not a question.
> >
> >My previous example for 1) was simply following the example
> in the standard. It could also be given to relate the inner
> list to the outer dimension like:
> >
> >var integer MyArray [5][3][2] :=
> > { { {1,2}, {11,12}, {21,22} },
> >// ^---^ ^
^ these inner lists relate to the third dimension
> >// ^
^ relates to the second dimension
> > { {101,102}, {111,112}, {121,122} },
> >// ^-relates to the second dimension-^
> >
> >...
> > { {401,402}, {411,412}, {421,422} } }
> >//^---relates to the first dimension----^
> >
> >I agree this is better for slices. The matter here is to
> specify the way to do initialization. The decision may also
> be influenced by backward compatibility and by compatibility
> with record of.
> >
> >
>
> That is indeed an important aspect. With the 'C and Java'
> approach, we
> would get that, if we define:
>
> type record length (2) of integer Pair;
> type record length (3) of Pair Triple;
> type record length (5) of Triple Quintuple;
>
> then
>
> var integer x[5][3][2] := ... ;
> var Quintuple y := x;
>
> would be a valid assignment.
>
> I can live with that. Shall I write a CR that promotes the 'C
> and Java'
> notation + slices + this type compatibility?
>
> BR
>
> Stephan
>
> --
> Stephan Tobies Sr. Research Engineer, Nokia Research Center
> ~ Mobile Networks Lab, Protocol Engineering Group
> E-Mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Work Phone: +49-234-9842262
> Mobile: +49-163-9842405
> Fax: +49-234-9843491
> Address: NRC Bochum, Meesmannstr. 103, 44807 Bochum, Germany
>
The administrator has disabled public write access.
  • Page:
  • 1
  • 2

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin