Suggested Matrix Routines For JAMA



I am new to this listserv.

Over the last few years I have developed an extensive library of matrix
routines.
I have used these heavily for all my work with matrix operations.
I developed the source code in a BASIC/PASCAL/C type of language
called Clipper.

This language is not important. The important thing is the functionality
that has been developed within my matrix package which I call a matrix
utility
package.

It functions in a command line type of way like DOS does.
This command structure, however,  can easily be adapted
in a functional or procedural type of calling.

I would love it if someone or "many ones" could implement this in JAMA.
Most of the implementation is simple. But the functionality and the
procedural
benefits are real and tremendous time savers.

I can supply the source code for these routines if any of you guys want it.

- Mike Peralta
peralta_mike@burr-brown.com

The user manual for this package is included in the text below.
Hopefully most of this will cary through the email system.

-------------------------------------------------------------------------------

MATRIX UTILITY SOFTWARE
MAT 1.2

(Dec 16, 1998 )

By Michael O. Peralta


FEATURES
Intuitive Command Structure. Easy To Learn And Use.
Files Are Importable To Most Spreadsheet Software (Excel, Quatro Pro,
etc.).
Automate Repetitive Operations By Using DOS Batch Files.
Easily Interface With User Programs And Data Files.
Matrix Sizes Up To 4096 Rows And 1000 Columns.


GENERAL INFORMATION
This Matrix Utility Software, is implemented as a "Matrix Command Language"
similiar to DOS commands. Each command can be entered at the DOS prompt one
command at a time, or into an ASCII text file as part of a DOS batch file.


GENERAL STRUCTURE

MAT COMMAND ARG1 ARG2 ...

n Every Program Line Starts With MAT (The Root Name of The Executable
Matrix Program).
n The First Word After MAT Is The Command Name.
n Words After The Command Are The Arguments Applicable to the Command Being
Used.
n Generally Every Argument (After The Command Word) Is A File Name. (This
Is True Except
    For The Commands: CREATE, NUMLIST, SCALAR, and STRLIST.)
n Usually Each File Has A DBF (dBase III) Format. For DBF Files Which
Represent Numerical
    Matrices Each Field Type Is A 24 Length Character String, The String
Represents A Numeric
    Value In Scientific Notation. (If a DBF file has numeric fields convert
the fields to character
    type by using the NUM2CHR command.)
n Other File Formats Supported Are The ASCII Text Formats: CSV, SDF, and
TXT. These
    Formats Are Useful For Interfacing With User Programs. (Refer To The
DBF2CSV,
    DBF2SDF, And DBF2TXT Commands.)


LIST OF COMMANDS

COMMAND     DESCRIPTION

ADD         Add Two Matrices
APPEND      Append A Text File To Another
AUTOPRINT   Print Report File Without Confirmation
CALL        Call Batch File Within MAT Program
CHOLESKY    Cholesky (Matrix Square Root) Decomposition
CHR2NUM     Convert DBF With Char Fields To DBF With Numeric Fields
COL2DIAG    Column Vector To Diagonal Matrix
COLAVG      Average Values Down Columns & Assign To Row Vector
COLCORR     Correlation Matrix From Column Data
COLCOUNT    Count The Number Of Columns In A Matrix
COLCOV      Covariance Matrix From Column Data
COLMEDIAN   Get Median Values Down Columns & Assign To Row Vector
COLMULT     Multiply Values Down Columns & Assign To Row Vector
COLNORM     Normalize Matrix For Column Data
COLQUARTILE      Get Quartile Values Down Columns & Assign To Row Vector
COLREPEAT   Repeat Column Vector Specified Times To Form Matrix
COLSORT     Sort Matrix By Specified Column
COLSTDDEV   Std Dev Down Columns & Assign To Row Vector
COLSUM      Sum Values Down Columns & Assign To Row Vector
COLSWAP     Swap Matrix Columns & Assign To New Matrix
COMPLEMENT       Logical Complement Of A Matrix.
COPY        Copy File To Another File
CREATE      Create A New Matrix (Integer Arguments)
CREATE2     Create A New Matrix (File Name Arguments)
CSV2DBF     Convert Comma Separated Variable Text File To DBF File.
DBF2CSV     Convert DBF File To Comma Separated Variable Text File.
DBF2FTC     Convert DBF File To Special 8 Byte Float Char File
DBF2SDF     Copy DBF File Format To SDF File Format
DCOND            Determine Condition Number Of Diagonal Matrix
DELETE      Delete File

COMMAND     DESCRIPTION

DELETECOL   Delete Specified Columns
DELETEROW   Delete Specified Rows
DET         Determinant Of A Matrix
DETDIAG     Determinant Of Diagonal Matrix
DIAG2COL    Diagonal Matrix To Column Vector
DIAG2ROW    Diagonal Matrix To Row Vector
DINV        Matrix Inverse Of A Diagonal Matrix
DMULT            Multiply Diagonal Matrix With General Matrix
DNORM            Matrix Norm Of Diagonal Matrix
DPSEUDOINV       Pseudo-Inverse Of Diagonal Matrix
EABSOLUTE     Take Absolute Value Of All Elements In A Matrix
EARCCOS     Calculate Arc-cosine Value For All Elements In A Matrix
EARCCOSH    Calculate Hyperbolic Arc-cosine For All Elements In A Matrix
EARCSIN     Calculate Arc-sine Value For All Elements In A Matrix
EARCSINH    Calculate Hyperbolic Arc-sine For All Elements In A Matrix
EARCTAN     Calculate Arc-tangent Value For All Elements In A Matrix
EARCTANH    Calculate Hyperbolic Arc-tangent For All Elements In A Matrix
ECOS        Calculate Cosine Value For All Elements In A Matrix
ECOSH            Calculate Hyperbolic Cosine For All Elements In A Matrix
EDIT        To View Or Edit A Matrix (DBF) File
EEXP        Calculate EXP Value For All Elements In A Matrix
EIGENHERM   Eigenvectors And Eigenvalues Of A Hermitian Matrix
EIGENREAL   Eigenvectors And Eigenvalues Of A General Real Matrix
EIGENSYM    Eigenvectors And Eigenvalues Of A Symmetric Real Matrix
EINVERSE    Take The Reciprocal Value Of All Elements In A Matrix
ELOG        Calculate Natural LOG Value For All Elements In A Matrix
ELOG10      Calculate (Base 10) LOG10 Value For All Elements In A Matrix
EMULTIPLY   Multiply All Elements In A Matrix With A Scalar
EPOWER      Take All Elements In A Matrix To A Power
ESIGN            Determine The Sign Of All Elements In A Matrix
ESIN        Calculate Sine Value For All Elements In A Matrix
ESINH            Calculate Hyperbolic Sine For All Elements In A Matrix

COMMAND     DESCRIPTION

ESQRT            Take The Square Root Of All Elements In A Matrix
ESQUARE     Take The Square Of All Elements In A Matrix
ETAN        Calculate Tangent Value For All Elements In A Matrix
ETANH            Calculate Hyperbolic Tangent For All Elements In A Matrix
EXTRACTCOL       Extract Specified Columns To Another Matrix
EXTRACTROW    Extract Specified Rows To Another Matrix
FLDRENAME   Rename Field Names
FFT         Fast Fourier Transform
FTC2DBF     Convert Special 8 Byte Float Char File To DBF File
GE          Are Elements In A Greater Than Or Equal To Elements In B
GT          Are Elements In A Greater Than Elements In B
INVERSE     Inverse Of A Matrix
INVFFT      Inverse Fast Fourier Transform
INVJUXCOL   Inverse Juxtaposition Cols Of A Matrix To Two Matrices
INVJUXROW   Inverse Juxtaposition Rows Of A Matrix To Two Matrices
JOINCOL     Join Columns From Two Matrices To Another
JOINROW     Join Rows From Two Matrices To Another
JUXTACOL    Juxtaposition Cols Of Two Matrices To Another
JUXTAROW    Juxtaposition Rows Of Two Matrices To Another
LDLT        L*D*LT Decomposition Of A Matrix { LT=Transpose(L) }
LE          Are Elements In A Less Than Or Equal To Elements In B
LT          Are Elements In A Less Than Elements In B
LUD         L*U Decomposition Of A Matrix
MASKMAX     Mask Maximum Of Two Matrices
MASKMIN     Mask Minimum Of Two Matrices
MASKMULT    Mask Multiply Two Matrices
MAT2DIAG    Zero All Elements Except Diagonal Elements
MULTD            Multiply General Matrix With A Diagonal Matrix
MULTILIST   List Of Numbers In Interval (Multiple Columns)
MULTIPLY    Multiply Two Matrices
MULTTRAN    Multiply A Matrix With Its Transpose

COMMAND     DESCRIPTION

NUMLIST     List Of Numbers In Interval (Numeric Arguments)
NUMLIST2    List Of Numbers In Interval (File Arguments)
NUM2CHR     Convert DBF With Numeric Fields To DBF With Char Fields
OVERLAY     Overlay A Matrix Onto Another Matrix
PCD         Principal Component Decomposition
PRINT            Print Report File With Confirmation
PSEUDOINV   Pseudo-Inverse Of A Matrix
RANDOM      Create Matrix Of Random Numbers (Uniform, 0 to 1)
RANK        Rank Of A Matrix
RANKDIAG    Rank Of A Diagonal Matrix
RENAME      Rename A File
REPORT      Convert DBF File To Text Report File
ROW2DIAG    Row Vector To Diagonal Matrix
ROWAVG      Average Values Across Rows & Assign To Col Vector
ROWCORR     Correlation Matrix From Row Data
ROWCOUNT    Count The Number Of Rows In A Matrix
ROWMEDIAN   Get Median Values Across Rows & Assign To Col Vector
ROWMULT     Multiply Values Across Rows & Assign To Col Vector
ROWNORM     Normalize Matrix For Row Data
ROWQUARTILE   Get Quartile Values Across Rows & Assign To Col Vector
ROWREPEAT   Repeat Row Vector Specified Times To Form Matrix
ROWSORT     Sort Matrix By Specified Row
ROWSTDDEV   Std Dev Across Rows & Assign To Col Vector
ROWSUM      Sum Values Across Rows & Assign To Col Vector
ROWSWAP     Swap Matrix Rows & Assign To New Matrix
SCALAR      Create 1x1 Matrix & Assign Scalar Value
SCALE            Create A Scale Matrix
SDF2DBF     Copy SDF File Format To DBF File Format
STRLIST     Create List Of Strings
SUBTRACT    Subtract Two Matrices
SVD         Singular Value Decomposition Of A Matrix

COMMAND     DESCRIPTION

TRACE            Trace Of A Matrix
TRANSPOSE   Transpose Of A Matrix
TXT2DBF     Convert TEXT File (24 Data Width) To DBF File Format
WITHINEQ    Are Elements In A within or equal to elements in B & C
WITHINNE    Are Elements In A within (but not equal) to elements in B & C




INTRODUCTION

A couple of examples will demonstrate the steps that typically need to be
taken to perform matrix operations.

Example 1 : Adding Two Matrices

As an example of the typical steps that are taken to use the software, let
us say we wish to add the two matrices

               1    2                    2     3
           A   =    5    0        and    B  =      6    -1
               4    2                    3     3

and assign the result to matrix C .

The steps to perform this are as follows:

(1) Create a 3x2 matrix (3 rows, 2 columns) and call it A.MAT by entering
the following
     statement at the DOS prompt:

MAT  CREATE  3  2  A.MAT

(2) Edit the A.MAT matrix file by entering the following at the DOS prompt:

MAT  EDIT  A.MAT

    At this point a table, similiar to a spreadsheet, is displayed. Enter
the elements of the A
    matrix. Press ESC when done editing.

(3) Create another 3x2 matrix and call it B.MAT

MAT  CREATE  3  2  B.MAT



(4) Edit the B.MAT matrix file
MAT  EDIT  B.MAT

    Enter the values for the B matrix. Press ESC when done editing.

(5) Add A.MAT and B.MAT and assign result to C.MAT with the statement

MAT  ADD  A.MAT  B.MAT  C.MAT

(6) To view/edit the C.MAT matrix file enter

MAT  EDIT  C.MAT

     Be careful not to overwrite data in the cells as it will update the
matrix.

(7) To create a text file report (viewable by any ASCII text editor) enter
the statement

MAT  REPORT  C.MAT  C.RPT

     Here we called the report file C.RPT, but you can name it any other
valid file name.

(8) To print the C.RPT report file enter the statement

MAT  PRINT  C.RPT

    A prompt box will show which pages to print and number of copies to
print. If pages are not
    specified all the pages in the report file will be printed. Select the
Print option if you wish to
    print otherwise select Cancel.


NOTE: Instead of using the EDIT command, to specify matrix element values,
it may be desirable to use the TXT2DBF or CSV2DBF command. This will allow
the user to create matrix values in an ASCII text file (usually with a user
developed program) and then use the TXT2DBF or CSV2DBF command to convert
to MAT's native format, which is the DBF (dBase III) format.


Example 2 : Solving Simultaneous Equations

Say we have the set of simultaneous equations consisting of three equations
and three unknowns (x, y, and z):

x + y + z = 6
x + 4y + 9z = 36
x + 2y + 3z = 14

In matrix form this is represented as:
 A u = w

where
          1    1    1         x                6
     A   =     1    4    9    u   =      y       w  =   36
          1    2    3         z                14


Assuming the matrix A has an inverse, denoted A^-1 , we can premultiply the
expression, A u = w,
by A^-1  to obtain

A^-1 A u = A^-1 w

Since A-1 A = I, the identity matrix, and since any matrix multiplied by
the identity matrix is not changed then  I u = u, and so
u = A-1 w

Hence we can determine u (which contain the values of x, y, and z) by
simply performing a matrix multiplication of A-1  and w.


The steps to perform this, using the matrix software is:

(1) Use the CREATE and EDIT commands to form the 3x1 matrix W.MAT, and the
3x3 matrix,
     A.MAT.

(2) Obtain the inverse of A.MAT, and name it AINV.MAT, by entering

MAT  INVERSE  A.MAT  AINV.MAT

(3) Obtain U.MAT (which will have the values for x, y, and z) by entering

MAT  MULTIPLY  AINV.MAT  W.MAT  U.MAT

(4)  Use the EDIT command to view the U.MAT matrix.




Example 3 : Using Batch Files

Instead of entering commands at the DOS prompt one at a time it may be
convenient to create a batch file. For example, for the operations
described in example 2 we could write the following batch file (created by
using any ASCII "DOS Text" Editor),

                    MAT INVERSE A.MAT AINV.MAT
                    MAT MULTIPLY AINV.MAT W.MAT U.MAT
                    MAT REPORT A.MAT A.RPT
                    MAT REPORT W.MAT W.RPT
                    MAT REPORT U.MAT U.RPT

Let us name this batch file SIM.BAT. Now by simply entering SIM at the DOS
prompt the statements in the SIM.BAT batch file are executed. Notice that
the MAT executable program is loaded each time for each line containing a
MAT statement. To avoid calling up the MAT executable each time, you can
use the MAT CALL command. For the example here that would be done by
entering the following at the DOS prompt:

MAT CALL SIM.BAT

The batch file, SIM.BAT, is read and then executed within the MAT program.
The MAT CALL command is recursive meaning that the batch file (SIM.BAT in
this case) can also contain MAT CALL commands.


(NOTE: More examples are provided after the COMMAND REFERENCE.)



COMMAND REFERENCE

------------------------------------------------------------------------------------------

MAT ADD AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Add Two Matrices.
Let A=AFILE, B=BFILE, C=CFILE. Add matrices A and B and assign to matrix C.
C=A+B.

Example:
          1    2    0              2      3   1
Let    A  =    5    0    3    and   B   =     6    -1   4
          4    2    7              3      3   6

                          3    5    1
Then  C  will be         C   =     11    -1    7
                          7    5   13

Related Command: SUBTRACT

------------------------------------------------------------------------------------------

MAT APPEND AFILE BFILE
Input: AFILE, BFILE   Output: AFILE

Description: Append A Text File To Another
Append text file BFILE at the bottom of text file AFILE.
CAUTION: AFILE is overwritten.

Example:
                      John Doe                                 PH: (555)
444-3333
Let       AFILE  =  123 Main St.      and      BFILE   =     FAX: (555)
444-3332
                      Albany, NY 90013                         www.doe.com

Then AFILE will become
                          John Doe
                         123 Main St.
               AFILE     =    Albany, NY 90013
                         PH: (555) 444-3333
                         FAX: (555) 444-3332
                         www.doe.com

Related Commands: JOINCOL, JOINROW, JUXTACOL, JUXTAROW

------------------------------------------------------------------------------------------

MAT AUTOPRINT AFILE
Input: AFILE

Description: Print Report File Without Confirmation
Print AFILE to system printer. There will be no prompt for the user to
confirm the printing. If it is desired to -- confirm, select specific
pages, or select number of copies -- use the PRINT command instead.

NOTE: AFILE must be a report file. Use the REPORT command to convert a DBF
file to a report
           file format.

Related Commands: REPORT,PRINT

------------------------------------------------------------------------------------------

MAT CALL AFILE
Input: AFILE

Description: Call Batch File Within MAT Program

The advantage of using the CALL command is that the MAT executable file is
loaded only once. The batch file, AFILE, is read and then executed within
the MAT program. Calls to the CALL command can be recursive meaning that if
AFILE contains a statement with a CALL command it will run the statement as
expected and then return to the next statement in AFILE.

Note: Only statement lines beginning with MAT in AFILE are executed. This
gives the flexibility of being able to run AFILE as a regular batch file
(complete with REMarks) or with the MAT CALL command.

------------------------------------------------------------------------------------------

MAT CHOLESKY AFILE LFILE
Input: AFILE   Output: LFILE

Description: Cholesky (Matrix Square Root) Decomposition
Let A=AFILE, L=LFILE. Given the positive definite matrix A, this command
decomposes the  A  matrix in such a way that  A=L*LT , where L  is a lower
triangular matrix, and  LT is the transpose of L.

Example:
                         2    1    0
Let                 A    =    1    2     0
                         0    0    3

                         1.414        0    0
then                     L    =    0.707      1.225       0
                            0    0 1.732

Related Commands: LDLT, MULTTRAN

------------------------------------------------------------------------------------------

MAT CHR2NUM AFILE BFILE
Input: AFILE   Output: BFILE

Description: Convert DBF With Char Fields To DBF With Numeric Fields
Converts AFILE which is a DBF file with character type fields (scientific
notation) to BFILE, which is a DBF file with numeric fields.

NOTE: Numeric fields in DBF (dBase III) files are limited to values that
can be represented in non-scientfic notation. This is why MAT's native
format is the DBF file format where all fields are character type of length
24, where the character string can use scientific notation.

Related Commands: DBF2SDF,NUM2CHR,SDF2DBF

------------------------------------------------------------------------------------------

MAT COL2DIAG AFILE DFILE
Input: AFILE   Output: DFILE

Description: Column Vector To Diagonal Matrix.
Let A=AFILE a column vector, D=DFILE a diagonal matrix. Copy the elements
of column vector A and assign to diagonal matrix D. D[i,i]=A[i,1].  All
other elements of matrix D are set to 0.

Example:
                1                  1      0   0
Let         A  =    1.3       then D   =      0    1.3  0
                3                  0      0   3

Related Commands: DIAG2COL,DIAG2ROW,MAT2DIAG,ROW2DIAG

------------------------------------------------------------------------------------------

MAT COLAVG AFILE BFILE
Input: AFILE   Output: BFILE

Description: Average Values Down Columns & Assign To Row Vector.
Let A=AFILE, B=BFILE a row vector. Average the elements down the columns of
A and assign to row vector B. B[1, j] = Average of column j of matrix A.

Example:
          1    1    2
Let         A  =    2    0    2    then    B   =   [  1     1.333      3  ]
          0    3    5

Related Commands:
COLMULT, COLSTDDEV, COLSUM, ROWAVG, ROWMULT, ROWSTDDEV, ROWSUM

------------------------------------------------------------------------------------------

MAT COLCORR AFILE BFILE
Input: AFILE   Output: BFILE

Description: Correlation Matrix From Column Data.
Let A=AFILE, B=BFILE. Let each column of A represent statistical data for a
variable. B will then give the correlation matrix using the data in matrix
A.  B=COLCORR(A) The number of statistical variables is the number of
columns in matrix A. Hence the number of rows and columns in the
correlation matrix B will be the number of columns of matrix A.

Example:
                         1    1.7  -1
Let                 A  = 2    4.2  -4
                         0    -0.4 -1
                         1    1.3  -1

Then to 3 significant digits  B  will be

                1   r12  r13        1        0.988       -0.817
            B  =    r21   1   r23  =     0.988          1     -0.878
               r31  r32   1        -0.817   -0.878          1


NOTE: The element r12  is the correlation coefficient between columns 1 and
2 of matrix A.
      The element r13  is the correlation coefficient between columns 1 and
3 of matrix A.
      The element r23  is the correlation coefficient between columns 2 and
3 of matrix A.

     r21  = r12     ;   r31  = r13     ;    r32  = r23   ;   or in general
rki  = rik

Related Command: ROWCORR

------------------------------------------------------------------------------------------

MAT COLCOUNT AFILE BFILE
Input: AFILE   Output: BFILE

Description: Count The Number Of Columns In A Matrix
Let A=AFILE, B=BFILE a 1x1 matrix. Count the number of columns in matrix A
and assign to B.

Example:
                3    5    1    1
 Let  A  be    A   =     11   -1    7    21        then      B   =     [  4
]
                7    5   13   -1

Related Command: ROWCOUNT

------------------------------------------------------------------------------------------

MAT COLCOV AFILE BFILE
Input: AFILE   Output: BFILE

Description: Covariance Matrix From Column Data.
Let A=AFILE, B=BFILE. Let each column of A represent statistical data for a
variable. B will then give the covariance matrix using the data in matrix
A. The number of statistical variables is the number of columns in matrix
A. Hence the number of rows and columns in the covariance matrix B will be
the number of columns of matrix A.

Example:
                         1     1.7  -1
Let                 A  = 2     4.2  -4
                         0    -0.4  -1
                         1     1.3  -1

Then to 3 significant digits  B  will be

               c11  c12  c13       0.666         1.533  -1.000
            B  =    c21  c22  c23  =     1.533        3.607  -2.500
               c31  c32  c33       -1.000   -2.500       2.250


NOTE: The element c12  is the covariance between columns 1 and 2 of matrix
A.
      The element c13  is the covariance between columns 1 and 3 of matrix
A.
      The element c23  is the covariance between columns 2 and 3 of matrix
A.
     c21  = c12     ;   c31  = c13     ;    c32  = c23   ;   or in general
cki  = cik

Related Command: COLCORR

------------------------------------------------------------------------------------------

MAT COLMEDIAN AFILE BFILE
Input: AFILE   Output: BFILE

Description: Get Median Values Down Columns & Assign To Row Vector.
Let A=AFILE, B=BFILE a row vector. Get the median value of the elements
down the columns of A and assign to row vector B. B[1, j] = Median of
column j of matrix A.

Example:
          1    2    1
Let    A  =    5    3    0    then       B   =    [    3     3     1   ]
          3    5    4

Related Commands:
COLMULT,COLSTDDEV,COLSUM,ROWAVG,ROWMEDIAN,ROWMULT,ROWSTDDEV, ROWSUM

------------------------------------------------------------------------------------------

MAT COLMULT AFILE BFILE
Input: AFILE   Output: BFILE

Description: Multiply Values Down Columns & Assign To Row Vector.
Let A=AFILE, B=BFILE a row vector. Multiply the elements down the columns
of A and assign to B. B[1, j] = Product of Column j of matrix A.

Example:
          1    5    3
Let         A  =    2    1    2    then    B   =   [  0      15   12  ]
          0    3    2

Related Commands: COLAVG,COLSTDDEV,COLSUM,ROWAVG,ROWMULT,ROWSTDDEV,ROWSUM

------------------------------------------------------------------------------------------

MAT COLNORM AFILE BFILE
Input: AFILE   Output: BFILE

Description: Normalize Matrix For Column Data.
Let A=AFILE, B=BFILE. Normalize values down the columns of A and assign to
matrix B. Column normalization means that for each element of A subtract
the "down the columns mean" and divide this quantity by the "down the
columns standard deviation".

B[i, j]  =  (A[i, j] - Mean Of Col i) / (Std Dev Of Col i)

Example:
          1    1    2                 0  -0.218    -0.577
Let   A   =    2    0    2    then    B  =   1     -0.873    -0.577
          0    3    5                -1  1.091     1.155

Notice that for the (output) matrix B the down the columns mean (mean of
each column) is exactly 0, and the down the columns standard deviation
(standard deviation for each column) is exactly 1.

Related Commands: COLAVG,COLSTDDEV,ROWAVG,ROWNORM,ROWSTDDEV

------------------------------------------------------------------------------------------

MAT COLQUARTILE AFILE BFILE
Input: AFILE   Output: BFILE

Description: Get Quartile Values Down Columns & Assign To Row Vector.
Let A=AFILE, B=BFILE a row vector. Get the quartile value of the elements
down the columns of A and assign to row vector B. B[1, j] = Quartile of
column j of matrix A. The quartile value is equal to (VAL75 - VAL25)/2,
where VAL25 is the value of the data point which is 25% down in a sorted
list of the values, and VAL75 is the data point value which is 75% down the
sorted list. For example, for the first column in the A matrix, where the
values (if sorted) are { 1, 2, 3, 5 } then VAL25 is the value 2, and VAL75
is the value 3. Hence the quartile value is

(VAL75 - VAL25)/2 = (3-2)/2 = 0.5

Example:
          1    2    1
Let         A  =    5    3    0    then       B   =    [    0.5    0.5
1.0   ]
          3    5    4
          2    1    3

Related Commands: COLSTDDEV,ROWQUARTILE,ROWSTDDEV

------------------------------------------------------------------------------------------

MAT COLREPEAT AFILE NFILE BFILE
Input: AFILE, NFILE   Output: BFILE

Description: Repeat Column Vector Specified Times To Form Matrix.
Let A=AFILE a column vector, B=BFILE a matrix, N=NFILE a 1x1 matrix.
Repeat, A, the column vector, N times and assign to matrix B.

Example:
                1
Let            A  = 1.3       and         N   =    [ 2 ]
                3

                          1    1
then  B  will be         B   =     1.3   1.3
                          3    3

Related Commands: COLCOUNT,ROWREPEAT,ROWCOUNT

------------------------------------------------------------------------------------------

MAT COLSORT AFILE NFILE BFILE
Input: AFILE, NFILE   Output: BFILE

Description: Sort Matrix By Specified Column.
Let A=AFILE, B=BFILE a matrix, N=NFILE a 1x1 matrix. Sort the matrix, A, by
the N'th column (from smallest to biggest) and assign to matrix B. (A
negative value for N means to sort from biggest to smallest.)

Example:
               1    1    2
Let        A   =    2    0    2    and         N   =    [  2  ]
               0    3    5

                         2    0    2
then  B  will be         B   =     1     1    2
                         0    3    5

Related Commands: COLMEDIAN,COLQUARTILE,ROWSORT

------------------------------------------------------------------------------------------

MAT COLSTDDEV AFILE BFILE
Input: AFILE   Output: BFILE

Description: Std Dev Down Columns & Assign To Row Vector.
Let A=AFILE, B=BFILE a row vector. Determine the standard deviation of the
elements down the columns of A and assign to row vector B. B[1, j] =
Standard Deviation of Column j of matrix A.

Example:
          1    1    2
Let         A  =    2    0    2    then    B   =   [  1      1.528
1.732  ]
          0    3    5

Related Commands: COLAVG,COLMULT,COLSUM,ROWAVG,ROWMULT,ROWSTDDEV,ROWSUM

------------------------------------------------------------------------------------------

MAT COLSUM AFILE BFILE
Input: AFILE   Output: BFILE

Description: Sum Values Down Columns & Assign To Row Vector.
Let A=AFILE, B=BFILE a row vector. Sum the elements down the columns of A
and assign to B. B[1, j] = Sum of Column j of matrix A.

Example:
          1    1    2
Let    A  =    2    0    2    then    B   =   [  3        4        9   ]
          0    3    5

Related Commands: COLAVG,COLMULT,COLSTDDEV,ROWAVG,ROWMULT,ROWSTDDEV,ROWSUM

------------------------------------------------------------------------------------------

MAT COLSWAP AFILE BFILE
Input: AFILE   Output: BFILE

Description: Swap Matrix Columns & Assign To New Matrix
Let A=AFILE, B=BFILE. For the A matrix, swap the first and last columns,
the 2nd and the 2nd to the last columns, etc. Assign to matrix B.

Example:
          9    1    1    2               2    1    1    9
Let    A  =    4    2    0    2      then B   =    2    0    2    4
          7    0    3    5               5    3    0    7

Related Command: ROWSWAP

------------------------------------------------------------------------------------------

MAT COMPLEMENT  AFILE BFILE
Input: AFILE   Output: BFILE

Description: Logical Complement Of A Matrix.
Let A=AFILE, B=BFILE. The logical complement of the elements of A is output
as the elements of B.  B=Complement(A). If an element value is 0 (zero) in
matrix A its corresponding value in matrix B will be 1. If the element
value is 1 in matrix A the corresponding value in matrix B will be 0
(zero).

Example:
               1    0              0     1
Let        A    =   0    1    then B   =      1    0
               0    0              1     1

Related Commands: GE,GT,LE,LT,WITHINEQ,WITHINNE

------------------------------------------------------------------------------------------

MAT COPY AFILE BFILE
Input: AFILE  Output: BFILE

Description: Copy File To Another File.
Copy AFILE To BFILE.

Related Commands: DELETE,EXTRACTCOL,EXTRACTROW,JOINCOL,JOINROW,RENAME

------------------------------------------------------------------------------------------

MAT CREATE 3 2 AFILE
Input: Num Of Rows, Num Of Cols  Output: AFILE

Description: Create A New Matrix (Integer Arguments).
"Num Of Rows" is an integer argument (not a file name) specifying the
number of rows of the AFILE matrix. "Num Of Cols" is an integer argument
(not a file name) specifying the number of columns of the AFILE matrix. The
output AFILE will contain all 0's for its elements.

Example:
Let "Num Of Rows" be 3, and the "Num Of Cols" be 2, and denote AFILE by A,
then

                              0    0
                        A   = 0    0
                              0    0

Related Commands: CREATE2,CSV2DBF,EDIT,SDF2DBF,TXT2DBF

------------------------------------------------------------------------------------------

MAT CREATE2 RFILE CFILE AFILE
Input: RFILE, CFILE   Output: AFILE

Description: Create A New Matrix (File Name Arguments).
RFILE is a file (a 1x1 matrix) containing the number of rows of the AFILE
matrix. CFILE is a file (also a 1x1 matrix) containing the number of
columns of the AFILE matrix. The output AFILE will contain all 0's for its
elements.

Example:
Let RFILE contain the value 3, CFILE contain the value 2, and denote AFILE
by A, then

                              0    0
                       A   =  0    0
                              0    0

Related Commands: CREATE,CSV2DBF,EDIT,SCALAR,SDF2DBF,TXT2DBF

------------------------------------------------------------------------------------------

MAT CSV2DBF AFILE BFILE
Input: AFILE    Output: BFILE

Description: Convert Comma Separated Variable Text File To DBF File Format.
Convert the CSV text file, AFILE, to create a DBF file, BFILE. Each data
value (in AFILE) is surrounded by quotes, and separated from other data

values with commas (,). Also it is required that each row of data is ended
with a carriage return/line feed pair (ASCII characters 13 and 10).

Example:
Let AFILE be the ASCII text file:

"5","3","2"
"1","2","1"
"3","4","2"
"-1","7","8"

where each data cell is surrounded by quotes, and separated from other data
with commas (,). Each line is terminated with a carriage return/ line feed
pair (ASCII characters 13 and 10). For the AFILE given above the resulting
DBF file BFILE will be such that each field is of character type and of
length 24:

COL1                COL2                 COL3
5                   3                    2
1                   2                    1
3                   4                    2
-1                  7                    8

The field names in the DBF file are automatically assigned the names COL1,
COL2 , etc.

Related Commands: DBF2CSV,DBF2SDF, SDF2DBF,TXT2DBF

------------------------------------------------------------------------------------------

MAT DBF2CSV AFILE BFILE
Input: AFILE    Output: BFILE

Description: Convert DBF File To Comma Separated Variable Text File.
Convert the DBF file, AFILE, to create a CSV (Comma Separated Variable)
file, BFILE. Each data value in the output file BFILE will be surrounded by
quotes, and separated from other data values with commas (,). Also each row
of data will be ended with a carriage return/line feed pair (ASCII
characters 13 and 10).

Example:
Let AFILE be the DBF file:

COL1                COL2                 COL3
5                   3                    2
1                   2                    1
3                   4                    2
-1                  7                    8

The resulting BFILE will be a CSV file which will look as follows:

"5","3","2"
"1","2","1"
"3","4","2"
"-1","7","8"

Each data value will be surrounded by quotes, and separated from other data
values with commas (,). Each line will be terminated with a carriage
return/ line feed pair (ASCII characters 13 and 10).

Related Commands: DBF2CSV,DBF2SDF, SDF2DBF,TXT2DBF

------------------------------------------------------------------------------------------

MAT DBF2FTC AFILE BFILE
Input: AFILE    Output: BFILE

Description: Convert DBF File To Special 8 Byte Float Char File.
Convert the DBF file, AFILE, to create another database file, BFILE, but
with 8 bytes per cell instead of the regular 24 character length of the
original DBF file. The special 8 byte format preserves the full 64 bit
(double) precision of floating point numbers. It is also 1/3 the byte size
of the standard DBF file format. However, the advantage of the standard DBF
file format is that it can be read by popular software programs such as
Excel, Access, Quatro-Pro, etc.

Related Commands: DBF2CSV,DBF2SDF, FTC2DBF

------------------------------------------------------------------------------------------

MAT DBF2SDF AFILE BFILE CFILE
Input: AFILE  Output: BFILE, CFILE

Description: Copy DBF File Format To SDF File Format.
Convert the DBF file, AFILE, to the SDF format, BFILE. The ASCII text file
CFILE will contain the structure of the DBF file.

Example:
Let's say we have the DBF file AFILE where each field is of character type
and of length 24:

COL1                COL2                 COL3
-32.18              279.3                     255.2
-31.15              287.0                     289.0
27.37                    364.5                     256.9
-30.0                    381.1                     278.9

Then executing the command  MAT DBF2SDF AFILE BFILE CFILE  results in the
BFILE and the CFILE being created. The BFILE will be an ASCII text file
which contains the data, and the width of each data location will be the
length of the corresponding field in the original DBF file. For the example
above the BFILE would look as follows:

-32.18              279.3                     255.2
-31.15              287.0                     289.0
27.37                    364.5                     256.9
-30.0                    381.1                     278.9

The CFILE will be an ASCII text file which contains the DBF structure
information. The first column of data (always of width 10) will contain the
field names. The second column (always of width 1) will contain the data
type (C for character, D for Date, L for Logical, M for Memo, and N for
Numeric). The third column (always of width 3) will contain the field
width. The fourth column (always of width 3) will contain the number of
decimal places for the field. For the example above  the CFILE would look
as follows:

COL1      C 24   0
COL2      C 24   0
COL3      C 24   0

Related Command: CSV2DBF,DBF2CSV,SDF2DBF

------------------------------------------------------------------------------------------

MAT DCOND DFILE EFILE
Input: DFILE   Output: EFILE

Description: Determine Condition Number Of Diagonal Matrix.
Let D=DFILE a diagonal matrix, E=EFILE a 1x1 matrix. Determine the
condition number of matrix D and assign to E. For a diagonal matrix, the
condition number is simply the ratio of the largest absolute magnitude
diagonal element to the smallest absolute magnitude diagonal element.
E=MAX(ABS(D[i,i]))/MIN(ABS(D[i,i])). If MIN(ABS(D[i,i]))=0 then E is
assigned the value 1E308.

Example:
               5    0     0
Let       D     =   0    2     0   then    E    =  [  2.5  ]
               0    0    -4

Related Command: DNORM

------------------------------------------------------------------------------------------

MAT DELETE AFILE
Input: AFILE   Output: None

Description: Delete File.
Deletes AFILE From Current Directory.

Related Commands: COPY,RENAME

------------------------------------------------------------------------------------------

MAT DELETECOL AFILE SFILE LFILE BFILE
Input: AFILE, SFILE, LFILE   Output: BFILE

Description: Delete Specified Columns.
Delete Specified Columns from AFILE and assign to BFILE. SFILE (A 1x1
Matrix) Has Starting Col Number Of AFILE To Delete. LFILE (A 1x1 Matrix)
Has Last Col Number Of AFILE To Delete.

Example:
               -5    0    1   3
Let     A     =      4    2   -7   4     ;   S   =      [  2  ]     ;    L
= [  3  ]
                3    1    4   1
                2   -9    8   5

                               -5   3
Then the matrix B will be    B   =   4    4
                                3   1
                                2   5

Related Commands: COPY,DELETEROW,EXTRACTCOL,EXTRACTROW,JOINCOL,JOINROW

------------------------------------------------------------------------------------------

MAT DELETEROW AFILE SFILE LFILE BFILE
Input: AFILE, SFILE, LFILE   Output: BFILE

Description: Delete Specified Rows.
Delete Specified Rows from AFILE and assign to BFILE. SFILE (A 1x1 Matrix)
Has Starting Row Number Of AFILE To Delete. LFILE (A 1x1 Matrix) Has Last
Row Number Of AFILE To Delete.

Example:
               -5    0    1   3
Let     A     =      4    2   -7   4      ;  S   =      [  3  ]     ;    L
= [  4  ]
                3    1    4   1
                2   -9    8   5

Then the matrix B will be    A =   -5     0    1   3
                               4    2    -7   4

Related Commands: COPY,DELETECOL,EXTRACTCOL,EXTRACTROW,JOINCOL,JOINROW

------------------------------------------------------------------------------------------

MAT DET AFILE BFILE
Input: AFILE   Output: BFILE

Description: Determinant Of A Matrix.
Let A=AFILE be diagonal matrix, B=BFILE a 1x1 Matrix. Determine the
determinant of A and assign to B.

Example:
               5    2    -1
Let    A     = 0    2     3   then      B   =      [  -32  ]
               1    0    -4

Related Commands: DETDIAG, LUD, SVD

------------------------------------------------------------------------------------------

MAT DETDIAG DFILE EFILE
Input: DFILE   Output: EFILE

Description: Determinant Of Diagonal Matrix.
Let D=DFILE a diagonal matrix, E=EFILE a 1x1 Matrix. Determine the
determinant of D and assign to E.

Example:
               5    0     0
Let    D     = 0    2     0   then    E    =  [  -40  ]
               0    0    -4

Related Commands: DET, LUD, SVD

------------------------------------------------------------------------------------------

MAT DIAG2COL DFILE EFILE
Input: DFILE   Output: EFILE

Description: Diagonal Matrix To Column Vector.
Let D=DFILE a diagonal matrix, E=EFILE a column vector. Copy the elements
of diagonal matrix D and assign to col vector E. E[i,1]=D[i,i].

Example:
               5    0     0                    5
Let    D     = 0    2     0      then   E  =   2
               0    0    -4                   -4

Related Commands: DIAG2ROW,MAT2DIAG,ROW2DIAG

------------------------------------------------------------------------------------------

MAT DIAG2ROW DFILE EFILE
Input: DFILE   Output: EFILE

Description: Diagonal Matrix To Row Vector.
Let D=DFILE a diagonal matrix, E=EFILE a row vector. Copy the elements of
diagonal matrix D and assign to row vector E. E[1,i]=D[i,i].

Example:
               5    0     0
Let      D  =       0    2     0   then       E   =     [  5   2   -4  ]
               0    0    -4

Related Commands: DIAG2COL,MAT2DIAG,ROW2DIAG

------------------------------------------------------------------------------------------

MAT DINV DFILE EFILE
Input: DFILE   Output: EFILE

Description: Matrix Inverse Of A Diagonal Matrix.
Let D=DFILE a diagonal matrix, E=EFILE a diagonal matrix. E is the matrix
inverse of the diagonal matrix D. E=DINV(D). For diagonal elements E[i,i] =
1/D[i,i]. All other off-diagonal elements of E are 0. If D[i,i]=0 then
E[i,i] is assigned the value 1E308.

Example:
               5     0    0              0.2   0     0
Let      D   = 0    0.5   0   then  E =   0    2     0
               0     0   -4               0    0   -0.25

Related Commands: DPSEUDOINV,EINVERSE,INVERSE,PSEUDOINV

------------------------------------------------------------------------------------------

MAT DMULT DFILE AFILE EFILE
Input: DFILE, AFILE   Output: EFILE

Description: Multiply Diagonal Matrix With General Matrix.
Let D=DFILE a diagonal matrix, A=AFILE, E=EFILE. Multiply diagonal matrix D
and matrix A and assign to matrix E.  E=D*A. When it is known that a matrix
is diagonal the matrix multiplication using DMULT is much more efficient
than MULTIPLY.

Example:
               5    0     0              1    3    4
Let      D   = 0    2     0   and   A  =      0    2    0
               0    0    -4              2    0    1

                          5   15   20
Then  E  will be         E  =  0    4     0
                         -8    0   -4

Related Commands: EMULT,MASKMULT,MULTD,MULTIPLY,MULTTRAN

------------------------------------------------------------------------------------------

MAT DNORM DFILE EFILE
Input: DFILE   Output: EFILE

Description: Matrix Norm Of Diagonal Matrix.
Let D=DFILE a diagonal matrix, E=EFILE a 1x1 matrix. Determine the matrix
norm of D and assign to E. For a diagonal matrix, the norm is simply the
absolute value of the largest magnitude diagonal element of D.
E=MAX(ABS(D[i,i]))

Example:
               -5   0    0
Let       D  =  0   2    0    then    E    =  [  5  ]
                0   0    4

Related Command: DCOND

------------------------------------------------------------------------------------------

MAT DPSEUDOINV DFILE EFILE [TAUFILE]
Input: DFILE, TAUFILE   Output: EFILE

Description: Pseudo-Inverse Of Diagonal Matrix.
Let D=DFILE a diagonal matrix, E=EFILE a diagonal matrix, T=TAUFILE is a
scalar (actually a 1x1 matrix), and let THRESHOLD=T*ABSMAX(D[i,i]). Then E
will be output as the matrix pseudo inverse of the diagonal matrix D. If
ABS(D[i,i])>=THRESHOLD then E[i,i] = 1/D[i,i] otherwise E[i,i]=0. Also all
off-diagonal elements of E are 0.

Example:
                    5      0   0
Let            D  = 0    0.02  0   and        T  = [  0.01  ]
                    0      0  -4

                         0.2   0     0
 Then  E  will be        E  =  0    0      0
                          0    0   -0.25

Notice that if a diagonal element from D is less than the threshold value
then the corresponding diagonal element in E is assigned 0. If the absolute
magnitude of the element is greater than this threshold then the
corresponding element in E is assigned 1/D[i,i]. For the example above the
threshold is
 THRESHOLD=T*ABSMAX(D[i,i]) = 0.01*5=0.05.

Related Commands: DINV,EINVERSE,INVERSE,PSEUDOINV,SVD

------------------------------------------------------------------------------------------

MAT EABSOLUTE AFILE BFILE
Input: AFILE   Output: BFILE

Description: Take Absolute Value Of All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
absolute value of the elements of matrix A.  B[i,j] = ABS(A[i,j]). The
letter E in EABSOLUTE is used to represent an "elemental" matrix operation
-- a specific operation that is applied to all elements of a matrix.
Example:
               -5    0    1              5    0    1
Let            A     =    4    2   -7       then    B    =   4    2    7
                3    1    4              3    1    4
                2   -9    8              2    9    8

Related Commands: EINVERSE,EMULT,ESIGN,ESQRT,ESQUARE

------------------------------------------------------------------------------------------

MAT EARCCOS AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Arc-cosine Value For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
trigonometric arc-cosine values of the elements of matrix A.  B[i,j] =
ARCCOS(A[i,j]). The letter E in EARCCOS is used to represent an "elemental"
matrix operation--a specific operation that is applied to all elements of a
matrix.

Example:
               0.0                 1.571
Let       A  = 0.7     then     B =      0.795
               1.0                 0.000

Related Commands: EARCSIN,EARCTAN,ECOS,ESIN,ETAN

------------------------------------------------------------------------------------------

MAT EARCCOSH AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Hyperbolic Arc-cosine For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
hyperbolic arc-cosine values of the elements of matrix A.  B[i,j] =
ARCCOSH(A[i,j]). The letter E in EARCCOSH is used to represent an
"elemental" matrix operation--a specific operation that is applied to all
elements of a matrix.

Example:
               1.0                 0.000
Let      A   = 2.0     then     B  =     1.317
               5.0                 2.292

Related Commands: ECOSH,ESINH,ETANH

------------------------------------------------------------------------------------------

MAT EARCSIN AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Arc-sine Value For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
trigonometric arc-sine values of the elements of matrix A.  B[i,j] =
ARCSIN(A[i,j]). The letter E in EARCSIN is used to represent an "elemental"
matrix operation--a specific operation that is applied to all elements of a
matrix.

Example:
               0.0                 0.000
Let      A  =  0.7     then    B  =      0.775
               1.0                 1.571

Related Commands: EARCCOS,EARCTAN,ECOS,ESIN,ETAN

------------------------------------------------------------------------------------------

MAT EARCSINH AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Hyperbolic Arc-sine For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
hyperbolic arc-sine values of the elements of matrix A.  B[i,j] =
ARCSINH(A[i,j]). The letter E in EARCSINH is used to represent an
"elemental" matrix operation--a specific operation that is applied to all
elements of a matrix.

Example:
               0.0                 0.000
Let       A  = 0.7     then   B  = 0.652
               1.0                 0.881

Related Commands: ECOSH,ESINH,ETANH

------------------------------------------------------------------------------------------

MAT EARCTAN AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Arc-tangent Value For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
trigonometric arc-tangent values of the elements of matrix A.  B[i,j] =
ARCTAN(A[i,j]). The letter E in EARCTAN is used to represent an "elemental"
matrix operation--a specific operation that is applied to all elements of a
matrix.

Example:
               0.0                 0.000
Let            A  = 0.7     then    B  =      0.611
               1.0                 0.785

Related Commands: EARCCOS,EARCSIN,ECOS,ESIN,ETAN

------------------------------------------------------------------------------------------

MAT EARCTANH AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Hyperbolic Arc-tangent For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
hyperbolic arc-tangent values of the elements of matrix A.  B[i,j] =
ARCTANH(A[i,j]). The letter E in EARCTANH is used to represent an
"elemental" matrix operation--a specific operation that is applied to all
elements of a matrix.

Example:
               0.0                 0.000
Let      A   = 0.7     then   B  = 0.867
               0.9                 1.472

Related Commands: ECOSH,ESINH,ETANH

------------------------------------------------------------------------------------------

MAT ECOS AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Cosine Value For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
trigonometric cosine values of the elements of matrix A.  B[i,j] =
COS(A[i,j]). The letter E in ECOS is used to represent an "elemental"
matrix operation--a specific operation that is applied to all elements of a
matrix.

Example:
               0.0                 1.000
Let      A   = 0.7     then    B  =      0.765
               1.0                 0.540

Related Commands: EARCCOS,EARCSIN,EARCTAN,ESIN,ETAN

------------------------------------------------------------------------------------------

MAT ECOSH AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Hyperbolic Cosine For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
hyperbolic cosine values of the elements of matrix A.  B[i,j] =
COSH(A[i,j]). The letter E in ECOSH is used to represent an "elemental"
matrix operation--a specific operation that is applied to all elements of a
matrix.

Example:
               0.0                 1.000
Let      A   = 0.7     then    B  =      1.255
               1.0                 1.543

Related Commands: EARCCOSH,ESINH,ETANH

------------------------------------------------------------------------------------------

MAT EDIT AFILE
Input: AFILE   Output: AFILE

Description: To View Or Edit A Matrix (DBF) File.
This command is used to view or edit matrix (DBF) files. Notice that the
file passed is modified if any changes are made. That is the file is
modified immediately upon any edit. There is no confirmation to forfeit any
changes.

Related Commands: CREATE, SDF2DBF, TXT2DBF

------------------------------------------------------------------------------------------

MAT EEXP AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate EXP Value For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to  e
taken to the power values of the elements of matrix A.  B[i,j] =
EXP(A[i,j]). The letter E in EEXP is used to represent an "elemental"
matrix operation--a specific operation that is applied to all elements of a
matrix.

Example:
               1     0                   2.718     1
Let    A     = 0    -1      then  B =      1         0.368
               2     1                   7.389       2.718

Related Commands: EABSOLUTE,EINVERSE,ELOG,EMULT,EPOWER,ESIGN,ESQRT,ESQUARE

------------------------------------------------------------------------------------------

MAT EIGENHERM AFILE BFILE CFILE
Input: AFILE   Output: BFILE, CFILE

Description: Eigenvectors And Eigenvalues Of A Hermitian Matrix.
Let A=AFILE, B=BFILE, and C=CFILE. Given the Hermitian matrix A, this
command determines its eigenvectors and eigenvalues. The matrix A is input
with the odd columns containing the real parts, and the even columns
containing the imaginary parts.

The eigenvectors (which are normalized to a have a magnitude of 1) are
included as columns in the B matrix (the odd columns containing the real
parts, the even columns the imaginary parts). The corresponding eigenvalues
are elements in the column vector, C. (Since A is Hermitian all the
eigenvalues will be real.)

Note: A and B will be nx2n matrices and C will be an nx1 matrix, where n is
the number of rows in the matrix A.

Example:
                    2    0    1    0     0    0
Let            A    =    1    0    2     0    0    0
                    0    0    0    0     3    0

           0.707   0     0.707       0    0   0              1
Then  B   =    -0.707   0     0.707        0   0        0     and  C  =
3
              0        0    0   0   1    0              3

Related Command: EIGENREAL, EIGENSYM, SVD

------------------------------------------------------------------------------------------

To Be Developed

MAT EIGENREAL AFILE BFILE CFILE
Input: AFILE   Output: BFILE, CFILE

Description: Eigenvectors And Eigenvalues Of A General Real Matrix.
Let A=AFILE, B=BFILE, and C=CFILE. Given the nxn real square matrix A, this
command determines its eigenvectors and eigenvalues. The eigenvectors
(which are normalized to have a magnitude of 1) are included as columns in
the B matrix (the odd columns containing the real parts, the even columns
the imaginary parts). The corresponding eigenvalues are elements in the 2
column matrix, C (the first column containing the real part and the second
column the imaginary part of the eigenvalues). Note: B will be an nx2n
matrix and C will be an nx2 matrix, where n is the number of rows in the
matrix A.

Example:
                         2    1    0
Let                 A    =    1    2     0
                         0    0    3

           0.707   0     0.707        0    0   0             1    0
Then  B   =    -0.707   0     0.707         0        0        0    and  C
=    3    0
             0    0    0    0   1   0              3    0

Comment: For best efficiency, if a matrix is symmetric use the EIGENSYM
command.

Related Command: EIGENHERM, EIGENSYM, SVD

------------------------------------------------------------------------------------------

MAT EIGENSYM AFILE BFILE CFILE
Input: AFILE   Output: BFILE, CFILE

Description: Eigenvectors And Eigenvalues Of A Symmetric Real Matrix.
Let A=AFILE, B=BFILE, and C=CFILE. Given the nxn symmetric real square
matrix A, this command determines its eigenvectors and eigenvalues. The
eigenvectors (which are normalized to a have a magnitude of 1) are included
as columns in the B matrix. The corresponding eigenvalues are elements in
the column vector, C.  Note: B will be an nxn matrix and C will be an nx1
matrix, where n is the number of rows (same as num of columns) in the
square matrix A.

Example:
                         2    1    0
Let                 A    =    1    2     0
                         0    0    3

                0.707   0.707  0              1
Then       B  =     -0.707   0.707  0    and  C  =      3
                   0          0     1              3

Related Command: EIGENHERM, EIGENREAL, SVD

------------------------------------------------------------------------------------------

MAT EINVERSE AFILE BFILE
Input: AFILE   Output: BFILE

Description: Take The Reciprocal Value Of All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
reciprocals of the elements of matrix A.  B[i, j] = 1/A[i, j]. If A[i,j] =
0 then B[i,j] is set equal to 1E308. The letter E in EINVERSE is used to
represent an "elemental" matrix operation -- a specific operation that is
applied to all elements of a matrix.

Example:
               -5    2    1              -0.200  0.500   1.000
Let       A   =      4    2   -6   then  B  =      0.250       0.500
-0.166
                3    1    4              0.333       1.000   0.250
                2   -9    8              0.500       -0.111  0.125

Related Commands: DINV,DPSEUDOINV,INVERSE,PSEUDOINV

------------------------------------------------------------------------------------------

MAT ELOG AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Natural LOG Value For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
natural logarithm of the elements of matrix A.  B[i,j] = LOG(A[i,j]). The
letter E in ELOG is used to represent an "elemental" matrix operation -- a
specific operation that is applied to all elements of a matrix.

Example:
                2    1                   0.693    0
Let    A     = 10   0.1     then    B    =    2.303      -2.303
                3    5                   1.099       1.609

Related Commands: EEXP,ELOG10,EPOWER

------------------------------------------------------------------------------------------

MAT ELOG10 AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate (Base 10) LOG10 Value For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the base
10 logarithm of the elements of matrix A.  B[i,j] = LOG10(A[i,j]). The
letter E in ELOG10 is used to represent an "elemental" matrix operation --
a specific operation that is applied to all elements of a matrix.

Example:
                2    1                   0.301         0
Let      A   = 10   0.1     then    B  =      1.000     -1.000
                3    5                   0.477      0.699

Related Commands: EEXP,ELOG,EPOWER

------------------------------------------------------------------------------------------

MAT EMULTIPLY AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Multiply All Elements In A Matrix With A Scalar.
Let A=AFILE, B=BFILE a scalar, C=CFILE. B is a scalar (actually represented
as a 1x1 matrix). The elements of matrix C are simply equal to the elements
of matrix A multiplied by the scalar value in B.  C[i,j] = B*A[i,j]. The
letter E in EMULTIPLY is used to represent an "elemental" matrix operation
-- a specific operation that is applied to all elements of a matrix.

Example:
               1     0
Let     A   =  0    -1      and    B    =   [  3  ]
               2     1

                         3     0
Then               C  =  0    -3
                         6     3

Related Commands: DMULT,MASKMULT,MULTD,MULTIPLY,MULTTRAN

------------------------------------------------------------------------------------------

MAT EPOWER AFILE PFILE BFILE
Input: AFILE, PFILE   Output: BFILE

Description: Take All Elements In A Matrix To A Power.
Let A=AFILE, P=PFILE (a 1x1 matrix), B=BFILE. The elements of matrix B are
simply equal to the elements of A each taken to the P'th power.  B[i,j] =
(A[i,j])P .The letter E in EPOWER is used to represent an "elemental"
matrix operation--a specific operation that is applied to all elements of a
matrix.

Example:
               1     4
Let       A   =     0    -2      and       P    =   [  3  ]
               3     1

                         1     64
Then              C   =  0     -8
                         27     1

Related Commands: EABSOLUTE,EEXP,EINVERSE,ELOG,EMULT,ESIGN,ESQRT,ESQUARE

------------------------------------------------------------------------------------------

MAT ESIGN AFILE BFILE
Input: AFILE   Output: BFILE

Description: Determine The Sign Of All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the sign
(-1,0,+1) of the elements of matrix A.  B[i,j] = SIGN(A[i,j]). ( SIGN(x) =
-1  if x<0 ; +1 if x>=0 ). The letter E in ESIGN is used to represent an
"elemental" matrix operation--a specific operation that is applied to all
elements of a matrix.

Example:
               -2    3                   -1    1
Let      A   =  0   0.1     then     B   =     1    1
                1   -5                    1   -1

Related Commands: EABSOLUTE,EINVERSE,EMULT,ESQRT,ESQUARE

------------------------------------------------------------------------------------------

MAT ESIN AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Sine Value For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
trigonometric sine values of the elements of matrix A.  B[i,j] =
SIN(A[i,j]). The letter E in ESIN is used to represent an "elemental"
matrix operation--a specific operation that is applied to all elements of a
matrix.

Example:
               0.0                 0.000
Let       A  = 0.7     then    B   =     0.644
               1.0                 0.841

Related Commands: EARCCOS,EARCSIN,EARCTAN,ECOS,ETAN

------------------------------------------------------------------------------------------

MAT ESINH AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Hyperbolic Sine Value For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
hyperbolic sine values of the elements of matrix A.  B[i,j] = SINH(A[i,j]).
The letter E in ESINH is used to represent an "elemental" matrix
operation--a specific operation that is applied to all elements of a
matrix.

Example:
               0.0                 0.000
Let        A  =     0.7     then     B  =     0.759
               1.0                 1.175

Related Commands: EARCSINH,ECOSH,ETANH

------------------------------------------------------------------------------------------

MAT ESQRT AFILE BFILE
Input: AFILE   Output: BFILE

Description: Take The Square Root Of All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
square root of the elements of matrix A.  B[i,j] = SQRT(A[i,j]). The letter
E in ESQRT is used to represent an "elemental" matrix operation--a specific
operation that is applied to all elements of a matrix.

Example:
                4   2                    2    1.414
Let       A  = 25   9    then      B  =  5       3
                1   5                    1    2.236

Related Commands: EABSOLUTE,EINVERSE,EMULT,ESIGN,ESQUARE

------------------------------------------------------------------------------------------

MAT ESQUARE AFILE BFILE
Input: AFILE   Output: BFILE

Description: Take The Square Of All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
square of the elements of matrix A. B[i,j] = A[i,j]*A[i,j]. The letter E in
ESQUARE is used to represent an "elemental" matrix operation--a specific
operation that is applied to all elements of a matrix.

Example:
               4    -2                   16    4
Let       A  = 3     9      then     B  =      9   81
               1     5                    1   25

Related Commands: EABSOLUTE,EINVERSE,EMULT,ESIGN,ESQRT

------------------------------------------------------------------------------------------

MAT ETAN AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Tangent Value For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
trigonometric tangent values of the elements of matrix A.  B[i,j] =
TAN(A[i,j]). The letter E in ETAN is used to represent an "elemental"
matrix operation--a specific operation that is applied to all elements of a
matrix.

Example:
               0.0                 0.000
Let       A  = 0.7     then    B  =      0.842
               1.0                 1.557

Related Commands: EARCCOS,EARCSIN,EARCTAN,ECOS,ESIN


------------------------------------------------------------------------------------------

MAT ETANH AFILE BFILE
Input: AFILE   Output: BFILE

Description: Calculate Hyperbolic Tangent For All Elements In A Matrix.
Let A=AFILE, B=BFILE. The elements of matrix B are simply equal to the
hyperbolic tangent values of the elements of matrix A.  B[i,j] =
TANH(A[i,j]). The letter E in ETANH is used to represent an "elemental"
matrix operation--a specific operation that is applied to all elements of a
matrix.

Example:
               0.0                 0.000
Let      A  =  0.7     then     B  =     0.604
               1.0                 0.762

Related Commands: EARCTAN,ECOSH,ESINH

------------------------------------------------------------------------------------------

MAT EXTRACTCOL AFILE SFILE LFILE BFILE
Input: AFILE, SFILE, LFILE   Output: BFILE

Description: Extract Specified Columns To Another Matrix.
Extract Specified Columns from AFILE Onto BFILE. SFILE (A 1x1 Matrix) Has
Starting Col Number Of AFILE To Extract To BFILE. LFILE (A 1x1 Matrix) Has
Last Col Number Of AFILE To Extract To BFILE.

Example:
               -5    0    1   3
Let       A   =      4    2   -7   4      ;     S   =  [  2  ]  ;    L  = [
3  ]
                3    1    4   1
                2   -9    8   5

                               0    1
Then the matrix B will be     B  =  2    -7
                               1    4
                              -9    8

Related Commands: COPY,EXTRACTROW,JOINCOL,JOINROW

------------------------------------------------------------------------------------------

MAT EXTRACTROW AFILE SFILE LFILE BFILE
Input: AFILE, SFILE, LFILE   Output: BFILE

Description: Extract Specified Rows To Another Matrix.
Extract Specified Rows from AFILE Onto BFILE. SFILE (A 1x1 Matrix) Has
Starting Row Number Of AFILE To Extract To BFILE. LFILE (A 1x1 Matrix) Has
Last Row Number Of AFILE To Extract To BFILE.

Example:
               -5    0    1   3
Let      A   =  4    2   -7   4      ;     S   =  [  2  ]   ;    L  = [  4
]
                3    1    4   1
                2   -9    8   5

                              4     2    -7   4
Then the matrix B will be   A  =   3      1    4   1
                              2    -9     8   5

Related Commands: COPY,EXTRACTCOL,JOINCOL,JOINROW

------------------------------------------------------------------------------------------

MAT FLDRENAME AFILE BFILE
Input: AFILE, BFILE   Output: AFILE

Description: Rename Field Names
Rename field names in AFILE according to the list of strings contained in
BFILE.

Example:
          COL1 COL2 COL3            COL1           <-- Field Names
             1    2    1            TIME           }   Contents
Let   A  =        3    5         2    then  B =     POS           }
Contents
             5    12        4             ACC           }   Contents

After FLDNAME is executed AFILE will have its field names changed:

          TIME POS  VEL        <-- Field Names
             1    2    1       }   Contents
Let    A  =       3    5         2        }   Contents
             5    12        4       }   Contents

Related Commands: STRLIST

------------------------------------------------------------------------------------------

MAT FFT AFILE BFILE
Input: AFILE   Output: BFILE

Description: Fast Fourier Transform.
Let A=AFILE, B=BFILE. B is output as the Fourier Transform of A.  B=FFT(A).

Example:
          5     3             12   15
Let   A  =     1     2    then B  =       5   -4
          3     5              4    1
          3     5             -1    0

Related Commands: INVFFT

------------------------------------------------------------------------------------------

MAT FTC2DBF AFILE BFILE
Input: AFILE    Output: BFILE

Description: Convert Special 8 Byte Float Char File To DBF File.
Convert the FTC file, AFILE, to create a DBF file, BFILE. The FTC file has
8 bytes per cell instead of the regular 24 character length of the DBF
file. The special 8 byte format preserves the full 64 bit (double)
precision of floating point numbers. It is also 1/3 the byte size of the
standard DBF file format. However, the advantage of the standard DBF file
format is that it can be read by popular software programs such as Excel,
Access, Quatro-Pro, etc.

Related Commands: DBF2CSV,DBF2FTC,DBF2SDF

------------------------------------------------------------------------------------------

MAT GE AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Are Elements In A Greater Than Or Equal To Elements In B
Let A=AFILE, B=BFILE, C=CFILE. A, B, C all have the same number of rows and
columns. Given the matrix files A and B, this command compares the element
values in A to the element values in B. If the element in A is greater than
or equal to the corresponding element in B then the element in C is
assigned 1, otherwise it is assigned 0 (zero).

Example:
               1     5             5     3
Let            A  = 2    -1    and   B =      2    1
               6     2             0     0

                         0     1
Then                C  = 1     0
                         1     1

Related Commands: COMPLEMENT, GT, LE, LT, WITHINEQ, WITHINNE

------------------------------------------------------------------------------------------

MAT GT AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Are Elements In A Greater Than Elements In B
Let A=AFILE, B=BFILE, C=CFILE. A, B, C all have the same number of rows and
columns. Given the matrix files A and B, this command compares the element
values in A to the element values in B. If the element in A is greater than
the corresponding element in B then the element in C is assigned 1,
otherwise it is assigned 0 (zero).

Example:

               1     5             5     3
Let       A   =     2    -1    and   B  =     2    1
               6     2             0     0

                         0     1
Then                C  = 0     0
                         1     1

Related Commands: COMPLEMENT, GE, LE, LT, WITHINEQ, WITHINNE

------------------------------------------------------------------------------------------

MAT INVERSE AFILE BFILE
Input: AFILE   Output: BFILE

Description: Inverse Of A Matrix.
Let A=AFILE, B=BFILE. B is output as the matrix inverse of A.
B=Inverse(A).

Example:
          5     3    0              0.250     -1.000     0.250
Let   A = 1     2    1    then  B =      -0.083     1.666    -0.416
          3     5    4             -0.083     -1.333     0.583

Related Commands: DINV,DPSEUDOINV,EINVERSE,PSEUDOINV

------------------------------------------------------------------------------------------

MAT INVFFT AFILE BFILE
Input: AFILE   Output: BFILE

Description: Inverse Fourier Transform.
Let A=AFILE, B=BFILE. B is output as the Inverse Fourier Transform of A.
B=INVFFT(A).

Example:
          5     3              3.00       3.75
Let  A  = 1     2     then  B =    -0.25       0.00
          3     5              1.00       0.25
          3     5              1.25      -1.00

Related Commands: FFT

------------------------------------------------------------------------------------------

MAT INVJUXCOL AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Inverse Juxtaposition Cols Of A Matrix To Two Matrices
Inverse juxtaposition columns from AFILE. Assign to BFILE and CFILE.

Example:
                    52   1    31   7
Let          A   =  10   2    22   5
                    33   4    54   3

               52    31            1     7
then           B  = 10    22    and  C  =     2    5
               33    54            4     3

Related Commands: EXTRACTCOL, INVJUXROW, JOINCOL, JUXTACOL

------------------------------------------------------------------------------------------

MAT INVJUXROW AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Inverse Juxtaposition Rows Of A Matrix To Two Matrices
Juxtaposition rows from AFILE. Assign to BFILE and CFILE.

Example:
                         10   22   11
Let               A     =      2    5     4
                         33   54   -48
                          4    3    8

then   B =     10    22   11    and   C =     2    5    4
          33    54  -48            4     3    8

Related Commands: EXTRACTROW, INVJUXCOL, JOINROW, JUXTAROW

------------------------------------------------------------------------------------------

MAT JOINCOL AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Join Columns From Two Matrices To Another.
Join Columns From AFILE & BFILE And Assign TO CFILE.

Example:
               4    -2                   2    4    3
Let        A  =     3     9      and     B  =      9    8    5
               1     5                   1    2    6

                    4    -2    2   4     3
Then             C =     3     9    9    8    5
                    1     5    1   2     6

Related Commands: COPY,EXTRACTCOL,EXTRACTROW,JOINROW,JUXTACOL

------------------------------------------------------------------------------------------

MAT JOINROW AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Join Rows From Two Matrices To Another.
Join Rows From AFILE & BFILE And Assign To CFILE.

Example:
                                         2    7
Let      A =   3     9      and     B  =      9    8
               1     5                   4    3

                         3    9
Then              C  =   1    5
                         2    7
                         9    8
                         4    3

Related Commands: COPY,EXTRACTCOL,EXTRACTROW,JOINCOL,JUXTAROW

------------------------------------------------------------------------------------------

MAT JUXTACOL AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Juxtaposition Cols Of Two Matrices To Another.
Let A=AFILE, B=BFILE, C=CFILE. Juxtaposition columns from A & B and assign
to C. The columns of A will be the odd columns of C and the columns of B
will be the even columns of C.

Example:
               52    31            1     7
Let      A   = 10    22    and  B  =     2    5
               33    54            4     3

                    52   1    31   7
Then          C   = 10   2    22   5
                    33   4    54   3

Related Commands: COPY,EXTRACTCOL,INVJUXCOL,JOINCOL,JUXTAROW

------------------------------------------------------------------------------------------

MAT JUXTAROW AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Juxtaposition Rows Of Two Matrices To Another.
Let A=AFILE, B=BFILE, C=CFILE. Juxtaposition rows from A & B and assign to
C. The rows of A will be the odd rows of C. The rows of B will be the even
rows of C.

Example:

Let     A    = 10    22   11        and     B   =  2    5    4
          33    54  -48            4     3    8

                         10   22   11
Then                    C  =   2    5     4
                         33   54   -48
                          4    3    8

Related Commands: COPY,EXTRACTROW,INVJUXROW,JOINROW,JUXTACOL

------------------------------------------------------------------------------------------

MAT LDLT AFILE LFILE DFILE
Input: AFILE   Output: LFILE, DFILE

Description: L*D*LT Decomposition Of A Matrix { LT=Transpose(L) }.
Let A=AFILE, L=LFILE a lower triangular matrix, D=DFILE a diagonal matrix,
LT=Transpose(L). Given the symmetric matrix file A, this command decomposes
the matrix A into matrices L and D such that A=L*D*LT.

Example:
                         5     3   0
Let                 A    =    1     2    1
                         3     5   4

           1     0   0             5      0      0
Then L   =     0.2    1   0    and   D  =     0    1.8     0
          0.6  2.444      1              0     0   -8.555

Related Commands: INVERSE,LUD,PSEUDOINV,SVD

------------------------------------------------------------------------------------------

MAT LE AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Are Elements In A Less Than Or Equal To Elements In B
Let A=AFILE, B=BFILE, C=CFILE. A, B, C all have the same number of rows and
columns. Given the matrix files A and B, this command compares the element
values in A to the element values in B. If the element in A is less than or
equal to the corresponding element in B then the element in C is assigned
1, otherwise it is assigned 0 (zero).

Example:
               1     5             5     3
Let         A  =    2    -1       and       B   =  2    1
               6     2             0     0

                         1     0
Then                C    =    1     1
                         0     0

Related Commands: COMPLEMENT, GE, GT, LT, WITHINEQ, WITHINNE

------------------------------------------------------------------------------------------

MAT LT AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Are Elements In A Less Than Elements In B
Let A=AFILE, B=BFILE, C=CFILE. A, B, C all have the same number of rows and
columns. Given the matrix files A and B, this command compares the element
values in A to the element values in B. If the element in A is less than
the corresponding element in B then the element in C is assigned 1,
otherwise it is assigned 0 (zero).

Example:

               1     5             5     3
Let       A  = 2    -1    and   B  =     2    1
               6     2             0     0

                         1     0
Then                C   =     0     0
                         0     0

Related Commands: COMPLEMENT, GE, GT, LE, WITHINEQ, WITHINNE

------------------------------------------------------------------------------------------

MAT LUD AFILE LFILE UFILE PFILE DFILE
Input: AFILE   Output: LFILE, UFILE, PFILE, DFILE

Description: L*U Decomposition Of A Matrix.
Let A=AFILE, L=LFILE, U=UFILE, P=PFILE, D=DFILE. Given the matrix  A, this
command decomposes the  A  matrix in such a way that  P*A=L*U , where P  is
a permutation matrix, L  is a lower triangular matrix, and  U  is an upper
triangular matrix. The permutation matrix, P, is based on the pivot
exchanges used within the LUD algorithm. D (a 1x1 matrix) contains the
value +1 for even number of row exchanges and -1 for odd number of row
exchanges.

Example:
                         1    2    1
Let                 A    =    5    3     0
                         3    5    4

           1       0    0                5     3      0
Then  L =  0.2     1        0        U =      0    1.4     1
           0.6  2.286   1                0     0   1.714

          0    1    0
     P =  1    0    0              D = [ -1 ]
          0    0    1

Related Commands: DET, INVERSE, LDLT, PSEUDOINV, SVD

------------------------------------------------------------------------------------------

MAT MASKMAX AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Mask Maximum Of Two Matrices.
Let A=AFILE, B=BFILE, C=CFILE. Get the mask maximum of A and B and assign
to matrix C.  C=MASKMAX(A,B). In a mask maximum the matrices A and B must
be exactly the same dimensions.The value of each element in matrix C is
given by C[i,j]=MAX(A[i,j],B[i,j]). For example, element C[3,2] is given by
MAX(A[3,2],B[3,2]). The prefix MASK is used to represent a matrix operation
which operates on the same matrix position of the matrix operands (as if a
mask was used to view the same matrix element position of the matrix
operands).

Example:
          -5   0    1                    1    3    0
Let   A =  3   2    0        and    B  =      4    2    1
           1   4    1                    0    0    2

                         1    3    1
Then               C  =  4    2    1
                         1    4    2

Related Commands: MASKMIN,MASKMULT

------------------------------------------------------------------------------------------

MAT MASKMIN AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Mask Minimum Of Two Matrices.
Let A=AFILE, B=BFILE, C=CFILE. Get the mask minimum of A and B and assign
to matrix C.  C=MASKMIN(A,B). In a mask minimum the matrices A and B must
be exactly the same dimensions. The value of each element in matrix C is
given by C[i,j]=MIN(A[i,j],B[i,j]). For example, element C[3,2] is given by
MIN(A[3,2],B[3,2]). The prefix MASK is used to represent a matrix operation
which operates on the same matrix position of the matrix operands (as if a
mask was used to view the same matrix element position of the matrix
operands).

Example:
          -5   0    1                    1    3    0
Let    A =      3   2    0       and      B  =     4    2    1
           1   4    1                    0    0    2

                         -5   0    0
Then               C   =  3   2    0
                          0   0    1

Related Commands: MASKMAX,MASKMULT

------------------------------------------------------------------------------------------

MAT MASKMULT AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Mask Multiply Two Matrices.
Let A=AFILE, B=BFILE, C=CFILE. Mask Multiply A and B and assign to matrix
C.  C=MASKMULT(A,B). In a mask multiply the matrices A and B must be
exactly the same dimensions. The value of each element in matrix C is given
by C[i,j]=A[i,j]*B[i,j]. For example, element C[3,2] is given by
A[3,2]*B[3,2]. The prefix MASK is used to represent a matrix operation
which operates on the same matrix position of the matrix operands (as if a
mask was used to view the same matrix element position of the matrix
operands).

Example:
          -5   0    1                    1    3    0
Let  A  =  3   2    0      and       B  =     4    2    1
           2   4    3                    5    0    2

                         -5   0    0
Then                C  = 12   4    0
                         10   0    6

Related Commands: DMULT,EMULT,MASKMAX,MASKMIN,MULTD,MULTIPLY,MULTTRAN

------------------------------------------------------------------------------------------

MAT MAT2DIAG AFILE DFILE
Input: AFILE   Output: DFILE

Description: Zero All Elements Except The Diagonal Elements.
Let A=AFILE, D=DFILE a diagonal matrix. Copy the diagonal elements of
matrix A and assign to matrix D. All off-diagonal elements of matrix D are
set to 0.

Example:
          -5   0    1                    -5   0    0
Let    A  =     3   2    0       then       B  =    0   2    0
           2   4    3                     0   0    3

Related Commands: COL2DIAG,DIAG2COL,DIAG2ROW

------------------------------------------------------------------------------------------

MAT MULTD AFILE DFILE EFILE
Input: AFILE, DFILE   Output: EFILE

Description: Multiply General Matrix With A Diagonal Matrix.
Let A=AFILE, D=DFILE a diagonal matrix, E=EFILE. Multiply matrix A and
diagonal matrix D and assign to matrix E.  E=A*D. When it is known that a
matrix is diagonal the matrix multiplication using MULTD is much more
efficient than MULTIPLY.

Example:
          -5   0    1                    1    0    0
Let    A  =     3   2    0        and     B  =     0    2    0
           2   4    3                    0    0    2

                         -5   0    2
Then                C  =  3   4    0
                          2   8    6

Related Commands: DMULT,EMULT,MASKMULT,MULTIPLY,MULTTRAN

------------------------------------------------------------------------------------------

MAT MULTILIST AFILE BFILE
Input:  AFILE  Output: BFILE

Description: List Of Numbers In Interval (Multiple Columns).
AFILE contains all the information to create the Multiple Column list which
will be assigned to BFILE. Each row in AFILE contains the start value, end
value, and number of values between the start and end values (inclusive)
for each BFILE column. Notice that each row of the resulting BFILE will
have a different set of values from the other rows of BFILE. Also notice
that all possible combinations between the values of each column with the
other columns is created.

NOTE: Up to 5 rows can be specified in the AFILE (i.e. up to 5 columns in
the BFILE).
      Information in AFILE beyond 5 rows is ignored.

Example:

Let              A.MAT  =     1    2     2
                         5    6    2

 Then the statement   MAT MULTILIST A.MAT B.MAT  results in the matrix:

                         1.000     5.000
               B.MAT  =  1.000     6.000
                         2.000     5.000
                         2.000     6.000

Related Commands: CREATE, NUMLIST, NUMLIST2, SCALAR

------------------------------------------------------------------------------------------

MAT MULTIPLY AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Multiply Two Matrices.
Let A=AFILE, B=BFILE, C=CFILE. Matrix Multiply A and B and assign to matrix
C.  C=A*B.

Example:
               -5   0
Let         A  =     3   2       and      B  =     1    2
                2   4                    5    0

                         -5   -10
Then               C  =  13     6
                         22     4

Related Commands: DMULT,EMULT,MASKMULT,MULTD,MULTTRAN

------------------------------------------------------------------------------------------

MAT MULTTRAN AFILE BFILE
Input: AFILE   Output: BFILE

Description: Multiply A Matrix With Its Transpose.
Let A=AFILE, B=BFILE, AT=Transpose(A). Matrix Multiply A and AT and assign
to matrix B.  B=A*AT.

Example:
          1    0    1                    2     1    5
Let   A  =     1    2    0     then     B   =      1     5   10
          2    4    3                    5    10   29

Notice that  B  equals the matrix multiplication  A AT  and not  A A .

Related Commands: DMULT,EMULT,ESQRT,ESQUARE,MASKMULT,MULTD,MULTIPLY

------------------------------------------------------------------------------------------

MAT NUMLIST  1  10  11  DFILE
Input: Start_Value  End_Value  Num_Of_Values   Output: DFILE

Description: List Of Numbers In Interval (Numeric Arguments).
Create a one column matrix of equally spaced values (Num_Of_Values of them)
from Start_Value to End_Value. The inputs (Start_Value, End_Value, and
Num_Of_Values) denote actual numeric values passed as arguments. The file
created is DFILE.

Example:  Entering the statement      MAT NUMLIST  3  5  3  D.MAT
results in the matrix:

                         3.000
               D.MAT   =      4.000
                         5.000

Related Commands: MULTILIST, NUMLIST2

------------------------------------------------------------------------------------------

MAT NUMLIST2 AFILE BFILE CFILE DFILE
Input:  AFILE  BFILE  CFILE  Output: DFILE

Description: List Of Numbers In Interval (File Arguments).
AFILE contains the start value of the interval (call it A), BFILE contains
the end value of the interval (call this B), and CFILE contains the number
of values between the start and end values (call it C). Then the NUMLIST2
command creates a one column matrix of equally spaced values (C of them)
from A to B. The file created is DFILE.

Example: Entering the statement   MAT NUMLIST2 ONE.MAT FOUR.MAT FOUR.MAT
D.MAT  (where ONE.MAT contains the value 1, and FOUR.MAT contains the value
4) results in the matrix:
                              1.000
                    D.MAT  =  2.000
                              3.000
                              4.000

Related Commands: CREATE, CREATE2, MULTILIST, NUMLIST, SCALAR

------------------------------------------------------------------------------------------

MAT NUM2CHR AFILE BFILE
Input: AFILE   Output: BFILE

Description: Convert DBF With Numeric Fields To DBF With Char Fields.
Converts AFILE which is a DBF file with numeric type fields to BFILE, which
a DBF file with 24 length char fields (scientific notation).

Related Commands: CHR2NUM,DBF2SDF,SDF2DBF

------------------------------------------------------------------------------------------

MAT OVERLAY  AFILE  BFILE  SRFILE  SCFILE  DFILE
Input: AFILE, BFILE, SRFILE, SCFILE   Output: DFILE

Description: Overlay A Matrix Onto Another Matrix.
Let A=AFILE, B=BFILE, SR=SRFILE, SC=SCFILE, and D=DFILE. Overlay the matrix
A onto the matrix B and assign to matrix D.  SR contains the row of B on
which to start the overlay. SC contains the column of B on which to start
the overlay. If rows or columns of A would extend beyond the dimensions of
B then they are truncated off. The AFILE, BFILE, SRFILE, or SCFILE files
are not changed.

Example:
                                   0     0    0
Let       A  = 5    1     and   B =      0    0    0
               4    2              0     0    0

and       SR   =    [   2   ]       and       SC   =    [   2   ]

                         0    0    0
Then  D  will be         D  = 0    5     1
                         0    4    2

Related Commands: CREATE,CREATE2,EDIT,JOINCOL,JOINROW

------------------------------------------------------------------------------------------

MAT PCD  AFILE  BFILE  UFILE CFILE
Input: AFILE   Output: BFILE, UFILE, CFILE

Description: Principal Component Decomposition.
Let A=AFILE, B=BFILE, U=UFILE, C=CFILE . Given the matrix A, where each
column has statistical data for a different variable, and where the
variables are possibly correlated, this command decomposes the  A  matrix
in such a way that

  A  =  B U^T C^-1

where U is an orthonormal matrix ( U^T = U^-1 ), B is such that each
variable (column) is not statistically correlated with the other variables
(columns) in B, and C is a full rank diagonal matrix used to scale the A
matrix to decompose AC to BUT.

NOTE: To check whether variables [columns] are statistically correlated a
COLCORR can be performed. If this is done you will find that B will always
give the identity matrix, implying that the variables [columns] in B are
statistically uncorrelated.

Example:
               91.7 -1.232                    -1.231    0.4703
               103.4     -1.312                    -1.362    0.4763
               104.5     -1.321                    -1.375    0.4780
                90.2     -1.219                    -1.213    0.4676
Let      A   = 104.5     -1.320       then    B  =      -1.375    0.4773
               102.9     -1.305                    -1.355    0.4736
               101.3     -1.280                    -1.333    0.4629
               102.1     -1.294                    -1.344    0.4693
                95.6     -1.263                    -1.276    0.4753
               113.7     -1.357                    -1.469    0.4639

and  U =  -0.9024   -0.4309    and     C  =   9.902E-3     0
          0.4309    -0.9024                      0           0.7750

Related Commands: COLCORR, COLCOV, SCALE, SVD

------------------------------------------------------------------------------------------

MAT PRINT AFILE
Input: AFILE

Description: Print Report File With Confirmation
Print AFILE to system printer. There will be a prompt for the user to
confirm the printing, the pages to print, and the number of copies to
print.

NOTE: AFILE must be a report file. Use the REPORT command to convert a DBF
file to a report
           file format.

Related Commands: AUTOPRINT, REPORT

------------------------------------------------------------------------------------------

MAT PSEUDOINV AFILE BFILE  [TFILE]
Input: AFILE, TFILE   Output: BFILE

Description: Pseudo-Inverse Of A Matrix.
Let A=AFILE a mxn matrix, B=BFILE a nxm matrix, T=TFILE is a scalar
(actually a 1x1 matrix). Using the Singular Value Decomposition (SVD), the
matrix A is decomposed into matrices U, W, and V. The pseudoinverse of A,
denoted B, is then given by B=V*WPINV*UT where WPINV=DPSEUDOINV(W) and
UT=TRANSPOSE(U). (Refer to SVD about the Singular Value Decomposition, and
refer to DPSEUDOINV about the pseudoinverse of a diagonal matrix. The T
value is used when the DPSEUDOINV is called.)

Example:
               0.5  1    2
Let       A   =      1   2    4         and        T  =      [   0.1  ]
                2   1    2

                         -0.133    -0.266      0.666
Then               B   =  0.053     0.107     -0.066
                          0.107     0.213     -0.133

Related Commands: DINV,DPSEUDOINV,EINVERSE,INVERSE,SVD

------------------------------------------------------------------------------------------

MAT RANDOM RFILE CFILE AFILE
Input: RFILE, CFILE   Output: AFILE

Description: Create Matrix Of Random Numbers (Uniform, 0 to 1).
RFILE is a file (a 1x1 matrix) containing the number of rows of the AFILE
matrix. CFILE is a file (also a 1x1 matrix) containing the number of
columns of the AFILE matrix. The output AFILE will contain random values
uniformly distributed between 0 and 1.

Example:
Let RFILE contain the value 3, CFILE contain the value 2, and denote AFILE
by A, then

                              0.137  0.981
                        A   = 0.854  0.236
                              0.629       0.075

Related Commands: CREATE2,SCALAR

------------------------------------------------------------------------------------------

MAT RANK AFILE BFILE [TFILE]
Input: AFILE, TFILE  Output: BFILE

Description: Rank Of A Matrix.
Let A=AFILE, B=BFILE a 1x1 matrix, T=TFILE a 1x1 matrix. B is assigned the
rank of matrix A. Because of roundoff error the "effective" rank is
determined by specifying T to be some low magnitude such that any singular
value magnitude lower or equal to T is considered a "zero" value as far as
the rank determination is concerned. (Refer to SVD about singular values.)
If TFILE is not specified then T defaults to zero (0).

Example:
          1    2     1
Let   A = 5    3    1.5      and     T  =   [  0.1  ]   then      B = [ 2 ]
          3    5    2.4
          1    3    1.5

Related Commands: RANKDIAG, SVD

------------------------------------------------------------------------------------------

MAT RANKDIAG AFILE BFILE [TFILE]
Input: AFILE, TFILE  Output: BFILE

Description: Rank Of A Diagonal Matrix.
Let A=AFILE, B=BFILE a 1x1 matrix, T=TFILE a 1x1 matrix. B is assigned the
rank of matrix A. The rank of a diagonal matrix is merely the number of
non-zero diagonal elements. Because of roundoff error the "effective" rank
is determined by specifying T to be some low magnitude such that any
diagonal element magnitude lower or equal to T is considered a "zero" value
as far as the rank determination is concerned. If TFILE is not specified
then T defaults to zero (0).

Example:
          9.364        0    0
Let  A   =       0  2.564        0   and    T  =  [   0.1   ]    then     B
= [ 2 ]
            0     0 0.058

Related Commands: RANK, SVD

------------------------------------------------------------------------------------------

MAT RENAME AFILE BFILE
Input: AFILE   Output: BFILE

Description: Rename A File.
Rename File Name Of AFILE To BFILE.

Related Commands: COPY,DELETE

------------------------------------------------------------------------------------------

MAT REPORT AFILE BFILE
Input: AFILE   Output: BFILE

Description: Convert DBF File To Text Report File
Convert the DBF file, AFILE, to an ASCII text report file. The report file
can be viewed or edited by any ASCII text editor. This is useful when it is
desired to only print part of the file.

Related Commands: AUTOPRINT,PRINT

------------------------------------------------------------------------------------------

MAT ROW2DIAG AFILE DFILE
Input: AFILE   Output: DFILE

Description: Row Vector To Diagonal Matrix.
Let A=AFILE a row vector, D=DFILE a diagonal matrix. Copy the elements of
row vector A and assign to diagonal matrix D. D[j, j]=A[1, j].  All other
elements of matrix D are set to 0.

Example:
                                         -5   0    0
Let  A   =  [   -5    3   2   ]    then   D  =      0   3    0
                                          0   0    2

Related Commands: DIAG2COL,DIAG2ROW,MAT2DIAG

------------------------------------------------------------------------------------------

MAT ROWAVG AFILE BFILE

Input: AFILE   Output: BFILE

Description: Average Values Across Rows & Assign To Col Vector.
Let A=AFILE, B=BFILE a column vector. Average values across the rows of A
and assign to column vector B. B[i,1] = Average of Row i of matrix A.

Example:
               1    1    2               1.333
Let       A  = 2    0    2    then   B =      1.333
               0    3    5               2.666

Related Commands: COLAVG,COLMULT,COLSTDDEV,COLSUM,ROWMULT,ROWSTDDEV,ROWSUM

------------------------------------------------------------------------------------------

MAT ROWCORR AFILE BFILE
Input: AFILE   Output: BFILE

Description: Correlation Matrix From Row Data.
Let A=AFILE, B=BFILE. Let each row of A represent statistical data for a
variable. B will then give the correlation matrix using the data in matrix
A. B=ROWCORR(A). The number of statistical variables is the number of rows
in matrix A. Hence the number of rows and columns in the correlation matrix
B will be the number of rows of matrix A.

Example:
                          1    2     0    1
Let                      A  = 1.7  4.2   -0.4      1.3
                         -1   -4    -1   -1

Then to 3 significant digits  B  will be

               1    r12  r13       1        0.988  -0.817
               B  = r21  1    r23  =     0.988          1    -0.878
               r31  r32  1         -0.817   -0.878         1


NOTE: The element r12  is the correlation coefficient between rows 1 and 2
of matrix A.
      The element r13  is the correlation coefficient between rows 1 and 3
of matrix A.
      The element r23  is the correlation coefficient between rows 2 and 3
of matrix A.
     r21  = r12     ;   r31  = r13     ;    r32  = r23   ;   or in general
rki  = rik

Related Command: COLCORR

------------------------------------------------------------------------------------------

MAT ROWCOUNT AFILE BFILE
Input: AFILE   Output: BFILE

Description: Count The Number Of Rows In A Matrix.
Let A=AFILE, B=BFILE a 1x1 matrix. Count the number of rows in matrix A and
assign to B.

Example:
                3    5    1    1
 Let  A  be    A  = 11   -1    7   21         then      B   =     [  3  ]
                7    5   13   -1

Related Command: COLCOUNT

------------------------------------------------------------------------------------------

MAT ROWMEDIAN AFILE BFILE
Input: AFILE   Output: BFILE

Description: Get Median Values Across Rows & Assign To Col Vector.
Let A=AFILE, B=BFILE a column vector. Get median values across the rows of
A and assign to column vector B. B[i,1] = Median of Row i of matrix A.

Example:
               1    2    1                    1
Let            A  = 5    3    0    then       B  =      3
               3    5    4                    4

Related Commands:
COLAVG,COLMEDIAN,COLMULT,COLSTDDEV,COLSUM,ROWMULT,ROWSTDDEV,
ROWSUM

------------------------------------------------------------------------------------------

MAT ROWMULT AFILE BFILE
Input: AFILE   Output: BFILE

Description: Multiply Values Across Rows & Assign To Col Vector.
Let A=AFILE, B=BFILE a column vector. Multiply the values across the rows
of A and assign to column vector B. B[i,1] = Product of Row i of matrix A.

Example:
               3     5    1    1               15
 Let  A  be     A = 4    -1    2    3         then  B  =     -24
               7     5    0   -1                0

Related Commands: COLAVG,COLMULT,COLSTDDEV,COLSUM,ROWAVG,ROWSTDDEV,ROWSUM

------------------------------------------------------------------------------------------

MAT ROWNORM AFILE BFILE
Input: AFILE   Output: BFILE

Description: Normalize Matrix For Row Data.
Let A=AFILE, B=BFILE. Normalize values across the rows of A and assign to
matrix B. Row normalization means that for each element of A subtract the
"across the rows mean" and divide this quantity by the "across the rows
standard deviation".

B[i,j] = (A[i,j] - Mean Of Row i)/(Std Dev Of Row i).

Example:
          1    2    0                  0          1       -1
Let    A =     1    0    3    then   B  =     -0.218  -0.873   1.091
          2    2    5              -0.577  -0.577   1.155

Notice that for the (output) matrix B the across the rows mean (mean of
each row) is exactly 0, and the across the rows standard deviation
(standard deviation for each row) is exactly 1.

Related Commands: COLAVG,COLNORM,COLSTDDEV,ROWAVG,ROWSTDDEV

------------------------------------------------------------------------------------------

MAT ROWQUARTILE AFILE BFILE
Input: AFILE   Output: BFILE

Description: Get Quartile Values Across Rows & Assign To Column Vector.
Let A=AFILE, B=BFILE a column vector. Get the quartile value of the
elements across the rows of A and assign to column vector B. B[i, 1] =
Quartile of row i of matrix A. The quartile value is equal to (VAL75 -
VAL25)/2, where VAL25 is the value of the data point which is 25% across a
sorted list of the values, and VAL75 is the data point value which is 75%
across the sorted list. For example, for the first row in the A matrix,
where the values (if sorted) are { 1, 2, 3, 5 } then VAL25 is the value 2,
and VAL75 is the value 3. Hence the quartile value is

(VAL75 - VAL25)/2 = (3-2)/2 = 0.5

Example:
          1    5    3    2               0.5
Let    A =     2    3    5    1    then  B  =      0.5
          1    0    4    3               1.0

Related Commands: COLQUARTILE,COLSTDDEV,ROWSTDDEV

------------------------------------------------------------------------------------------

MAT ROWREPEAT AFILE NFILE BFILE
Input: AFILE, NFILE   Output: BFILE

Description: Repeat Row Vector Specified Times To Form Matrix.
Let A=AFILE a row vector, B=BFILE a matrix, N=NFILE a 1x1 matrix. Repeat,
A, the row vector, N times and assign to matrix B.

Example:

Let     A    =  [   -5    3    2   ]         and        N  =   [   3   ]

                         -5   3    2
then                B  = -5   3    2
                         -5   3    2

Related Commands: COLREPEAT,COLCOUNT,ROWCOUNT

------------------------------------------------------------------------------------------

MAT ROWSORT AFILE NFILE BFILE
Input: AFILE, NFILE   Output: BFILE

Description: Sort Matrix By Specified Row.
Let A=AFILE, B=BFILE a matrix, N=NFILE a 1x1 matrix. Sort the matrix, A, by
the N'th row  (from smallest to biggest) and assign to matrix B. (A
negative value for N means to sort from biggest to smallest.)


Example:
               4    1    2
Let        A  =     2    7    1    and     N   =  [  3  ]
               3    0    5

                         1    4    2
then  B  will be         B =  7    2     1
                         0    3    5

Related Commands: COLMEDIAN,COLQUARTILE,COLSORT

------------------------------------------------------------------------------------------

MAT ROWSTDDEV AFILE BFILE
Input: AFILE   Output: BFILE

Description: Std Dev Across Rows & Assign To Col Vector.
Let A=AFILE, B=BFILE a column vector. Determine the standard deviation of
the values across the rows of A and assign to column vector B. B[i,1] =
Standard Deviation of Row i of matrix A.

Example:
               1    2    0                 1
Let        A = 1    0    3     then     B = 1.528
               2    2    5                1.732

Related Commands: COLAVG,COLMULT,COLSTDDEV,COLSUM,ROWAVG,ROWMULT,ROWSUM

------------------------------------------------------------------------------------------

MAT ROWSUM AFILE BFILE
Input: AFILE   Output: BFILE

Description: Sum Values Across Rows & Assign To Col Vector.
Let A=AFILE, B=BFILE a column vector. Sum the values across the rows of A
and assign to column vector B. B[i,1] = Sum of Row i of matrix A.

Example:
               1    2    0               3
Let        A = 1    0    3     then   B =     4
               2    2    5               9

Related Commands: COLAVG,COLMULT,COLSTDDEV,COLSUM,ROWAVG,ROWMULT,ROWSTDDEV

------------------------------------------------------------------------------------------

MAT ROWSWAP AFILE BFILE
Input: AFILE   Output: BFILE

Description: Swap Matrix Rows & Assign To New Matrix
Let A=AFILE, B=BFILE. For the A matrix, swap the first and last rows, the
2nd and the 2nd to the last rows, etc. Assign to matrix B.

Example:
          1    1    2              9     4    7
Let   A = 2    0    2    then  B = 0     3    5
          0    3    5              2     0    2
          9    4    7              1     1    2

Related Command: COLSWAP

------------------------------------------------------------------------------------------

MAT SCALAR VALUE AFILE
Input: VALUE    Output: AFILE

Description: Create 1x1 Matrix & Assign Scalar Value.
Create AFILE (a 1x1 matrix) and assign VALUE to its element.

Example: Calling out the command

MAT  SCALAR  0.1  A.MAT

results in the A.MAT file containing the following value

      A.MAT  =  [   0.1  ]

This is one of the few commands that contains an explicit value as one of
the arguments. Most other commands only have file names as arguments.

Related Commands: COLCOUNT, EMULTIPLY, ROWCOUNT

------------------------------------------------------------------------------------------

MAT SCALE AFILE BFILE
Input: AFILE    Output: BFILE

Description: Create A Scale Matrix.
Let A=AFILE, B=BFILE. The SCALE command creates a matrix which can be used
to scale the columns of A to values close to unit magnitude. This is useful
when the scales within each column of A are different by several orders of
magnitude. To scale the A matrix, postmultiply it by the B matrix, thereby
forming the modified matrix AB.

NOTE: The SCALE command, which creates the B file, is equivalent to the
following sequence (with A=A.MAT):
                    MAT EABSOLUTE A.MAT ABS.MAT
                    MAT COLAVG ABS.MAT AVG.VEC
                    MAT ROW2DIAG AVG.VEC AVG.MAT
                    MAT DINV AVG.MAT B.MAT

Example:
          1E-3 1.7  -100                 10E2         0          0
Let        A = 2E-3 4.2  -430    then   B   =        0   0.526    0
            0  -0.4 -142                   0     0         4.44E-3
          1E-3 1.3  -229

Related Commands: COLAVG,DINV,EABSOLUTE,PCD,ROW2DIAG

------------------------------------------------------------------------------------------

MAT SDF2DBF AFILE BFILE CFILE
Input: AFILE, BFILE    Output: CFILE

Description: Copy SDF File Format To DBF File Format.
Convert the SDF file, AFILE, together with the structure file BFILE, to
create a DBF file, CFILE.

Example:
Let AFILE be the ASCII text file:

-32.18              279.3                     255.2
-31.15              287.0                     289.0
27.37                    364.5                     256.9
-30.0                    381.1                     278.9

where the width of each data location is as specified in the following
BFILE:

COL1      C 24   0
COL2      C 24   0
COL3      C 24   0

The BFILE will be an ASCII text file which contains the DBF structure
information. The first column of data (always of width 10) will contain the
field names. The second column (always of width 1) will contain the data
type (C for character, D for Date, L for Logical, M for Memo, and N for
Numeric). The third column (always of width 3) will contain the field
width. The fourth column (always of width 3) will contain the number of
decimal places for the field.

For the AFILE and BFILE given above the resulting DBF file CFILE will be
such that each field is of character type and of length 24:

COL1                COL2                 COL3
-32.18              279.3                     255.2
-31.15              287.0                     289.0
27.37                    364.5                     256.9
-30.0                    381.1                     278.9

Related Commands: CSV2DBF,DBF2CSV,DBF2SDF,TXT2DBF

------------------------------------------------------------------------------------------

MAT STRLIST AFILE STR1 [STR2] [STR3]  ...  [STR9]
Input: STR1, [STR2],... [STR9]   Output: AFILE

Description: Create List Of Strings.
Create AFILE (one column) and fill with list of strings. Each string is
separated by a space. Each string can be up to 24 characters long. The
number of rows in AFILE will equal the number of strings being passed. At
least one string must be passed.

Example:
If we enter the following at the DOS prompt:

MAT STRLIST A.MAT TIME POSITION VELOCITY

                              TIME
then  A.MAT  will be       A.MAT = POSITION
                              VELOCITY

Comment:
The STRLIST command is often used with the FLDRENAME command in order to
change the field names in DBF files.

Related Command: FLDRENAME

------------------------------------------------------------------------------------------

MAT SUBTRACT AFILE BFILE CFILE
Input: AFILE, BFILE   Output: CFILE

Description: Subtract Two Matrices.
Let A=AFILE, B=BFILE, C=CFILE. From matrix A subtract matrix B and assign
to matrix C.
C = A - B.

Example:
          2     3    1             1     1    0
Let   A  =     6    -1    7     and  B =      5    0    3
          3     5    6             5     2    7

                              1     2     1
Then  C  will be              C   =      1    -1    4
                              -2    3    -1

Related Command: ADD

------------------------------------------------------------------------------------------

MAT SVD AFILE UFILE SFILE VFILE
Input: AFILE   Output: UFILE, SFILE, VFILE

Description: Singular Value Decomposition Of A Matrix.
Let A=AFILE, U=UFILE, S=SFILE, V=VFILE, VT=Transpose(V). Given the matrix
A, this command decomposes the matrix A into matrices U, S, and V such that

 A  =  U S VT

where U is an orthonormal matrix, S is a diagonal matrix with all elements
>=0, and V is another orthonormal matrix. The diagonal elements in the
diagonal matrix S are known as singular values.

Example:
                         1    2    1
Let                 A  = 5    3    0
                         3    5    4
                         1    3    2

          -0.252    -0.092    -0.548               9.530         0
0
Then  U  =     -0.523    0.845           -0.044      and   S =       0
 3.581     0
          -0.725    -0.408    0.545                        0          0
    0.592
          -0.370    -0.331    -0.633

                         -0.568    0.720           0.399
and                 V    =    -0.715     -0.191    -0.673
                         -0.409    -0.667      0.623

Related Commands: DET,LDLT,LUD,DPSEUDOINV,PSEUDOINV,RANK,RANKDIAG

------------------------------------------------------------------------------------------

MAT TRACE AFILE BFILE
Input: AFILE   Output: BFILE

Description: Trace Of A Matrix.
Let A=AFILE, B=BFILE. Assign the trace of A to the 1x1 matrix B.
B=Trace(A).

Example:
                3    5   1
 Let  A  be    A  = 11   -2   7    then      B   =      [  5  ]
                7    5   4

Related Commands: None

------------------------------------------------------------------------------------------

MAT TRANSPOSE AFILE BFILE
Input: AFILE   Output: BFILE

Description: Transpose Of A Matrix.
Let A=AFILE, B=BFILE. B is output as the transpose of A.  B=Transpose(A).

Example:
               2     3
Let        A  =     6    -1     then   B   =  2     6   3
               3     5                   3    -1   5

Related Commands: None

------------------------------------------------------------------------------------------

MAT TXT2DBF AFILE BFILE
Input: AFILE    Output: BFILE

Description: Convert TEXT File (24 Data Width) To DBF File Format.
Convert the TXT file, AFILE, to create a DBF file, BFILE. A data width of
24 characters is required for the TXT file. Also it is required that each
row of data is ended with a carriage return/line feed pair (ASCII
characters 13 and 10).

Example:
Let AFILE be the ASCII text file:

-32.18         279.3                     255.2
-31.15         287.0                     289.0
27.37               364.5                     256.9
-30.0               381.1                     278.9

where each data cell must be 24 characters in width, and each line is
terminated with a carriage return/ line feed pair (ASCII characters 13 and
10). For the AFILE given above the resulting DBF file BFILE will be such
that each field is of character type and of length 24:

COL1           COL2                COL3
-32.18         279.3                     255.2
-31.15         287.0                     289.0
27.37               364.5                     256.9
-30.0               381.1                     278.9

The field names in the DBF file are automatically assigned the names COL1,
COL2 , etc.

Related Commands: CSV2DBF,DBF2CSV,DBF2SDF, SDF2DBF

------------------------------------------------------------------------------------------

MAT WITHINEQ AFILE BFILE CFILE DFILE
Input: AFILE, BFILE, CFILE   Output: DFILE

Description: Are Elements In A within or equal to elements in B & C
Let A=AFILE, B=BFILE, C=CFILE, D=DFILE. A, B, C, & D all have the same
number of rows and columns. Given the matrix files A, B, and C this command
checks to see if the element values in A are between the element values in
B and C. If the element in A is within or equal to the corresponding
elements in B and C then the element in D is assigned 1, otherwise it is
assigned 0 (zero).

Example:
          1     5               -10  1        10   2
Let  A  = 2    -1       and  B   =  2   0      C =       5   1
          7     1                1  0          3   6

                         1     0
Then                C  = 1     0
                         0     1

Related Commands: COMPLEMENT,GE,GT,LE,LT,WITHINNE

------------------------------------------------------------------------------------------

MAT WITHINNE AFILE BFILE CFILE DFILE
Input: AFILE, BFILE, CFILE   Output: DFILE

Description: Are Elements In A Within (But Not Equal) To Elements In B & C
Let A=AFILE, B=BFILE, C=CFILE, D=DFILE. A, B, C, & D all have the same
number of rows and columns. Given the matrix files A, B, and C this command
checks to see if the element values in A are between the element values in
B and C. If the element in A is within but not equal to the corresponding
elements in B and C then the element in D is assigned 1, otherwise it is
assigned 0 (zero).

Example:
          1     5             -10  1          10   2
Let   A = 2    -1    and   B  =      2   0     C =   5  1
          3     2               1  0           3   6

                         1     0
Then                C  = 0     0
                         0     1

Related Commands: COMPLEMENT,GE,GT,LE,LT,WITHINEQ

------------------------------------------------------------------------------------------

Example 4 : Polynomial Interpolation

Polynomial interpolation consists of determining the unique n-th order
polynomial that fits n+1 data points. For example, let's say we are given
the three data points

                          X    Y
                         1.0  5.2
                         2.0  7.8
                         3.0  3.5

and we desire a polynomial formula of the form

y  =  a1 + a2 x + a3 x2

>From this we see that
5.2   =   a1  +  a2 (1.0)  +  a3 (1.0)^2
7.8   =   a1  +  a2 (2.0)  +  a3 (2.0)^2
3.5   =   a1  +  a2 (3.0)  +  a3 (3.0)^2

In matrix form this can also be represented as

y   =  B a

where

          5.2            1    1.0  (1.0)^2              a1
     y  = 7.8       B =  1    2.0  (2.0)^2         a  =      a2
          3.5            1    3.0  (3.0)^2              a3

Similiar to example 2, the solution for a (which has the values of a1 , a2
, and a3 ) is:

a  =  B^-1 y



In terms of MAT commands this would be

                    MAT INVERSE B.MAT BINV.MAT
                    MAT MULTIPLY BINV.MAT Y.MAT A.MAT

------------------------------------------------------------------------------------------

Example 5 : Least Squares Curve Fitting

In contrast to interpolation there are times when you may want to fit a
curve to several data points not by having the curve follow a high order
equation but by fitting a low order equation approximately. Usually this
fit is done in the "least squares" sense. The coefficients in the fitted
equation are those which results in the least sum-of-square deviations
between each data point and the curve. For example, let us say we have the
six data points:

                         X     Y
                         0     2.1
                         1     7.7
                         2    13.6
                         3    27.2
                         4    40.9
                         5    61.1

and that we desire to fit a 2nd order polynomial of the form

y  =  a1 + a2 x + a3 x^2

>From this we have the system of equations

2.1   @   a1  +  a2 (0)  +  a3 (0)^2
7.7   @   a1  +  a2 (1)  +  a3 (1)^2
13.6   @   a1  +  a2 (2)  +  a3 (2)^2
27.2   @   a1  +  a2 (3)  +  a3 (3)^2
40.9   @   a1  +  a2 (4)  +  a3 (4)^2
61.1   @   a1  +  a2 (5)  +  a3 (5)^2

Here we see that we have 6 equations but only 3 unknowns. In matrix form
the system reads

y  =  B a    (approx.)




 where
           2.1           1    0    (0)^2
           7.7           1    1    (1)^2                a1
     y  = 13.6      B =  1    2    (2)^2            a  =     a2
          27.2           1    3    (3)^2                a3
          40.9           1    4    (4)^2
          61.1           1    5    (5)^2


In general, we will not be able to determine an a which will solve  y = B a
exactly. (That is the reason that the relations are denoted as
approximately equal.) However, a "best fit" a can be calculated by using
the formula

a  =  Bp y

where Bp is known as the pseudoinverse of the matrix B. (The pseudoinverse
is more general than the regular inverse and simplifies to the regular
inverse when the matrix B is square and non-singular.)

The MAT commands to use to obtain the best fit a are:

                    MAT PSEUDOINV B.MAT BPINV.MAT
                    MAT MULTIPLY BPINV.MAT Y.MAT A.MAT

The result for this case will be

a1 = 2.47857,    a2 = 2.35928,     a3 = 1.86071

------------------------------------------------------------------------------------------

Example 6 : Curve Fit Of A Power Equation

The equation relating diameter (D), slope (S), and flow (F) for concrete
circular pipes is given by

F  =  a1 D^a2 S^a3

Taking the natural logarithm of this equation gives

log(F)  =  log(a1)  +  a2 log(D)  +  a3 log(S)

An experiment was performed for 3 different diameter pipes at three
different slopes. The measurements were

               D (ft)    S (ft/ft) F (ft3/sec)

-----------------------------------------------------------------
                 1       0.001             1.4
                 2       0.001             8.3
                 3       0.001            24.2
                 1       0.010             4.7
                 2       0.010            28.9
                 3       0.010            84.0
                 1       0.050            11.1
                 2       0.050            69.0
                 3       0.050           200.0


Letting y = log(F),  c1 = log(a1 ) ,  c2 = a2 ,  c3 = a3  we will have the
system of equations

y  =  B c  (approx)




where
          log(1.4)            1    log(1)     log(0.001)
          log(8.3)            1    log(2)     log(0.001)
          log(24.2)           1    log(3)     log(0.001)
          log(4.7)            1    log(1)     log(0.010)
     y  = log(28.9)      B =  1    log(2)     log(0.010)
          log(84.0)           1    log(3)     log(0.010)
          log(11.1)           1    log(1)     log(0.050)
          log(69.0)           1    log(2)     log(0.050)
          log(200.0)               1     log(3)    log(0.050)


The "best fit" c will be given by

c  =  Bp y

where Bp is the pseudoinverse of the matrix B. To initially determine the y
and B matrices the MAT command ELOG is handy. Let us say we start with the
one column matrices:


            1            0.001                  1.4               1
            2            0.001                  8.3               1
            3            0.001                 24.2               1
            1            0.010                  4.7               1
COL2.MAT =       2    COL3.MAT=    0.010         Y1.MAT =     28.9
B.MAT=    1
            3            0.010                 84.0               1
            1            0.050                 11.1               1
            2            0.050                 69.0               1
            3            0.050                200.0               1


To get the y we use the ELOG command on Y1.MAT

MAT ELOG Y1.MAT Y.MAT


To get the log of COL2.MAT

MAT ELOG COL2.MAT LCOL2.MAT

To get the log of COL3.MAT

MAT ELOG COL3.MAT LCOL3.MAT

Now we join column matrix LCOL2.MAT to B.MAT with the JOINCOL command.
Result is assigned to B.MAT (although another file name is also valid)

MAT JOINCOL B.MAT LCOL2.MAT B.MAT

The third column, LCOL3.MAT, is now joined to B.MAT

MAT JOINCOL B.MAT LCOL3.MAT B.MAT

The "best fit" one column matrix, C.MAT, is determined by

               MAT PSEUDOINV B.MAT BPINV.MAT
               MAT MULTIPLY BPINV.MAT Y.MAT C.MAT

The value of  a2 = c2 and  a3 = c3  . To get the value of a1 = ec1  we use
the EEXP command operated on the C.MAT matrix:

MAT EEXP C.MAT CEXP.MAT

The first element of the CEXP.MAT one column matrix has the value of a1 .

It is recommended that a batch file with the above commands be created. In
this way if there are any corrections or additional data, the analysis can
be easily reperformed.

------------------------------------------------------------------------------------------

Example 7 : Gaussian Random Number Generation

Using the RANDOM command (which generates uniformly distributed values
between 0 and 1) we can generate random numbers which approximately follow
a Gaussian distribution. This is done by transforming the uniformly
distributed random numbers, a, by the function:

b  =  0.5555*LOG[ a / (1-a) ]

where LOG is the natural logarithm.

An example to generate 1 column of random data (with 300 rows of data
points) follows:

------------------------------------------------------------------------------------------

REM --- File: RAND2.BAT     Dec 16, 1998     By: M.Peralta ---
REM --- B.MAT Will Have An Approx. Gaussian Distribution ---
REM --- With An Average Close To Zero, And A Std Dev Close To 1.0 ---

MAT SCALAR 300 NROW.MAT
MAT SCALAR 1 NCOL.MAT
MAT SCALAR 1 ONE.MAT
MAT SCALAR 0.55555 CONST.MAT

REM --- Create Matrix Of Uniform Random Numbers ---
MAT RANDOM NROW.MAT NCOL.MAT A.MAT

REM --- Create NROWx1 Matrix Of 1's ---
MAT ROWREPEAT ONE.MAT NROW.MAT MAT1.MAT

REM --- From Matrix Of 1's Subtract A.MAT ---
MAT SUBTRACT MAT1.MAT A.MAT A2.MAT

REM --- Calc Reciprocal Of Each Element In A2.MAT ---
MAT EINVERSE A2.MAT A3.MAT

REM --- Multiply Each Element In A.MAT With Corresponding Element In A3.MAT
REM --- NOTE: This Is NOT Multiplication Of Matrices
MAT MASKMULT A.MAT A3.MAT A4.MAT

REM --- Take Natural Log Of Each Element In A4.MAT ---
MAT ELOG A4.MAT A5.MAT

REM --- Multiply Each Element Of A5.MAT By CONST.MAT ---
MAT EMULTIPLY A5.MAT CONST.MAT B.MAT

------------------------------------------------------------------------------------------


Example 8 : Eigenvectors & Eigenvalues

                                     m1             m2
                        |______o______o__________________
                                       |-> x1          |-> x2

The equations of motion for two masses attached together with a spring with
one of the masses attached with a spring to an unmovable wall are:

m1  d2x1 /dt2    =   -k1 x1  + k2 (x2  - x1 )   =   (-k1  - k2 )x1  +  k2
x2

m2  d2x2/dt2   =   -k2 (x2  - x1 )    =    k2 x1   -  k2 x2


Dividing the equations by the masses we obtain

d2x1 /dt2   =    [(-k1  - k2 )/m1 ] x1   +   (k2/m1 ) x2

d2x2/dt2   =    (k2 /m2 ) x1    +   (-k2 /m2 ) x2

Assuming oscillatory motion of the form:

               x1  = x10sin(wt)          x2  = x20sin(wt)

then the first derivative of these relations are

          dx1 /dt   =    w x10cos(wt)          ,      dx2/dt   =  w
x20cos(wt)

The second derivatives are

d2x1 /dt2   =   -w2 x10sin(wt)   =  -w2 x1

d2x2/dt2   =  -w2 x20sin(wt)  =  -w2 x2


This implies that

d2x1 /dt2   =   -w2 x1   =   [(-k1  - k2 )/m1 ] x1   +   (k2/m1 ) x2

d2x2/dt2   =  -w2 x2  =    (k2 /m2 ) x1    +   (-k2 /m2 ) x2

or multiplying both sides by -1

w2 x1   =   [(k1  + k2 )/m1 ] x1    -   (k2/m1 ) x2

w2 x2  =    (-k2 /m2 ) x1    +   (k2 /m2 ) x2


Defining
               x1        (k1  + k2 )/m1        -k2/m1
            x =     x2   A  =      -k2 /m2          k2 /m2


Then the previous two equations represented in matrix form is

A x = w2 x

Defining l = w2  we then have the eigensystem

A x = l x

Values of l which meet the conditions of this equation are known as
eigenvalues and x vectors satisfying the equation are known are
eigenvectors. As a numeric example let m1  = 2, k1  = 4, m2 = 2, and k2  =
2  then

                               3   -1
                    A   =     -1    1

To determine the eigenvalues and eigenvectors for this real symmetric
matrix we use the EIGENSYM command:

MAT EIGENSYM A.MAT AVEC.MAT AVAL.MAT


------------------------------------------------------------------------------------------






Date Index | Thread Index | Problems or questions? Contact list-master@nist.gov