28 mwpointer plhs(*), prhs(*)
35 mwpointer mxcreatedoublematrix
36 mwpointer mxgetm, mxgetn
50 mwsize hrows, hcols, brows, bcols, cols
54 real*8,
allocatable :: h_eff(:,:), b_eff(:,:)
55 real*8,
allocatable :: alphar(:), alphai(:)
56 real*8,
allocatable :: beta(:)
57 real*8,
allocatable :: l_eigvec(:,:)
58 real*8,
allocatable :: r_eigvec(:,:)
61 real*8,
allocatable :: work(:)
63 mwsignedindex lwork, info
69 call mexerrmsgidandtxt (
'MATLAB:timestwo:nInput',
70 +
'Two inputs required.')
71 elseif(nlhs .gt. 5)
then 72 call mexerrmsgidandtxt (
'MATLAB:timestwo:nOutput',
73 +
'Too many output arguments.')
79 if ((mxisnumeric(prhs(1)) .eq. 0) .or.
80 + (mxisnumeric(prhs(2)) .ne. 1))
then 81 call mexerrmsgidandtxt (
'MATLAB:timestwo:NonNumeric',
82 +
'Input must be a number.')
86 if ((mxiscomplex(prhs(1)) .ne. 0) .or.
87 + (mxiscomplex(prhs(2)) .ne. 0))
then 88 call mexerrmsgidandtxt (
'MATLAB:convec:NonComplex',
89 +
'Inputs must be real.')
93 hrows = mxgetm(prhs(1))
94 hcols = mxgetn(prhs(1))
95 brows = mxgetm(prhs(2))
96 bcols = mxgetn(prhs(2))
101 if ((hrows .ne. brows) .or.
102 + (hcols .ne. bcols))
then 103 call mexerrmsgidandtxt (
'MATLAB:zggev:WrongSize',
104 +
'The dimensions of the matrices must equal.')
109 allocate(h_eff(hrows,hcols))
110 allocate(b_eff(brows,bcols))
111 allocate(alphar(brows))
112 allocate(alphai(brows))
113 allocate(beta(brows))
114 allocate(l_eigvec(brows,bcols))
115 allocate(r_eigvec(brows,bcols))
118 if (.not. (
allocated(h_eff) .and.
119 +
allocated(h_eff) .and.
120 +
allocated(b_eff) .and.
121 +
allocated(alphar) .and.
122 +
allocated(alphai) .and.
123 +
allocated(beta) .and.
124 +
allocated(l_eigvec) .and.
125 +
allocated(r_eigvec) ))
then 126 call mexerrmsgidandtxt (
'MATLAB:zggev:BadAllocation',
127 +
'The allocation of variables was unsuccesfull.')
131 call mxcopyptrtoreal8(mxgetpr(prhs(1)),
134 call mxcopyptrtoreal8(mxgetpr(prhs(2)),
139 call dggev(
'V',
'V', hcols, h_eff, hrows,
141 + alphar, alphai, beta, l_eigvec, hrows, r_eigvec, hrows,
142 + work1, lwork, info )
148 allocate( work(lwork))
149 if (.not. (
allocated(work) ))
then 150 call mexerrmsgidandtxt (
'MATLAB:zggev:BadAllocation',
151 +
'The allocation of variable Work was unsuccesfull.')
155 call dggev(
'V',
'V', hcols, h_eff, hrows,
157 + alphar, alphai, beta, l_eigvec, hrows, r_eigvec, hrows,
158 + work, lwork, info )
165 plhs(1) = mxcreatedoublematrix(hrows,cols,0)
166 plhs(2) = mxcreatedoublematrix(hrows,cols,0)
167 plhs(3) = mxcreatedoublematrix(hrows,cols,0)
168 plhs(4) = mxcreatedoublematrix(hrows,hcols,1)
169 plhs(5) = mxcreatedoublematrix(hrows,hcols,1)
172 alphar_ptr = mxgetpr(plhs(1))
173 call mxcopyreal8toptr(alphar,alphar_ptr, hrows)
175 alphai_ptr = mxgetpr(plhs(2))
176 call mxcopyreal8toptr(alphai,alphai_ptr, hrows)
178 beta_ptr = mxgetpr(plhs(3))
179 call mxcopyreal8toptr(beta,beta_ptr, hrows)
181 lvecs_ptr = mxgetpr(plhs(4))
182 call mxcopyreal8toptr(l_eigvec, lvecs_ptr,sizeb)
184 rvecs_ptr = mxgetpr(plhs(5))
185 call mxcopyreal8toptr(r_eigvec, rvecs_ptr,sizeb)
210 character(len=100) :: msg
213 msg =
'Illegal argumemnt in the LAPACK function' 214 call mexerrmsgidandtxt (
'MATLAB:zggev:IllegalLAPACKArgument',
217 msg =
'Calculations failed in the LAPACK function' 218 call mexerrmsgidandtxt (
'MATLAB:zggev:FailedLAPACK',
subroutine checkinfo(INFO)
subroutine mexfunction(nlhs, plhs, nrhs, prhs)