28 mwpointer plhs(*), prhs(*)
35 mwpointer mxcreatedoublematrix
36 mwpointer mxgetm, mxgetn
43 mwpointer alpha_ptr_real, alpha_ptr_imag
44 mwpointer beta_ptr_real, beta_ptr_imag
45 mwpointer lvecs_ptr_real, lvecs_ptr_imag
46 mwpointer rvecs_ptr_real, rvecs_ptr_imag
49 mwsize hrows, hcols, brows, bcols, cols
53 complex*16,
allocatable :: H_eff(:,:), B_eff(:,:)
54 complex*16,
allocatable :: ALPHA(:), BETA(:)
55 complex*16,
allocatable :: l_eigvec(:,:)
56 complex*16,
allocatable :: r_eigvec(:,:)
59 complex*16,
allocatable :: Work(:)
60 DOUBLE PRECISION,
allocatable :: RWork(:)
62 mwsignedindex lwork, info
68 call mexerrmsgidandtxt (
'MATLAB:timestwo:nInput',
69 +
'Two inputs required.')
70 elseif(nlhs .gt. 4)
then 71 call mexerrmsgidandtxt (
'MATLAB:timestwo:nOutput',
72 +
'Too many output arguments.')
78 if ((mxisnumeric(prhs(1)) .eq. 0) .or.
79 + (mxisnumeric(prhs(2)) .ne. 1))
then 80 call mexerrmsgidandtxt (
'MATLAB:timestwo:NonNumeric',
81 +
'Input must be a number.')
85 if ((mxiscomplex(prhs(1)) .ne. 1) .or.
86 + (mxiscomplex(prhs(2)) .ne. 1))
then 87 call mexerrmsgidandtxt (
'MATLAB:convec:NonComplex',
88 +
'Inputs must be complex.')
92 hrows = mxgetm(prhs(1))
93 hcols = mxgetn(prhs(1))
94 brows = mxgetm(prhs(2))
95 bcols = mxgetn(prhs(2))
100 if ((hrows .ne. brows) .or.
101 + (hcols .ne. bcols))
then 102 call mexerrmsgidandtxt (
'MATLAB:zggev:WrongSize',
103 +
'The dimensions of the matrices must equal.')
108 allocate(h_eff(hrows,hcols))
109 allocate(b_eff(brows,bcols))
110 allocate(alpha(brows))
111 allocate(beta(brows))
112 allocate(l_eigvec(brows,bcols))
113 allocate(r_eigvec(brows,bcols))
114 allocate(rwork(8*hrows))
117 if (.not. (
allocated(h_eff) .and.
118 +
allocated(h_eff) .and.
119 +
allocated(b_eff) .and.
120 +
allocated(alpha) .and.
121 +
allocated(beta) .and.
122 +
allocated(l_eigvec) .and.
123 +
allocated(r_eigvec) .and.
124 +
allocated(rwork) ))
then 125 call mexerrmsgidandtxt (
'MATLAB:zggev:BadAllocation',
126 +
'The allocation of variables was unsuccesfull.')
130 call mxcopyptrtocomplex16(mxgetpr(prhs(1)),
131 + mxgetpi(prhs(1)),h_eff,sizeh)
133 call mxcopyptrtocomplex16(mxgetpr(prhs(2)),
134 + mxgetpi(prhs(2)),b_eff,sizeb)
138 call zggev(
'V',
'V', hcols, h_eff, hrows,
140 + alpha, beta, l_eigvec, hrows, r_eigvec, hrows,
141 + work1, lwork, rwork, info )
147 allocate( work(lwork))
148 if (.not. (
allocated(work) ))
then 149 call mexerrmsgidandtxt (
'MATLAB:zggev:BadAllocation',
150 +
'The allocation of variable Work was unsuccesfull.')
154 call zggev(
'V',
'V', hcols, h_eff, hrows,
156 + alpha, beta, l_eigvec, hrows, r_eigvec, hrows,
157 + work, lwork, rwork, info )
164 plhs(1) = mxcreatedoublematrix(hrows,cols,1)
165 plhs(2) = mxcreatedoublematrix(hrows,cols,1)
166 plhs(3) = mxcreatedoublematrix(hrows,hcols,1)
167 plhs(4) = mxcreatedoublematrix(hrows,hcols,1)
170 alpha_ptr_real = mxgetpr(plhs(1))
171 alpha_ptr_imag = mxgetpi(plhs(1))
172 call mxcopycomplex16toptr(alpha,alpha_ptr_real,alpha_ptr_imag,
175 beta_ptr_real = mxgetpr(plhs(2))
176 beta_ptr_imag = mxgetpi(plhs(2))
177 call mxcopycomplex16toptr(beta,beta_ptr_real,beta_ptr_imag,
180 lvecs_ptr_real = mxgetpr(plhs(3))
181 lvecs_ptr_imag = mxgetpi(plhs(3))
182 call mxcopycomplex16toptr(l_eigvec,lvecs_ptr_real,
183 + lvecs_ptr_imag,sizeb)
185 rvecs_ptr_real = mxgetpr(plhs(4))
186 rvecs_ptr_imag = mxgetpi(plhs(4))
187 call mxcopycomplex16toptr(r_eigvec,rvecs_ptr_real,
188 + rvecs_ptr_imag,sizeb)
213 character(len=100) :: msg
216 msg =
'Illegal argumemnt in the LAPACK function' 217 call mexerrmsgidandtxt (
'MATLAB:zggev:IllegalLAPACKArgument',
220 msg =
'Calculations failed in the LAPACK function' 221 call mexerrmsgidandtxt (
'MATLAB:zggev:FailedLAPACK',
subroutine checkinfo(INFO)
subroutine mexfunction(nlhs, plhs, nrhs, prhs)