Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Questions about lud() and lusolve()

    Hi there!

    I have several questions about lud()and lusolve() functions.

    Reading MATA manual relative to LU factorization - i.e., lud(numeric matrix A, L, U, p) function - I do not really get the arguments Mata is expected to receive other than the known matrix A because L and U come from LU decomposition - so, they are not yet known. Also, I do not understand how the permutation vector p is chosen. What confused me even more is the statement in the manual "2. The types of L, U, p, and q are irrelevant; results are returned there." because if I do not create L, U, and p I get an error because Mata does not find them, but if I create them with, for example, zero or empty elements, they are not filled after the decomposition.
    I also tried to use the function _lud_la(numeric matrix A, q) setting q = (1\2\2) as documented in MATA manual. The function performs the LU decomposition smoothly but the original matrix A is modified from which L and U matrices can be extrapolated as explained in the documentation. But I do not want the original matrix A to be modified that is why I want to use lud(). So, how am I supposed to proceed?

    Finally, I have a computational doubt: Is it correct that cholsolve() and lusolve() return the same solution (i.e., a vector x) when the matrix A is symmetric (and, of course, positive definite and square)? For example,

    Code:
    A = (2,-1\-1,2) 
    b = J(rows(A),1,1)
    MatrixLUSolve = lusolve(A,b) 
    MatrixCholSolve = cholsolve(A, b)
    Here, the solution is the same even though AX=B is solved for X using two different decompositions.



    Thank you,

    Anna
Working...
X