## doubt using dsygv

## doubt using dsygv

(OP)

hi, I am using fortran to get the Eigen values for generalized Eigen value problem of type Ax=lamda.Bx. I am using lapack routine dsygv for this and it works perfectly for all my 5 case studies and not working as expected for the 6th one. i get first two Eigen values as -ve which was not expected. I do not see anything which could cause this error. both matrices are symmetric square matrices, all diagonals are positive. I am attaching the A and B matrices here. someone could look into them to see what is going wrong. appreciate any guidance on this.

## RE: doubt using dsygv

Are you solving all 6 problems in a row? If so, sometimes is good to change the order of things...maybe something is getting corrupted in memory by the time you get to 6...solve 6 first, instead or something.

## RE: doubt using dsygv

## RE: doubt using dsygv

Link : http://files.engineering.com/getfile.aspx?folder=6...

## RE: doubt using dsygv

## RE: doubt using dsygv

With the matrices taken from your files, and using the Scipy front-end to dsygv, the first two results are negative as you found. I wrote a VBA routine to copy the upper triangle to the lower triangle, to ensure that they were symmetrical, and after doing that only the first result was negative. Also the following results are approximately equal to the Matlab results, but diverge after the 3rd significant figure.

In the attached file, on sheet1, I have copied all the Scipy function results to column 2, and I have converted the function call to text in cell A1. Let me know if you want a copy of the required VBA and Python code to run the function. You would need to install Python, Scipy, and xlwings to run it.

The Scipy manual was not very helpful, it just lists the input and output for the lapack function. Scipy may have some alternative code to do what you want but it wasn't obvious to me if it does.

Doug Jenkins

Interactive Design Services

http://newtonexcelbach.wordpress.com/

## RE: doubt using dsygv

http://files.engineering.com/getfile.aspx?folder=3...

the matrices A, B and the fortran program is attached

http://files.engineering.com/getfile.aspx?folder=5...

## RE: doubt using dsygv

I had assumed the Eig function just called the Lapack function, but it seems not. Is there a reason why you don't want to use Mathcad?

If you want to call the scipy functions from Excel you can download a spreadsheet from:

https://newtonexcelbach.wordpress.com/2016/03/20/x...

Doug Jenkins

Interactive Design Services

http://newtonexcelbach.wordpress.com/

## RE: doubt using dsygv

## RE: doubt using dsygv

Scipy Linalg source: https://github.com/scipy/scipy/tree/master/scipy/l...

The link below may (or may not) help:

http://conference.scipy.org/proceedings/scipy2015/...

Did you get anything useful from the other forums?

If you do find a way to get Fortran code that works, I'd be interested to hear it.

Doug Jenkins

Interactive Design Services

http://newtonexcelbach.wordpress.com/

## RE: doubt using dsygv

From the Scipy manual:

Imagine you’d like to find the smallest and largest eigenvalues and the corresponding eigenvectors for a

large matrix. ARPACK can handle many forms of input: dense matrices such as numpy.ndarray instances,

sparse matrices such as scipy.sparse.csr_matrix, or a general linear operator derived from

scipy.sparse.linalg.LinearOperator. For this example, for simplicity, we’ll construct a symmetric,

positive-definite matrix.

Doug Jenkins

Interactive Design Services

http://newtonexcelbach.wordpress.com/