Statistica Visual Basic contains a large number of designated matrix and statistical functions, which make the SVB environment ideal for prototyping algorithms or for developing custom statistical procedures. The matrix and statistical functions are documented in detail in Statistica Matrix Function Library.

One major advantage of using the Statistica library of matrix functions, instead of writing these functions "by hand" in Visual Basic, is that the former will evaluate much faster. For example, when you want to invert large matrices, the MatrixInverse function will perform the actual matrix inversion using the highly optimized (compiled) algorithms of Statistica.

Include file: STB.svx. To provide convenient access to the matrix functions without requiring you to pass explicitly the dimensions of the arrays that are being passed, Statistica includes a file with function interfaces: STB.svx. You may want to open this file to review the functions and see how they provide simplified access to the actual matrix library. It is recommended that you routinely include that file at the beginning of your program when you intend to use functions from the Statistica libraries of matrix and statistical functions.

In order to insure the portability of all Statistica Visual Basic macros, you can specify an asterisk in front of the root file name for the standard include files. When Statistica detects the *, it will automatically search for the STB.svx file in standard places (e.g., the directory where the macro has been saved, the global macro directory, and the directory where the Statistica application is located). Thus it is not necessary to state the complete path for the STB.svx file when including this file in your Statistica Visual Basic programs via the $Include statement.

Please note that Statistica*'s *Matrix functions are also available
directly via the MatrixObject.

Reviewing the matrix
functions in the function browser. You can review the available
matrix functions either in Statistica Help or in the Function
Browser, which also lists various other functions available in
Statistica Visual Basic. The
Function Browser is accessible
via the SVB View menu or by clicking
the

Example. The following example illustrates how to use the functions in the Statistica library of matrix functions, to perform some basic matrix operations: Namely, matrix inversion and matrix multiplication:

' declared by default as 1-referenced, i.e., the

' first element in an array will be element 1, not 0.

' Note that the matrix and statistical functions

' will work fine with 0-referenced arrays; however,

' it can be confusing to write programs with 0-

' referenced arrays, because many of the matrix

' functions expect arguments based on 1-referenced

' arrays.

Option Base 1

Sub Main

' Set up two 4 x 4 matrices.

Dim a(4,4) As Double, ainv(4,4) As Double

Dim i As Long, j As Long

' Fill the matrix with random numbers

For i=1 To 4

For j=1 To 4

a(i,j)=Rnd(10)

Next j

Next i

' Display the original matrix.

MatrixObject.MatrixDisplay (a, "Original Matrix A")

' Invert the matrix.

MatrixObject.MatrixInverse(a,ainv)

' Display the inverted matrix.

MatrixObject.MatrixDisplay (ainv, "A, Inverse")

' Multiply a*a-inverse

MatrixObject.MatrixMultiply(a,ainv,a)

MatrixObject.MatrixDisplay(a,"A * A-inverse")

End Sub