Include File STB.svx and Statistica Visual Basic Library of Matrix Functions

The include file STB.svx includes various interfaces to (1) the STB library of matrix functions and (2) various spreadsheet functions that were included in Statistica Version 5 to manage scrollsheets (which were the output documents used in Statistica Version 5; see also Include file Graphics.svx); these ("old-style") scrollsheet functions are provided for backward compatibility (with Version 5) only (note that the current version's data spreadsheet functions are much more general, powerful, and usually easier to use).

Therefore, in order to access any of the functions of, for example, the STB Visual Basic library of matrix functions, you must include the file STB.svx at the beginning of the file:

'$include: "*STB.svx"

' This program will now have access to all

' functions of the STATISTICA Visual Basic

' library of matrix functions.

Sub Main

  ....

  ....

An example of a complete program is also provided below.

The asterisk convention
In order to ensure 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.
When to include STB.svx.
When you create new macros (e.g., see Create New Document - Macro tab), an option is provided to automatically include this file (with the interfaces described above) in the newly created macro. Remember that this is only necessary if you need to access the matrix functions (or "old-style" scrollsheet functions for backward compatibility). It is not necessary to routinely include this file. STB.svx includes a large number of (interface-) subroutines and functions, and therefore, compiling programs that include this file may require slightly more time.
Statistica Visual Basic library of matrix functions
Statistica Visual Basic contains a large number of designated matrix and statistical functions that 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.

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:

' The following line is very important!

' It contains the "interfaces" to the Statistica

' Matrix and Statistical Function libraries. Note

' that we are using the "asterisk" (*) convention to

' direct the program to "look for" file STB.svx

' in the current installation of STATISTICA; this

' ensures portability of code from one machine

' (installation of STATISTICA) to another.

'$include: "*STB.svx"

' The next statement will cause all arrays to be

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

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

Option Base 1

Sub Main

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

  Dim i As Long, j As Long

  For i=1 To 4

   For j=1 To 4

    a(i,j)=Rnd(10)

   Next j

  Next i

  MatrixDisplay (a, "Original Matrix A")

  MatrixInverse(a,ainv)

  MatrixDisplay (ainv, "A, Inverse")

End Sub