Readme file for PROMATH 3.0 Visual Basic
-----------------------
Release date: 10/2/98

This VB Readme updated 3/16/99 and 10/20/1999

PROMATH 3.0 IS COMPATIBLE WITH QuickBASIC, PDS BASIC, PowerBasic, VBDOS,
and Visual Basic for Windows.

The VB directory contains demo projects for VB3, 4, 5, and 6, and a 
compiled file MATHDEMO5.EXE which demonstrates the PROMATH routines. 

Simple demo for VB3,4: just one form.  
Project for VB3: MATHDEM3.MAK
Project for VB4: MATHDEM4.MAK

Complex demo for VB5 and VB6
Project for VB5: mathdemo5.vbp
Project for VB6: mathdemo6.vbp
Compiled for Win 95, 98, NT: mathdemo5.exe


Another note: 
Installation instructions described in manual are slightly incorrect.
1) There is no DOS install available right now.

2) To install, run ProMathInstall.exe, not Setup.exe

3) This install has versions for QuickBasic, PowerBasic, and VB. 

4) ProMathInstall.exe is for Win32 (Win 95, 98, NT)
   to install in DOS or Windows 3.1, you need to install this 
   on a Win9x or NT computer, then copy the directories.

   If you only have DOS or Windows 3.1, and wish to get the ProMath 
   files for it, contact TeraTech at info@teratech.com, or phone 
   +1-301-424-3903.


Below we describe routines which are in ProMath, but not in Manual
------------------------------------------------------------------

Routine:      MatEleDiv
File:         MATRIX.BAS
Usage:        Call CMatEleDiv(A(), B(), R(), N, M)

Divide all the elements of a complex matrix A(), by another B(). 
All elements are complex.
         A(I,J)
R(I,J) = ------
         B(I,J)

A, B and R must be the same size NxM.
The following parameters are passed:

A() Name of first input (complex) NxM matrix
B() Name of second input (complex) NxM matrix
R() Name of output (complex) NxM matrix
N   Number of rows in A(),B(), and R()
M   Number of columns in A(),B(), and R()


------------------------------------------------------------------
Routine:      AllStats
File:         STATS.BAS
Usage:        Call Allstats(Dat#(), Start%, NSamples%, Min#, Max#, Range#, _
 	                    Average#, StdDev#)

Calculates the average, standard deviation, minimum, maximum and range of 
all or part of a set of samples.

The following arguments are passed:
Dat#()     the array holding the data. It must be dimensioned to at least 
	   (Start% + Nsamples% -1) locations. It is unchanged.
Start%     the location from which calculation starts
Nsamples%  the Number of samples used in calculation
min#       returned with the least value found
max#       returned with the largest value found
Range#     returned with the range, Max# - Min#
Average#   returned with the average of the Nsamples%
StdDev#    returned with the Standard Deviation of the Nsamples%

Algorithm:
The routine combines several of the most used statistic routines and 
allows you the additional flexibility of starting from any location. 
It will exit if Nsamples% is less than 2. Please see AVERAGE and STANDARDDEV 
for similar individual routines.

------------------------------------------------------------------
------------------------------------------------------------------
------------------------------------------------------------------
Corrections :
------------------------------------------------------------------
------------------------------------------------------------------

Routine:      MatEquate
File:         MATRIX.BAS
Usage:        CALL MatEquate(A(),B(),N,M)

This routine copies one real matrix into another.
The following parameters are passed:
A()	A real matrix of dimension NM. A() is unchanged
B()	A real matrix of dimension NM. B() is replaced by A()
N	The first dimension of the real matrices, A() and B().
M	The second dimension of the real matrices, A() and B().

Caution:  It is important to remember that the matrix B() is altered 
on return to the calling module.

Algorithm:
The matrix is copied term by term.

------------------------------------------------------------------
Routine:      CMatEquate
File:         MATRIX.BAS
Usage:        CALL CMatEquate(A() AS COMPLEX,B() AS COMPLEX,N,M)

This routine copies one complex matrix into another.
The following parameters are passed:
A()	A complex matrix of dimension NM. A() is unchanged
B()	A complex matrix of dimension NM. B() is replaced by A()
N	The first dimension of the complex matrices, A() and B().
M	The second dimension of the complex matrices, A() and B().

Caution:  It is important to remember that the matrix B() is altered 
on return to the calling module.

Algorithm:
The matrix is copied term by term.

------------------------------------------------------------------
Routine:      CMatEquateReal
File:         MATRIX.BAS
Usage:        CALL CMatEquateReal(A() AS COMPLEX,B(),N,M)

This routine copies the real parts of a complex matrix into a real matrix.
The following parameters are passed:
A()	A complex matrix of dimension NM. A() is unchanged
B()	A real matrix of dimension NM. B() is replaced by the real parts of A()
N	The first dimension of the matrices, A() and B().
M	The second dimension of the matrices, A() and B().

Caution:  It is important to remember that the matrix B() is altered 
on return to the calling module.

Algorithm:
The real parts of the matrix is copied term by term into a real matrix

------------------------------------------------------------------
Routine:      CMatIdent
File:         MATRIX.BAS
Usage:        CALL CMatIdent(A() AS COMPLEX,N)

Makes A() into a unit matrix.
The following arguments are passed:
A()	The complex, square matrix to be returned as a unit complex matrix. 
	Note the dimension of this matrix is NxN.
N	The dimension of the NxN square matrix A().

Algorithm:
Writes 1 + i0 on the main diagonal of A() and 0 + i0 elsewhere.

------------------------------------------------------------------
Routine:      CMATINV
File:         MATRIX.BAS
Usage:        CALL CMATINV(A() AS COMPLEX,Y() AS COMPLEX,N, ErrCode)

To invert a complex square matrix and return its inverse.
The following arguments are passed:
A()	The complex, square matrix whose inverse is to be computed. 
	Note that this matrix is destroyed. The dimension of this matrix is NxN.
Y()	Returned with the inverse of the matrix A().
N	The dimension of the NxN square matrices A() and Y().

Algorithm:
One of the most efficient ways to compute the inverse of a matrix is using the 
LU decomposition technique. Given a square matrix A, if we decompose it once 
using the LU decomposition and subsequently use back substitution on the 
LU decomposed matrix, the resulting matrix is the inverse of the matrix A. 
We have adapted the LU method to complex matrices.


------------------------------------------------------------------
------------------------------------------------------------------
------------------------------------------------------------------
Matrix Printing for Visual Basic

Tip:  The matrix print routines have been updated to allow them to be used 
	in Visual Basic. Some Basic Language definitions allow you to write 
	Print <expression> where Visual Basic requires you to write statements 
	like FormName.Print <expression>. We have introduced an extra parameter 
	to specify where you want the printing to take place, so that our routines 
	will work on VB 4.0 and later versions 

Caution:  We have kept the same routine names for routines with the same function. 
	Since they have different parameters please take care not to mix them up.
------------------------------------------------------------------
------------------------------------------------------------------

------------------------------------------------------------------
Routine:      MATPRINT
File:         MATRIX.BAS
Usage:        CALL MATPRINT (ObjName As Object, A#(), N%, M%, Formt$)

MatPrint lists a matrix on a form, picture or printer.
The following arguments are passed:

ObjName	The name of the place where printing is to take place. 
	ObjectName may be a form name or a picture name, or a printer name. 
	Or, to print on the default printer, use Printer. Also during 
	development you may use Debug.
A()	The matrix of dimension NM to be listed on the ObjName.
N	The number of rows in the matrix A() (printing starts at 1)
M	The number of columns in the matrix A(). M should be 1 if the array is 
	one-dimensional.
Formt$	A string specifying the number format to be used in printing the numbers. 
	The format is identical to BASIC's PRINT USING. If Formt$ = "", default 
	scientific notation is used (i.e., 10.5 is written as 0.105D+2).

Algorithm
Matprint calls MatPrint1 if it is printing a one-dimensional array or MatPrint2 for two-dimensional arrays.
Example:
DIM A(3, 5)
N = 3                                 ' number of rows
M = 5                                 ' number of columns
'--- define the matrix A
FOR I = 1 TO N
  FOR J = 1 TO M
    A(I, J) = I + J
  NEXT J
NEXT I
F$ = ""        ' default scientific notation for matprint
CALL MATPRINT(Form1, A(), N, M,F$,)  ' print to Form1
Results:
0.200D+1  0.300D+1  0.400D+1  0.500D+1  0.600D+1
0.300D+1  0.400D+1  0.500D+1  0.600D+1  0.700D+1
0.400D+1  0.500D+1  0.600D+1  0.700D+1  0.800D+1

------------------------------------------------------------------
Routine:      MATPRINT1
File:         MATRIX.BAS
Usage:        CALL MATPRINT1(ObjName As Object, A#(), N%, Formt$)

This routine lists a one-dimensional matrix on a form, picture or printer. 
(You don't have to call it directly).

The following arguments are passed:
ObjName	The name of the place where printing is to take place. 
	ObjectName may be a form name or a picture name, or a printer name. 
	Or, to print on the default printer, use Printer. Also during 
	development you may use Debug.
A()	The matrix of dimension N to be listed on the ObjName.
N	The number of rows in the matrix A() (printing starts at 1)
Formt$	A string specifying the number format to be used in printing the numbers. 
	The format is identical to BASIC's PRINT USING. If FORM$ = "", default 
	scientific notation is used (i.e., 10.5 is written as 0.105D+2).

Example:
DIM A(3, 5)
N = 3                                 ' number of rows
M = 5                                 ' number of columns
'--- define the matrix A
FOR I = 1 TO N
  FOR J = 1 TO M
    A(I, J) = I + J
  NEXT J
NEXT I
F$ = ""        ' default scientific notation for matprint
CALL MATPRINT(form1, A(), N, M,F$,"SCREEN")  ' print to form1
Results:
0.200D+1  0.300D+1  0.400D+1  0.500D+1  0.600D+1

------------------------------------------------------------------
Routine:      MATPRINT2
File:         MATRIX.BAS
Usage:        CALL MATPRINT2(ObjName As Object, A#(), N%, M%, Formt$)

This routine lists a two-dimensional matrix on a form, picture or printer. 
(You don't have to call it directly).

The following arguments are passed:
ObjName	The name of the place where printing is to take place. 
	ObjectName may be a form name or a picture name, or a printer name. 
	Or, to print on the default printer, use Printer. Also during 
	development you may use Debug.
A()	The matrix of dimension NM to be listed on the ObjName.
N	The number of rows in the matrix A() (printing starts at 1)
M	The number of columns in the matrix A().(printing starts at 1)
Formt$	A string specifying the number format to be used in printing the numbers. 
	The format is identical to BASIC's PRINT USING. If Formt$ = "", default 
	scientific notation is used (i.e., 10.5 is written as 0.105D+2).

Example:
DIM A(3, 5)
N = 3                                 ' number of rows
M = 5                                 ' number of columns
'--- define the matrix A
FOR I = 1 TO N
  FOR J = 1 TO M
    A(I, J) = I + J
  NEXT J
NEXT I
F$ = ""        ' default scientific notation for matprint
CALL MATPRINT(form1, A(), N, M,F$,"SCREEN")  ' print to form1
Results:
0.200D+1  0.300D+1  0.400D+1  0.500D+1  0.600D+1
0.300D+1  0.400D+1  0.500D+1  0.600D+1  0.700D+1
0.400D+1  0.500D+1  0.600D+1  0.700D+1  0.800D+1

------------------------------------------------------------------
Routine:      CMATPRINT
File:         MATRIX.BAS
Usage:        CALL CMATPRINT(ObjName As Object, A() As COMPLEX, N%, M%, _
			     MaxCha%, Formt$)

This routine lists a complex matrix on a form, picture or printer.

The following arguments are passed:
ObjName	The name of the place where printing is to take place. 
	ObjectName may be a form name or a picture name, or a printer name. 
	Or, to print on the default printer, use Printer. 
	Also during development you may use Debug.
A()	The complex matrix of dimension NM to be listed on the ObjectName.
N	The number of rows in the matrix A() (printing starts at 1)
M	The number of columns in the matrix A(). Use M = 1 for a 1-dimensional array.
MaxCha%	the real part and the imaginary part of each number will be printed 
	to a maximum of MaxCha% characters (may override Formt$)
Formt$	A string specifying the number format to be used in printing the numbers. 
	The format is identical to BASIC's PRINT USING. If Formt$ = "", default 
	scientific notation is used (i.e., 10.5 is written as 0.105D+2).

Algorithm:
CMatprint calls CMatPrint1 if it is printing a one-dimensional complex array 
or CMatPrint2 for two-dimensional complex arrays. These routines both use Cformat$ 
to get a print string for each complex number and then add brackets for separation.

Example:
DIM A(3, 3) AS COMPLEX
N = 3                                 ' number of rows
M = 3                                 ' number of columns
'--- define the matrix A
FOR I = 1 TO N
  FOR J = 1 TO M
    A(I, J).X = I : A(I,J).Y= J
  NEXT J
NEXT I
F$ = ""       ' default scientific notation for cmatprint
CALL CMATPRINT(form1, A(), N, M,F$,"SCREEN") ' print to form1
Results:
(0.100D+1 0.100D+1i) (0.100D+1 0.200D+1i) (0.100D+1 0.300D+1i)
(0.200D+1 0.100D+1i) (0.200D+1 0.200D+1i) (0.200D+1 0.300D+1i)
(0.300D+1 0.100D+1i) (0.300D+1 0.200D+1i) (0.300D+1 0.300D+1i)

------------------------------------------------------------------
Routine:      CMATPRINT1
File:         MATRIX.BAS
Usage:        CALL CMATPRINT1(ObjName As Object, A() As COMPLEX, N%, _
				MaxCha%, Formt$)
 

This routine lists a one-dimensional complex matrix on a form, picture or printer. 
You do not have to call it directly.

The following arguments are passed:
ObjName	The name of the place where printing is to take place. 
	ObjectName may be a form name or a picture name, or a printer name. 
	Or, to print on the default printer, use Printer. Also during 
	development you may use Debug.
A()	The matrix of dimension N to be listed on the ObjName
N	The number of rows in the matrix A().
MaxCha%	the real part and the imaginary part of each number will be printed to 
	a maximum of MaxCha% characters (may override Formt$)
Formt$	A string specifying the number format to be used in printing the numbers. 
	The format is identical to BASIC's PRINT USING. If Formt$ = "", default 
	scientific notation is used (i.e., 10.5 is written as 0.105D+2).
Example:
DIM A(3, 3) AS COMPLEX
N = 3                                 ' number of rows
M = 3                                 ' number of columns
'--- define the matrix A
FOR I = 1 TO N
  FOR J = 1 TO M
    A(I, J).X = I : A(I,J).Y= J
  NEXT J
NEXT I
F$ = ""       ' default scientific notation for cmatprint
CALL CMATPRINT(form1, A(), N, M,F$,"SCREEN") ' print to form1
Results:
(0.100D+1 0.100D+1i) (0.100D+1 0.200D+1i) (0.100D+1 0.300D+1i)

------------------------------------------------------------------
Routine:      CMATPRINT2
File:         MATRIX.BAS
Usage:        CALL CMATPRINT2(ObjName As Object, A() As COMPLEX, N%, M%, _
				MaxCha%, Formt$)

This routine lists a two-dimensional complex matrix on a form, picture or printer. 
(You do not have to call it directly)

The following arguments are passed:
ObjName	The name of the place where printing is to take place. 
	ObjectName may be a form name or a picture name, or a printer name. 
	Or, to print on the default printer, use Printer. Also during 
	development you may use Debug.
A()	The matrix of dimension NM to be listed on the ObjectName.
N	The number of rows in the matrix A() (printing starts at one)
M	The number of columns in the matrix A().
MaxCha%	the real part and the imaginary part of each number will be printed 
	to a maximum of MaxCha% characters (may override Formt$)
Formt$	A string specifying the number format to be used in printing the numbers. 
	The format is identical to BASIC's PRINT USING. If Formt$ = "", default 
	scientific notation is used (i.e., 10.5 is written as 0.105D+2).

Example:
DIM A(3, 3) AS COMPLEX
N = 3                                 ' number of rows
M = 3                                 ' number of columns
'--- define the matrix A
FOR I = 1 TO N
  FOR J = 1 TO M
    A(I, J).X = I : A(I,J).Y= J
  NEXT J
NEXT I
F$ = ""       ' default scientific notation for cmatprint
CALL CMATPRINT(form1, A(), N, M,F$,"SCREEN") ' print to form1
Results:
(0.100D+1 0.100D+1) (0.100D+1 0.200D+1) (0.100D+1 0.300D+1)
(0.200D+1 0.100D+1) (0.200D+1 0.200D+1) (0.200D+1 0.300D+1)
(0.300D+1 0.100D+1) (0.300D+1 0.200D+1) (0.300D+1 0.300D+1)

------------------------------------------------------------------
------------------------------------------------------------------
Matrix Printing for DOS
These versions of the matrix printing routines are the original ones, 
with some corrections. 
------------------------------------------------------------------
------------------------------------------------------------------

---
End of readme.
