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

$%MTXSUB^MATH

M[UMPS] by Example

Approved for inclusion in a future M[UMPS] language standard as part of the library for Matrix Mathematics.

This function subtracts two (sparse) matrices.

3   5   7       1   2   3       2   3   4
8   5   2   -   3   2   1   =   5   3   1
8   8   8       1   2   3       7   6   5

Cells that were not defined in the source matrices will not be defined in the result matrices (sparsity is retained) (a cell containing "#" means no defined value):

#   5   7       1   2   #      –1   3   4
8   #   2   -   3   #   1   =   5   #   1
8   8   #       #   2   3       8   6  –3

Kill FIRST,SECOND
Set FIRST(1,2)=5,FIRST(1,3)=7
Set FIRST(2,1)=8,FIRST(2,3)=2
Set FIRST(3,1)=8,FIRST(3,2)=8
Set SECOND(1,1)=1,SECOND(1,2)=2
Set SECOND(2,1)=3,SECOND(2,3)=1
Set SECOND(3,2)=2,SECOND(3,3)=3
Set X=$%MTXSUB^MATH(.FIRST,.SECOND,.RESULT,3,3)

performs the math that is depicted in the second example above. The result in array RESULT will be that:

RESULT(1,1)=–1, RESULT(1,2)=5, RESULT(1,3)=4
RESULT(2,1)=5, RESULT(2,2) is not defined, RESULT(2,3)=1
RESULT(3,1)=8, RESULT(3,2)=6, RESULT(3,3)=–3

The MDC has approved code to approximate the return value of this function. Implementors are encouraged to provide more accurate and efficient code).
Click here for $%MTXSUB^MATH sample code to view or download the code for this function.
Click here for AllFunctions to view or download the code for all M[UMPS] Library Functions.

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.

The information in this page is NOT authoritative and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an authoritative definition.

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 29-Nov-2011, 20:00:18.

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