error : Matrix not positive definite


error G0121 : Matrix not positive definite

this is program line 94 make error

SD_fnl = sqrt(diag(invpd(_opfhess)));

what make error?

asked June 26, 2014

1 Answer


The function invpd returns the inverse of a positive definite matrix. If the input to invpd is not positive definite, then you will get the error:

error G0121 : Matrix not positive definite

You need to look at the matrix _opfhess before it is passed into the function invpd. You can do this with by using the debugger or a print statement.

If the contents of _opfhess are missing values or a scalar error code, they will print out like this:


If you see this, you will need to trace back in the program and see what caused this.