Forums before death by AOL, social media and spammers... "We can't have nice things"
|    sci.math.symbolic    |    Symbolic algebra discussion    |    10,432 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 9,604 of 10,432    |
|    Piet van Oostrum to asetofsymbols@gmail.com    |
|    Re: [Axiom] matrix element access    |
|    13 Aug 17 15:11:38    |
      From: piet-l@vanoostrum.org              asetofsymbols@gmail.com writes:              > a:=matrix[[i+j for i in 1..4] for j in 1..4]       >       > One can access the element i,j with       >       > a(i,j)       >       > But if i want a matrix of lists as       > a:=matrix[[[i,j] for i in 1..4] for j in 1..4]       >       > a(i,j) result to me can not return [i,j]       >       > Where is the error? What does it mean "SUB"?              Elements of a matrix must belong to a domain that is an Abelian monoid       (AbelianMonoid), and lists are not that. Therefore you cannot make a       matrix out of [[[i,j] for i in 1..4] for j in 1..4]              The consequence is that there is no function called 'matrix' that       applies. Then 'matrix' will be interpreted as a symbol, and the [...] as       a subscript, like in              (47) -> m[1]               (47) m        1        Type: Symbol       (48) -> matrix[1]               (48) matrix        1        Type: Symbol       And the same when the expression between [...] is more complicated.              The reason that SUB is added is that the subscript is so long that it is       broken across lines and you probably would not recognize that it is a       subscript. So the SUB is there to remind you that it really is a       subscript operation that you see. If you make it smaller, it disappears:              (50) -> a := matrix [[[i,j] for i in 1..2] for j in 1..2]               (50) matrix        [[1, 1], [2, 1]], [[1, 2], [2, 2]]        Type: Symbol              You can also check that is a subscript expression with 'scripts':              (51) -> a := matrix [[[i,j] for i in 1..4] for j in 1..4]               (51)        SUB        matrix        ,        [[1, 1], [2, 1], [3, 1], [4, 1]], [[1, 2], [2, 2], [3, 2], [4, 2]]        ,        [[1, 3], [2, 3], [3, 3], [4, 3]], [[1, 4], [2, 4], [3, 4], [4, 4]]        Type: Symbol       (52) -> scripts a               (52)        [        sub        =        [[[1, 1], [2, 1], [3, 1], [4, 1]], [[1, 2], [2, 2], [3, 2], [4, 2]],        [[1, 3], [2, 3], [3, 3], [4, 3]], [[1, 4], [2, 4], [3, 4], [4, 4]]]        ,        sup = [], presup = [], presub = [], args = []]       Type: Record(sub: List(OutputForm),sup: List(OutputForm),presup:       List(OutputForm),presub: List(OutputForm),args: List(OutputForm))              > What about use as nxn matrix, list of list?       >       > Here       > b:=[[[i,j] for i in 1..4] for j in 1..4]       >       > here b.i.j return [i,j]       >       > But if with list of list one can have matrix types, why define a new type       Matrix?              Because Matrix does have additional operations, like matrix addition,       multiplication (if the elements come from a Ring) and inverse (if the       elements come from a Field).       --       Piet van Oostrum |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca