Hi,
I have a rather unusual question: I downloaded a VBA code for a VBA function, but I can't figure out what the necessary input paramaters are.
The Function (called "Cholesky") is supposed to convert a given (pos. symmetric) Matrix into another Matrix.
No comes the relevant part: While the function is defined as '=Cholesky(), I cannot figure out what paramters I have to insert into the function (i.e. the brackets)
I was wondering whether anyone might be able to derive from the code what paramters to insert into the brackets
The code is as follows:
Function Cholesky(Mat As Range) Dim A, L() As Double, s As Double A = Mat n = Mat.Rows.Count M = Mat.Columns.Count If n <> M Then Cholesky = "?" Exit Function End If
ReDim L(1 To n, 1 To n) For j = 1 To n s = 0 For k = 1 To j - 1 s = s + L(j, k) ^ 2 Next k L(j, j) = A(j, j) - s If L(j, j) <= 0 Then Exit For L(j, j) = Sqr(L(j, j)) For i = j + 1 To n s = 0 For k = 1 To j - 1 s = s + L(i, k) * L(j, k) Next k L(i, j) = (A(i, j) - s) / L(j, j) Next i Next j Cholesky = L End Function
Based on this cpde, I was wondering what exactly are the input parameters of the function 'Cholesky? In other words, when I type into a cell =Cholesky(x,y,etc), what do I have to input for the x,y,? I have tried inserting the range that defines the symmetric Matrix [eg '=Cholesky(A1:E5)] but it doesnt work (instead the Excel error message' #Values' pops up, suggesting that simply inserting the Matrix is not sufficient). Any help would be most apreciated!
Many thanx and best regards, Burki
|