Eötvös Quantum Utilities  v4.9.146
Providing the Horsepowers in the Quantum Realm
dggev.c
Go to the documentation of this file.
1 /*======================================================================
2  (See: http://www.netlib.org/lapack/explore-html/d9/d52/dggev_8f.html for details)
3  Copyright (C) 2016 Peter Rakyta, Ph.D.
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see http://www.gnu.org/licenses/.
17 
18 ====================================================================== */
19 
32 #include "mex.h"
33 #define lapack_int long
34 #include "mkl.h"
35 #ifdef __cplusplus
36 extern "C"
37 #endif
38 
39 
46 void mexFunction(int nlhs, mxArray *plhs[],
47  int nrhs, const mxArray *prhs[])
48 {
49 /* variable declarations here */
50 /* Array information: */
51  mwSize nonzerosA; /*number of nonzeros elements in A*/
52  mwSize sizeAm, sizeAn; /*size of the matrix A (rows, and cols) */
53  mwSize sizeBm, sizeBn; /*size of the matrix B (rows, and cols) */
54  lapack_int sizeAm_mkl, sizeAn_mkl;
55  lapack_int sizeBm_mkl, sizeBn_mkl;
56 
57 
58  double* a, *b; /* pointers to the matrices */
59  double *alphar, *alphai, *beta;
60  double *l_eigvec, *r_eigvec;
61 
62  double Work1[1];
63  double *Work;
64 
65  lapack_int Lwork, info;
66 
67 
68 
69 /* code here */
70 /*-----------------------------------------------------------------------*/
71 /* Check for proper number of arguments. */
72  if(nrhs != 2) {
73  mexErrMsgIdAndTxt ("MATLAB:dggev:nInput", "Two inputs required.");
74  }
75  else if (nlhs > 5) {
76  mexErrMsgIdAndTxt ("MATLAB:dggev:nOutput", "Too many output arguments.");
77  }
78 
79 /* Validate inputs */
80 
81 /* Check that the input is a double.*/
82  if ((mxIsDouble(prhs[0]) == 0) && (mxIsDouble(prhs[1]) == 0)) {
83  mexErrMsgIdAndTxt ("MATLAB:dggev:NonDouble", "Inputs must be both a double.");
84  }
85 
86 /* Check if inputs are real.*/
87  if ((mxIsComplex(prhs[0]) != 0) && (mxIsComplex(prhs[1]) != 0)) {
88  mexErrMsgIdAndTxt ("MATLAB:dggev:NonReal", "Inputs must be both real.");
89  }
90 
91 /* Get the size of the input array. (MATLAB) */
92  sizeAm = mxGetM(prhs[0]);
93  sizeAn = mxGetN(prhs[0]);
94  sizeBm = mxGetM(prhs[1]);
95  sizeBn = mxGetN(prhs[1]);
96 
97  a = mxGetPr(prhs[0]);
98  b = mxGetPr(prhs[1]);
99 
100 /* Creating output arrays */
101  plhs[0] = mxCreateDoubleMatrix(sizeAm, 1, mxREAL); /* alphar*/
102  plhs[1] = mxCreateDoubleMatrix(sizeAm, 1, mxREAL); /* alphai*/
103  plhs[2] = mxCreateDoubleMatrix(sizeAm, 1, mxREAL); /* beta*/
104  plhs[3] = mxCreateDoubleMatrix(sizeAm, sizeAn, mxREAL); /* l_eigvec*/
105  plhs[4] = mxCreateDoubleMatrix(sizeAm, sizeAn, mxREAL); /* r_eigvec*/
106 
107 
108  alphar = mxGetPr(plhs[0]);
109  alphai = mxGetPr(plhs[1]);
110  beta = mxGetPr(plhs[2]);
111  l_eigvec = mxGetPr(plhs[3]);
112  r_eigvec = mxGetPr(plhs[4]);
113 
114 
115 
116  sizeAm_mkl = (lapack_int)sizeAm;
117  sizeAn_mkl = (lapack_int)sizeAn;
118  sizeBm_mkl = (lapack_int)sizeBm;
119  sizeBn_mkl = (lapack_int)sizeBn;
120 
121  if ( sizeAm != sizeAn || sizeAm != sizeBm || sizeAm != sizeBn ) {
122  mexErrMsgIdAndTxt ("MATLAB:dggev:MatrixSize", "Inputs must be square matrices and must have the same dimensions.");
123  }
124 
125 #ifdef DEBUG
126  mexPrintf("Size of the matrix: %d\n", sizeAm_mkl);
127 #endif
128 
129  info = LAPACKE_dggev( LAPACK_COL_MAJOR, 'V', 'V',
130  sizeAm_mkl, a, sizeAn_mkl, b,
131  sizeBm_mkl, alphar, alphai,
132  beta, l_eigvec, sizeAm_mkl, r_eigvec,
133  sizeAm_mkl );
134 
135 /* TODO_ check info */
136 
137 }
138 
139 
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Gateway routine to call the dggev function from LAPACKE package.
Definition: dggev.c:46
#define lapack_int
Definition: dggev.c:33