MTH$CSQRT                                                        21-AUG-1978 19:03:08   VAX-11 MACRO X0.3-11               Page   0

TABLE OF CONTENTS   



   (2)     100  HISTORY		; Detailed Current Edit History

   (3)     100  DECLARATIONS

   (4)     100  MTH$CSQRT - compute COMPLEX square root

MTH$CSQRT                                                        21-AUG-1978 19:03:08   VAX-11 MACRO X0.3-11               Page   1

0-3                                                                                                                              (1)



                                     0000   100 	.TITLE	MTH$CSQRT

                                     0000   200 	.IDENT	/0-3/		; File: MTHCSQRT.MAR

                                     0000   300 

                                     0000   400 ;

                                     0000   500 ; Copyright (C) 1977

                                     0000   600 ; Digital Equipment Corporation, Maynard, Massachusetts 01754

                                     0000   700 ;

                                     0000   800 ; This software is furnished under a license for use only on a single

                                     0000   900 ; computer  system  and  may be copied only with the inclusion of the

                                     0000  1000 ; above copyright notice. This software, or any other copies thereof,

                                     0000  1100 ; may not be provided or otherwise made available to any other person

                                     0000  1200 ; except for use on such system and to one who agree to these license 

                                     0000  1300 ; terms.  Title to  and  ownership of the software shall at all times 

                                     0000  1400 ; remain in DEC.

                                     0000  1500 ;

                                     0000  1600 ; The information in the software is subject to change without notice

                                     0000  1700 ; and should  not  be construed  as a commitment by Digital Equipment 

                                     0000  1800 ; Corporation.

                                     0000  1900 ;

                                     0000  2000 ; DEC assumes  no  responsibility  for the use or  reliability of its

                                     0000  2100 ; software on equipment which is not supplied by DEC.

                                     0000  2200 ;

                                     0000  2300 ;

                                     0000  2400 ; FACILITY: MATH LIBRARY

                                     0000  2500 ;++

                                     0000  2600 ; ABSTRACT:

                                     0000  2700 ;	This module contains routine MTH$CSQRT - compute COMPLEX square root.

                                     0000  2800 ;

                                     0000  2900 ;--

                                     0000  3000 ;

                                     0000  3100 ; VERSION: 0

                                     0000  3200 ;

                                     0000  3300 ; HISTORY:

                                     0000  3400 ;

                                     0000  3500 ; AUTHOR:

                                     0000  3600 ;	Jonathan M. Taylor, 20-JUL-77: Version 0

                                     0000  3700 ;

                                     0000  3800 ; MODIFIED BY:

                                     0000  3900 ;

                                     0000  4000 ;

                                     0000  4100 ;

MTH$CSQRT                                                        21-AUG-1978 19:03:08   VAX-11 MACRO X0.3-11               Page   2

0-3             HISTORY  ; Detailed Current Edit History                                                                         (2)



                                     0000   100 	.SBTTL	HISTORY		; Detailed Current Edit History

                                     0000   200 

                                     0000   300 

                                     0000   400 ; Edit History for Version 0 of MTH$CSQRT

                                     0000   500 ;

                                     0000   600 ; 0-3	- Fix comments.  TNH 16-June-78

MTH$CSQRT                                                        21-AUG-1978 19:03:08   VAX-11 MACRO X0.3-11               Page   3

0-3             DECLARATIONS                                                                                                     (3)



                                     0000   100 	.SBTTL	DECLARATIONS

                                     0000   200 

                                     0000   300 ;

                                     0000   400 ; INCLUDE FILES:

                                     0000   500 ;	OERR.MAR

                                     0000   600 

                                     0000   700 ;

                                     0000   800 ; EXTERNAL SYMBOLS:

                                     0000   900 	.GLOBL	MTH$CABS

                                     0000  1000 	.GLOBL	MTH$SQRT_R2

                                     0000  1100 

                                     0000  1200 ;

                                     0000  1300 ; MACROS:

                                     0000  1400 ;	NONE

                                     0000  1500 

                                     0000  1600 ;

                                     0000  1700 ; PSECT DECLARATIONS:

                                 00000000  1800 	.PSECT	MTH$CODE	PIC, SHR, LONG, EXE, NOWRT

                                     0000  1900 

                                     0000  2000 ;

                                     0000  2100 ; EQUATED SYMBOLS:

                           00000004  0000  2200 	argadr	=	4	; offset from AP of arg address

                                     0000  2300 

                                     0000  2400 ;

                                     0000  2500 ; OWN STORAGE:

                                     0000  2600 ;	NONE

MTH$CSQRT                                                        21-AUG-1978 19:03:08   VAX-11 MACRO X0.3-11               Page   4

0-3             MTH$CSQRT - compute COMPLEX square root                                                                          (4)



                                     0000   100 	.SBTTL	MTH$CSQRT - compute COMPLEX square root

                                     0000   200 

                                     0000   300 ;++

                                     0000   400 ; FUNCTIONAL DESCRIPTION:

                                     0000   500 ;

                                     0000   600 ;	The square root of a complex number (r, i) is computed

                                     0000   700 ;	as follows:

                                     0000   800 ;

                                     0000   900 ;	ROOT = SQRT((ABS(r) + CABS((r, i))) / 2)

                                     0000  1000 ;	Q = i / (2*ROOT)

                                     0000  1100 ;

                                     0000  1200 ;

                                     0000  1300 ;	r	i	CSQRT((r, i))

                                     0000  1400 ;	-	-	-------------

                                     0000  1500 ;

                                     0000  1600 ;	>=0	any	(ROOT, Q)

                                     0000  1700 ;	<0	>=0	(Q, ROOT)

                                     0000  1800 ;	<0	<0	(-Q, -ROOT)

                                     0000  1900 ;

                                     0000  2000 ; CALLING SEQUENCE:

                                     0000  2100 ;

                                     0000  2200 ;	Square_root.wfc.v	= MTH$CSQRT (arg.rfc.r)

                                     0000  2300 ;

                                     0000  2400 ; INPUT PARAMETERS:

                                     0000  2500 ;

                                     0000  2600 ;	The one input parameter is the address of a COMPLEX number (r, i)

                                     0000  2700 ;	where r and i are both single-precision floating point values.

                                     0000  2800 ;

                                     0000  2900 ; IMPLICIT INPUTS:

                                     0000  3000 ;	NONE

                                     0000  3100 ;

                                     0000  3200 ; OUTPUT PARAMETERS:

                                     0000  3300 ;	NONE

                                     0000  3400 ;

                                     0000  3500 ; IMPLICIT OUTPUTS:

                                     0000  3600 ;	NONE

                                     0000  3700 ;

                                     0000  3800 ; COMPLETION CODES:

                                     0000  3900 ;	NONE

                                     0000  4000 ;

                                     0000  4100 ; SIDE EFFECTS:

                                     0000  4200 ;

                                     0000  4300 ;	Signals:	Reserved Operand if r or i is bad (-0.0)

                                     0000  4400 ;

                                     0000  4500 ;--

                                     0000  4600 

                                     0000  4700 

                               000C' 0000  4800 	.ENTRY	MTH$CSQRT,	^M<R2, R3>

                                     0002  4900 	MTH$FLAG_JACKET			; flag as math routine

                                     0002      

            6D       0000'CF     3E  0002       	MOVAW	W^MTH$$JACKET_HND, (FP)

                                     0007       					; set handler address to jacket

                                     0007       					; handler

                                     0007       

                                     0007  5000 

            52         04 BC     50  0007  5100 	MOVF	@argadr(AP), R2		; R2 = r

            52       8000 8F     AA  000B  5200 	BICW	#^X8000, R2		; R2 = ABS(r)

MTH$CSQRT                                                        21-AUG-1978 19:03:08   VAX-11 MACRO X0.3-11               Page   5

0-3             MTH$CSQRT - compute COMPLEX square root                                                                          (4)



   00000000'EF            6C     FA  0010  5300 	CALLG	(AP), MTH$CABS		; R0 = CABS((r, i))

            50            52     40  0017  5400 	ADDF	R2, R0			; R0 = ABS(r) + CABS((r, i))

            50            00     44  001A  5500 	MULF	#0.5, R0		; R0 = (ABS(r) + CABS((r, i))) / 2

                 00000000'EF     16  001D  5600 	JSB	MTH$SQRT_R2		; R0 = ROOT = SQRT(above)

            52         04 AC     D0  0023  5700 	MOVL	argadr(AP), R2		; R2 -> (r, i)

         04 A2            50     47  0027  5800 	DIVF3	R0, 4(R2), R1		; R1 = i / ROOT

                          51         002B       

            51            00     44  002C  5900 	MULF	#0.5, R1		; R1 = Q = i / (2 * ROOT)

                          82     53  002F  6000 	TSTF	(R2)+			; if r positive,

                          14     18  0031  6100 	BGEQ	RETRN			; then return (ROOT, Q)

            53            50     D0  0033  6200 	MOVL	R0, R3			; else switch ROOT and Q

                          62     53  0036  6300 	TSTF	(R2)			; if i positive

                          07     18  0038  6400 	BGEQ	RETRN1			; then return (Q, ROOT)

            50            51     52  003A  6500 	MNEGF	R1, R0			; else negate ROOT and Q

            51            53     52  003D  6600 	MNEGF	R3, R1			; and return (-Q, -ROOT)

                                 04  0040  6700 	RET

                                     0041  6800 

                                     0041  6900 RETRN1:

            50            51     D0  0041  7000 	MOVL	R1, R0			; continue to swap ROOT and Q

            51            53     D0  0044  7100 	MOVL	R3, R1			; and return (Q, ROOT)

                                     0047  7200 RETRN:

                                 04  0047  7300 	RET

                                     0048  7400 

                                     0048  7500 

                                     0048  7600 	.END

MTH$CSQRT                                                        21-AUG-1978 19:03:08   VAX-11 MACRO X0.3-11               Page   6

SYMBOL TABLE                                                                                                                     (4)



ARGADR         = 00000004            

FOR$K_ERR_PREFX= 00000018            

MTH$$JACKET_HND  ********   X   02   

MTH$CABS         ********  GX   01   

MTH$CSQRT        00000000 RG    02   

MTH$K_ERR_PREFX= 00000016            

MTH$SQRT_R2      ********  GX   01   

MTH__FLOOVEMAT = 00000058            

MTH__FLOUNDMAT = 00000059            

MTH__INVARG    = 00000051            

MTH__LOGZERNEG = 00000053            

MTH__SINSIGLOS = 00000057            

MTH__SQUROONEG = 00000054            

MTH__UNDEXP    = 00000052            

MTH__WRONUMARG = 00000050            

RETRN            00000047 R     02   

RETRN1           00000041 R     02   





PROGRAM SECTION SYNOPSIS



.  ABS  .        00000000      00     NOPIC   USR   CON   ABS   LCL NOSHR NOEXE NORD  NOWRT BYTE  

. BLANK .        00000000      01     NOPIC   USR   CON   REL   LCL NOSHR   EXE   RD    WRT BYTE  

MTH$CODE         00000048      02       PIC   USR   CON   REL   LCL   SHR   EXE   RD  NOWRT LONG  





THERE WERE NO ERRORS OR WARNINGS.

27948. BYTES LEFT IN FREE MEMORY POOL.

OBJ$:MTHCSQRT,LIS$:MTHCSQRT/-SP=LIB$:S/ML,SRC$:P,MTHCSQRT

0 MLB DIR RDS - 0 GETS TO DEFINE 0 MACROS. 2 INTER. FILE WRITES. 

