Listing 5: Using the numeric objects from VB.NET.
Imports System Imports System.Runtime.InteropServices Imports NAGLIB Module Module1 Public Class DCLASS Inherits NAG_FUNCTIONS Public Function the_integrand_c(ByVal x As Double) As Double Dim pi As Double Dim val As Double pi = Math.PI val = (x * Math.Sin(x * 30) / 1 - x * x / (pi * pi * 4)) Return val End Function End Class Sub Main() Dim x, the_answer As Double Dim flag, j, tda, n As Integer Dim a(,), r(), a1, b1, abserr As Double Dim tt As New DCLASS() Dim myfun As New INTEGRAND_FUN_TYPE(AddressOf tt.the_integrand_c) a1 = 0 b1 = Math.PI * 2 flag = 0 tt.QUADRATURE(a1, b1, the_answer, abserr, flag, myfun) Console.WriteLine("The integral (default number of subintervals) = {0,8:F4}", the_answer) tt.QUADRATURE_max_subint = 3 flag = 0 tt.QUADRATURE(a1, b1, the_answer, abserr, flag, myfun) Console.WriteLine("The integral (number of subintervals set to 3) = {0,8:F4}", the_answer) x = -1 the_answer = tt.CUM_NORM(x) Console.WriteLine("The value of the cumulative normal = {0,8:F4}", the_answer) flag = 0 n = 4 tda = n ReDim r(n - 1) ReDim a(n - 1, n - 1) ' first row a(0, 0) = 0.5 a(0, 1) = 0 a(0, 2) = 2.3 a(0, 3) = -2.6 'second row a(1, 0) = 0 a(1, 1) = 0.5 a(1, 2) = -1.4 a(1, 3) = -0.7 ' third row a(2, 0) = 2.3 a(2, 1) = -1.4 a(2, 2) = 0.5 a(2, 3) = 0 'fourth row a(3, 0) = -2.6 a(3, 1) = -0.7 a(3, 2) = 0 a(3, 3) = 0.5 tt.REAL_SYMM_EIGEN(n, a(0, 0), tda, r(0), flag) Console.Write("The Eigenvalues are:") For j = 0 To n - 1 Console.Write("{0,8:F4}", r(j)) Next j Console.WriteLine() End Sub End Module