tags:

views:

25

answers:

1

I need to be able to input and output 2-D matrices (normally numeric) in a form independent of the programming language used to process them. I have adopted the approach below and want to check whether there are any agreed conventions that support or contradict this.

Specifically I have an XML representation of the form (which is required to be a simple whitespace-separated array):

<array rows="2" columns="3">1 2 3 4 5 6</array>

which I interpret as

1 2 3
4 5 6

Using subscript notation for matrix elements (which I assume always start at 1,1 regardless of the programming language) this would give

M<sub>1,2</sub> = 2

where rows come first and columns second. Is this universal?

The major languages I have to support are C, C++, C#, Java, Fortran). Which of these have specific support for 2-D matrices and are their conventions consistent or contradictory? For example is the fastest running index always the column index?

[Note: This is not a question of whether 0-based or 1-based arrays are "better". However it would be useful to know if in all 0-based languages the second index was fastest moving and in all 1-based languages the slowest.]

A: 

Slightly surprised at the lack of interest. No definite answer, so will re-ask a different aspect

peter.murray.rust