Hi Doug and Sergey,
Thanks for your replies. Doug, I'm really impressed by your blog. Many people must have benefited from your work on integrating ALGLIB into easy to use Excel worksheets (which is especially great for people like me who only have Excel and can't program anything themselves). I got the statistics file and I think I get the idea.
The function VarAToDouble1D_0 is vital since it converts between Excel "ranges" and somthing ALGLIB can digest.
I copied that function into my module and tried to feed my data range to IDWBuildModifiedShepardR. I tried to keep it as simple as possible and fixed the number of nodes, dimensions, etc.
Code:
Function VarAtoDouble1D_0(XL_A As Variant, ByRef Cpp_A() As Double, ByRef Nrows As Long, ByRef Ncols As Long) As Long
Dim i As Long, j As Long, LB As Long
On Error GoTo iErr
If TypeName(XL_A) = "Range" Then XL_A = XL_A.Value2
LB = LBound(XL_A)
Nrows = UBound(XL_A)
Ncols = UBound(XL_A, 2)
' Copy 2D base 1 variant array to 1D base 0 double array
ReDim Cpp_A(0 To Nrows * Ncols - 1)
For i = 1 To Nrows
For j = 1 To Ncols
Cpp_A((i - 1) * Ncols + j - 1) = XL_A(i, j)
Next j
Next i
VarAtoDouble1D_0 = 0
Exit Function
iErr:
VarAtoDouble1D_0 = 1
End Function
Public Function AL_Interpol(ByRef XA As Variant)
Dim XA0() As Double, M As Long, N As Long, O As Long, Ncols As Long, Rtn As Long
Rtn = VarAtoDouble1D_0(XA, XA0, N, M)
Call IDWBuildModifiedShepardR(XA, 3354, 2, 10, ???)
End Function
My data set has 3354 values: 1118 x, 1118 y, and 1118 z; therefore 2 dimensions (right?) and I chose R to be 10.
I'm still not quite sure how to deal with the interpolants (???). The only thing I want to get to work right now is feed my data points into the Shepard algorithm. Isn't all it needs a range of x,y, and z data (in my case)? I don't mind if all the other parameters are 'hard coded' for the moment, I can change that later.
Guys, if you can't be bothered helping a newbie like me, it's really not a problem at all. You did all the great work already and maybe I just have to wait for another update in the newtonexcelbach blog that covers interpolation of surfaces for irregular data sets.
Thanks,
Alex