Mercury consists of a set of functions that enable programmers to interact with GAUSS or the Gauss Engine, as part of an external application. This enables programmers to make use of the power of GAUSS as part of an integrated system in which data and message transfer to and from GAUSS is required, and which is to be controlled by an external application. Support files for these libraries are provided for Excel, VB6, VB.NET, C, MFC, VC6, C#, and VC.NET
The GAUSS programming language lets you express in a couple of statements what would take many pages of custom written code. You simply embed complete GAUSS programs in your application, or permit access to GAUSS through your GUI.
The Mercury routines are provided as a class. Mercury is instanced (in C) with the statement:
Mercury ge;
Now, typing ge. results in a drop down menu of all the available methods - this makes programming very easy.
A typical Mercury session might send data from an application to GAUSS, using the MatPut command, running GAUSS commands using the ExecCode command, and retrieving results back to the application using the MatGet command. These libraries permit sending messages, strings, values and data between the external application and GAUSS, as well as routines for status checking status. This idea is shown in the Visual Basic screen shot. The core VB routines for this application for Mercury for Gauss are shown below:
- xname = inputname.Text
- zname = outputname.Text
- ge.MatPut xname, xmat
- ge.Exec Editbox.Text
- ge.MatGet zname, zmat()
Lines 1 and 2 pick up the name of the input and output matrices from two text boxes. The array xmat is stored in GAUSS using the MatPut command, and the GAUSS code in the Editbox is executed using the Exec command; this creates the variable zname, which is retrieved back into the application using the MatGet command.
A second example, using Mercury_GE is shown in the accompanying screen shot. This example was generated using VC. The MFC code is shown below:
- Mercury GE;
- GE.WorkspaceCreate();
- GE.ExecCode(m_code.GetBuffer(2048));
- GE.ArgListCreate(ahin);
- GE.ValPut(variance,1);
- GE.ThreadBegin("betahat",1);
- for (ahout = 1; ahout < rep+1; ahout++)
- GE.ExecProc("olssim", ahin, ahout);
- GE.ThreadEnd();
The code is executed when the Execute button is clicked. Line 1 creates an instance of the Mercury class called GE. A default workspace #1 is created in line 2 (Mercury allows for 64 separate workspaces). The GAUSS code for the "olssim" procedure, which is stored in the CString m_code is executed in line 3, so now workspace #1 has the proc olssim as a global. The GAUSS Engine allows for variables to be stored as globals in a given workspace, or as arguments in an argument list. Line 4 creates an argument list with the identifier (number) ahin, and makes it current. Line 5 places the variable variance as the first argument of the current argument list. Line 6 instructs Mercury that the following Gauss code is to be executed as separate threads, and to store the first output argument of each thread in betahat. These threads will occur concurrently, and can use multiple CPUs, if available. The "olssim" proc is executed rep times, with a new output argument ahout in each case. Line 10 informs Mercury to wait until all the threads are complete (joined). Subsequent code shows the output of each thread, and undertakes the analysis of betahat. Mercury permits the programmer to use the multithreading capability of the GAUSS Engine with a very shallow learning curve.
Libraries have been included for VB6, C++, C# and VB. NET; however, the code can be ported to any program that can access the Windows APIs -- for example, Toolbook, Delphi, Powerbuilder, etc. The code and DLL files are provided for use in your application under the same distribution rights as you have for the Gauss Engine. They can also be distributed, as part of an application. to any registered Gauss user. Mercury_GE also provides support for the Gauss Run Time Engine.