diff options
| author | Jon duSaint | 2022-04-30 16:16:25 -0700 |
|---|---|---|
| committer | Jon duSaint | 2022-04-30 16:16:25 -0700 |
| commit | 3160d814a1a088cfbcbd3c48c02d36273fd56383 (patch) | |
| tree | ee703f562c870ee7ea675b8b682a48da2750ecfa /matfun | |
| parent | 659f12ede69726f46487d6e44aa79f48c2bd2aae (diff) | |
Commit a bunch of old software
Diffstat (limited to 'matfun')
| -rw-r--r-- | matfun/README | 17 | ||||
| -rw-r--r-- | matfun/matfun.glb | bin | 0 -> 6669 bytes | |||
| -rw-r--r-- | matfun/matfun.h | 15 | ||||
| -rw-r--r-- | matfun/matfun.hg | 3 | ||||
| -rw-r--r-- | matfun/matfun.hs | 3 | ||||
| -rw-r--r-- | matfun/matfun.slb | bin | 0 -> 6669 bytes | |||
| -rw-r--r-- | matfun/matfun.src | 2197 | ||||
| -rw-r--r-- | matfun/matfun.txt | 164 |
8 files changed, 2399 insertions, 0 deletions
diff --git a/matfun/README b/matfun/README new file mode 100644 index 0000000..482217c --- /dev/null +++ b/matfun/README @@ -0,0 +1,17 @@ +In this distribution: + +README This file +matfun.glb The compiled library for the G(X) +matfun.slb The compiled library for the S(X) +matfun.src The source code suitable for compilation with Jazz. +matfun.h The main header file. +matfun.hg G(X) specific header file +matfun.hs S(X) specific header file +matfun.txt Inadequate documentation + +To install: +Download either matfun.glb or matfun.slb (depending upon what type +of calculator you have). RCL the library to the stack and purge the +variable it was in. Execute 0 STO and then warm start your calculator +(press ON+C). If all is OK, it should be available in the library +menu. diff --git a/matfun/matfun.glb b/matfun/matfun.glb Binary files differnew file mode 100644 index 0000000..5d6af97 --- /dev/null +++ b/matfun/matfun.glb diff --git a/matfun/matfun.h b/matfun/matfun.h new file mode 100644 index 0000000..8a10406 --- /dev/null +++ b/matfun/matfun.h @@ -0,0 +1,15 @@ +DEFINE FINDVAR PTR 353AB +DEFINE C%C*R PTR 51D4C +DEFINE C%R*C PTR 51D60 +DEFINE C%C+C PTR 51C16 +DEFINE CKRARRY PTR 194BB +DEFINE DOARRY> PTR 1D0AB +DEFINE C%C*C PTR 51D88 +DEFINE C%C-C PTR 51CFC +DEFINE DOARRYPRG1 PTR 35C2C +DEFINE MAT+ PTR 36115 +DEFINE MAT- PTR 36278 +DEFINE MATR>C PTR 36039 +DEFINE MATC>R PTR 360B6 +DEFINE MATCONJ PTR 35F30 +DEFINE MATFLOAT* PTR 362DC diff --git a/matfun/matfun.hg b/matfun/matfun.hg new file mode 100644 index 0000000..d0276e9 --- /dev/null +++ b/matfun/matfun.hg @@ -0,0 +1,3 @@ +(GX Specific)
+DEFINE SWITCHFLOATS PTR 35B47
+DEFINE MATFLOAT/ PTR 363DB
diff --git a/matfun/matfun.hs b/matfun/matfun.hs new file mode 100644 index 0000000..03ada95 --- /dev/null +++ b/matfun/matfun.hs @@ -0,0 +1,3 @@ +(SX Specific)
+DEFINE SWITCHFLOATS PTR 35B4F
+DEFINE MATFLOAT/ PTR 3633C
diff --git a/matfun/matfun.slb b/matfun/matfun.slb Binary files differnew file mode 100644 index 0000000..6af5526 --- /dev/null +++ b/matfun/matfun.slb diff --git a/matfun/matfun.src b/matfun/matfun.src new file mode 100644 index 0000000..426a6b5 --- /dev/null +++ b/matfun/matfun.src @@ -0,0 +1,2197 @@ +INCLUDE matfun.hgx
+INCLUDE matfun.h
+
+ASSEMBLE
+ TITLE MATFUN C 1997-98 Jon duSaint
+ STITLE Last modified 02/03/98 11:31:57A
+RPL
+
+xROMID 837
+xTITLE MATFUN A collection of useful matrix functions, 1997-98 Jon duSaint
+xCONFIG MCnfg
+
+(User Commands)
+EXTERNAL xIARR
+EXTERNAL xONES
+EXTERNAL xZEROS
+EXTERNAL x\->2D
+EXTERNAL xLENGTH
+EXTERNAL xFLIPLR
+EXTERNAL xFLIPUD
+EXTERNAL xMTXELM
+EXTERNAL xMMIN
+EXTERNAL xMMAX
+EXTERNAL xMPLOT
+EXTERNAL xMFFT
+EXTERNAL xFILTER
+EXTERNAL xCONV
+EXTERNAL xCCONV
+EXTERNAL xINTERP
+EXTERNAL xMPLUS
+EXTERNAL xMMINUS
+EXTERNAL xMMULT
+EXTERNAL xMDIV
+EXTERNAL xSINC
+EXTERNAL xMTRN
+EXTERNAL xMRL
+EXTERNAL xMRR
+EXTERNAL xMSUM
+EXTERNAL xMPROD
+
+(Internal Commands)
+EXTERNAL iarr
+EXTERNAL rdisp
+EXTERNAL ldisp
+EXTERNAL ones
+EXTERNAL zeros
+EXTERNAL ckdim
+EXTERNAL \->2d
+EXTERNAL LEN
+EXTERNAL FLIP
+EXTERNAL FFLIP
+EXTERNAL errf2
+EXTERNAL errf
+EXTERNAL min
+EXTERNAL max
+EXTERNAL MCOMP
+EXTERNAL rplot
+EXTERNAL cplot
+EXTERNAL xyrng
+EXTERNAL ddchs
+EXTERNAL get
+EXTERNAL rsinc
+EXTERNAL csinc
+EXTERNAL chk2
+EXTERNAL iconv
+EXTERNAL mplus
+EXTERNAL mcplus
+EXTERNAL plus
+EXTERNAL minus%
+EXTERNAL minusc%
+EXTERNAL %minus
+EXTERNAL cminus
+EXTERNAL m%-
+EXTERNAL mc%-
+EXTERNAL mult
+EXTERNAL div1
+EXTERNAL div
+EXTERNAL fft2
+EXTERNAL fftc
+EXTERNAL dft
+EXTERNAL isscalar
+EXTERNAL isrvec
+EXTERNAL iscvec
+EXTERNAL isarray
+EXTERNAL mtxelm
+EXTERNAL frr
+EXTERNAL frl
+EXTERNAL msum
+EXTERNAL mprod
+EXTERNAL cconv
+
+(For debugging)
+EXTERNAL dbreak
+
+LABEL MCnfg
+::
+ 837 TOSRRP
+;
+(
+* IARR
+* Create incremented array
+* %s %i %f \-> []
+* %s %f \-> []
+)
+NIBB 3 000
+sNAME IARR IARR
+::
+ CK2&Dispatch
+ 3REAL
+ ::
+ THREE NDUP ROT
+ %- SWAP %/ %0>
+ NOT_IT SETSIZEERR
+ iarr
+ ;
+ 2REAL
+ ::
+ %1 SWAP
+ IARR
+ ;
+;
+
+(
+* ONES
+* Create array of %1
+* %c \-> []
+* {%r %c} \-> []
+)
+NIBB 3 000
+sNAME ONES ONES
+::
+ CK1&Dispatch
+ ONE
+ ::
+ rdisp
+ ones
+ ;
+ FIVE
+ ::
+ ldisp
+ ones
+ ;
+;
+
+(
+* ZEROS
+* Create array of %0
+* %c \-> []
+* {%r %c} \-> []
+)
+NIBB 1 8
+sNAME ZEROS ZEROS
+::
+ CK1&Dispatch
+ ONE
+ ::
+ rdisp
+ zeros
+ ;
+ FIVE
+ ::
+ ldisp
+ zeros
+ ;
+;
+
+(
+* \->2D
+* Ensure a matrix is 2-D
+* [1-D] \-> [2-D]
+* [2-D] \-> [2-D]
+)
+NIBB 1 8
+sNAME \->2D \->2D
+::
+ CK1&Dispatch FOUR
+ \->2d
+;
+
+(
+* LENGTH
+* Size of largest dimension of
+* an array
+* [] \-> %
+)
+NIBB 1 8
+sNAME LENGTH LENGTH
+::
+ CK1&Dispatch FOUR
+ LEN
+;
+
+(
+* FLIPLR
+* Exchange all columns of
+* an array. A different algorithm
+* is used when the array is
+* 1xN and is ~10x faster
+* [] \-> []
+)
+NIBB 1 8
+sNAME FLIPLR FLIPLR
+::
+ CK1&Dispatch FOUR
+ ::
+ iscvec
+ case errf2
+ FLIP
+ ;
+;
+
+(
+* FLIPUD
+* Equivalent to TRN FLIPLR TRN
+* [] \-> []
+)
+NIBB 1 8
+sNAME FLIPUD FLIPUD
+::
+ CK1&Dispatch FOUR
+ ::
+ isrvec
+ case errf2
+ MATTRN FLIP MATTRN
+ ;
+;
+
+(
+* MTXELM
+* Apply a program or an
+* equation to each element
+* of an array
+* [] :: \-> []'
+* [] SYMB \-> []'
+)
+NIBB 1 8
+sNAME MTXELM MTXELM
+::
+ CK2&Dispatch SIXTYFOUR
+ ::
+ DUPTYPESYMB?
+ IT
+ ::
+ DUP FINDVAR
+ SWAP
+ INNERCOMP DUP
+CODE
+ GOSBVL =POP#
+ GOSBVL =SAVPTR
+ B=A A
+ B=-B A
+ D1=D1+ 5
+ LA(5) =DOIDNT
+- C=DAT1 A
+ CD1EX
+ D=C A
+ C=DAT1 A
+ ?A#C A
+ GOYES +
+ LC(5) =DOLAM
+ DAT1=C A
++ C=D A
+ CD1EX
+ D1=D1+ 5
+ B=B+1 A
+ GONC -
+ GOVLNG =GETPTRLOOP
+ENDCODE
+ SYMBN
+ ' x<< SWAP
+ ' xALG-> SWAP
+ 4ROLL
+ DUPLENCOMP
+ ONE #> case
+ ::
+ DROP SWAPDROP SWAPDROP
+ DO>STR palparse DROP
+ #103 DO#EXIT
+ ;
+ ONE NTHCOMPDROP
+CODE
+ GOSBVL =SAVPTR
+ A=DAT1 A
+ D1=A
+ LA(5) =DOLAM
+ DAT1=A A
+ GOVLNG =GETPTRLOOP
+ENDCODE
+ SWAP
+ ' x>>
+ FIVE ::N
+ ;
+ DUPTYPECOL?
+ NcaseTYPEERR
+ DEPTH #2-
+ ' NULLLAM DUPDUP THREE
+ DOBIND
+ 3GETLAM TYPERARRY? ITE %1 C%1
+ 2GETLAM
+ ERRSET
+ ::
+ EVAL
+ ;
+ ERRTRAP
+ ::
+ ERROR@ DUP # 201 #=
+ SWAP # 202 #= OR ITE errf
+ ::
+ 3GETLAM 2GETLAM ABND
+ AtUserStack ERRJMP
+ ;
+ ;
+ DEPTH #1-
+ 1GETLAM #= ?SKIP
+ ::
+ DROP DEPTH 1GETLAM #-
+ NDROP errf
+ ;
+ DUPTYPEREAL? SWAP
+ TYPECMP? OR ?SKIP errf
+ 3GETLAM 2GETLAM
+ ABND
+ mtxelm
+ ;
+;
+
+(
+* MMIN
+* Columnwise minimum of an array
+* [] \-> %
+)
+NIBB 1 8
+sNAME MMIN MMIN
+::
+ CK1&Dispatch FOUR
+ min
+;
+
+(
+* MMAX
+* Columnwise maximum of an array
+* [] \-> %
+)
+NIBB 1 8
+sNAME MMAX MMAX
+::
+ CK1&Dispatch FOUR
+ max
+;
+
+(
+* MPLOT
+* Plots the columns of an array
+* in the same manner as Matlab's
+* plot routine.
+* If the array is real:
+* if Nx1 plots the array vs the
+* index
+* if Nx2 plots column 2 vs
+* column 1
+* if NxM plots column 2 vs
+* column 1, column 3 vs column
+* 1, etc
+* If complex:
+* for each column plots imag
+* vs real
+* [] \->
+)
+NIBB 1 8
+sNAME MPLOT MPLOT
+::
+ CK1&Dispatch FOUR
+ ::
+ DUP MDIMS
+ NOTcasedrop errf2
+ DROP #1=case errf2
+ DUP TYPECARRY?
+ case cplot
+ 1LAMBIND
+ 1GETLAM MDIMSDROP SWAPDROP
+ ::
+ ONE #=casedrop
+ ::
+ %1 %1 1GETLAM LEN
+ iarr
+ MATTRN 1GETLAM
+ %2 xCOL+ 1PUTLAM
+ rplot
+ ;
+ TWO #=casedrop rplot
+ ONE_DO
+ 1GETLAM %1 xCOL-
+ \->2d MATTRN SWAP
+ INDEX@ UNCOERCE
+ xCOL- SWAPDROP
+ \->2d MATTRN MATR>C
+ LOOP
+ 1GETLAM MDIMSDROP
+ SWAPDROP #1-
+ ONE_DO
+ %1 xCOL+
+ LOOP
+ cplot
+ ;
+ ABND
+ ;
+;
+
+(
+* MFFT
+* The fast fourier transform
+* of a vector. If the length
+* is a power of 2, a fast
+* radix 2 algorithm is used.
+* If the length is factorizeable,
+* a mixed radix algorithm is
+* used. If the length is
+* prime, the transform is
+* calculated from the definition
+* [] \-> []'
+)
+NIBB 1 8
+sNAME MFFT MFFT
+::
+ CK1&Dispatch FOUR
+ ::
+ isarray case errf2
+ DUP LEN COERCE
+ #1= ?SEMI
+ DUP LEN COERCE
+ TWO #=casedrop
+ ::
+ DOARRY> UNROT
+ 2DUP DUPTYPEREAL?
+ ITE
+ ::
+ %+ UNROT %-
+ ;
+ ::
+ C%C+C UNROT C%C-C
+ ;
+ ROT XEQ>ARRAY
+ ;
+ UNCOERCE
+ %LN %2 %LN %/ %FP
+ %0= case xFFT
+ dft
+ ;
+;
+
+(
+* FILTER
+* An implementation of an
+* FIR filter and an IIR
+* filter. Uses the proper
+* filter type automaticaly.
+* [] [] [] \-> [] IIR
+* [] [] % \-> [] FIR
+)
+NIBB 1 8
+sNAME FILTER FILTER
+::
+ CK3&Dispatch
+ # 441
+ ::
+
+ ;
+ # 444
+ ::
+
+ ;
+;
+
+(
+* CONV
+* Convolution and polynomial
+* multiplication
+* [] [] \-> []
+)
+NIBB 1 8
+sNAME CONV CONV
+::
+ CK2&Dispatch SIXTYEIGHT
+ ::
+ chk2
+ DUP ARSIZE 3PICK ARSIZE
+ #> IT SWAP FLIP
+ iconv
+ ;
+;
+
+(
+* CCONV
+* Circular convolution
+* [] [] \-> []
+)
+NIBB 1 8
+sNAME CCONV CCONV
+::
+ CK2&Dispatch # 44
+ ::
+ chk2
+ OVER DIMLIMITS
+ OVER DIMLIMITS
+ EQUAL NOTcase errf2
+ cconv
+ ;
+;
+
+(
+* INTERP
+* Interpolation
+* Works best for periodic
+* signals, but will still
+* work with those that are
+* aperiodic
+* [] % \-> []'
+)
+NIBB 1 8
+sNAME INTERP INTERP
+::
+ CK2&Dispatch #41
+ ::
+ DUP %1 %> OVER
+ %FP %0= AND
+ ?SKIP SETSIZEERR
+ OVER isscalar SWAP
+ isarray ROT OR
+ casedrop errf2
+ CKRARRY DROP
+ OVER MDIMS IT #*
+ OVER COERCE #*
+ 3PICK MDIMS ITE
+ ::
+ DROP #1= ITE ONESWAP ONE
+ TWO{}N
+ ;
+ ::
+ DROP ONE{}N
+ ;
+ 3PICKSWAP MATREDIM
+ %0 MATCON
+ 3PICK LEN
+ { LAM arry LAM mf
+ LAM outarry LAM N }
+ BIND
+ LAM outarry LEN COERCE
+ #1+_ONE_DO
+ %0 LAM N COERCE
+ ZERO_DO
+ INDEX@ #1+ LAM arry
+ GETATELN DROP
+ %PI INDEX@ UNCOERCE
+ JINDEX@ UNCOERCE
+ %1- LAM mf %/ %-
+ %* rsinc %* %+
+ LOOP
+ LAM outarry SWAP INDEX@
+ PUTREALEL
+ ' LAM outarry STO
+ LOOP
+ LAM outarry
+ ABND
+ ;
+;
+
+(
+* MPLUS
+* Element-wise addition
+* [] [] \-> []
+* [] % \-> []
+* % [] \-> []
+* [] C% \-> []
+* C% [] \-> []
+)
+NIBB 3 000
+sNAME MPLUS MPLUS
+::
+ CK2&Dispatch
+ # 41 mplus
+ # 42 mcplus
+ # 44 MAT+
+ TWENTY
+ ::
+ SWAP mplus
+ ;
+ THIRTYSIX
+ ::
+ SWAP mcplus
+ ;
+;
+
+(
+* MMINUS
+* Element-wise subtraction
+* Stack same as for MPLUS
+)
+NIBB 3 000
+sNAME MMINUS MMINUS
+::
+ CK2&Dispatch
+ # 41 minus%
+ # 42 minusc%
+ TWENTY %minus
+ THIRTYSIX cminus
+ # 44 MAT-
+;
+
+(
+* MMULT
+* Element-wise multiplication
+* Stack same as for MPLUS
+)
+NIBB 3 000
+sNAME MMULT MMULT
+::
+ CK2&Dispatch
+ # 41 MATFLOAT*
+ # 42 MATFLOAT*
+ TWENTY MATFLOAT*
+ THIRTYSIX MATFLOAT*
+ # 44 mult
+;
+
+(
+* MDIV
+* Element-wise division
+* Stack same as for MPLUS
+)
+NIBB 3 000
+sNAME MDIV MDIV
+::
+ CK2&Dispatch
+ # 41 MATFLOAT/
+ # 42 MATFLOAT/
+ TWENTY div1
+ THIRTYSIX div1
+ # 44 div
+;
+
+(
+* SINC
+* sin(x)/x
+* % \-> %'
+* C% \-> C%'
+* [] \-> []'
+)
+NIBB 3 000
+sNAME SINC SINC
+::
+ CK1&Dispatch
+ ONE rsinc
+ TWO csinc
+ FOUR
+ ::
+ ' ::
+ x<< ROMPTR 345 14 x>>
+ ;
+ mtxelm
+ ;
+;
+
+(
+* MTRN
+* Same as TRN except for
+* complex arrays, does not
+* take the complex conjugate
+)
+NIBB 1 8
+sNAME MTRN MTRN
+::
+ CK1&Dispatch
+ FOUR
+ ::
+ ckdim NOTcase errf2
+ MATTRN
+ MATCONJ
+ ;
+;
+
+(
+* MRL
+* Circular matrix rotation.
+* MRL rotates a vector left
+* the number of elements
+* specified.
+* [] % \-> []
+)
+NIBB 1 8
+sNAME MRL MRL
+::
+ CK2&Dispatch # 41
+ ::
+ SWAP \->2d SWAP
+ COERCE
+ frl
+ ;
+;
+
+(
+* MRR
+* Circular matrix rotation.
+* Rotates a matrix right the
+* number of elements specified
+* [] % \-> []
+)
+NIBB 1 8
+sNAME MRR MRR
+::
+ CK2&Dispatch # 41
+ ::
+ SWAP \->2d SWAP
+ COERCE
+ frr
+ ;
+;
+
+(
+* MSUM
+* The sum of all of the elements
+* in an array
+* [%] \-> %
+* [C%] \-> C%
+)
+NIBB 1 8
+sNAME MSUM MSUM
+::
+ CK1&Dispatch FOUR
+ msum
+;
+
+(
+* MPROD
+* The product of all of the
+* elements of an array.
+* Stack same as for MSUM
+)
+NIBB 1 8
+sNAME MPROD MPROD
+::
+ CK1&Dispatch FOUR
+ mprod
+;
+
+NULLNAME iarr
+::
+ TOTEMPOB ROT
+ TOTEMPOB ROT
+ TOTEMPOB ROT
+ DUP 4PICK %MAX
+ %2 %* % 1E-11 %*
+ OVER5PICK %- %SGN
+ 5PICK 5PICK 5PICK ROTSWAP
+ %- SWAP %/ %ABS %0
+ RNDXY 5PICK OVER %*
+ 7PICK %+ 5PICK %-
+ 4PICK %> IT %1-
+ 5PICK OVER %* 7PICK
+ %+ ROT OVER 6PICK
+ %- %* 4ROLL %CHS
+ %> ITE DROPSWAP ROTDROP
+ SWAP COERCE DUP#1+
+ ONESWAP TWO{}N %0
+ MAKEARRY SWAP
+CODE
+ GOSBVL =POP#
+ GOSBVL =SAVPTR
+ C=A A
+ RSTK=C
+ CSRB.F A
+ RSTK=C
+ D1=D1+ 5
+ C=DAT1 A
+ CD1EX
+ D1=D1+ 5
+ A=DAT1 W
+ R4=A
+ D1=C
+ D1=D1+ 5
+ C=DAT1 A
+ CD1EX
+ D1=D1+ 5
+ A=DAT1 W
+ R3=A
+ D1=C
+ D1=D1+ 5
+ C=DAT1 A
+ CD1EX
+ D1=D1+ 5
+ A=DAT1 W
+ R2=A
+ D1=C
+ D1=D1- 15
+ A=DAT1 A
+ D1=A
+ D1=D1+ 30
+ C=RSTK
+- RSTK=C
+ A=0 W
+ A=C A
+ GOSBVL =HXDCW
+ GOSBVL =FLOAT
+ C=R3
+ GOSBVL =SPLTAC
+ GOSBVL =MULTF
+ GOSBVL =STAB0
+ A=R4
+ GOSBVL =SPLITA
+ GOSBVL =XYEX
+ GOSBVL =RCAB0
+ A=-A-1 S
+ GOSBVL =ADDF
+ GOSBVL =PACK
+ SETHEX
+ C=RSTK
+ D=C A
+ C=RSTK
+ RSTK=C
+ CDEX A
+ RSTK=C
+ CDEX A
+ C=C-D A
+ CSL A
+ D=C A
+ CD1EX
+ CDEX A
+ C=C+D A
+ D1=C
+ DAT1=A W
+ C=D A
+ D1=C
+ A=R2
+ GOSBVL =SPLITA
+ GOSBVL =XYEX
+ GOSBVL =RCAB0
+ GOSBVL =ADDF
+ GOSBVL =PACK
+ SETHEX
+ C=RSTK
+ RSTK=C
+ CSL A
+ D=C A
+ CD1EX
+ CDEX A
+ C=C+D A
+ D1=C
+ DAT1=A W
+ C=D A
+ D1=C
+ C=RSTK
+ C=C-1 A
+ GOC +
+ GOTO -
++ C=RSTK
+ GOVLNG =GETPTRLOOP
+ENDCODE
+ DUP LEN COERCEDUP
+ #1- ZERO #> SWAP
+ TWO #/ SWAPDROP #0=
+ AND IT
+ ::
+ 4PICK 3PICK %+ %2 %/
+ OVER LEN COERCE #2/
+ PUTEL
+ ;
+ 4UNROLL THREE NDROP
+;
+
+NULLNAME rdisp
+::
+ DUP %1 %>=
+ NcaseSIZEERR
+ COERCE ONESWAP TWO{}N
+;
+
+NULLNAME ldisp
+::
+ DUPLENCOMP TWO #<> caseSIZEERR
+ INCOMPDROP DUPTYPEREAL? 3PICK
+ TYPEREAL? AND ?SKIP
+ ::
+ TWO{}N SETSIZEERR
+ ;
+ DUP %1 %>= 3PICK %1 %>= AND
+ ?SKIP
+ ::
+ TWO{}N SETSIZEERR
+ ;
+ COERCE2 TWO{}N
+;
+
+NULLNAME ones
+::
+ %1 MAKEARRY
+;
+
+NULLNAME zeros
+::
+ %0 MAKEARRY
+;
+
+( [] \-> [] T/F )
+NULLNAME ckdim
+CODE
+ GOSBVL =SAVPTR
+ A=DAT1 A
+ D1=A
+ D1=D1+ 15
+ A=DAT1 A
+ LC(5) 1
+ ?A=C A
+ GOYES +
+ GOVLNG =GPPushTLoop
++ GOVLNG =GPPushFLoop
+ENDCODE
+
+NULLNAME \->2d
+::
+ ckdim
+ ?SEMI
+ FIVE EXPAND
+CODE
+ GOSBVL =SAVPTR
+ A=DAT1 A
+ D1=A
+ D1=D1+ 5
+ A=DAT1 A
+ LC(5) 25
+ A=A-C A
+ C=A A
+ D1=D1+ 20
+ AD1EX
+ A=A+C A
+ D1=A
+ D0=A
+ D1=D1+ 5
+ GOSBVL =MOVEUP
+ D0=D0- 10
+ LA(5) 2
+ DAT0=A A
+ D0=D0+ 5
+ A=DAT0 A
+ LC(5) 1
+ DAT0=C A
+ D0=D0+ 5
+ DAT0=A A
+ GOVLNG =GETPTRLOOP
+ENDCODE
+;
+
+NULLNAME LEN
+::
+ MDIMS IT ::
+ 2DUP #<
+ ITE SWAPDROP DROP
+ ;
+ UNCOERCE
+;
+
+NULLNAME FLIP
+::
+ TOTEMPOB
+ isscalar case errf2
+ isrvec
+ case FFLIP
+ DUP MDIMSDROP SWAPDROP
+ UNCOERCE DUP %1
+ { LAM H LAM L }
+ BIND
+ %2 %/ %0 RNDXY %1 SWAP
+ xSTART
+ LAM H LAM L xCSWP
+ %1 ' LAM L xSTO+
+ ' LAM H %1 xSTO-
+ xNEXT
+ ABND
+;
+
+NULLNAME FFLIP
+CODE
+ GOSBVL =SAVPTR
+ A=DAT1 A
+ D1=A
+ D1=D1+ 5
+ A=DAT1 A
+ LC(5) 20
+ A=A-C A
+ LC(5) =DOREAL
+ D=C A
+ D1=D1+ 5
+ C=DAT1 A
+ ST=0 0
+ ST=0 1
+ ?C=D A
+ GOYES +
+ ST=1 1
++ D1=D1+ 5
+ C=DAT1 A
+ D1=D1+ 10
+ C=C-1 A
+ C=C-1 A
+ GOC +
+ ST=1 0
+ A=A-CON A,5
+ D1=D1+ 5
++ CD1EX
+ D1=C
+ C=C+A A
+ D0=C
+ D0=D0- 16
+ ASR A
+ ASRB.F A
+ ?ST=0 1
+ GOYES +
+ ASRB.F A
+ D0=D0- 16
++ B=A A
+ B=-B A
+- A=DAT1 W
+ C=DAT0 W
+ DAT1=C W
+ DAT0=A W
+ ?ST=0 1
+ GOYES +
+ D1=D1+ 16
+ D0=D0+ 16
+ A=DAT1 W
+ C=DAT0 W
+ DAT1=C W
+ DAT0=A W
+ D0=D0- 32
++ D1=D1+ 16
+ D0=D0- 16
+ B=B+1 A
+ GONC -
+ GOVLNG =GETPTRLOOP
+ENDCODE
+
+NULLNAME errf2
+::
+ CK0NOLASTWD # 501 ERROROUT
+;
+
+NULLNAME errf
+::
+ 3GETLAM 2GETLAM
+ AtUserStack
+ ABND
+ # 103 ERROROUT
+;
+
+NULLNAME min
+::
+ %MAXREAL ' %<
+ TWO{}N
+ MCOMP
+;
+
+NULLNAME max
+::
+ %MINREAL ' %>
+ TWO{}N
+ MCOMP
+;
+
+NULLNAME MCOMP
+::
+ SWAPDUP TYPECARRY?
+ IT
+ ::
+ SWAPDROP SETSIZEERR
+ ;
+ \->2d NULLLAM DUPTWO
+ DOBIND
+ 1GETLAM MDIMSDROP
+ SWAPDROP
+ #1+_ONE_DO
+ 2GETLAM ONE NTHCOMPDROP
+ 1GETLAM MDIMSDROP DROP
+ #1+_ONE_DO
+ JINDEX@ INDEX@ #1-
+ 1GETLAM MDIMSDROP
+ SWAPDROP #* #+
+ 1GETLAM GETATELN
+ DROP 2DUP 2GETLAM
+ TWO NTHCOMPDROP EVAL
+ ITE DROP SWAPDROP
+ LOOP
+ LOOP
+ ABND
+;
+
+NULLNAME rplot
+::
+ DOERASE
+ 1GETLAM DUP min ROT max
+ ROTDUP %0>
+ ddchs
+ SWAPDUP %0<
+ ddchs
+ PUTYMAX PUTYMIN
+ DUP %0<
+ ddchs
+ SWAPDUP %0>
+ ddchs
+ PUTXMIN PUTXMAX
+ GDISPCENTER
+ TURNMENUOFF
+ 1GETLAM MDIMSDROP DROP
+ ONE_DO
+ INDEX@ #2* #1-
+ get
+ INDEX@ #2*
+ get
+ %>C%
+ INDEX@ #1+ #2* #1-
+ get
+ INDEX@ #1+ #2*
+ get
+ %>C%
+ xLINE
+ LOOP
+ xDRAX
+ xPICTURE
+;
+
+NULLNAME cplot
+::
+ DOERASE
+ DUP MDIMSDROP SWAPDROP
+ #1=case
+ ::
+ MATC>R %2 xCOL+
+ 1LAMBIND
+ rplot
+ ABND
+ ;
+ { LAM arry }
+ BIND
+ LAM arry MATC>R
+ xyrng
+ PUTYMAX PUTYMIN
+ xyrng
+ PUTXMAX PUTXMIN
+ GDISPCENTER
+ TURNMENUOFF
+ LAM arry MDIMSDROP SWAPDROP
+ #1+_ONE_DO
+ LAM arry INDEX@ UNCOERCE
+ xCOL- SWAPDROP
+ { LAM ar1 }
+ BIND
+ LAM ar1 MDIMSDROP
+ ONE_DO
+ INDEX@ LAM ar1
+ GETATELN DROP
+ INDEX@ #1+ LAM ar1
+ GETATELN DROP
+ xLINE
+ LOOP
+ ABND
+ LOOP
+ ABND
+ xDRAX
+ xPICTURE
+;
+
+NULLNAME xyrng
+::
+ DUP max
+ LAM arry MDIMSDROP SWAPDROP
+ ONE_DO
+ 2DUP %> ITE DROP SWAPDROP
+ LOOP
+ SWAP min
+ LAM arry MDIMSDROP SWAPDROP
+ ONE_DO
+ 2DUP %< ITE DROP SWAPDROP
+ LOOP
+ DUP %0> ddchs
+ SWAPDUP %0< ddchs
+;
+
+NULLNAME ddchs
+::
+ IT
+ ::
+ DROPDUP %20 %/
+ %CHS
+ ;
+;
+
+NULLNAME get
+::
+ 1GETLAM GETATELN DROP
+;
+
+NULLNAME rsinc
+::
+ %0=case
+ ::
+ DROP %1
+ ;
+ DUP %SIN SWAP %/
+;
+
+NULLNAME csinc
+::
+ DUP C%0 EQUALcase
+ ::
+ DROP C%1
+ ;
+ DUP C%SIN SWAP PTR 51EC8
+;
+
+NULLNAME chk2
+::
+ CKRARRY SWAP
+ CKRARRY SWAP
+ isscalar SWAP isarray
+ ROT OR ROT isscalar
+ SWAP isarray ROT OR
+ ROT ORcase errf2
+ \->2d SWAP \->2d
+ iscvec IT MATTRN
+ SWAP iscvec IT MATTRN
+ SWAP
+;
+
+NULLNAME iconv
+::
+ DUP LEN
+ ROTSWAP
+ COERCE DUP ROTSWAP
+ #1- SWAPCKREF
+ DUP MDIMSDROP DROP
+ #1<> IT MATTRN
+ OVER SIXTEEN #*
+ EXPAND SWAP
+CODE
+ GOSBVL =POP#
+ GOSBVL =SAVPTR
+ C=DAT1 A
+ D1=C
+ D1=D1+ 5
+ C=DAT1 A
+ B=C A
+ D1=D1+ 20
+ C=DAT1 A
+ C=C+A A
+ DAT1=C A
+ D1=D1+ 5
+ ASL A
+ B=B-CON A,16
+ B=B-CON A,9
+ ABEX A
+ A=A-B A
+ C=A A
+ D=C A
+ A=A-CON A,16
+ CD1EX
+ C=C+A A
+ CD1EX
+ DSR A
+Moveel A=DAT1 W
+ C=0 W
+ DAT1=C W
+ CD1EX
+ C=C+B A
+ CD1EX
+ DAT1=A W
+ CD1EX
+ C=C-B A
+ CD1EX
+ D1=D1- 16
+ D=D-1 A
+ ?D#0 A
+ GOYES Moveel
+ GOVLNG =GETPTRLOOP
+ENDCODE
+ DUP LEN COERCE #1-
+ ROT#+ ONESWAP
+ TWO{}N MATREDIM
+ ONE OVERARSIZE
+ 4PICK ARSIZE #1- #-
+ TWO{}N %0 MAKEARRY
+ NULLLAM THREE NDUPN
+ DOBIND
+ 1GETLAM ARSIZE
+ #1+_ONE_DO
+ %%0 3GETLAM ARSIZE
+ #1+_ONE_DO
+ INDEX@ 3GETLAM
+ GETATELN DROP %>%%
+ JINDEX@ #1-
+ INDEX@ #+
+ 2GETLAM GETATELN DROP
+ %>%% %%* %%+
+ LOOP
+ %%>% 1GETLAM SWAP
+ INDEX@ PUTEL
+ 1PUTLAM
+ LOOP
+ 1GETLAM
+ ABND
+;
+
+NULLNAME mplus
+::
+ SWAPDUP
+ TYPECARRY?
+ ITE
+ ::
+ SWAP Re>C%
+ ;
+ SWAP
+ plus
+;
+
+NULLNAME mcplus
+::
+ SWAPDUP
+ TYPERARRY?
+ IT
+ ::
+ DUP %0 MATCON
+ MATR>C
+ ;
+ SWAP
+ plus
+;
+
+NULLNAME plus
+::
+ OVERSWAP
+ MATCON
+ x+
+;
+
+NULLNAME minus%
+::
+ %CHS
+ m%-
+;
+
+NULLNAME minusc%
+::
+ C%CHS
+ mc%-
+;
+
+NULLNAME %minus
+::
+ PTR 35DEB
+ SWAP m%-
+;
+
+NULLNAME cminus
+::
+ PTR 35DEB
+ SWAP mc%-
+;
+
+NULLNAME m%-
+::
+ SWAPDUP
+ TYPECARRY?
+ ITE
+ ::
+ SWAP
+ Re>C%
+ ;
+ SWAP
+ plus
+;
+
+NULLNAME mc%-
+::
+ SWAPDUP TYPERARRY?
+ IT
+ ::
+ DUP %0 MATCON
+ MATR>C
+ ;
+ SWAP plus
+;
+
+NULLNAME mult
+::
+ SWAPCKREF
+ SWAPCKREF
+ OVER \->2d DIMLIMITS
+ OVER \->2d DIMLIMITS
+ EQUAL NOTcase errf2
+ \->2d SWAP \->2d
+ OVER TYPECARRY?
+ OVER TYPECARRY?
+ OR
+ ITE
+ ::
+ DUP TYPECARRY?
+ IT SWAP
+ DUP TYPECARRY?
+ ?SKIP
+ ::
+ DUP %0 MATCON
+ MATR>C
+ ;
+ OVERARSIZE
+CODE
+ GOSBVL =POP#
+ GOSBVL =SAVPTR
+ C=A A
+ A=DAT1 A
+ D0=A
+ D1=D1+ 5
+ A=DAT1 A
+ D1=A
+ D0=D0+ 30
+ D1=D1+ 30
+calcp RSTK=C
+ A=DAT1 W
+ R4=A
+ D1=D1+ 16
+ A=DAT1 W
+ R1=A
+ D1=D1- 16
+ A=DAT0 W
+ R3=A
+ D0=D0+ 16
+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
+ SETHEX
+ C=RSTK
+ RSTK=C
+ A=C A
+ GOSUB getn
+ ?A=C A
+ GOYES +
+ C=C+1 A
+ GOSUB putn
+ GOTO rnloop
++ GOSBVL =D1=DSKTOP
+ D1=D1+ 5
+ A=DAT1 A
+ GOSUB getk
+ CSL A
+ C=C+C A
+ A=A+C A
+ LC(5) 30
+ A=A+C A
+ D1=A
+ GOSUB D0\->R0
+ A=DAT0 W
+ D0=D0+ 16
+ C=DAT0 W
+ B=C W
+ SETDEC
+ GOSBVL =PACK
+ SETHEX
+ DAT1=A W
+ D1=D1+ 16
+ A=R2
+ C=R3
+ B=C W
+ SETDEC
+ GOSBVL =PACK
+ SETHEX
+ ?A=0 W
+ GOYES +
+ ST=1 0
++ DAT1=A W
+ C=RSTK
+ RSTK=C
+ A=C A
+ GOSUB getk
+ ?A=C A
+ GOYES +
+ C=C+1 A
+ GOSUB putk
+ C=0 A
+ GOSUB putn
+ GOTO rkloop
++ C=RSTK
+ ?ST=0 0
+ GOYES +
+ GOVLNG =GPPushFLoop
++ GOVLNG =GPPushTLoop
+Cmp GOSBVL =SAVPTR
+
+ GOVLNG =GPPushTLoop
+
+GetInd P= 0
+ A=0 W
+ A=C A
+ GOSBVL =HXDCW
+ GOVLNG =FLOAT
+
+pbuff P= 0
+ LC(5) 42
+ D=C A
+ GOSBVL =D1=DSKTOP
+ C=DAT1 A
+ C=C+D A
+ D1=C
+ RTN
+
+x*W GOSUB pbuff
+ LC(5) 32
+ D=C A
+ CD1EX
+ C=C+D A
+ D1=C
+ DAT1=A W
+ D1=D1+ 16
+ C=B W
+ DAT1=C W
+ GOSBVL =D1=DSKTOP
+ D1=D1+ 10
+ A=DAT1 A
+ GOSUB getn
+ CSL A
+ A=A+C A
+ LC(5) 30
+ A=A+C A
+ D1=A
+ A=DAT1 W
+ SETDEC
+ GOSBVL =SPLITA
+ SETHEX
+ GOSUB pbuff
+ LC(5) 48
+ D=C A
+ CD1EX
+ C=C+D A
+ D1=C
+ C=DAT1 W
+ D=C W
+ D1=D1- 16
+ C=DAT1 W
+ SETDEC
+ GOSBVL =MULTF
+ P= 0
+ RTN
+
+getn C=R4
+ RTN
+
+putn R4=C
+ RTN
+
+getk C=R4
+ CSR W
+ CSR W
+ CSR W
+ CSR W
+ CSR W
+ SB=0
+ RTN
+
+putk CSL W
+ CSL W
+ CSL W
+ CSL W
+ CSL W
+ SB=0
+ C=R4.F A
+ R4=C
+ RTN
+
+D0\->R0 R0=A
+ R1=C
+ GOSBVL =D0=DSKTOP
+ A=DAT0 A
+ LC(5) 106
+ A=A+C A
+ D0=A
+ A=R0
+ C=R1
+ RTN
+
+D0\->R1 R0=A
+ R1=C
+ GOSBVL =D0=DSKTOP
+ A=DAT0 A
+ LC(5) 122
+ A=A+C A
+ D0=A
+ A=R0
+ C=R1
+ RTN
+ENDCODE
+ SWAPDROP ROTDROP
+ IT xRE
+;
+
+NULLNAME isscalar
+::
+ DUP MDIMS ITE
+ ::
+ #1= SWAP #1= AND
+ ;
+ #1=
+;
+
+NULLNAME isrvec
+::
+ DUP MDIMS ITE
+ ::
+ DROP #1=
+ ;
+ DROPTRUE
+;
+
+NULLNAME iscvec
+::
+ DUP MDIMS ITE
+ ::
+ SWAPDROP #1=
+ ;
+ DROPFALSE
+;
+
+NULLNAME isarray
+::
+ DUP MDIMS ITE
+ ::
+ #1<> SWAP #1<> AND
+ ;
+ DROPFALSE
+;
+
+NULLNAME mtxelm
+::
+ SWAP TOTEMPOB SWAP
+ INNERCOMP
+ '
+ ::
+ SWITCHFLOATS
+ NOP
+ NOP
+ %%>%
+ C%%>C%
+ ;
+ OVER #1+UNROLL
+ #1+ ::N
+ SWAP
+ DOARRYPRG1
+;
+
+NULLNAME frr
+::
+ SWAP TOTEMPOB SWAP
+ DUP #0=case DROP
+CODE
+ GOSBVL =POP#
+ GOSBVL =SAVPTR
+ C=A A
+ A=DAT1 A
+ D1=A
+ D1=D1+ 5
+ A=DAT1 A
+ D1=D1+ 5
+ D=C A
+ D=-D A
+ LC(5) 25
+ A=A-C A
+ B=A A
+ LC(5) =DOREAL
+ ST=0 0
+ A=DAT1 A
+ ?A=C A
+ GOYES +
+ ST=1 0
++ D1=D1+ 20
+ LC(5) 16
+ ?ST=0 0
+ GOYES +
+ C=C-CON A,16
++ B=B-C A
+ CD1EX
+ D1=C
+ R0=C
+ C=C+B A
+ R1=C
+ C=C+CON A,16
+ ?ST=0 0
+ GOYES +
+ C=C+CON A,16
++ R2=C
+- C=R1
+ D0=C
+ C=DAT0 W
+ R3=C
+ ?ST=0 0
+ GOYES +
+ D0=D0+ 16
+ C=DAT0 W
+ R4=C
+ D0=D0- 16
++ C=R2
+ D1=C
+ C=B A
+ GOSBVL =MOVEUP
+ C=R0
+ D1=C
+ C=R3
+ DAT1=C W
+ ?ST=0 0
+ GOYES +
+ D1=D1+ 16
+ C=R4
+ DAT1=C W
++ D=D+1 A
+ GONC -
+ GOVLNG =GETPTRLOOP
+ENDCODE
+;
+
+NULLNAME frl
+::
+ OVERARSIZE SWAP #-
+ frr
+;
+
+NULLNAME msum
+::
+ isscalar case
+ ::
+ ONESWAP GETATELN DROP
+ ;
+ \->2d DOARRY> ldisp
+ INCOMPDROP #*
+ OVER TYPEREAL? ITE
+ ::
+ ONE_DO
+ %+
+ LOOP
+ ;
+ ::
+ ONE_DO
+ C%C+C
+ LOOP
+ ;
+;
+
+NULLNAME mprod
+::
+ isscalar case
+ ::
+ ONESWAP GETATELN DROP
+ ;
+ \->2d DOARRY> ldisp
+ INCOMPDROP #*
+ OVER TYPEREAL? ITE
+ ::
+ ONE_DO
+ %*
+ LOOP
+ ;
+ ::
+ ONE_DO
+ C%C*C
+ LOOP
+ ;
+;
+
+NULLNAME cconv
+::
+ DUP DIMLIMITS %0 MAKEARRY
+ NULLLAM THREE NDUPN DOBIND
+ 1GETLAM ARSIZE
+ #1+_ONE_DO
+ 1GETLAM 3GETLAM 2GETLAM
+ mult msum
+ INDEX@ PUTEL 1PUTLAM
+ 2GETLAM ONE frr 2PUTLAM
+ LOOP
+ 1GETABND
+;
+
+NULLNAME dbreak
+::
+ # 123 DO#EXIT
+;
diff --git a/matfun/matfun.txt b/matfun/matfun.txt new file mode 100644 index 0000000..324c11a --- /dev/null +++ b/matfun/matfun.txt @@ -0,0 +1,164 @@ +MATFUN v2 beta 1 +by Jonathan duSaint +jon@wpi.edu +jdusaint@mathworks.com + +Disclaimer: This is a beta release and as such, some bugs +may exist which can cause a severe crash (however unlikely). + +Please email me at either of the above addresses with +suggestions, comments, questions, bug reports, bug fixes, +etc. + +For slightly better documentation, read the source code. All user +level functions are prefixed with a block explaining the +functionality. On Windows, it is best viewed in wordpad, and +on Unix, any editor will work (I use emacs). I don't know about +the Mac (sorry!). + +Matfun is a collection of very useful matrix oriented functions. +Stack diagrams will be shown as: + 3 2 1 -> 3 2 1 +Various symbols are used: +% real number +C% complex number +[] array +:: program + +IARR + %s %i %f -> [] +This program creates an incremented array from %s to %f in +steps of %i. +For example: +0 .1 1 <IARR> -> [[ 0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1 ]] +The stepsize can also be negative: +1 -.1 0 <IARR> -> [[ 1 .9 .8 .7 .6 .5 .4 .3 .2 .1 0 ]] + +->2D +[2d] -> [2d] +[1d] -> [2d] +This program turns a one dimensional vector into a two dimensional +array without changing the elements. If a two dimensional array is +entered, it will be unchanged. + +LENGTH +[] -> % +Returns the length of an array. + +FLIPLR +[] -> []' +Flips an array from left to right. + +FLIPUD +[] -> []' +Flips an array upside down. + +MTXELM +[] :: -> []' +Applies a program to each element of an array. The program should +take one real or complex argument and return one real or +complex argument. Errors for invalid programs. + +MMIN +[] -> % ... % +Returns the smallest element of each column of an array. + +MMAX +[] -> % ... % +Returns the largest element of each column of an array. + +MPLOT +[] -> +This program plots an array columnwise. For an Nx1 real array, +the elements are plotted versus their indices. For an Nx2 +real array, column two is plotted versus column one, For an NxM +real array, columns two through M are plotted individually versus +column one. For an Nx1 complex array, the plot is of imag versus +real. For an NxM complex array, the plot is imag versus real for +each column of the array. + +CONV +[] [] -> []' +Convolution. This program convolves the two arrays with each +other. A practical application of which is polynomial multiplication. For example, the two equations x-1 and x+1 can be represented +by [1 -1] and [1 1]. Convolving these two vectors returns +[1 0 -1], or x^2-1 which is (x-1)(x+1). + +INTERP +[] % -> []' +Interpolation. This program interpolates the input array to +be % times larger. + +MPLUS +[] [] -> [] +[] % -> [] +% [] -> [] +[] C% -> [] +C% [] -> [] +Matrix addition. + +MMINUS +Stack same as MPLUS +Matrix subtraction. + +MMULT +Stack same as for MPLUS +Matrix multiplication. + +MDIV +Stack same as for MPLUS +Matrix division. + +All four of the above commands are element by element operations. + +MTRN +[] -> [] +Matrix transposition, but the complex conjugate is not taken. + +SINC +% -> %' +C% -> C%' +[] -> []' +The sinc function is sin(x)/x. This function find the sinc of +real numbers, complex numbers, and the elements of arrays, real +or complex. + + +New in this beta: +ONES + % -> [] +{ % % } -> [] +Creates a vector of ones + +ZEROS +Same as ones, but creates a vector of zeros. + +CCONV +[] [] -> []' +Circular convolution + +MFFT +[] -> [] +This still has a long way to go before it is fully functional. As +of this release, it only performs the DFT on real vectors. It is, +however, useful for arbitrary length real vectors. + +FILTER +This doesn't do anything yet. Someday it will implement both a FIR +and an IIR filter. + +MRL +[] -> [] +Rotates a vector left one element. + +MRR +[] -> [] +Rotates a vector right one element. + +MSUM +[] -> % +The sum of all of the elements in a matrix. + +MPROD +[] -> % +The product of all of the elements in a matrix. |
