Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

$%MTXADD^MATH

Annotations

Matrices, Rows and Columns

In a language like "C", and array can be initialized as {0, 1, 2, 3, 4, 5, 6, ..., 119}, and then passed to a procedure, where its dimensions could be defined to be any one of:

and many other possibilities.

In its rendition as "two_dimensional_1", the array would look like:

a [0,0]
=0
a [0,1]
=1
a [0,2]
=2
a [0,3]
=3
a [0,4]
=4
a [0,5]
=5
a [0,6]
=6
a [0,7]
=7
a [0,8]
=8
a [0,9]
=9
a [0,10]
=10
a [0,11]
=11
a [1,0]
=12
a [1,1]
=13
a [1,2]
=14
a [1,3]
=15
a [1,4]
=16
a [1,5]
=17
a [1,6]
=18
a [1,7]
=19
a [1,8]
=20
a [1,9]
=21
a [1,10]
=22
a [1,11]
=23
a [2,0]
=24
a [2,1]
=25
a [2,2]
=26
a [2,3]
=27
a [2,4]
=28
a [2,5]
=29
a [2,6]
=30
a [2,7]
=31
a [2,8]
=32
a [2,9]
=33
a [2,10]
=34
a [2,11]
=35
a [3,0]
=36
a [3,1]
=37
a [3,2]
=38
a [3,3]
=39
a [3,4]
=40
a [3,5]
=41
a [3,6]
=42
a [3,7]
=43
a [3,8]
=44
a [3,9]
=45
a [3,10]
=46
a [3,11]
=47
a [4,0]
=48
a [4,1]
=49
a [4,2]
=50
a [4,3]
=51
a [4,4]
=52
a [4,5]
=53
a [4,6]
=54
a [4,7]
=55
a [4,8]
=56
a [4,9]
=57
a [4,10]
=58
a [4,11]
=59
a [5,0]
=60
a [5,1]
=61
a [5,2]
=62
a [5,3]
=63
a [5,4]
=64
a [5,5]
=65
a [5,6]
=66
a [5,7]
=67
a [5,8]
=68
a [5,9]
=69
a [5,10]
=70
a [5,11]
=71
a [6,0]
=72
a [6,1]
=73
a [6,2]
=74
a [6,3]
=75
a [6,4]
=76
a [6,5]
=77
a [6,6]
=78
a [6,7]
=79
a [6,8]
=80
a [6,9]
=81
a [6,10]
=82
a [6,11]
=83
a [7,0]
=84
a [7,1]
=85
a [7,2]
=86
a [7,3]
=87
a [7,4]
=88
a [7,5]
=89
a [7,6]
=90
a [7,7]
=91
a [7,8]
=92
a [7,9]
=93
a [7,10]
=94
a [7,11]
=95
a [8,0]
=96
a [8,1]
=97
a [8,2]
=98
a [8,3]
=99
a [8,4]
=100
a [8,5]
=101
a [8,6]
=102
a [8,7]
=103
a [8,8]
=104
a [8,9]
=105
a [8,10]
=106
a [8,11]
=107
a [9,0]
=108
a [9,1]
=109
a [9,2]
=110
a [9,3]
=111
a [9,4]
=112
a [9,5]
=113
a [9,6]
=114
a [9,7]
=115
a [9,8]
=116
a [9,9]
=117
a [9,10]
=118
a [9,11]
=119

In its rendition as "two_dimensional_1", the array would look like:

a [0,0]
=0
a [0,1]
=1
a [0,2]
=2
a [0,3]
=3
a [0,4]
=4
a [0,5]
=5
a [0,6]
=6
a [0,7]
=7
a [0,8]
=8
a [0,9]
=9
a [1,0]
=10
a [1,1]
=11
a [1,2]
=12
a [1,3]
=13
a [1,4]
=14
a [1,5]
=15
a [1,6]
=16
a [1,7]
=17
a [1,8]
=18
a [1,9]
=19
a [2,0]
=20
a [2,1]
=21
a [2,2]
=22
a [2,3]
=23
a [2,4]
=24
a [2,5]
=25
a [2,6]
=26
a [2,7]
=27
a [2,8]
=28
a [2,9]
=29
a [3,0]
=30
a [3,1]
=31
a [3,2]
=32
a [3,3]
=33
a [3,4]
=34
a [3,5]
=35
a [3,6]
=36
a [3,7]
=37
a [3,8]
=38
a [3,9]
=39
a [4,0]
=40
a [4,1]
=41
a [4,2]
=42
a [4,3]
=43
a [4,4]
=44
a [4,5]
=45
a [4,6]
=46
a [4,7]
=47
a [4,8]
=48
a [4,9]
=49
a [5,0]
=50
a [5,1]
=51
a [5,2]
=52
a [5,3]
=53
a [5,4]
=54
a [5,5]
=55
a [5,6]
=56
a [5,7]
=57
a [5,8]
=58
a [5,9]
=59
a [6,0]
=60
a [6,1]
=61
a [6,2]
=62
a [6,3]
=63
a [6,4]
=64
a [6,5]
=65
a [6,6]
=66
a [6,7]
=67
a [6,8]
=68
a [6,9]
=69
a [7,0]
=70
a [7,1]
=71
a [7,2]
=72
a [7,3]
=73
a [7,4]
=74
a [7,5]
=75
a [7,6]
=76
a [7,7]
=77
a [7,8]
=78
a [7,9]
=79
a [8,0]
=80
a [8,1]
=81
a [8,2]
=82
a [8,3]
=83
a [8,4]
=84
a [8,5]
=85
a [8,6]
=86
a [8,7]
=87
a [8,8]
=88
a [8,9]
=89
a [9,0]
=90
a [9,1]
=91
a [9,2]
=92
a [9,3]
=93
a [9,4]
=94
a [9,5]
=95
a [9,6]
=96
a [9,7]
=97
a [9,8]
=98
a [9,9]
=99
a [10,0]
=100
a [10,1]
=101
a [10,2]
=102
a [10,3]
=103
a [10,4]
=104
a [10,5]
=105
a [10,6]
=106
a [10,7]
=107
a [10,8]
=108
a [10,9]
=109
a [11,0]
=110
a [11,1]
=111
a [11,2]
=112
a [11,3]
=113
a [11,4]
=114
a [11,5]
=115
a [11,6]
=116
a [11,7]
=117
a [11,8]
=118
a [11,9]
=119

In a language like M[UMPS] arrays are not pre-allocated, nor is there a predefined notion that makes a specific subscript correspond to "rows" or "columns". Since it is attractive to write code like:
Set one="" For  Set one=$Order(array(one)) Quit:one=""  Do
. Write !
. Set two="" For  Set two=$Order(array(two)) Quit:two=""  Do
. . ;
etcetera
many people will consider the first subscript in a two-dimensional array to be the "row" subscript and the second one the "column" subscript.

However, there is nothing that prohibits a programmer from creating an array with elements like:
Set A(1,1)=11,A(1,2)=12,A(1,3)=13
Set A(2,1)=21,A(2,2)=22,A(2,3)=23

and then using the data in this array in either of the following ways:
For y=1:1:2 Write ! For x=1:1:3 Write $Justify(A(y,x),6)
which would lead to:
    11    12    13
    21    22    23

which looks like two rows of three columns, whereas:
For x=1:1:3 Write ! For y=1:1:2 Write $Justify(A(x,y),6)
which would lead to:
    11    21
    12    22
    13    23

which looks like three rows of two columns.

In M[UMPS] the assignment of subscripts to notions like rows and columns is up to the author of the application. However, for the purpose of the standardized functions for matrix manipulation, a choice has been pre-made to use the first subscript for rows and the second one for columns.

Be aware, though, that it is possible to define an array like:

a [0,0]
=0
    a [0,3]
=3
a [0,4]
=4
  a [0,6]
=6
    a [0,9]
=9
a [1,0]
=10
  a [1,2]
=12
a [1,3]
=13
  a [1,5]
=15
      a [1,9]
=19
a [2,0]
=20
a [2,1]
=21
a [2,2]
=22
a [2,3]
=23
a [2,4]
=24
a [2,5]
=25
  a [2,7]
=27
a [2,8]
=28
a [2,9]
=29
a [3,0]
=30
a [3,1]
=31
  a [3,3]
=33
a [3,4]
=34
a [3,5]
=35
a [3,6]
=36
  a [3,8]
=38
a [3,9]
=39
a [4,0]
=40
a [4,1]
=41
a [4,2]
=42
a [4,3]
=43
a [4,4]
=44
a [4,5]
=45
a [4,6]
=46
a [4,7]
=47
a [4,8]
=48
 
a [5,0]
=50
a [5,1]
=51
  a [5,3]
=53
a [5,4]
=54
a [5,5]
=55
  a [5,7]
=57
a [5,8]
=58
a [5,9]
=59
  a [6,1]
=61
a [6,2]
=62
a [6,3]
=63
a [6,4]
=64
  a [6,6]
=66
  a [6,8]
=68
a [6,9]
=69
a [7,0]
=70
a [7,1]
=71
a [7,2]
=72
a [7,3]
=73
a [7,4]
=74
a [7,5]
=75
a [7,6]
=76
a [7,7]
=77
  a [7,9]
=79
a [8,0]
=80
  a [8,2]
=82
a [8,3]
=83
    a [8,6]
=86
  a [8,8]
=88
a [8,9]
=89
a [9,0]
=90
a [9,1]
=91
a [9,2]
=92
a [9,3]
=93
  a [9,5]
=95
  a [9,7]
=97
a [9,8]
=98
a [9,9]
=99

When used in a function call like:
Set X=$%MTXADD^MATH(.a,.SECOND,.RESULT,3,3)
only the part of the matrix that is highlighted below would be used.

a [0,0]
=0
    a [0,3]
=3
a [0,4]
=4
  a [0,6]
=6
    a [0,9]
=9
a [1,0]
=10
  a [1,2]
=12
a [1,3]
=13
  a [1,5]
=15
      a [1,9]
=19
a [2,0]
=20
a [2,1]
=21
a [2,2]
=22
a [2,3]
=23
a [2,4]
=24
a [2,5]
=25
  a [2,7]
=27
a [2,8]
=28
a [2,9]
=29
a [3,0]
=30
a [3,1]
=31
  a [3,3]
=33
a [3,4]
=34
a [3,5]
=35
a [3,6]
=36
  a [3,8]
=38
a [3,9]
=39
a [4,0]
=40
a [4,1]
=41
a [4,2]
=42
a [4,3]
=43
a [4,4]
=44
a [4,5]
=45
a [4,6]
=46
a [4,7]
=47
a [4,8]
=48
 
a [5,0]
=50
a [5,1]
=51
  a [5,3]
=53
a [5,4]
=54
a [5,5]
=55
  a [5,7]
=57
a [5,8]
=58
a [5,9]
=59
  a [6,1]
=61
a [6,2]
=62
a [6,3]
=63
a [6,4]
=64
  a [6,6]
=66
  a [6,8]
=68
a [6,9]
=69
a [7,0]
=70
a [7,1]
=71
a [7,2]
=72
a [7,3]
=73
a [7,4]
=74
a [7,5]
=75
a [7,6]
=76
a [7,7]
=77
  a [7,9]
=79
a [8,0]
=80
  a [8,2]
=82
a [8,3]
=83
    a [8,6]
=86
  a [8,8]
=88
a [8,9]
=89
a [9,0]
=90
a [9,1]
=91
a [9,2]
=92
a [9,3]
=93
  a [9,5]
=95
  a [9,7]
=97
a [9,8]
=98
a [9,9]
=99

When used in a function call like:
Set X=$%MTXADD^MATH(.a,.SECOND,.RESULT,8,5)
only the part of the matrix that is highlighted below would be used.

a [0,0]
=0
    a [0,3]
=3
a [0,4]
=4
  a [0,6]
=6
    a [0,9]
=9
a [1,0]
=10
  a [1,2]
=12
a [1,3]
=13
  a [1,5]
=15
      a [1,9]
=19
a [2,0]
=20
a [2,1]
=21
a [2,2]
=22
a [2,3]
=23
a [2,4]
=24
a [2,5]
=25
  a [2,7]
=27
a [2,8]
=28
a [2,9]
=29
a [3,0]
=30
a [3,1]
=31
  a [3,3]
=33
a [3,4]
=34
a [3,5]
=35
a [3,6]
=36
  a [3,8]
=38
a [3,9]
=39
a [4,0]
=40
a [4,1]
=41
a [4,2]
=42
a [4,3]
=43
a [4,4]
=44
a [4,5]
=45
a [4,6]
=46
a [4,7]
=47
a [4,8]
=48
 
a [5,0]
=50
a [5,1]
=51
  a [5,3]
=53
a [5,4]
=54
a [5,5]
=55
  a [5,7]
=57
a [5,8]
=58
a [5,9]
=59
  a [6,1]
=61
a [6,2]
=62
a [6,3]
=63
a [6,4]
=64
  a [6,6]
=66
  a [6,8]
=68
a [6,9]
=69
a [7,0]
=70
a [7,1]
=71
a [7,2]
=72
a [7,3]
=73
a [7,4]
=74
a [7,5]
=75
a [7,6]
=76
a [7,7]
=77
  a [7,9]
=79
a [8,0]
=80
  a [8,2]
=82
a [8,3]
=83
    a [8,6]
=86
  a [8,8]
=88
a [8,9]
=89
a [9,0]
=90
a [9,1]
=91
a [9,2]
=92
a [9,3]
=93
  a [9,5]
=95
  a [9,7]
=97
a [9,8]
=98
a [9,9]
=99
Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.

Some specifications are "approved for inclusion in a future standard". Note that the MUMPS Development Committee cannot guarantee that such future standards will indeed be published.

This page most recently updated on 13-Sep-2014, 17:04:44.

For comments, contact Ed de Moel (demoel@jacquardsystems.com)