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

$%MTXEQU

Draft MDC Standard

2 MATH Library
2.41 MTXEQU

MTXEQU(A,B,R,N,M) ;
	; Solve matrix equation A [M,M] * R [M,N] = B [M,N]
	If $Get(M)<1 Quit ""
	If $Get(N)<1 Quit ""
	If '$%MTXDET^MATH(.A,M) Quit 0
	;
	New I,I1,J,J1,J2,K,L,T,T1,T2,TEMP,X
	;
	Set X=$%MTXCOPY^MATH(.A,.T,N,N)
	Set X=$%MTXCOPY^MATH(.B,.R,N,M)
	;
	; Reduction of matrix A
	; Steps of reduction are counted by index K
	;
	For K=1:1:N–1 Do
	. ;
	. ; Search for largest coefficient of T
	. ; (denoted by TEMP)
	. ; in first column of reduced system
	. ;
	. Set TEMP=0,J2=K
	. For J1=K:1:N Do
	. . Quit:$TRanslate($Get(T(J1,K)),"-")>$TRanslate(TEMP,"-")
	. . Set TEMP=T(J1,K),J2=J1
	. . Quit
	. ;
	. ; Exchange row number K with row number J2,
	. ; if necessary
	. ;
	. Do:J2'=K
	. . ;
	. . For J=K:1:N Do
	. . . Set T1=$Get(T(K,J)),T2=$Get(T(J2,J))
	. . . Kill T(K,J),T(J2,J)
	. . . If T1'="" Set T(J2,J)=T1
	. . . If T2'="" Set T(K,J)=T2
	. . . Quit
	. . For J=1:1:M Do
	. . . Set T1=$Get(R(K,J)),T2=$Get(R(J2,J))
	. . . Kill R(K,J),R(J2,J)
	. . . If T1'="" Set R(J2,J)=T1
	. . . If T2'="" Set R(K,J)=T2
	. . . Quit
	. . Quit
	. ;
	. ; Actual reduction
	. ;
	. For I=K+1:1:N Do
	. . For J=K+1:1:N Do
	. . . Quit:'$Get(T(K,K))
	. . . Set T(I,J)=-$Get(T(K,J))*$Get(T(I,K))/T(K,K)+$Get(T(I,J))
	. . . Quit
	. . For J=1:1:M Do
	. . . Quit:'$Get(T(K,K))
	. . . Set R(I,J)=-$Get(R(K,J))*$Get(T(I,K))/T(K,K)+$Get(R(I,J))
	. . . Quit
	. . Quit
	. Quit
	;
	; Backsubstitution
	;
	For J=1:1:M Do
	. If $Get(T(N,N)) Set R(N,J)=$Get(R(N,J))/T(N,N)
	. If N–1>0 For I1=1:1:N–1 Do
	. . Set I=N-I1
	. . For L=I+1:1:N Do
	. . . Set R(I,J)=-$Get(T(I,L))*$Get(R(L,J))+$Get(R(I,J))
	. . . Quit
	. . If $Get(T(I,I)) Set R(I,J)=$Get(R(I,J))/$Get(T(I,I))
	. . Quit
	. Quit
	Quit $Select(M=N:$%MTXDET^MATH(.R,M),1:1)
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 16-Nov-2023, 16:52:01.

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