# [SciPy-user] Wrapping geqp3 (Rank revealing QR)

Nils Wagner nwagner at mecha.uni-stuttgart.de
Fri Feb 24 09:51:17 CST 2006

```Pearu Peterson wrote:
>On Fri, 24 Feb 2006, Nils Wagner wrote:
>
>
>>The next issues are
>>
>>1. How do I handle JPVT ?
>>
>>2. How do I find the size of LWORK in *geqp3 ?
>>
>
>subroutines are explained.
>
>
Sure. I mean the special handling inside the wrapper.
I found several ways for different routines to declare  _lwork

<_lwork=3*n-1,\0,2*n-1,\2>
integer optional,intent(in),depend(n) :: lwork=<_lwork>
check(<_lwork>\<=lwork) lwork

! <_lwork=(compute_vl||compute_vr)?4*n:3*n,\0,2*n,\2>
integer optional,intent(in),depend(n,compute_vl,compute_vr) ::
lwork=<_lwork>
check(lwork>=<_lwork>) :: lwork

!
<_lwork=3*minmn+MAX(2*minmn\,MAX(maxmn\,nrhs)),\0,2*minmn+MAX(maxmn\,nrhs),\2>
integer optional,intent(in),depend(nrhs,minmn,maxmn), &
check(lwork>=1) &
:: lwork=<_lwork>
!check(lwork>=<_lwork>)

! <_lwork=n,\0,\0,\0>
integer optional,intent(in),depend(n),check(lwork\>=<_lwork>) ::
lwork=<_lwork>
<ftype> dimension(lwork),intent(hide,cache),depend(lwork) :: work

Which way is suitable here ?

Nils

>>I am willing to learn it :-)
>>but the contents of flapack_esv.pyf.src is somehow cryptic in many
>>places e.g.
>>
>>    callstatement
>>if(irange_capi==Py_None);else{irange[0]++;irange[1]++;}(*f2py_func)((compute_v?"V":"N"),(vrange_capi==Py_None?(irange_capi==Py_None?"A":"I"):"V"),(lower?"L":"U"),&n,a,&n,vrange,vrange+1,irange,irange+1,&atol,&m,w,z,&ldz,isuppz,work,&lwork,<_2=,,rwork\,&lrwork\,,\2>iwork,&liwork,&info);if(irange_capi==Py_None);else{irange[0]--;irange[1]--;}if(vrange_capi==Py_None);else
>>{capi_w_tmp-\>dimensions[0]=capi_z_tmp-\>dimensions[1]=m;/*capi_z_tmp-\>strides[0]=m*capi_z_tmp-\>descr-\>elsize;*/}
>>
>
>That is simple C code in one line and takes care of the offset between C
>and Fortran array indices:
>
>if (irange_capi==Py_None)
>   ;
>else {
>   irange[0]++;
>   irange[1]++;
>}
>(*f2py_func)((compute_v?"V":"N"),
>              (vrange_capi==Py_None?(irange_capi==Py_None?"A":"I"):"V"),
>              (lower?"L":"U"),
>              &n,a,&n,vrange,vrange+1,irange,irange+1,&atol,&m,
>              w,z,&ldz,isuppz,work,&lwork,
>              <_2=,,rwork\,&lrwork\,,\2>iwork,&liwork,&info);
>if (irange_capi==Py_None)
>   ;
>else {
>   irange[0]--;
>   irange[1]--;
>}
>if (vrange_capi==Py_None)
>   ;
>else {
>   capi_w_tmp-\>dimensions[0]=capi_z_tmp-\>dimensions[1]=m;
>   /*capi_z_tmp-\>strides[0]=m*capi_z_tmp-\>descr-\>elsize;*/
>}
>
>
>Pearu
>
>_______________________________________________
>SciPy-user mailing list
>SciPy-user at scipy.net
>http://www.scipy.net/mailman/listinfo/scipy-user
>

```