12.07.2015 Views

Calling 32-bit NAG C DLL functions from Visual Basic

Calling 32-bit NAG C DLL functions from Visual Basic

Calling 32-bit NAG C DLL functions from Visual Basic

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8where the rst two arguments specify the numbers of rows and columns in the matrix. Theroutine would treat the array as representing a 3-by-2 matrix stored in row order:0B@11 2131 1222 <strong>32</strong>1CAwhich isnot the intended matrix A.One solution (which is used in Appendix C) is to store the matrix in a 1-dimensional arraya1, with the element a ij stored in a1((i-1)*tda+j-1), where tda is the trailing dimensionof the matrix (in this case 2).Dim a1(5) As DoubleDim tda As Longtda = 2a1(0) = 11a1(1) = 12a1(2) = 21a1(3) = 22a1(4) = 31a1(5) = <strong>32</strong>Call f02wec(3,2,a1(0),tda ... )Another solution is to store the transpose of the matrix A in a 2-dimensional array at, withtda now being the leading dimension of the array at:Dim at(1,2) As DoubleDim tda As Longtda = 2at(0,0) = 11at(0,1) = 21at(0,2) = 31at(1,0) = 12at(1,1) = 22at(1,2) = <strong>32</strong>Call f02wec(3,2,at(0,0),tda, ... )The <strong>Visual</strong> <strong>Basic</strong> array at can be larger than is needed to store the 2-by-3 matrix A T inorder that the C routine accesses the correct array elements it is essential that tda is set tothe correct value:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!