* Add C equivalents of the Fortran routines from Reference-LAPACK as fallbacks, and C_LAPACK variable to trigger their usepull/3578/head
| @@ -22,6 +22,8 @@ option(BUILD_WITHOUT_LAPACK "Do not build LAPACK and LAPACKE (Only BLAS or CBLAS | |||
| option(BUILD_TESTING "Build LAPACK testsuite when building LAPACK" ON) | |||
| option(C_LAPACK "Build LAPACK from C sources instead of the original Fortran" OFF) | |||
| option(BUILD_WITHOUT_CBLAS "Do not build the C interface (CBLAS) to the BLAS functions" OFF) | |||
| option(DYNAMIC_ARCH "Include support for multiple CPU targets, with automatic selection at runtime (x86/x86_64, aarch64 or ppc only)" OFF) | |||
| @@ -175,7 +177,7 @@ endforeach () | |||
| # Can't just use lapack-netlib's CMake files, since they are set up to search for BLAS, build and install a binary. We just want to build a couple of lib files out of lapack and lapacke. | |||
| # Not using add_subdirectory here because lapack-netlib already has its own CMakeLists.txt. Instead include a cmake script with the sources we want. | |||
| if (NOT NOFORTRAN AND NOT NO_LAPACK) | |||
| if (NOT NO_LAPACK) | |||
| include("${PROJECT_SOURCE_DIR}/cmake/lapack.cmake") | |||
| if (NOT NO_LAPACKE) | |||
| include("${PROJECT_SOURCE_DIR}/cmake/lapacke.cmake") | |||
| @@ -25,11 +25,14 @@ ifeq ($(NO_FORTRAN), 1) | |||
| define NOFORTRAN | |||
| 1 | |||
| endef | |||
| define NO_LAPACK | |||
| ifneq ($(NO_LAPACK), 1) | |||
| define C_LAPACK | |||
| 1 | |||
| endef | |||
| endif | |||
| export NOFORTRAN | |||
| export NO_LAPACK | |||
| export C_LAPACK | |||
| endif | |||
| LAPACK_NOOPT := $(filter-out -O0 -O1 -O2 -O3 -Ofast -O -Og -Os,$(LAPACK_FFLAGS)) | |||
| @@ -241,19 +244,14 @@ hpl_p : | |||
| fi; \ | |||
| done | |||
| ifeq ($(NO_LAPACK), 1) | |||
| netlib : | |||
| else | |||
| netlib : lapack_prebuild | |||
| ifeq ($(NOFORTRAN), $(filter 0,$(NOFORTRAN))) | |||
| ifneq ($(NO_LAPACK), 1) | |||
| @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapacklib | |||
| @$(MAKE) -C $(NETLIB_LAPACK_DIR) tmglib | |||
| endif | |||
| ifneq ($(NO_LAPACKE), 1) | |||
| @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapackelib | |||
| endif | |||
| endif | |||
| ifeq ($(NO_LAPACK), 1) | |||
| re_lapack : | |||
| @@ -267,7 +265,7 @@ prof_lapack : lapack_prebuild | |||
| @$(MAKE) -C $(NETLIB_LAPACK_DIR) lapack_prof | |||
| lapack_prebuild : | |||
| ifeq ($(NOFORTRAN), $(filter 0,$(NOFORTRAN))) | |||
| ifeq ($(NO_LAPACK), $(filter 0,$(NO_LAPACK))) | |||
| -@echo "FC = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc | |||
| -@echo "override FFLAGS = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc | |||
| -@echo "FFLAGS_DRV = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc | |||
| @@ -352,7 +352,7 @@ OBJCONV = $(CROSS_SUFFIX)objconv | |||
| # When fortran support was either not detected or actively deselected, only build BLAS. | |||
| ifeq ($(NOFORTRAN), 1) | |||
| NO_LAPACK = 1 | |||
| C_LAPACK = 1 | |||
| override FEXTRALIB = | |||
| endif | |||
| @@ -1303,6 +1303,10 @@ ifeq ($(DYNAMIC_OLDER), 1) | |||
| CCOMMON_OPT += -DDYNAMIC_OLDER | |||
| endif | |||
| ifeq ($(C_LAPACK), 1) | |||
| CCOMMON_OPT += -DC_LAPACK | |||
| endif | |||
| ifeq ($(NO_LAPACK), 1) | |||
| CCOMMON_OPT += -DNO_LAPACK | |||
| #Disable LAPACK C interface | |||
| @@ -1661,6 +1665,7 @@ export USE_OPENMP | |||
| export CROSS | |||
| export CROSS_SUFFIX | |||
| export NOFORTRAN | |||
| export C_LAPACK | |||
| export NO_FBLAS | |||
| export EXTRALIB | |||
| export CEXTRALIB | |||
| @@ -25,11 +25,19 @@ check_language(Fortran) | |||
| if(CMAKE_Fortran_COMPILER) | |||
| enable_language(Fortran) | |||
| else() | |||
| set (NOFORTRAN 1) | |||
| if (NOT NO_LAPACK) | |||
| message(STATUS "No Fortran compiler found, can build only BLAS but not LAPACK") | |||
| if (NOT MSVC) | |||
| message(STATUS "No Fortran compiler found, can build only BLAS and f2c-converted LAPACK") | |||
| set(C_LAPACK 1) | |||
| if (INTERFACE64) | |||
| set (CCOMMON_OPT "${CCOMMON_OPT} -DLAPACK_ILP64") | |||
| endif () | |||
| set(TIMER "NONE") | |||
| else () | |||
| message(STATUS "No Fortran compiler found, can build only BLAS") | |||
| endif() | |||
| endif() | |||
| set (NOFORTRAN 1) | |||
| set (NO_LAPACK 1) | |||
| endif() | |||
| if (NOT ONLY_CBLAS) | |||
| @@ -1,5 +1,6 @@ | |||
| # Sources for compiling lapack-netlib. Can't use CMakeLists.txt because lapack-netlib already has its own cmake files. | |||
| if (NOT C_LAPACK) | |||
| message (STATUS "fortran lapack") | |||
| set(ALLAUX ilaenv.f ilaenv2stage.f ieeeck.f lsamen.f iparmq.f iparam2stage.F | |||
| ilaprec.f ilatrans.f ilauplo.f iladiag.f chla_transtype.f dlaset.f | |||
| ../INSTALL/ilaver.f xerbla_array.f | |||
| @@ -488,6 +489,499 @@ if(BUILD_COMPLEX16) | |||
| message(STATUS "Building Double Precision Complex") | |||
| endif() | |||
| else () | |||
| message (STATUS "c lapack") | |||
| set(ALLAUX ilaenv.c ilaenv2stage.c ieeeck.c lsamen.c iparmq.c iparam2stage.c | |||
| ilaprec.c ilatrans.c ilauplo.c iladiag.c chla_transtype.c dlaset.c | |||
| ../INSTALL/ilaver.c xerbla_array.c | |||
| ../INSTALL/slamch.c) | |||
| set(SCLAUX | |||
| scombssq.c sbdsvdx.c sstevx.c sstein.c | |||
| sbdsdc.c | |||
| sbdsqr.c sdisna.c slabad.c slacpy.c sladiv.c slae2.c slaebz.c | |||
| slaed0.c slaed1.c slaed2.c slaed3.c slaed4.c slaed5.c slaed6.c | |||
| slaed7.c slaed8.c slaed9.c slaeda.c slaev2.c slagtf.c | |||
| slagts.c slamrg.c slanst.c | |||
| slapy2.c slapy3.c slarnv.c | |||
| slarra.c slarrb.c slarrc.c slarrd.c slarre.c slarrf.c slarrj.c | |||
| slarrk.c slarrr.c slaneg.c | |||
| slartg.c slaruv.c slas2.c slascl.c | |||
| slasd0.c slasd1.c slasd2.c slasd3.c slasd4.c slasd5.c slasd6.c | |||
| slasd7.c slasd8.c slasda.c slasdq.c slasdt.c | |||
| slaset.c slasq1.c slasq2.c slasq3.c slasq4.c slasq5.c slasq6.c | |||
| slasr.c slasrt.c slassq.c slasv2.c spttrf.c sstebz.c sstedc.c | |||
| ssteqr.c ssterf.c slaisnan.c sisnan.c | |||
| slartgp.c slartgs.c | |||
| ../INSTALL/second_${TIMER}.c) | |||
| set(DZLAUX | |||
| dbdsdc.c | |||
| dbdsvdx.c dstevx.c dstein.c | |||
| dbdsqr.c ddisna.c dlabad.c dlacpy.c dladiv.c dlae2.c dlaebz.c | |||
| dlaed0.c dlaed1.c dlaed2.c dlaed3.c dlaed4.c dlaed5.c dlaed6.c | |||
| dlaed7.c dlaed8.c dlaed9.c dlaeda.c dlaev2.c dlagtf.c | |||
| dlagts.c dlamrg.c dlanst.c | |||
| dlapy2.c dlapy3.c dlarnv.c | |||
| dlarra.c dlarrb.c dlarrc.c dlarrd.c dlarre.c dlarrf.c dlarrj.c | |||
| dlarrk.c dlarrr.c dlaneg.c | |||
| dlartg.c dlaruv.c dlas2.c dlascl.c | |||
| dlasd0.c dlasd1.c dlasd2.c dlasd3.c dlasd4.c dlasd5.c dlasd6.c | |||
| dlasd7.c dlasd8.c dlasda.c dlasdq.c dlasdt.c | |||
| dlasq1.c dlasq2.c dlasq3.c dlasq4.c dlasq5.c dlasq6.c | |||
| dlasr.c dlasrt.c dlassq.c dlasv2.c dpttrf.c dstebz.c dstedc.c | |||
| dsteqr.c dsterf.c dlaisnan.c disnan.c | |||
| dlartgp.c dlartgs.c | |||
| ../INSTALL/dlamch.c ../INSTALL/dsecnd_${TIMER}.c) | |||
| set(SLASRC | |||
| sgbbrd.c sgbcon.c sgbequ.c sgbrfs.c sgbsv.c | |||
| sgbsvx.c sgbtf2.c sgbtrf.c sgbtrs.c sgebak.c sgebal.c sgebd2.c | |||
| sgebrd.c sgecon.c sgeequ.c sgees.c sgeesx.c sgeev.c sgeevx.c | |||
| sgehd2.c sgehrd.c sgelq2.c sgelqf.c | |||
| sgels.c sgelsd.c sgelss.c sgelsy.c sgeql2.c sgeqlf.c | |||
| sgeqp3.c sgeqr2.c sgeqr2p.c sgeqrf.c sgeqrfp.c sgerfs.c sgerq2.c sgerqf.c | |||
| sgesc2.c sgesdd.c sgesvd.c sgesvdx.c sgesvx.c sgetc2.c | |||
| sgetrf2.c sgetri.c | |||
| sggbak.c sggbal.c | |||
| sgges.c sgges3.c sggesx.c sggev.c sggev3.c sggevx.c | |||
| sggglm.c sgghrd.c sgghd3.c sgglse.c sggqrf.c | |||
| sggrqf.c sggsvd3.c sggsvp3.c sgtcon.c sgtrfs.c sgtsv.c | |||
| sgtsvx.c sgttrf.c sgttrs.c sgtts2.c shgeqz.c | |||
| shsein.c shseqr.c slabrd.c slacon.c slacn2.c | |||
| slaein.c slaexc.c slag2.c slags2.c slagtm.c slagv2.c slahqr.c | |||
| slahr2.c slaic1.c slaln2.c slals0.c slalsa.c slalsd.c | |||
| slangb.c slange.c slangt.c slanhs.c slansb.c slansp.c | |||
| slansy.c slantb.c slantp.c slantr.c slanv2.c | |||
| slapll.c slapmt.c | |||
| slaqgb.c slaqge.c slaqp2.c slaqps.c slaqsb.c slaqsp.c slaqsy.c | |||
| slaqr0.c slaqr1.c slaqr2.c slaqr3.c slaqr4.c slaqr5.c | |||
| slaqtr.c slar1v.c slar2v.c ilaslr.c ilaslc.c | |||
| slarf.c slarfb.c slarfb_gett.c slarfg.c slarfgp.c slarft.c slarfx.c slarfy.c slargv.c | |||
| slarrv.c slartv.c | |||
| slarz.c slarzb.c slarzt.c slasy2.c | |||
| slasyf.c slasyf_rook.c slasyf_rk.c slasyf_aa.c | |||
| slatbs.c slatdf.c slatps.c slatrd.c slatrs.c slatrz.c | |||
| sopgtr.c sopmtr.c sorg2l.c sorg2r.c | |||
| sorgbr.c sorghr.c sorgl2.c sorglq.c sorgql.c sorgqr.c sorgr2.c | |||
| sorgrq.c sorgtr.c sorm2l.c sorm2r.c sorm22.c | |||
| sormbr.c sormhr.c sorml2.c sormlq.c sormql.c sormqr.c sormr2.c | |||
| sormr3.c sormrq.c sormrz.c sormtr.c spbcon.c spbequ.c spbrfs.c | |||
| spbstf.c spbsv.c spbsvx.c | |||
| spbtf2.c spbtrf.c spbtrs.c spocon.c spoequ.c sporfs.c sposv.c | |||
| sposvx.c spotrf2.c spotri.c spstrf.c spstf2.c | |||
| sppcon.c sppequ.c | |||
| spprfs.c sppsv.c sppsvx.c spptrf.c spptri.c spptrs.c sptcon.c | |||
| spteqr.c sptrfs.c sptsv.c sptsvx.c spttrs.c sptts2.c srscl.c | |||
| ssbev.c ssbevd.c ssbevx.c ssbgst.c ssbgv.c ssbgvd.c ssbgvx.c | |||
| ssbtrd.c sspcon.c sspev.c sspevd.c sspevx.c sspgst.c | |||
| sspgv.c sspgvd.c sspgvx.c ssprfs.c sspsv.c sspsvx.c ssptrd.c | |||
| ssptrf.c ssptri.c ssptrs.c sstegr.c sstev.c sstevd.c sstevr.c | |||
| ssycon.c ssyev.c ssyevd.c ssyevr.c ssyevx.c ssygs2.c | |||
| ssygst.c ssygv.c ssygvd.c ssygvx.c ssyrfs.c ssysv.c ssysvx.c | |||
| ssytd2.c ssytf2.c ssytrd.c ssytrf.c ssytri.c ssytri2.c ssytri2x.c | |||
| ssyswapr.c ssytrs.c ssytrs2.c | |||
| ssyconv.c ssyconvf.c ssyconvf_rook.c | |||
| ssysv_aa.c ssysv_aa_2stage.c ssytrf_aa.c ssytrf_aa_2stage.c ssytrs_aa.c ssytrs_aa_2stage.c | |||
| ssytf2_rook.c ssytrf_rook.c ssytrs_rook.c | |||
| ssytri_rook.c ssycon_rook.c ssysv_rook.c | |||
| ssytf2_rk.c ssytrf_rk.c ssytrs_3.c | |||
| ssytri_3.c ssytri_3x.c ssycon_3.c ssysv_rk.c | |||
| ssysv_aa.c ssytrf_aa.c ssytrs_aa.c | |||
| stbcon.c | |||
| stbrfs.c stbtrs.c stgevc.c stgex2.c stgexc.c stgsen.c | |||
| stgsja.c stgsna.c stgsy2.c stgsyl.c stpcon.c stprfs.c stptri.c | |||
| stptrs.c | |||
| strcon.c strevc.c strevc3.c strexc.c strrfs.c strsen.c strsna.c strsyl.c | |||
| strtrs.c stzrzf.c sstemr.c | |||
| slansf.c spftrf.c spftri.c spftrs.c ssfrk.c stfsm.c stftri.c stfttp.c | |||
| stfttr.c stpttf.c stpttr.c strttf.c strttp.c | |||
| sgejsv.c sgesvj.c sgsvj0.c sgsvj1.c | |||
| sgeequb.c ssyequb.c spoequb.c sgbequb.c | |||
| sbbcsd.c slapmr.c sorbdb.c sorbdb1.c sorbdb2.c sorbdb3.c sorbdb4.c | |||
| sorbdb5.c sorbdb6.c sorcsd.c sorcsd2by1.c | |||
| sgeqrt.c sgeqrt2.c sgeqrt3.c sgemqrt.c | |||
| stpqrt.c stpqrt2.c stpmqrt.c stprfb.c | |||
| sgelqt.c sgelqt3.c sgemlqt.c | |||
| sgetsls.c sgetsqrhrt.c sgeqr.c slatsqr.c slamtsqr.c sgemqr.c | |||
| sgelq.c slaswlq.c slamswlq.c sgemlq.c | |||
| stplqt.c stplqt2.c stpmlqt.c | |||
| ssytrd_2stage.c ssytrd_sy2sb.c ssytrd_sb2st.c ssb2st_kernels.c | |||
| ssyevd_2stage.c ssyev_2stage.c ssyevx_2stage.c ssyevr_2stage.c | |||
| ssbev_2stage.c ssbevx_2stage.c ssbevd_2stage.c ssygv_2stage.c | |||
| sgesvdq.c slaorhr_col_getrfnp.c | |||
| slaorhr_col_getrfnp2.c sorgtsqr.c sorgtsqr_row.c sorhr_col.c ) | |||
| set(SXLASRC sgesvxx.c sgerfsx.c sla_gerfsx_extended.c sla_geamv.c | |||
| sla_gercond.c sla_gerpvgrw.c ssysvxx.c ssyrfsx.c | |||
| sla_syrfsx_extended.c sla_syamv.c sla_syrcond.c sla_syrpvgrw.c | |||
| sposvxx.c sporfsx.c sla_porfsx_extended.c sla_porcond.c | |||
| sla_porpvgrw.c sgbsvxx.c sgbrfsx.c sla_gbrfsx_extended.c | |||
| sla_gbamv.c sla_gbrcond.c sla_gbrpvgrw.c sla_lin_berr.c slarscl2.c | |||
| slascl2.c sla_wwaddw.c) | |||
| set(CLASRC | |||
| cbdsqr.c cgbbrd.c cgbcon.c cgbequ.c cgbrfs.c cgbsv.c cgbsvx.c | |||
| cgbtf2.c cgbtrf.c cgbtrs.c cgebak.c cgebal.c cgebd2.c cgebrd.c | |||
| cgecon.c cgeequ.c cgees.c cgeesx.c cgeev.c cgeevx.c | |||
| cgehd2.c cgehrd.c cgelq2.c cgelqf.c | |||
| cgels.c cgelsd.c cgelss.c cgelsy.c cgeql2.c cgeqlf.c cgeqp3.c | |||
| cgeqr2.c cgeqr2p.c cgeqrf.c cgeqrfp.c cgerfs.c cgerq2.c cgerqf.c | |||
| cgesc2.c cgesdd.c cgesvd.c cgesvdx.c | |||
| cgesvj.c cgejsv.c cgsvj0.c cgsvj1.c | |||
| cgesvx.c cgetc2.c cgetrf2.c | |||
| cgetri.c | |||
| cggbak.c cggbal.c | |||
| cgges.c cgges3.c cggesx.c cggev.c cggev3.c cggevx.c | |||
| cggglm.c cgghrd.c cgghd3.c cgglse.c cggqrf.c cggrqf.c | |||
| cggsvd3.c cggsvp3.c | |||
| cgtcon.c cgtrfs.c cgtsv.c cgtsvx.c cgttrf.c cgttrs.c cgtts2.c chbev.c | |||
| chbevd.c chbevx.c chbgst.c chbgv.c chbgvd.c chbgvx.c chbtrd.c | |||
| checon.c cheev.c cheevd.c cheevr.c cheevx.c chegs2.c chegst.c | |||
| chegv.c chegvd.c chegvx.c cherfs.c chesv.c chesvx.c chetd2.c | |||
| chetf2.c chetrd.c | |||
| chetrf.c chetri.c chetri2.c chetri2x.c cheswapr.c | |||
| chetrs.c chetrs2.c | |||
| chetf2_rook.c chetrf_rook.c chetri_rook.c | |||
| chetrs_rook.c checon_rook.c chesv_rook.c | |||
| chetf2_rk.c chetrf_rk.c chetri_3.c chetri_3x.c | |||
| chetrs_3.c checon_3.c chesv_rk.c | |||
| chesv_aa.c chesv_aa_2stage.c chetrf_aa.c chetrf_aa_2stage.c chetrs_aa.c chetrs_aa_2stage.c | |||
| chgeqz.c chpcon.c chpev.c chpevd.c | |||
| chpevx.c chpgst.c chpgv.c chpgvd.c chpgvx.c chprfs.c chpsv.c | |||
| chpsvx.c | |||
| chptrd.c chptrf.c chptri.c chptrs.c chsein.c chseqr.c clabrd.c | |||
| clacgv.c clacon.c clacn2.c clacp2.c clacpy.c clacrm.c clacrt.c cladiv.c | |||
| claed0.c claed7.c claed8.c | |||
| claein.c claesy.c claev2.c clags2.c clagtm.c | |||
| clahef.c clahef_rook.c clahef_rk.c clahef_aa.c clahqr.c | |||
| clahr2.c claic1.c clals0.c clalsa.c clalsd.c clangb.c clange.c clangt.c | |||
| clanhb.c clanhe.c | |||
| clanhp.c clanhs.c clanht.c clansb.c clansp.c clansy.c clantb.c | |||
| clantp.c clantr.c clapll.c clapmt.c clarcm.c claqgb.c claqge.c | |||
| claqhb.c claqhe.c claqhp.c claqp2.c claqps.c claqsb.c | |||
| claqr0.c claqr1.c claqr2.c claqr3.c claqr4.c claqr5.c | |||
| claqsp.c claqsy.c clar1v.c clar2v.c ilaclr.c ilaclc.c | |||
| clarf.c clarfb.c clarfb_gett.c clarfg.c clarfgp.c clarft.c | |||
| clarfx.c clarfy.c clargv.c clarnv.c clarrv.c clartg.c clartv.c | |||
| clarz.c clarzb.c clarzt.c clascl.c claset.c clasr.c classq.c | |||
| clasyf.c clasyf_rook.c clasyf_rk.c clasyf_aa.c | |||
| clatbs.c clatdf.c clatps.c clatrd.c clatrs.c clatrz.c | |||
| cpbcon.c cpbequ.c cpbrfs.c cpbstf.c cpbsv.c | |||
| cpbsvx.c cpbtf2.c cpbtrf.c cpbtrs.c cpocon.c cpoequ.c cporfs.c | |||
| cposv.c cposvx.c cpotrf2.c cpotri.c cpstrf.c cpstf2.c | |||
| cppcon.c cppequ.c cpprfs.c cppsv.c cppsvx.c cpptrf.c cpptri.c cpptrs.c | |||
| cptcon.c cpteqr.c cptrfs.c cptsv.c cptsvx.c cpttrf.c cpttrs.c cptts2.c | |||
| crot.c cspcon.c csprfs.c cspsv.c | |||
| cspsvx.c csptrf.c csptri.c csptrs.c csrscl.c cstedc.c | |||
| cstegr.c cstein.c csteqr.c csycon.c | |||
| csyrfs.c csysv.c csysvx.c csytf2.c csytrf.c csytri.c | |||
| csytri2.c csytri2x.c csyswapr.c | |||
| csytrs.c csytrs2.c | |||
| csyconv.c csyconvf.c csyconvf_rook.c | |||
| csytf2_rook.c csytrf_rook.c csytrs_rook.c | |||
| csytri_rook.c csycon_rook.c csysv_rook.c | |||
| csytf2_rk.c csytrf_rk.c csytrf_aa.c csytrf_aa_2stage.c csytrs_3.c csytrs_aa.c csytrs_aa_2stage.c | |||
| csytri_3.c csytri_3x.c csycon_3.c csysv_rk.c csysv_aa.c csysv_aa_2stage.c | |||
| ctbcon.c ctbrfs.c ctbtrs.c ctgevc.c ctgex2.c | |||
| ctgexc.c ctgsen.c ctgsja.c ctgsna.c ctgsy2.c ctgsyl.c ctpcon.c | |||
| ctprfs.c ctptri.c | |||
| ctptrs.c ctrcon.c ctrevc.c ctrevc3.c ctrexc.c ctrrfs.c ctrsen.c ctrsna.c | |||
| ctrsyl.c ctrtrs.c ctzrzf.c cung2l.c cung2r.c | |||
| cungbr.c cunghr.c cungl2.c cunglq.c cungql.c cungqr.c cungr2.c | |||
| cungrq.c cungtr.c cunm2l.c cunm2r.c cunmbr.c cunmhr.c cunml2.c cunm22.c | |||
| cunmlq.c cunmql.c cunmqr.c cunmr2.c cunmr3.c cunmrq.c cunmrz.c | |||
| cunmtr.c cupgtr.c cupmtr.c icmax1.c scsum1.c cstemr.c | |||
| chfrk.c ctfttp.c clanhf.c cpftrf.c cpftri.c cpftrs.c ctfsm.c ctftri.c | |||
| ctfttr.c ctpttf.c ctpttr.c ctrttf.c ctrttp.c | |||
| cgeequb.c cgbequb.c csyequb.c cpoequb.c cheequb.c | |||
| cbbcsd.c clapmr.c cunbdb.c cunbdb1.c cunbdb2.c cunbdb3.c cunbdb4.c | |||
| cunbdb5.c cunbdb6.c cuncsd.c cuncsd2by1.c | |||
| cgeqrt.c cgeqrt2.c cgeqrt3.c cgemqrt.c | |||
| ctpqrt.c ctpqrt2.c ctpmqrt.c ctprfb.c | |||
| cgelqt.c cgelqt3.c cgemlqt.c | |||
| cgetsls.c cgetsqrhrt.c cgeqr.c clatsqr.c clamtsqr.c cgemqr.c | |||
| cgelq.c claswlq.c clamswlq.c cgemlq.c | |||
| ctplqt.c ctplqt2.c ctpmlqt.c | |||
| chetrd_2stage.c chetrd_he2hb.c chetrd_hb2st.c chb2st_kernels.c | |||
| cheevd_2stage.c cheev_2stage.c cheevx_2stage.c cheevr_2stage.c | |||
| chbev_2stage.c chbevx_2stage.c chbevd_2stage.c chegv_2stage.c | |||
| cgesvdq.c claunhr_col_getrfnp.c claunhr_col_getrfnp2.c | |||
| cungtsqr.c cungtsqr_row.c cunhr_col.c ) | |||
| set(CXLASRC cgesvxx.c cgerfsx.c cla_gerfsx_extended.c cla_geamv.c | |||
| cla_gercond_c.c cla_gercond_x.c cla_gerpvgrw.c | |||
| csysvxx.c csyrfsx.c cla_syrfsx_extended.c cla_syamv.c | |||
| cla_syrcond_c.c cla_syrcond_x.c cla_syrpvgrw.c | |||
| cposvxx.c cporfsx.c cla_porfsx_extended.c | |||
| cla_porcond_c.c cla_porcond_x.c cla_porpvgrw.c | |||
| cgbsvxx.c cgbrfsx.c cla_gbrfsx_extended.c cla_gbamv.c | |||
| cla_gbrcond_c.c cla_gbrcond_x.c cla_gbrpvgrw.c | |||
| chesvxx.c cherfsx.c cla_herfsx_extended.c cla_heamv.c | |||
| cla_hercond_c.c cla_hercond_x.c cla_herpvgrw.c | |||
| cla_lin_berr.c clarscl2.c clascl2.c cla_wwaddw.c) | |||
| set(DLASRC | |||
| dgbbrd.c dgbcon.c dgbequ.c dgbrfs.c dgbsv.c | |||
| dgbsvx.c dgbtf2.c dgbtrf.c dgbtrs.c dgebak.c dgebal.c dgebd2.c | |||
| dgebrd.c dgecon.c dgeequ.c dgees.c dgeesx.c dgeev.c dgeevx.c | |||
| dgehd2.c dgehrd.c dgelq2.c dgelqf.c | |||
| dgels.c dgelsd.c dgelss.c dgelsy.c dgeql2.c dgeqlf.c | |||
| dgeqp3.c dgeqr2.c dgeqr2p.c dgeqrf.c dgeqrfp.c dgerfs.c dgerq2.c dgerqf.c | |||
| dgesc2.c dgesdd.c dgesvd.c dgesvdx.c dgesvx.c dgetc2.c | |||
| dgetrf2.c dgetri.c | |||
| dggbak.c dggbal.c | |||
| dgges.c dgges3.c dggesx.c dggev.c dggev3.c dggevx.c | |||
| dggglm.c dgghrd.c dgghd3.c dgglse.c dggqrf.c | |||
| dggrqf.c dggsvd3.c dggsvp3.c dgtcon.c dgtrfs.c dgtsv.c | |||
| dgtsvx.c dgttrf.c dgttrs.c dgtts2.c dhgeqz.c | |||
| dhsein.c dhseqr.c dlabrd.c dlacon.c dlacn2.c | |||
| dlaein.c dlaexc.c dlag2.c dlags2.c dlagtm.c dlagv2.c dlahqr.c | |||
| dlahr2.c dlaic1.c dlaln2.c dlals0.c dlalsa.c dlalsd.c | |||
| dlangb.c dlange.c dlangt.c dlanhs.c dlansb.c dlansp.c | |||
| dlansy.c dlantb.c dlantp.c dlantr.c dlanv2.c | |||
| dlapll.c dlapmt.c | |||
| dlaqgb.c dlaqge.c dlaqp2.c dlaqps.c dlaqsb.c dlaqsp.c dlaqsy.c | |||
| dlaqr0.c dlaqr1.c dlaqr2.c dlaqr3.c dlaqr4.c dlaqr5.c | |||
| dlaqtr.c dlar1v.c dlar2v.c iladlr.c iladlc.c | |||
| dlarf.c dlarfb.c dlarfb_gett.c dlarfg.c dlarfgp.c dlarft.c dlarfx.c dlarfy.c | |||
| dlargv.c dlarrv.c dlartv.c | |||
| dlarz.c dlarzb.c dlarzt.c dlasy2.c | |||
| dlasyf.c dlasyf_rook.c dlasyf_rk.c dlasyf_aa.c | |||
| dlatbs.c dlatdf.c dlatps.c dlatrd.c dlatrs.c dlatrz.c | |||
| dopgtr.c dopmtr.c dorg2l.c dorg2r.c | |||
| dorgbr.c dorghr.c dorgl2.c dorglq.c dorgql.c dorgqr.c dorgr2.c | |||
| dorgrq.c dorgtr.c dorm2l.c dorm2r.c dorm22.c | |||
| dormbr.c dormhr.c dorml2.c dormlq.c dormql.c dormqr.c dormr2.c | |||
| dormr3.c dormrq.c dormrz.c dormtr.c dpbcon.c dpbequ.c dpbrfs.c | |||
| dpbstf.c dpbsv.c dpbsvx.c | |||
| dpbtf2.c dpbtrf.c dpbtrs.c dpocon.c dpoequ.c dporfs.c dposv.c | |||
| dposvx.c dpotrf2.c dpotri.c dpotrs.c dpstrf.c dpstf2.c | |||
| dppcon.c dppequ.c | |||
| dpprfs.c dppsv.c dppsvx.c dpptrf.c dpptri.c dpptrs.c dptcon.c | |||
| dpteqr.c dptrfs.c dptsv.c dptsvx.c dpttrs.c dptts2.c drscl.c | |||
| dsbev.c dsbevd.c dsbevx.c dsbgst.c dsbgv.c dsbgvd.c dsbgvx.c | |||
| dsbtrd.c dspcon.c dspev.c dspevd.c dspevx.c dspgst.c | |||
| dspgv.c dspgvd.c dspgvx.c dsprfs.c dspsv.c dspsvx.c dsptrd.c | |||
| dsptrf.c dsptri.c dsptrs.c dstegr.c dstev.c dstevd.c dstevr.c | |||
| dsycon.c dsyev.c dsyevd.c dsyevr.c | |||
| dsyevx.c dsygs2.c dsygst.c dsygv.c dsygvd.c dsygvx.c dsyrfs.c | |||
| dsysv.c dsysvx.c | |||
| dsytd2.c dsytf2.c dsytrd.c dsytrf.c dsytri.c dsytrs.c dsytrs2.c | |||
| dsytri2.c dsytri2x.c dsyswapr.c | |||
| dsyconv.c dsyconvf.c dsyconvf_rook.c | |||
| dsytf2_rook.c dsytrf_rook.c dsytrs_rook.c | |||
| dsytri_rook.c dsycon_rook.c dsysv_rook.c | |||
| dsytf2_rk.c dsytrf_rk.c dsytrs_3.c | |||
| dsytri_3.c dsytri_3x.c dsycon_3.c dsysv_rk.c | |||
| dsysv_aa.c dsysv_aa_2stage.c dsytrf_aa.c dsytrf_aa_2stage.c dsytrs_aa.c dsytrs_aa_2stage.c | |||
| dtbcon.c | |||
| dtbrfs.c dtbtrs.c dtgevc.c dtgex2.c dtgexc.c dtgsen.c | |||
| dtgsja.c dtgsna.c dtgsy2.c dtgsyl.c dtpcon.c dtprfs.c dtptri.c | |||
| dtptrs.c | |||
| dtrcon.c dtrevc.c dtrevc3.c dtrexc.c dtrrfs.c dtrsen.c dtrsna.c dtrsyl.c | |||
| dtrtrs.c dtzrzf.c dstemr.c | |||
| dsgesv.c dsposv.c dlag2s.c slag2d.c dlat2s.c | |||
| dlansf.c dpftrf.c dpftri.c dpftrs.c dsfrk.c dtfsm.c dtftri.c dtfttp.c | |||
| dtfttr.c dtpttf.c dtpttr.c dtrttf.c dtrttp.c | |||
| dgejsv.c dgesvj.c dgsvj0.c dgsvj1.c | |||
| dgeequb.c dsyequb.c dpoequb.c dgbequb.c | |||
| dbbcsd.c dlapmr.c dorbdb.c dorbdb1.c dorbdb2.c dorbdb3.c dorbdb4.c | |||
| dorbdb5.c dorbdb6.c dorcsd.c dorcsd2by1.c | |||
| dgeqrt.c dgeqrt2.c dgeqrt3.c dgemqrt.c | |||
| dtpqrt.c dtpqrt2.c dtpmqrt.c dtprfb.c | |||
| dgelqt.c dgelqt3.c dgemlqt.c | |||
| dgetsls.c dgetsqrhrt.c dgeqr.c dlatsqr.c dlamtsqr.c dgemqr.c | |||
| dgelq.c dlaswlq.c dlamswlq.c dgemlq.c | |||
| dtplqt.c dtplqt2.c dtpmlqt.c | |||
| dsytrd_2stage.c dsytrd_sy2sb.c dsytrd_sb2st.c dsb2st_kernels.c | |||
| dsyevd_2stage.c dsyev_2stage.c dsyevx_2stage.c dsyevr_2stage.c | |||
| dsbev_2stage.c dsbevx_2stage.c dsbevd_2stage.c dsygv_2stage.c | |||
| dcombssq.c dgesvdq.c dlaorhr_col_getrfnp.c | |||
| dlaorhr_col_getrfnp2.c dorgtsqr.c dorgtsqr_row.c dorhr_col.c ) | |||
| set(DXLASRC dgesvxx.c dgerfsx.c dla_gerfsx_extended.c dla_geamv.c | |||
| dla_gercond.c dla_gerpvgrw.c dsysvxx.c dsyrfsx.c | |||
| dla_syrfsx_extended.c dla_syamv.c dla_syrcond.c dla_syrpvgrw.c | |||
| dposvxx.c dporfsx.c dla_porfsx_extended.c dla_porcond.c | |||
| dla_porpvgrw.c dgbsvxx.c dgbrfsx.c dla_gbrfsx_extended.c | |||
| dla_gbamv.c dla_gbrcond.c dla_gbrpvgrw.c dla_lin_berr.c dlarscl2.c | |||
| dlascl2.c dla_wwaddw.c) | |||
| set(ZLASRC | |||
| zbdsqr.c zgbbrd.c zgbcon.c zgbequ.c zgbrfs.c zgbsv.c zgbsvx.c | |||
| zgbtf2.c zgbtrf.c zgbtrs.c zgebak.c zgebal.c zgebd2.c zgebrd.c | |||
| zgecon.c zgeequ.c zgees.c zgeesx.c zgeev.c zgeevx.c | |||
| zgehd2.c zgehrd.c zgelq2.c zgelqf.c | |||
| zgels.c zgelsd.c zgelss.c zgelsy.c zgeql2.c zgeqlf.c zgeqp3.c | |||
| zgeqr2.c zgeqr2p.c zgeqrf.c zgeqrfp.c zgerfs.c zgerq2.c zgerqf.c | |||
| zgesc2.c zgesdd.c zgesvd.c zgesvdx.c zgesvx.c | |||
| zgesvj.c zgejsv.c zgsvj0.c zgsvj1.c | |||
| zgetc2.c zgetrf2.c | |||
| zgetri.c | |||
| zggbak.c zggbal.c | |||
| zgges.c zgges3.c zggesx.c zggev.c zggev3.c zggevx.c | |||
| zggglm.c zgghrd.c zgghd3.c zgglse.c zggqrf.c zggrqf.c | |||
| zggsvd3.c zggsvp3.c | |||
| zgtcon.c zgtrfs.c zgtsv.c zgtsvx.c zgttrf.c zgttrs.c zgtts2.c zhbev.c | |||
| zhbevd.c zhbevx.c zhbgst.c zhbgv.c zhbgvd.c zhbgvx.c zhbtrd.c | |||
| zhecon.c zheev.c zheevd.c zheevr.c zheevx.c zhegs2.c zhegst.c | |||
| zhegv.c zhegvd.c zhegvx.c zherfs.c zhesv.c zhesvx.c zhetd2.c | |||
| zhetf2.c zhetrd.c | |||
| zhetrf.c zhetri.c zhetri2.c zhetri2x.c zheswapr.c | |||
| zhetrs.c zhetrs2.c | |||
| zhetf2_rook.c zhetrf_rook.c zhetri_rook.c | |||
| zhetrs_rook.c zhecon_rook.c zhesv_rook.c | |||
| zhetf2_rk.c zhetrf_rk.c zhetri_3.c zhetri_3x.c | |||
| zhetrs_3.c zhecon_3.c zhesv_rk.c | |||
| zhesv_aa.c zhesv_aa_2stage.c zhetrf_aa.c zhetrf_aa_2stage.c zhetrs_aa.c zhetrs_aa_2stage.c | |||
| zhgeqz.c zhpcon.c zhpev.c zhpevd.c | |||
| zhpevx.c zhpgst.c zhpgv.c zhpgvd.c zhpgvx.c zhprfs.c zhpsv.c | |||
| zhpsvx.c | |||
| zhptrd.c zhptrf.c zhptri.c zhptrs.c zhsein.c zhseqr.c zlabrd.c | |||
| zlacgv.c zlacon.c zlacn2.c zlacp2.c zlacpy.c zlacrm.c zlacrt.c zladiv.c | |||
| zlaed0.c zlaed7.c zlaed8.c | |||
| zlaein.c zlaesy.c zlaev2.c zlags2.c zlagtm.c | |||
| zlahef.c zlahef_rook.c zlahef_rk.c zlahef_aa.c zlahqr.c | |||
| zlahr2.c zlaic1.c zlals0.c zlalsa.c zlalsd.c zlangb.c zlange.c | |||
| zlangt.c zlanhb.c | |||
| zlanhe.c | |||
| zlanhp.c zlanhs.c zlanht.c zlansb.c zlansp.c zlansy.c zlantb.c | |||
| zlantp.c zlantr.c zlapll.c zlapmt.c zlaqgb.c zlaqge.c | |||
| zlaqhb.c zlaqhe.c zlaqhp.c zlaqp2.c zlaqps.c zlaqsb.c | |||
| zlaqr0.c zlaqr1.c zlaqr2.c zlaqr3.c zlaqr4.c zlaqr5.c | |||
| zlaqsp.c zlaqsy.c zlar1v.c zlar2v.c ilazlr.c ilazlc.c | |||
| zlarcm.c zlarf.c zlarfb.c zlarfb_gett.c | |||
| zlarfg.c zlarfgp.c zlarft.c | |||
| zlarfx.c zlarfy.c zlargv.c zlarnv.c zlarrv.c zlartg.c zlartv.c | |||
| zlarz.c zlarzb.c zlarzt.c zlascl.c zlaset.c zlasr.c | |||
| zlassq.c zlasyf.c zlasyf_rook.c zlasyf_rk.c zlasyf_aa.c | |||
| zlatbs.c zlatdf.c zlatps.c zlatrd.c zlatrs.c zlatrz.c | |||
| zpbcon.c zpbequ.c zpbrfs.c zpbstf.c zpbsv.c | |||
| zpbsvx.c zpbtf2.c zpbtrf.c zpbtrs.c zpocon.c zpoequ.c zporfs.c | |||
| zposv.c zposvx.c zpotrf2.c zpotri.c zpotrs.c zpstrf.c zpstf2.c | |||
| zppcon.c zppequ.c zpprfs.c zppsv.c zppsvx.c zpptrf.c zpptri.c zpptrs.c | |||
| zptcon.c zpteqr.c zptrfs.c zptsv.c zptsvx.c zpttrf.c zpttrs.c zptts2.c | |||
| zrot.c zspcon.c zsprfs.c zspsv.c | |||
| zspsvx.c zsptrf.c zsptri.c zsptrs.c zdrscl.c zstedc.c | |||
| zstegr.c zstein.c zsteqr.c zsycon.c | |||
| zsyrfs.c zsysv.c zsysvx.c zsytf2.c zsytrf.c zsytri.c | |||
| zsytri2.c zsytri2x.c zsyswapr.c | |||
| zsytrs.c zsytrs2.c | |||
| zsyconv.c zsyconvf.c zsyconvf_rook.c | |||
| zsytf2_rook.c zsytrf_rook.c zsytrs_rook.c zsytrs_aa.c zsytrs_aa_2stage.c | |||
| zsytri_rook.c zsycon_rook.c zsysv_rook.c | |||
| zsytf2_rk.c zsytrf_rk.c zsytrf_aa.c zsytrf_aa_2stage.c zsytrs_3.c | |||
| zsytri_3.c zsytri_3x.c zsycon_3.c zsysv_rk.c zsysv_aa.c zsysv_aa_2stage.c | |||
| ztbcon.c ztbrfs.c ztbtrs.c ztgevc.c ztgex2.c | |||
| ztgexc.c ztgsen.c ztgsja.c ztgsna.c ztgsy2.c ztgsyl.c ztpcon.c | |||
| ztprfs.c ztptri.c | |||
| ztptrs.c ztrcon.c ztrevc.c ztrevc3.c ztrexc.c ztrrfs.c ztrsen.c ztrsna.c | |||
| ztrsyl.c ztrtrs.c ztzrzf.c zung2l.c | |||
| zung2r.c zungbr.c zunghr.c zungl2.c zunglq.c zungql.c zungqr.c zungr2.c | |||
| zungrq.c zungtr.c zunm2l.c zunm2r.c zunmbr.c zunmhr.c zunml2.c zunm22.c | |||
| zunmlq.c zunmql.c zunmqr.c zunmr2.c zunmr3.c zunmrq.c zunmrz.c | |||
| zunmtr.c zupgtr.c | |||
| zupmtr.c izmax1.c dzsum1.c zstemr.c | |||
| zcgesv.c zcposv.c zlag2c.c clag2z.c zlat2c.c | |||
| zhfrk.c ztfttp.c zlanhf.c zpftrf.c zpftri.c zpftrs.c ztfsm.c ztftri.c | |||
| ztfttr.c ztpttf.c ztpttr.c ztrttf.c ztrttp.c | |||
| zgeequb.c zgbequb.c zsyequb.c zpoequb.c zheequb.c | |||
| zbbcsd.c zlapmr.c zunbdb.c zunbdb1.c zunbdb2.c zunbdb3.c zunbdb4.c | |||
| zunbdb5.c zunbdb6.c zuncsd.c zuncsd2by1.c | |||
| zgeqrt.c zgeqrt2.c zgeqrt3.c zgemqrt.c | |||
| ztpqrt.c ztpqrt2.c ztpmqrt.c ztprfb.c | |||
| ztplqt.c ztplqt2.c ztpmlqt.c | |||
| zgelqt.c zgelqt3.c zgemlqt.c | |||
| zgetsls.c zgetsqrhrt.c zgeqr.c zlatsqr.c zlamtsqr.c zgemqr.c | |||
| zgelq.c zlaswlq.c zlamswlq.c zgemlq.c | |||
| zhetrd_2stage.c zhetrd_he2hb.c zhetrd_hb2st.c zhb2st_kernels.c | |||
| zheevd_2stage.c zheev_2stage.c zheevx_2stage.c zheevr_2stage.c | |||
| zhbev_2stage.c zhbevx_2stage.c zhbevd_2stage.c zhegv_2stage.c | |||
| zgesvdq.c zlaunhr_col_getrfnp.c zlaunhr_col_getrfnp2.c | |||
| zungtsqr.c zungtsqr_row.c zunhr_col.c) | |||
| set(ZXLASRC zgesvxx.c zgerfsx.c zla_gerfsx_extended.c zla_geamv.c | |||
| zla_gercond_c.c zla_gercond_x.c zla_gerpvgrw.c zsysvxx.c zsyrfsx.c | |||
| zla_syrfsx_extended.c zla_syamv.c zla_syrcond_c.c zla_syrcond_x.c | |||
| zla_syrpvgrw.c zposvxx.c zporfsx.c zla_porfsx_extended.c | |||
| zla_porcond_c.c zla_porcond_x.c zla_porpvgrw.c zgbsvxx.c zgbrfsx.c | |||
| zla_gbrfsx_extended.c zla_gbamv.c zla_gbrcond_c.c zla_gbrcond_x.c | |||
| zla_gbrpvgrw.c zhesvxx.c zherfsx.c zla_herfsx_extended.c | |||
| zla_heamv.c zla_hercond_c.c zla_hercond_x.c zla_herpvgrw.c | |||
| zla_lin_berr.c zlarscl2.c zlascl2.c zla_wwaddw.c) | |||
| if(USE_XBLAS) | |||
| set(ALLXOBJ ${SXLASRC} ${DXLASRC} ${CXLASRC} ${ZXLASRC}) | |||
| endif() | |||
| list(APPEND SLASRC DEPRECATED/sgegs.c DEPRECATED/sgegv.c | |||
| DEPRECATED/sgeqpf.c DEPRECATED/sgelsx.c DEPRECATED/sggsvd.c | |||
| DEPRECATED/sggsvp.c DEPRECATED/slahrd.c DEPRECATED/slatzm.c DEPRECATED/stzrqf.c) | |||
| list(APPEND DLASRC DEPRECATED/dgegs.c DEPRECATED/dgegv.c | |||
| DEPRECATED/dgeqpf.c DEPRECATED/dgelsx.c DEPRECATED/dggsvd.c | |||
| DEPRECATED/dggsvp.c DEPRECATED/dlahrd.c DEPRECATED/dlatzm.c DEPRECATED/dtzrqf.c) | |||
| list(APPEND CLASRC DEPRECATED/cgegs.c DEPRECATED/cgegv.c | |||
| DEPRECATED/cgeqpf.c DEPRECATED/cgelsx.c DEPRECATED/cggsvd.c | |||
| DEPRECATED/cggsvp.c DEPRECATED/clahrd.c DEPRECATED/clatzm.c DEPRECATED/ctzrqf.c) | |||
| list(APPEND ZLASRC DEPRECATED/zgegs.c DEPRECATED/zgegv.c | |||
| DEPRECATED/zgeqpf.c DEPRECATED/zgelsx.c DEPRECATED/zggsvd.c | |||
| DEPRECATED/zggsvp.c DEPRECATED/zlahrd.c DEPRECATED/zlatzm.c DEPRECATED/ztzrqf.c) | |||
| message(STATUS "Building deprecated routines") | |||
| set(DSLASRC spotrs.c) | |||
| set(ZCLASRC cpotrs.c) | |||
| set(SCATGEN slatm1.c slaran.c slarnd.c) | |||
| set(SMATGEN slatms.c slatme.c slatmr.c slatmt.c | |||
| slagge.c slagsy.c slakf2.c slarge.c slaror.c slarot.c slatm2.c | |||
| slatm3.c slatm5.c slatm6.c slatm7.c slahilb.c) | |||
| set(CMATGEN clatms.c clatme.c clatmr.c clatmt.c | |||
| clagge.c claghe.c clagsy.c clakf2.c clarge.c claror.c clarot.c | |||
| clatm1.c clarnd.c clatm2.c clatm3.c clatm5.c clatm6.c clahilb.c slatm7.c) | |||
| set(DZATGEN dlatm1.c dlaran.c dlarnd.c) | |||
| set(DMATGEN dlatms.c dlatme.c dlatmr.c dlatmt.c | |||
| dlagge.c dlagsy.c dlakf2.c dlarge.c dlaror.c dlarot.c dlatm2.c | |||
| dlatm3.c dlatm5.c dlatm6.c dlatm7.c dlahilb.c) | |||
| set(ZMATGEN zlatms.c zlatme.c zlatmr.c zlatmt.c | |||
| zlagge.c zlaghe.c zlagsy.c zlakf2.c zlarge.c zlaror.c zlarot.c | |||
| zlatm1.c zlarnd.c zlatm2.c zlatm3.c zlatm5.c zlatm6.c zlahilb.c dlatm7.c) | |||
| if(BUILD_SINGLE) | |||
| set(LA_REL_SRC ${SLASRC} ${DSLASRC} ${ALLAUX} ${SCLAUX}) | |||
| set(LA_GEN_SRC ${SMATGEN} ${SCATGEN}) | |||
| message(STATUS "Building Single Precision") | |||
| endif() | |||
| if(BUILD_DOUBLE) | |||
| set(LA_REL_SRC ${LA_REL_SRC} ${DLASRC} ${DSLASRC} ${ALLAUX} ${DZLAUX}) | |||
| set(LA_GEN_SRC ${LA_GEN_SRC} ${DMATGEN} ${DZATGEN}) | |||
| message(STATUS "Building Double Precision") | |||
| endif() | |||
| if(BUILD_COMPLEX) | |||
| set(LA_REL_SRC ${LA_REL_SRC} ${CLASRC} ${ZCLASRC} ${ALLAUX} ${SCLAUX}) | |||
| SET(LA_GEN_SRC ${LA_GEN_SRC} ${CMATGEN} ${SCATGEN}) | |||
| message(STATUS "Building Single Precision Complex") | |||
| endif() | |||
| if(BUILD_COMPLEX16) | |||
| set(LA_REL_SRC ${LA_REL_SRC} ${ZLASRC} ${ZCLASRC} ${ALLAUX} ${DZLAUX}) | |||
| SET(LA_GEN_SRC ${LA_GEN_SRC} ${ZMATGEN} ${DZATGEN}) | |||
| # for zlange/zlanhe | |||
| if (NOT BUILD_DOUBLE) | |||
| set (LA_REL_SRC ${LA_REL_SRC} dcombssq.c) | |||
| endif () | |||
| message(STATUS "Building Double Precision Complex") | |||
| endif() | |||
| endif() | |||
| # add lapack-netlib folder to the sources | |||
| set(LA_SOURCES "") | |||
| foreach (LA_FILE ${LA_REL_SRC}) | |||
| @@ -496,4 +990,9 @@ endforeach () | |||
| foreach (LA_FILE ${LA_GEN_SRC}) | |||
| list(APPEND LA_SOURCES "${NETLIB_LAPACK_DIR}/TESTING/MATGEN/${LA_FILE}") | |||
| endforeach () | |||
| set_source_files_properties(${LA_SOURCES} PROPERTIES COMPILE_FLAGS "${LAPACK_FFLAGS}") | |||
| if (NOT C_LAPACK) | |||
| set_source_files_properties(${LA_SOURCES} PROPERTIES COMPILE_FLAGS "${LAPACK_FFLAGS}") | |||
| else () | |||
| set_source_files_properties(${LA_SOURCES} PROPERTIES COMPILE_FLAGS "${LAPACK_CFLAGS}") | |||
| endif () | |||
| @@ -284,8 +284,15 @@ if (NOT NOFORTRAN) | |||
| # Fortran Compiler dependent settings | |||
| include("${PROJECT_SOURCE_DIR}/cmake/fc.cmake") | |||
| else () | |||
| set(NO_LAPACK 1) | |||
| set(NO_LAPACKE 1) | |||
| if (NOT MSVC) | |||
| set(C_LAPACK 1) | |||
| if (INTERFACE64) | |||
| set (CCOMMON_OPT "${CCOMMON_OPT} -DLAPACK_ILP64") | |||
| endif () | |||
| set(TIMER "NONE") | |||
| else () | |||
| set (NO_LAPACK 1) | |||
| endif () | |||
| endif () | |||
| if (BINARY64) | |||
| @@ -4,6 +4,7 @@ include $(TOPSRCDIR)/make.inc | |||
| .PHONY: all testlsame testslamch testdlamch testsecond testdsecnd testieee testversion | |||
| all: testlsame testslamch testdlamch testsecond testdsecnd testieee testversion | |||
| ifneq ($(C_LAPACK), 1) | |||
| testlsame: lsame.o lsametst.o | |||
| $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $^ | |||
| @@ -27,6 +28,31 @@ testieee: tstiee.o | |||
| testversion: ilaver.o LAPACK_version.o | |||
| $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $^ | |||
| else | |||
| testlsame: lsame.o lsametst.o | |||
| $(CC) -O2 -o $@ $^ | |||
| testslamch: slamch.o lsame.o slamchtst.o | |||
| $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ | |||
| testdlamch: dlamch.o lsame.o dlamchtst.o | |||
| $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ | |||
| testsecond: second_$(TIMER).o secondtst.o | |||
| @echo "[INFO] : TIMER value: $(TIMER) (given by make.inc)" | |||
| $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ | |||
| testdsecnd: dsecnd_$(TIMER).o dsecndtst.o | |||
| @echo "[INFO] : TIMER value: $(TIMER) (given by make.inc)" | |||
| $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ | |||
| testieee: tstiee.o | |||
| $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ | |||
| testversion: ilaver.o LAPACK_version.o | |||
| $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ | |||
| endif | |||
| .PHONY: run | |||
| run: all | |||
| ./testlsame | |||
| @@ -46,5 +72,10 @@ cleanexe: | |||
| cleantest: | |||
| rm -f core | |||
| ifneq ($(C_LAPACK), 1) | |||
| slamch.o: slamch.f ; $(FC) $(FFLAGS_NOOPT) -c -o $@ $< | |||
| dlamch.o: dlamch.f ; $(FC) $(FFLAGS_NOOPT) -c -o $@ $< | |||
| else | |||
| slamch.o: slamch.c ; $(CC) $(CFLAGS) -c -o $@ $< | |||
| dlamch.o: dlamch.c ; $(CC) $(CFLAGS) -c -o $@ $< | |||
| endif | |||
| @@ -0,0 +1,445 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle_() continue; | |||
| #define myceiling_(w) ceil(w) | |||
| #define myhuge_(w) HUGE_VAL | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc_(w,s,e,n) dmaxloc_(w,*(s),*(e),n) | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b DSECND returns nothing */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION DSECND( ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > DSECND returns nothing instead of returning the user time for a process in seconds. */ | |||
| /* > If you are using that routine, it means that neither EXTERNAL ETIME, */ | |||
| /* > EXTERNAL ETIME_, INTERNAL ETIME, INTERNAL CPU_TIME is available on */ | |||
| /* > your machine. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup auxOTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal dsecnd_(void) | |||
| { | |||
| /* System generated locals */ | |||
| doublereal ret_val; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| ret_val = 0.; | |||
| return ret_val; | |||
| /* End of DSECND */ | |||
| } /* dsecnd_ */ | |||
| @@ -0,0 +1,445 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle_() continue; | |||
| #define myceiling_(w) ceil(w) | |||
| #define myhuge_(w) HUGE_VAL | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc_(w,s,e,n) dmaxloc_(w,*(s),*(e),n) | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b DSECND returns nothing */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* DOUBLE PRECISION FUNCTION DSECND( ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > DSECND returns nothing instead of returning the user time for a process in seconds. */ | |||
| /* > If you are using that routine, it means that neither EXTERNAL ETIME, */ | |||
| /* > EXTERNAL ETIME_, INTERNAL ETIME, INTERNAL CPU_TIME is available on */ | |||
| /* > your machine. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup auxOTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| doublereal dsecnd_(void) | |||
| { | |||
| /* System generated locals */ | |||
| doublereal ret_val; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| ret_val = 0.; | |||
| return ret_val; | |||
| /* End of DSECND */ | |||
| } /* dsecnd_ */ | |||
| @@ -0,0 +1,458 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle_() continue; | |||
| #define myceiling_(w) ceil(w) | |||
| #define myhuge_(w) HUGE_VAL | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc_(w,s,e,n) dmaxloc_(w,*(s),*(e),n) | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b ILAVER returns the LAPACK version. */ | |||
| /* * */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ILAVER( VERS_MAJOR, VERS_MINOR, VERS_PATCH ) */ | |||
| /* INTEGER VERS_MAJOR, VERS_MINOR, VERS_PATCH */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This subroutine returns the LAPACK version. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[out] VERS_MAJOR */ | |||
| /* > VERS_MAJOR is INTEGER */ | |||
| /* > return the lapack major version */ | |||
| /* > */ | |||
| /* > \param[out] VERS_MINOR */ | |||
| /* > VERS_MINOR is INTEGER */ | |||
| /* > return the lapack minor version from the major version */ | |||
| /* > */ | |||
| /* > \param[out] VERS_PATCH */ | |||
| /* > VERS_PATCH is INTEGER */ | |||
| /* > return the lapack patch version from the minor version */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2019 */ | |||
| /* > \ingroup auxOTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int ilaver_(integer *vers_major__, integer *vers_minor__, | |||
| integer *vers_patch__) | |||
| { | |||
| /* -- LAPACK computational routine -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* ===================================================================== */ | |||
| /* ===================================================================== */ | |||
| *vers_major__ = 3; | |||
| *vers_minor__ = 9; | |||
| *vers_patch__ = 0; | |||
| /* ===================================================================== */ | |||
| return 0; | |||
| } /* ilaver_ */ | |||
| @@ -0,0 +1,521 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle_() continue; | |||
| #define myceiling_(w) ceil(w) | |||
| #define myhuge_(w) HUGE_VAL | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc_(w,s,e,n) dmaxloc_(w,*(s),*(e),n) | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b LSAME */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* LOGICAL FUNCTION LSAME( CA, CB ) */ | |||
| /* CHARACTER CA, CB */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > LSAME returns .TRUE. if CA is the same letter as CB regardless of */ | |||
| /* > case. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] CA */ | |||
| /* > \verbatim */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] CB */ | |||
| /* > \verbatim */ | |||
| /* > CA and CB specify the single characters to be compared. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup auxOTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| logical lsame_(char *ca, char *cb) | |||
| { | |||
| /* System generated locals */ | |||
| logical ret_val; | |||
| /* Local variables */ | |||
| integer inta, intb, zcode; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test if the characters are equal */ | |||
| ret_val = *(unsigned char *)ca == *(unsigned char *)cb; | |||
| if (ret_val) { | |||
| return ret_val; | |||
| } | |||
| /* Now test for equivalence if both characters are alphabetic. */ | |||
| zcode = 'Z'; | |||
| /* Use 'Z' rather than 'A' so that ASCII can be detected on Prime */ | |||
| /* machines, on which ICHAR returns a value with bit 8 set. */ | |||
| /* ICHAR('A') on Prime machines returns 193 which is the same as */ | |||
| /* ICHAR('A') on an EBCDIC machine. */ | |||
| inta = *(unsigned char *)ca; | |||
| intb = *(unsigned char *)cb; | |||
| if (zcode == 90 || zcode == 122) { | |||
| /* ASCII is assumed - ZCODE is the ASCII code of either lower or */ | |||
| /* upper case 'Z'. */ | |||
| if (inta >= 97 && inta <= 122) { | |||
| inta += -32; | |||
| } | |||
| if (intb >= 97 && intb <= 122) { | |||
| intb += -32; | |||
| } | |||
| } else if (zcode == 233 || zcode == 169) { | |||
| /* EBCDIC is assumed - ZCODE is the EBCDIC code of either lower or */ | |||
| /* upper case 'Z'. */ | |||
| if (inta >= 129 && inta <= 137 || inta >= 145 && inta <= 153 || inta | |||
| >= 162 && inta <= 169) { | |||
| inta += 64; | |||
| } | |||
| if (intb >= 129 && intb <= 137 || intb >= 145 && intb <= 153 || intb | |||
| >= 162 && intb <= 169) { | |||
| intb += 64; | |||
| } | |||
| } else if (zcode == 218 || zcode == 250) { | |||
| /* ASCII is assumed, on Prime machines - ZCODE is the ASCII code */ | |||
| /* plus 128 of either lower or upper case 'Z'. */ | |||
| if (inta >= 225 && inta <= 250) { | |||
| inta += -32; | |||
| } | |||
| if (intb >= 225 && intb <= 250) { | |||
| intb += -32; | |||
| } | |||
| } | |||
| ret_val = inta == intb; | |||
| /* RETURN */ | |||
| /* End of LSAME */ | |||
| return ret_val; | |||
| } /* lsame_ */ | |||
| @@ -0,0 +1,595 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle_() continue; | |||
| #define myceiling_(w) ceil(w) | |||
| #define myhuge_(w) HUGE_VAL | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc_(w,s,e,n) dmaxloc_(w,*(s),*(e),n) | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__9 = 9; | |||
| static integer c__1 = 1; | |||
| static integer c__3 = 3; | |||
| /* > \brief \b LSAMETST */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* PROGRAM LSAMETST */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup auxOTHERauxiliary */ | |||
| /* ===================================================================== PROGRAM LSAMETST */ | |||
| /* -- LAPACK test routine (version 3.7.0) -- */ | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Main program */ main(void) | |||
| { | |||
| /* Format strings */ | |||
| static char fmt_9999[] = "(\002 *** Error: LSAME( \002,a1,\002, \002," | |||
| "a1,\002) is .FALSE.\002)"; | |||
| static char fmt_9998[] = "(\002 *** Error: LSAME( \002,a1,\002, \002," | |||
| "a1,\002) is .TRUE.\002)"; | |||
| /* System generated locals */ | |||
| integer i__1; | |||
| /* Local variables */ | |||
| extern logical lsame_(char *, char *); | |||
| integer i1, i2; | |||
| /* Fortran I/O blocks */ | |||
| static cilist io___3 = { 0, 6, 0, 0, 0 }; | |||
| static cilist io___4 = { 0, 6, 0, 0, 0 }; | |||
| static cilist io___5 = { 0, 6, 0, fmt_9999, 0 }; | |||
| static cilist io___6 = { 0, 6, 0, fmt_9999, 0 }; | |||
| static cilist io___7 = { 0, 6, 0, fmt_9999, 0 }; | |||
| static cilist io___8 = { 0, 6, 0, fmt_9999, 0 }; | |||
| static cilist io___9 = { 0, 6, 0, fmt_9998, 0 }; | |||
| static cilist io___10 = { 0, 6, 0, fmt_9998, 0 }; | |||
| static cilist io___11 = { 0, 6, 0, fmt_9998, 0 }; | |||
| static cilist io___12 = { 0, 6, 0, fmt_9998, 0 }; | |||
| static cilist io___13 = { 0, 6, 0, fmt_9998, 0 }; | |||
| static cilist io___14 = { 0, 6, 0, fmt_9998, 0 }; | |||
| static cilist io___15 = { 0, 6, 0, fmt_9998, 0 }; | |||
| static cilist io___16 = { 0, 6, 0, fmt_9998, 0 }; | |||
| static cilist io___17 = { 0, 6, 0, 0, 0 }; | |||
| /* Determine the character set. */ | |||
| i1 = 'A'; | |||
| i2 = 'a'; | |||
| if (i2 - i1 == 32) { | |||
| /* | |||
| s_wsle(&io___3); | |||
| do_lio(&c__9, &c__1, " ASCII character set", (ftnlen)20); | |||
| e_wsle(); | |||
| */ | |||
| printf(" ASCII character set"); | |||
| } else { | |||
| printf(" Non-ASCII character set, IOFF should be %d",i2-i1); | |||
| /* | |||
| s_wsle(&io___4); | |||
| do_lio(&c__9, &c__1, " Non-ASCII character set, IOFF should be ", ( | |||
| ftnlen)41); | |||
| i__1 = i2 - i1; | |||
| do_lio(&c__3, &c__1, (char *)&i__1, (ftnlen)sizeof(integer)); | |||
| e_wsle(); | |||
| */ | |||
| } | |||
| /* Test LSAME. */ | |||
| if (! lsame_("A", "A")) { | |||
| printf(" *** Error: LSAME(A,A) is .FALSE.\n"); | |||
| /* s_wsfe(&io___5); | |||
| do_fio(&c__1, "A", (ftnlen)1); | |||
| do_fio(&c__1, "A", (ftnlen)1); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| if (! lsame_("A", "a")) { | |||
| printf(" *** Error: LSAME(A,a) is .FALSE.\n"); | |||
| /* | |||
| s_wsfe(&io___6); | |||
| do_fio(&c__1, "A", (ftnlen)1); | |||
| do_fio(&c__1, "a", (ftnlen)1); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| if (! lsame_("a", "A")) { | |||
| printf(" *** Error: LSAME(a,A) is .FALSE.\n"); | |||
| /* s_wsfe(&io___7); | |||
| do_fio(&c__1, "a", (ftnlen)1); | |||
| do_fio(&c__1, "A", (ftnlen)1); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| if (! lsame_("a", "a")) { | |||
| printf(" *** Error: LSAME(a,a) is .FALSE.\n"); | |||
| /* s_wsfe(&io___8); | |||
| do_fio(&c__1, "a", (ftnlen)1); | |||
| do_fio(&c__1, "a", (ftnlen)1); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| if (lsame_("A", "B")) { | |||
| printf(" *** Error: LSAME(A,B) is .TRUE.\n"); | |||
| /* s_wsfe(&io___9); | |||
| do_fio(&c__1, "A", (ftnlen)1); | |||
| do_fio(&c__1, "B", (ftnlen)1); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| if (lsame_("A", "b")) { | |||
| printf(" *** Error: LSAME(A,b) is .TRUE.\n"); | |||
| /* s_wsfe(&io___10); | |||
| do_fio(&c__1, "A", (ftnlen)1); | |||
| do_fio(&c__1, "b", (ftnlen)1); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| if (lsame_("a", "B")) { | |||
| printf(" *** Error: LSAME(a,B) is .TRUE.\n"); | |||
| /* s_wsfe(&io___11); | |||
| do_fio(&c__1, "a", (ftnlen)1); | |||
| do_fio(&c__1, "B", (ftnlen)1); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| if (lsame_("a", "b")) { | |||
| printf(" *** Error: LSAME(a,b) is .TRUE.\n"); | |||
| /* s_wsfe(&io___12); | |||
| do_fio(&c__1, "a", (ftnlen)1); | |||
| do_fio(&c__1, "b", (ftnlen)1); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| if (lsame_("O", "/")) { | |||
| printf(" *** Error: LSAME(O,/) is .TRUE.\n"); | |||
| /* s_wsfe(&io___13); | |||
| do_fio(&c__1, "O", (ftnlen)1); | |||
| do_fio(&c__1, "/", (ftnlen)1); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| if (lsame_("/", "O")) { | |||
| printf(" *** Error: LSAME(/,O) is .TRUE.\n"); | |||
| /* s_wsfe(&io___14); | |||
| do_fio(&c__1, "/", (ftnlen)1); | |||
| do_fio(&c__1, "O", (ftnlen)1); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| if (lsame_("o", "/")) { | |||
| printf(" *** Error: LSAME(o,/) is .TRUE.\n"); | |||
| /* s_wsfe(&io___15); | |||
| do_fio(&c__1, "o", (ftnlen)1); | |||
| do_fio(&c__1, "/", (ftnlen)1); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| if (lsame_("/", "o")) { | |||
| printf(" *** Error: LSAME(/,o) is .TRUE.\n"); | |||
| /* s_wsfe(&io___16); | |||
| do_fio(&c__1, "/", (ftnlen)1); | |||
| do_fio(&c__1, "o", (ftnlen)1); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| printf(" Tests completed"); | |||
| /* s_wsle(&io___17); | |||
| do_lio(&c__9, &c__1, " Tests completed", (ftnlen)16); | |||
| e_wsle(); | |||
| */ | |||
| return 0; | |||
| } /* MAIN__ */ | |||
| @@ -0,0 +1,445 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle_() continue; | |||
| #define myceiling_(w) ceil(w) | |||
| #define myhuge_(w) HUGE_VAL | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc_(w,s,e,n) dmaxloc_(w,*(s),*(e),n) | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b SECOND returns nothing */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* REAL FUNCTION SECOND( ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > SECOND returns nothing instead of returning the user time for a process in seconds. */ | |||
| /* > If you are using that routine, it means that neither EXTERNAL ETIME, */ | |||
| /* > EXTERNAL ETIME_, INTERNAL ETIME, INTERNAL CPU_TIME is available on */ | |||
| /* > your machine. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup auxOTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| real second_(void) | |||
| { | |||
| /* System generated locals */ | |||
| real ret_val; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| ret_val = 0.f; | |||
| return ret_val; | |||
| /* End of SECOND */ | |||
| } /* second_ */ | |||
| @@ -0,0 +1,445 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle_() continue; | |||
| #define myceiling_(w) ceil(w) | |||
| #define myhuge_(w) HUGE_VAL | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc_(w,s,e,n) dmaxloc_(w,*(s),*(e),n) | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b SECOND returns nothing */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* REAL FUNCTION SECOND( ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > SECOND returns nothing instead of returning the user time for a process in seconds. */ | |||
| /* > If you are using that routine, it means that neither EXTERNAL ETIME, */ | |||
| /* > EXTERNAL ETIME_, INTERNAL ETIME, INTERNAL CPU_TIME is available on */ | |||
| /* > your machine. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup auxOTHERauxiliary */ | |||
| /* ===================================================================== */ | |||
| real second_(void) | |||
| { | |||
| /* System generated locals */ | |||
| real ret_val; | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| ret_val = 0.f; | |||
| return ret_val; | |||
| /* End of SECOND */ | |||
| } /* second_ */ | |||
| @@ -0,0 +1,566 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| typedef int integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle_() continue; | |||
| #define myceiling_(w) ceil(w) | |||
| #define myhuge_(w) HUGE_VAL | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc_(w,s,e,n) dmaxloc_(w,*(s),*(e),n) | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static integer c__1000 = 1000; | |||
| /* > \brief \b SECONDTST */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2017 */ | |||
| /* > \ingroup auxOTHERcomputational */ | |||
| /* ===================================================================== PROGRAM SECONDTST */ | |||
| /* -- LAPACK test routine (version 3.8.0) -- */ | |||
| /* -- LAPACK computational routine (version 3.8.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* November 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Main program */ main(void) | |||
| { | |||
| /* Format strings */ | |||
| static char fmt_9999[] = "(\002 Time for \002,g10.3,\002 SAXPY ops = " | |||
| "\002,g10.3,\002 seconds\002)"; | |||
| static char fmt_9998[] = "(\002 SAXPY performance rate = \002,g10" | |||
| ".3,\002 mflops \002)"; | |||
| static char fmt_9994[] = "(\002 *** Warning: Time for operations was le" | |||
| "ss or equal\002,\002 than zero => timing in TESTING might be dub" | |||
| "ious\002)"; | |||
| static char fmt_9997[] = "(\002 Including SECOND, time = \002,g10" | |||
| ".3,\002 seconds\002)"; | |||
| static char fmt_9996[] = "(\002 Average time for SECOND = \002,g10" | |||
| ".3,\002 milliseconds\002)"; | |||
| static char fmt_9995[] = "(\002 Equivalent floating point ops = \002,g10" | |||
| ".3,\002 ops\002)"; | |||
| /* System generated locals */ | |||
| real r__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| real alpha, x[1000], y[1000], total; | |||
| extern /* Subroutine */ int mysub_(integer *, real *, real *); | |||
| real t1, t2; | |||
| extern real second_(void); | |||
| real tnosec, avg; | |||
| /* Fortran I/O blocks */ | |||
| static cilist io___10 = { 0, 6, 0, fmt_9999, 0 }; | |||
| static cilist io___11 = { 0, 6, 0, fmt_9998, 0 }; | |||
| static cilist io___12 = { 0, 6, 0, fmt_9994, 0 }; | |||
| static cilist io___13 = { 0, 6, 0, fmt_9997, 0 }; | |||
| static cilist io___15 = { 0, 6, 0, fmt_9996, 0 }; | |||
| static cilist io___16 = { 0, 6, 0, fmt_9995, 0 }; | |||
| total = 1e8f; | |||
| /* Initialize X and Y */ | |||
| for (i__ = 1; i__ <= 1000; ++i__) { | |||
| x[i__ - 1] = 1.f / (real) i__; | |||
| y[i__ - 1] = (real) (1000 - i__) / 1e3f; | |||
| /* L10: */ | |||
| } | |||
| alpha = .315f; | |||
| /* Time TOTAL SAXPY operations */ | |||
| t1 = second_(); | |||
| for (j = 1; j <= 50000; ++j) { | |||
| for (i__ = 1; i__ <= 1000; ++i__) { | |||
| y[i__ - 1] += alpha * x[i__ - 1]; | |||
| /* L20: */ | |||
| } | |||
| alpha = -alpha; | |||
| /* L30: */ | |||
| } | |||
| t2 = second_(); | |||
| tnosec = t2 - t1; | |||
| /* | |||
| s_wsfe(&io___10); | |||
| do_fio(&c__1, (char *)&total, (ftnlen)sizeof(real)); | |||
| do_fio(&c__1, (char *)&tnosec, (ftnlen)sizeof(real)); | |||
| e_wsfe(); | |||
| if (tnosec > 0.f) { | |||
| s_wsfe(&io___11); | |||
| r__1 = total / 1e6f / tnosec; | |||
| do_fio(&c__1, (char *)&r__1, (ftnlen)sizeof(real)); | |||
| e_wsfe(); | |||
| } else { | |||
| s_wsfe(&io___12); | |||
| e_wsfe(); | |||
| } | |||
| */ | |||
| printf("Time for %f10.3 SAXPY ops = %f10.3 seconds\n",total,tnosec); | |||
| if (tnosec > 0.f) { | |||
| printf("SAXPY performance rate = %f10.3 mflops\n",total/1.e6/tnosec ); | |||
| } else { | |||
| printf("*** Warning: Time for operations was less or equal than zero => timing in TESTING might be dubious\n" ); | |||
| } | |||
| /* Time TOTAL SAXPY operations with SECOND in the outer loop */ | |||
| t1 = second_(); | |||
| for (j = 1; j <= 50000; ++j) { | |||
| for (i__ = 1; i__ <= 1000; ++i__) { | |||
| y[i__ - 1] += alpha * x[i__ - 1]; | |||
| /* L40: */ | |||
| } | |||
| alpha = -alpha; | |||
| t2 = second_(); | |||
| /* L50: */ | |||
| } | |||
| /* Compute the time used in milliseconds used by an average call */ | |||
| /* to SECOND. */ | |||
| /* | |||
| s_wsfe(&io___13); | |||
| r__1 = t2 - t1; | |||
| do_fio(&c__1, (char *)&r__1, (ftnlen)sizeof(real)); | |||
| e_wsfe(); | |||
| */ | |||
| printf("Including SECOND, time = %f10.3 seconds\n",t2-t1); | |||
| avg = (t2 - t1 - tnosec) * 1e3f / 5e4f; | |||
| if (avg > 0.f) { | |||
| printf("Average time for SECOND = %f10.3 milliseconds\n",avg ); | |||
| /* | |||
| s_wsfe(&io___15); | |||
| do_fio(&c__1, (char *)&avg, (ftnlen)sizeof(real)); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| /* Compute the equivalent number of floating point operations used */ | |||
| /* by an average call to SECOND. */ | |||
| if (avg > 0.f && tnosec > 0.f) { | |||
| printf("Equivalent floating point ops = %f10.3 ops\n", avg/1000*total/tnosec); | |||
| /* s_wsfe(&io___16); | |||
| r__1 = avg / 1000 * total / tnosec; | |||
| do_fio(&c__1, (char *)&r__1, (ftnlen)sizeof(real)); | |||
| e_wsfe(); | |||
| */ | |||
| } | |||
| mysub_(&c__1000, x, y); | |||
| return 0; | |||
| } /* MAIN__ */ | |||
| /* Subroutine */ int mysub_(integer *n, real *x, real *y) | |||
| { | |||
| /* Parameter adjustments */ | |||
| --y; | |||
| --x; | |||
| /* Function Body */ | |||
| return 0; | |||
| } /* mysub_ */ | |||
| @@ -0,0 +1,928 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b1 = {0.f,0.f}; | |||
| static complex c_b2 = {1.f,0.f}; | |||
| static integer c__0 = 0; | |||
| static integer c__2 = 2; | |||
| static integer c__1 = 1; | |||
| /* > \brief <b> CGELSX solves overdetermined or underdetermined systems for GE matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGELSX + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgelsx. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgelsx. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgelsx. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELSX( M, N, NRHS, A, LDA, B, LDB, JPVT, RCOND, RANK, */ | |||
| /* WORK, RWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LDB, M, N, NRHS, RANK */ | |||
| /* REAL RCOND */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), B( LDB, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine CGELSY. */ | |||
| /* > */ | |||
| /* > CGELSX computes the minimum-norm solution to a complex linear least */ | |||
| /* > squares problem: */ | |||
| /* > minimize || A * X - B || */ | |||
| /* > using a complete orthogonal factorization of A. A is an M-by-N */ | |||
| /* > matrix which may be rank-deficient. */ | |||
| /* > */ | |||
| /* > Several right hand side vectors b and solution vectors x can be */ | |||
| /* > handled in a single call; they are stored as the columns of the */ | |||
| /* > M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ | |||
| /* > matrix X. */ | |||
| /* > */ | |||
| /* > The routine first computes a QR factorization with column pivoting: */ | |||
| /* > A * P = Q * [ R11 R12 ] */ | |||
| /* > [ 0 R22 ] */ | |||
| /* > with R11 defined as the largest leading submatrix whose estimated */ | |||
| /* > condition number is less than 1/RCOND. The order of R11, RANK, */ | |||
| /* > is the effective rank of A. */ | |||
| /* > */ | |||
| /* > Then, R22 is considered to be negligible, and R12 is annihilated */ | |||
| /* > by unitary transformations from the right, arriving at the */ | |||
| /* > complete orthogonal factorization: */ | |||
| /* > A * P = Q * [ T11 0 ] * Z */ | |||
| /* > [ 0 0 ] */ | |||
| /* > The minimum-norm solution is then */ | |||
| /* > X = P * Z**H [ inv(T11)*Q1**H*B ] */ | |||
| /* > [ 0 ] */ | |||
| /* > where Q1 consists of the first RANK columns of Q. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of */ | |||
| /* > columns of matrices B and X. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, A has been overwritten by details of its */ | |||
| /* > complete orthogonal factorization. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the M-by-NRHS right hand side matrix B. */ | |||
| /* > On exit, the N-by-NRHS solution matrix X. */ | |||
| /* > If m >= n and RANK = n, the residual sum-of-squares for */ | |||
| /* > the solution in the i-th column is given by the sum of */ | |||
| /* > squares of elements N+1:M in that column. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,M,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] JPVT */ | |||
| /* > \verbatim */ | |||
| /* > JPVT is INTEGER array, dimension (N) */ | |||
| /* > On entry, if JPVT(i) .ne. 0, the i-th column of A is an */ | |||
| /* > initial column, otherwise it is a free column. Before */ | |||
| /* > the QR factorization of A, all initial columns are */ | |||
| /* > permuted to the leading positions; only the remaining */ | |||
| /* > free columns are moved as a result of column pivoting */ | |||
| /* > during the factorization. */ | |||
| /* > On exit, if JPVT(i) = k, then the i-th column of A*P */ | |||
| /* > was the k-th column of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] RCOND */ | |||
| /* > \verbatim */ | |||
| /* > RCOND is REAL */ | |||
| /* > RCOND is used to determine the effective rank of A, which */ | |||
| /* > is defined as the order of the largest leading triangular */ | |||
| /* > submatrix R11 in the QR factorization with pivoting of A, */ | |||
| /* > whose estimated condition number < 1/RCOND. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RANK */ | |||
| /* > \verbatim */ | |||
| /* > RANK is INTEGER */ | |||
| /* > The effective rank of A, i.e., the order of the submatrix */ | |||
| /* > R11. This is the same as the order of the submatrix T11 */ | |||
| /* > in the complete orthogonal factorization of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension */ | |||
| /* > (f2cmin(M,N) + f2cmax( N, 2*f2cmin(M,N)+NRHS )), */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEsolve */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelsx_(integer *m, integer *n, integer *nrhs, complex * | |||
| a, integer *lda, complex *b, integer *ldb, integer *jpvt, real *rcond, | |||
| integer *rank, complex *work, real *rwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| real anrm, bnrm, smin, smax; | |||
| integer i__, j, k, iascl, ibscl, ismin, ismax; | |||
| complex c1, c2; | |||
| extern /* Subroutine */ int ctrsm_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *), claic1_(integer *, | |||
| integer *, complex *, real *, complex *, complex *, real *, | |||
| complex *, complex *); | |||
| complex s1, s2, t1, t2; | |||
| extern /* Subroutine */ int cunm2r_(char *, char *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, complex *, integer *, | |||
| complex *, integer *), slabad_(real *, real *); | |||
| extern real clange_(char *, integer *, integer *, complex *, integer *, | |||
| real *); | |||
| integer mn; | |||
| extern /* Subroutine */ int clascl_(char *, integer *, integer *, real *, | |||
| real *, integer *, integer *, complex *, integer *, integer *), cgeqpf_(integer *, integer *, complex *, integer *, | |||
| integer *, complex *, complex *, real *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int claset_(char *, integer *, integer *, complex | |||
| *, complex *, complex *, integer *), xerbla_(char *, | |||
| integer *); | |||
| real bignum; | |||
| extern /* Subroutine */ int clatzm_(char *, integer *, integer *, complex | |||
| *, integer *, complex *, complex *, complex *, integer *, complex | |||
| *); | |||
| real sminpr; | |||
| extern /* Subroutine */ int ctzrqf_(integer *, integer *, complex *, | |||
| integer *, complex *, integer *); | |||
| real smaxpr, smlnum; | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| --jpvt; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| mn = f2cmin(*m,*n); | |||
| ismin = mn + 1; | |||
| ismax = (mn << 1) + 1; | |||
| /* Test the input arguments. */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*nrhs < 0) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -5; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(1,*m); | |||
| if (*ldb < f2cmax(i__1,*n)) { | |||
| *info = -7; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELSX", &i__1); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*nrhs) == 0) { | |||
| *rank = 0; | |||
| return 0; | |||
| } | |||
| /* Get machine parameters */ | |||
| smlnum = slamch_("S") / slamch_("P"); | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| /* Scale A, B if f2cmax elements outside range [SMLNUM,BIGNUM] */ | |||
| anrm = clange_("M", m, n, &a[a_offset], lda, &rwork[1]); | |||
| iascl = 0; | |||
| if (anrm > 0.f && anrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| clascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 1; | |||
| } else if (anrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| clascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 2; | |||
| } else if (anrm == 0.f) { | |||
| /* Matrix all zero. Return zero solution. */ | |||
| i__1 = f2cmax(*m,*n); | |||
| claset_("F", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| *rank = 0; | |||
| goto L100; | |||
| } | |||
| bnrm = clange_("M", m, nrhs, &b[b_offset], ldb, &rwork[1]); | |||
| ibscl = 0; | |||
| if (bnrm > 0.f && bnrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| clascl_("G", &c__0, &c__0, &bnrm, &smlnum, m, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| ibscl = 1; | |||
| } else if (bnrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| clascl_("G", &c__0, &c__0, &bnrm, &bignum, m, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| ibscl = 2; | |||
| } | |||
| /* Compute QR factorization with column pivoting of A: */ | |||
| /* A * P = Q * R */ | |||
| cgeqpf_(m, n, &a[a_offset], lda, &jpvt[1], &work[1], &work[mn + 1], & | |||
| rwork[1], info); | |||
| /* complex workspace MN+N. Real workspace 2*N. Details of Householder */ | |||
| /* rotations stored in WORK(1:MN). */ | |||
| /* Determine RANK using incremental condition estimation */ | |||
| i__1 = ismin; | |||
| work[i__1].r = 1.f, work[i__1].i = 0.f; | |||
| i__1 = ismax; | |||
| work[i__1].r = 1.f, work[i__1].i = 0.f; | |||
| smax = c_abs(&a[a_dim1 + 1]); | |||
| smin = smax; | |||
| if (c_abs(&a[a_dim1 + 1]) == 0.f) { | |||
| *rank = 0; | |||
| i__1 = f2cmax(*m,*n); | |||
| claset_("F", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| goto L100; | |||
| } else { | |||
| *rank = 1; | |||
| } | |||
| L10: | |||
| if (*rank < mn) { | |||
| i__ = *rank + 1; | |||
| claic1_(&c__2, rank, &work[ismin], &smin, &a[i__ * a_dim1 + 1], &a[ | |||
| i__ + i__ * a_dim1], &sminpr, &s1, &c1); | |||
| claic1_(&c__1, rank, &work[ismax], &smax, &a[i__ * a_dim1 + 1], &a[ | |||
| i__ + i__ * a_dim1], &smaxpr, &s2, &c2); | |||
| if (smaxpr * *rcond <= sminpr) { | |||
| i__1 = *rank; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = ismin + i__ - 1; | |||
| i__3 = ismin + i__ - 1; | |||
| q__1.r = s1.r * work[i__3].r - s1.i * work[i__3].i, q__1.i = | |||
| s1.r * work[i__3].i + s1.i * work[i__3].r; | |||
| work[i__2].r = q__1.r, work[i__2].i = q__1.i; | |||
| i__2 = ismax + i__ - 1; | |||
| i__3 = ismax + i__ - 1; | |||
| q__1.r = s2.r * work[i__3].r - s2.i * work[i__3].i, q__1.i = | |||
| s2.r * work[i__3].i + s2.i * work[i__3].r; | |||
| work[i__2].r = q__1.r, work[i__2].i = q__1.i; | |||
| /* L20: */ | |||
| } | |||
| i__1 = ismin + *rank; | |||
| work[i__1].r = c1.r, work[i__1].i = c1.i; | |||
| i__1 = ismax + *rank; | |||
| work[i__1].r = c2.r, work[i__1].i = c2.i; | |||
| smin = sminpr; | |||
| smax = smaxpr; | |||
| ++(*rank); | |||
| goto L10; | |||
| } | |||
| } | |||
| /* Logically partition R = [ R11 R12 ] */ | |||
| /* [ 0 R22 ] */ | |||
| /* where R11 = R(1:RANK,1:RANK) */ | |||
| /* [R11,R12] = [ T11, 0 ] * Y */ | |||
| if (*rank < *n) { | |||
| ctzrqf_(rank, n, &a[a_offset], lda, &work[mn + 1], info); | |||
| } | |||
| /* Details of Householder rotations stored in WORK(MN+1:2*MN) */ | |||
| /* B(1:M,1:NRHS) := Q**H * B(1:M,1:NRHS) */ | |||
| cunm2r_("Left", "Conjugate transpose", m, nrhs, &mn, &a[a_offset], lda, & | |||
| work[1], &b[b_offset], ldb, &work[(mn << 1) + 1], info); | |||
| /* workspace NRHS */ | |||
| /* B(1:RANK,1:NRHS) := inv(T11) * B(1:RANK,1:NRHS) */ | |||
| ctrsm_("Left", "Upper", "No transpose", "Non-unit", rank, nrhs, &c_b2, &a[ | |||
| a_offset], lda, &b[b_offset], ldb); | |||
| i__1 = *n; | |||
| for (i__ = *rank + 1; i__ <= i__1; ++i__) { | |||
| i__2 = *nrhs; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = 0.f, b[i__3].i = 0.f; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| /* B(1:N,1:NRHS) := Y**H * B(1:N,1:NRHS) */ | |||
| if (*rank < *n) { | |||
| i__1 = *rank; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = *n - *rank + 1; | |||
| r_cnjg(&q__1, &work[mn + i__]); | |||
| clatzm_("Left", &i__2, nrhs, &a[i__ + (*rank + 1) * a_dim1], lda, | |||
| &q__1, &b[i__ + b_dim1], &b[*rank + 1 + b_dim1], ldb, & | |||
| work[(mn << 1) + 1]); | |||
| /* L50: */ | |||
| } | |||
| } | |||
| /* workspace NRHS */ | |||
| /* B(1:N,1:NRHS) := P * B(1:N,1:NRHS) */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = (mn << 1) + i__; | |||
| work[i__3].r = 1.f, work[i__3].i = 0.f; | |||
| /* L60: */ | |||
| } | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = (mn << 1) + i__; | |||
| if (work[i__3].r == 1.f && work[i__3].i == 0.f) { | |||
| if (jpvt[i__] != i__) { | |||
| k = i__; | |||
| i__3 = k + j * b_dim1; | |||
| t1.r = b[i__3].r, t1.i = b[i__3].i; | |||
| i__3 = jpvt[k] + j * b_dim1; | |||
| t2.r = b[i__3].r, t2.i = b[i__3].i; | |||
| L70: | |||
| i__3 = jpvt[k] + j * b_dim1; | |||
| b[i__3].r = t1.r, b[i__3].i = t1.i; | |||
| i__3 = (mn << 1) + k; | |||
| work[i__3].r = 0.f, work[i__3].i = 0.f; | |||
| t1.r = t2.r, t1.i = t2.i; | |||
| k = jpvt[k]; | |||
| i__3 = jpvt[k] + j * b_dim1; | |||
| t2.r = b[i__3].r, t2.i = b[i__3].i; | |||
| if (jpvt[k] != i__) { | |||
| goto L70; | |||
| } | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = t1.r, b[i__3].i = t1.i; | |||
| i__3 = (mn << 1) + k; | |||
| work[i__3].r = 0.f, work[i__3].i = 0.f; | |||
| } | |||
| } | |||
| /* L80: */ | |||
| } | |||
| /* L90: */ | |||
| } | |||
| /* Undo scaling */ | |||
| if (iascl == 1) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &smlnum, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| clascl_("U", &c__0, &c__0, &smlnum, &anrm, rank, rank, &a[a_offset], | |||
| lda, info); | |||
| } else if (iascl == 2) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &bignum, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| clascl_("U", &c__0, &c__0, &bignum, &anrm, rank, rank, &a[a_offset], | |||
| lda, info); | |||
| } | |||
| if (ibscl == 1) { | |||
| clascl_("G", &c__0, &c__0, &smlnum, &bnrm, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| } else if (ibscl == 2) { | |||
| clascl_("G", &c__0, &c__0, &bignum, &bnrm, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| } | |||
| L100: | |||
| return 0; | |||
| /* End of CGELSX */ | |||
| } /* cgelsx_ */ | |||
| @@ -0,0 +1,764 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGEQPF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQPF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqpf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqpf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqpf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQPF( M, N, A, LDA, JPVT, TAU, WORK, RWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine CGEQP3. */ | |||
| /* > */ | |||
| /* > CGEQPF computes a QR factorization with column pivoting of a */ | |||
| /* > complex M-by-N matrix A: A*P = Q*R. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the upper triangle of the array contains the */ | |||
| /* > f2cmin(M,N)-by-N upper triangular matrix R; the elements */ | |||
| /* > below the diagonal, together with the array TAU, */ | |||
| /* > represent the unitary matrix Q as a product of */ | |||
| /* > f2cmin(m,n) elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] JPVT */ | |||
| /* > \verbatim */ | |||
| /* > JPVT is INTEGER array, dimension (N) */ | |||
| /* > On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted */ | |||
| /* > to the front of A*P (a leading column); if JPVT(i) = 0, */ | |||
| /* > the i-th column of A is a free column. */ | |||
| /* > On exit, if JPVT(i) = k, then the i-th column of A*P */ | |||
| /* > was the k-th column of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(n) */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a complex vector with */ | |||
| /* > v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i). */ | |||
| /* > */ | |||
| /* > The matrix P is represented in jpvt as follows: If */ | |||
| /* > jpvt(j) = i */ | |||
| /* > then the jth column of P is the ith canonical unit vector. */ | |||
| /* > */ | |||
| /* > Partial column norm updating strategy modified by */ | |||
| /* > Z. Drmac and Z. Bujanovic, Dept. of Mathematics, */ | |||
| /* > University of Zagreb, Croatia. */ | |||
| /* > -- April 2011 -- */ | |||
| /* > For more details see LAPACK Working Note 176. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqpf_(integer *m, integer *n, complex *a, integer *lda, | |||
| integer *jpvt, complex *tau, complex *work, real *rwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| real r__1, r__2; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| real temp, temp2; | |||
| integer i__, j; | |||
| real tol3z; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| cswap_(integer *, complex *, integer *, complex *, integer *); | |||
| integer itemp; | |||
| extern /* Subroutine */ int cgeqr2_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *); | |||
| extern real scnrm2_(integer *, complex *, integer *); | |||
| extern /* Subroutine */ int cunm2r_(char *, char *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, complex *, integer *, | |||
| complex *, integer *); | |||
| integer ma, mn; | |||
| extern /* Subroutine */ int clarfg_(integer *, complex *, complex *, | |||
| integer *, complex *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *); | |||
| extern integer isamax_(integer *, real *, integer *); | |||
| complex aii; | |||
| integer pvt; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --jpvt; | |||
| --tau; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQPF", &i__1); | |||
| return 0; | |||
| } | |||
| mn = f2cmin(*m,*n); | |||
| tol3z = sqrt(slamch_("Epsilon")); | |||
| /* Move initial columns up front */ | |||
| itemp = 1; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (jpvt[i__] != 0) { | |||
| if (i__ != itemp) { | |||
| cswap_(m, &a[i__ * a_dim1 + 1], &c__1, &a[itemp * a_dim1 + 1], | |||
| &c__1); | |||
| jpvt[i__] = jpvt[itemp]; | |||
| jpvt[itemp] = i__; | |||
| } else { | |||
| jpvt[i__] = i__; | |||
| } | |||
| ++itemp; | |||
| } else { | |||
| jpvt[i__] = i__; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| --itemp; | |||
| /* Compute the QR factorization and update remaining columns */ | |||
| if (itemp > 0) { | |||
| ma = f2cmin(itemp,*m); | |||
| cgeqr2_(m, &ma, &a[a_offset], lda, &tau[1], &work[1], info); | |||
| if (ma < *n) { | |||
| i__1 = *n - ma; | |||
| cunm2r_("Left", "Conjugate transpose", m, &i__1, &ma, &a[a_offset] | |||
| , lda, &tau[1], &a[(ma + 1) * a_dim1 + 1], lda, &work[1], | |||
| info); | |||
| } | |||
| } | |||
| if (itemp < mn) { | |||
| /* Initialize partial column norms. The first n elements of */ | |||
| /* work store the exact column norms. */ | |||
| i__1 = *n; | |||
| for (i__ = itemp + 1; i__ <= i__1; ++i__) { | |||
| i__2 = *m - itemp; | |||
| rwork[i__] = scnrm2_(&i__2, &a[itemp + 1 + i__ * a_dim1], &c__1); | |||
| rwork[*n + i__] = rwork[i__]; | |||
| /* L20: */ | |||
| } | |||
| /* Compute factorization */ | |||
| i__1 = mn; | |||
| for (i__ = itemp + 1; i__ <= i__1; ++i__) { | |||
| /* Determine ith pivot column and swap if necessary */ | |||
| i__2 = *n - i__ + 1; | |||
| pvt = i__ - 1 + isamax_(&i__2, &rwork[i__], &c__1); | |||
| if (pvt != i__) { | |||
| cswap_(m, &a[pvt * a_dim1 + 1], &c__1, &a[i__ * a_dim1 + 1], & | |||
| c__1); | |||
| itemp = jpvt[pvt]; | |||
| jpvt[pvt] = jpvt[i__]; | |||
| jpvt[i__] = itemp; | |||
| rwork[pvt] = rwork[i__]; | |||
| rwork[*n + pvt] = rwork[*n + i__]; | |||
| } | |||
| /* Generate elementary reflector H(i) */ | |||
| i__2 = i__ + i__ * a_dim1; | |||
| aii.r = a[i__2].r, aii.i = a[i__2].i; | |||
| i__2 = *m - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 1; | |||
| clarfg_(&i__2, &aii, &a[f2cmin(i__3,*m) + i__ * a_dim1], &c__1, &tau[ | |||
| i__]); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = aii.r, a[i__2].i = aii.i; | |||
| if (i__ < *n) { | |||
| /* Apply H(i) to A(i:m,i+1:n) from the left */ | |||
| i__2 = i__ + i__ * a_dim1; | |||
| aii.r = a[i__2].r, aii.i = a[i__2].i; | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| i__2 = *m - i__ + 1; | |||
| i__3 = *n - i__; | |||
| r_cnjg(&q__1, &tau[i__]); | |||
| clarf_("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, & | |||
| q__1, &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = aii.r, a[i__2].i = aii.i; | |||
| } | |||
| /* Update partial column norms */ | |||
| i__2 = *n; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| if (rwork[j] != 0.f) { | |||
| /* NOTE: The following 4 lines follow from the analysis in */ | |||
| /* Lapack Working Note 176. */ | |||
| temp = c_abs(&a[i__ + j * a_dim1]) / rwork[j]; | |||
| /* Computing MAX */ | |||
| r__1 = 0.f, r__2 = (temp + 1.f) * (1.f - temp); | |||
| temp = f2cmax(r__1,r__2); | |||
| /* Computing 2nd power */ | |||
| r__1 = rwork[j] / rwork[*n + j]; | |||
| temp2 = temp * (r__1 * r__1); | |||
| if (temp2 <= tol3z) { | |||
| if (*m - i__ > 0) { | |||
| i__3 = *m - i__; | |||
| rwork[j] = scnrm2_(&i__3, &a[i__ + 1 + j * a_dim1] | |||
| , &c__1); | |||
| rwork[*n + j] = rwork[j]; | |||
| } else { | |||
| rwork[j] = 0.f; | |||
| rwork[*n + j] = 0.f; | |||
| } | |||
| } else { | |||
| rwork[j] *= sqrt(temp); | |||
| } | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGEQPF */ | |||
| } /* cgeqpf_ */ | |||
| @@ -0,0 +1,910 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief <b> CGGSVD computes the singular value decomposition (SVD) for OTHER matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGGSVD + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cggsvd. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cggsvd. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cggsvd. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGGSVD( JOBU, JOBV, JOBQ, M, N, P, K, L, A, LDA, B, */ | |||
| /* LDB, ALPHA, BETA, U, LDU, V, LDV, Q, LDQ, WORK, */ | |||
| /* RWORK, IWORK, INFO ) */ | |||
| /* CHARACTER JOBQ, JOBU, JOBV */ | |||
| /* INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N, P */ | |||
| /* INTEGER IWORK( * ) */ | |||
| /* REAL ALPHA( * ), BETA( * ), RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), B( LDB, * ), Q( LDQ, * ), */ | |||
| /* $ U( LDU, * ), V( LDV, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine CGGSVD3. */ | |||
| /* > */ | |||
| /* > CGGSVD computes the generalized singular value decomposition (GSVD) */ | |||
| /* > of an M-by-N complex matrix A and P-by-N complex matrix B: */ | |||
| /* > */ | |||
| /* > U**H*A*Q = D1*( 0 R ), V**H*B*Q = D2*( 0 R ) */ | |||
| /* > */ | |||
| /* > where U, V and Q are unitary matrices. */ | |||
| /* > Let K+L = the effective numerical rank of the */ | |||
| /* > matrix (A**H,B**H)**H, then R is a (K+L)-by-(K+L) nonsingular upper */ | |||
| /* > triangular matrix, D1 and D2 are M-by-(K+L) and P-by-(K+L) "diagonal" */ | |||
| /* > matrices and of the following structures, respectively: */ | |||
| /* > */ | |||
| /* > If M-K-L >= 0, */ | |||
| /* > */ | |||
| /* > K L */ | |||
| /* > D1 = K ( I 0 ) */ | |||
| /* > L ( 0 C ) */ | |||
| /* > M-K-L ( 0 0 ) */ | |||
| /* > */ | |||
| /* > K L */ | |||
| /* > D2 = L ( 0 S ) */ | |||
| /* > P-L ( 0 0 ) */ | |||
| /* > */ | |||
| /* > N-K-L K L */ | |||
| /* > ( 0 R ) = K ( 0 R11 R12 ) */ | |||
| /* > L ( 0 0 R22 ) */ | |||
| /* > */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > C = diag( ALPHA(K+1), ... , ALPHA(K+L) ), */ | |||
| /* > S = diag( BETA(K+1), ... , BETA(K+L) ), */ | |||
| /* > C**2 + S**2 = I. */ | |||
| /* > */ | |||
| /* > R is stored in A(1:K+L,N-K-L+1:N) on exit. */ | |||
| /* > */ | |||
| /* > If M-K-L < 0, */ | |||
| /* > */ | |||
| /* > K M-K K+L-M */ | |||
| /* > D1 = K ( I 0 0 ) */ | |||
| /* > M-K ( 0 C 0 ) */ | |||
| /* > */ | |||
| /* > K M-K K+L-M */ | |||
| /* > D2 = M-K ( 0 S 0 ) */ | |||
| /* > K+L-M ( 0 0 I ) */ | |||
| /* > P-L ( 0 0 0 ) */ | |||
| /* > */ | |||
| /* > N-K-L K M-K K+L-M */ | |||
| /* > ( 0 R ) = K ( 0 R11 R12 R13 ) */ | |||
| /* > M-K ( 0 0 R22 R23 ) */ | |||
| /* > K+L-M ( 0 0 0 R33 ) */ | |||
| /* > */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > C = diag( ALPHA(K+1), ... , ALPHA(M) ), */ | |||
| /* > S = diag( BETA(K+1), ... , BETA(M) ), */ | |||
| /* > C**2 + S**2 = I. */ | |||
| /* > */ | |||
| /* > (R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N), and R33 is stored */ | |||
| /* > ( 0 R22 R23 ) */ | |||
| /* > in B(M-K+1:L,N+M-K-L+1:N) on exit. */ | |||
| /* > */ | |||
| /* > The routine computes C, S, R, and optionally the unitary */ | |||
| /* > transformation matrices U, V and Q. */ | |||
| /* > */ | |||
| /* > In particular, if B is an N-by-N nonsingular matrix, then the GSVD of */ | |||
| /* > A and B implicitly gives the SVD of A*inv(B): */ | |||
| /* > A*inv(B) = U*(D1*inv(D2))*V**H. */ | |||
| /* > If ( A**H,B**H)**H has orthnormal columns, then the GSVD of A and B is also */ | |||
| /* > equal to the CS decomposition of A and B. Furthermore, the GSVD can */ | |||
| /* > be used to derive the solution of the eigenvalue problem: */ | |||
| /* > A**H*A x = lambda* B**H*B x. */ | |||
| /* > In some literature, the GSVD of A and B is presented in the form */ | |||
| /* > U**H*A*X = ( 0 D1 ), V**H*B*X = ( 0 D2 ) */ | |||
| /* > where U and V are orthogonal and X is nonsingular, and D1 and D2 are */ | |||
| /* > ``diagonal''. The former GSVD form can be converted to the latter */ | |||
| /* > form by taking the nonsingular matrix X as */ | |||
| /* > */ | |||
| /* > X = Q*( I 0 ) */ | |||
| /* > ( 0 inv(R) ) */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOBU */ | |||
| /* > \verbatim */ | |||
| /* > JOBU is CHARACTER*1 */ | |||
| /* > = 'U': Unitary matrix U is computed; */ | |||
| /* > = 'N': U is not computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] JOBV */ | |||
| /* > \verbatim */ | |||
| /* > JOBV is CHARACTER*1 */ | |||
| /* > = 'V': Unitary matrix V is computed; */ | |||
| /* > = 'N': V is not computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] JOBQ */ | |||
| /* > \verbatim */ | |||
| /* > JOBQ is CHARACTER*1 */ | |||
| /* > = 'Q': Unitary matrix Q is computed; */ | |||
| /* > = 'N': Q is not computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrices A and B. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] P */ | |||
| /* > \verbatim */ | |||
| /* > P is INTEGER */ | |||
| /* > The number of rows of the matrix B. P >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] L */ | |||
| /* > \verbatim */ | |||
| /* > L is INTEGER */ | |||
| /* > */ | |||
| /* > On exit, K and L specify the dimension of the subblocks */ | |||
| /* > described in Purpose. */ | |||
| /* > K + L = effective numerical rank of (A**H,B**H)**H. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, A contains the triangular matrix R, or part of R. */ | |||
| /* > See Purpose for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,N) */ | |||
| /* > On entry, the P-by-N matrix B. */ | |||
| /* > On exit, B contains part of the triangular matrix R if */ | |||
| /* > M-K-L < 0. See Purpose for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,P). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ALPHA */ | |||
| /* > \verbatim */ | |||
| /* > ALPHA is REAL array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] BETA */ | |||
| /* > \verbatim */ | |||
| /* > BETA is REAL array, dimension (N) */ | |||
| /* > */ | |||
| /* > On exit, ALPHA and BETA contain the generalized singular */ | |||
| /* > value pairs of A and B; */ | |||
| /* > ALPHA(1:K) = 1, */ | |||
| /* > BETA(1:K) = 0, */ | |||
| /* > and if M-K-L >= 0, */ | |||
| /* > ALPHA(K+1:K+L) = C, */ | |||
| /* > BETA(K+1:K+L) = S, */ | |||
| /* > or if M-K-L < 0, */ | |||
| /* > ALPHA(K+1:M)=C, ALPHA(M+1:K+L)=0 */ | |||
| /* > BETA(K+1:M) =S, BETA(M+1:K+L) =1 */ | |||
| /* > and */ | |||
| /* > ALPHA(K+L+1:N) = 0 */ | |||
| /* > BETA(K+L+1:N) = 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] U */ | |||
| /* > \verbatim */ | |||
| /* > U is COMPLEX array, dimension (LDU,M) */ | |||
| /* > If JOBU = 'U', U contains the M-by-M unitary matrix U. */ | |||
| /* > If JOBU = 'N', U is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDU */ | |||
| /* > \verbatim */ | |||
| /* > LDU is INTEGER */ | |||
| /* > The leading dimension of the array U. LDU >= f2cmax(1,M) if */ | |||
| /* > JOBU = 'U'; LDU >= 1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX array, dimension (LDV,P) */ | |||
| /* > If JOBV = 'V', V contains the P-by-P unitary matrix V. */ | |||
| /* > If JOBV = 'N', V is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. LDV >= f2cmax(1,P) if */ | |||
| /* > JOBV = 'V'; LDV >= 1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] Q */ | |||
| /* > \verbatim */ | |||
| /* > Q is COMPLEX array, dimension (LDQ,N) */ | |||
| /* > If JOBQ = 'Q', Q contains the N-by-N unitary matrix Q. */ | |||
| /* > If JOBQ = 'N', Q is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDQ */ | |||
| /* > \verbatim */ | |||
| /* > LDQ is INTEGER */ | |||
| /* > The leading dimension of the array Q. LDQ >= f2cmax(1,N) if */ | |||
| /* > JOBQ = 'Q'; LDQ >= 1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (f2cmax(3*N,M,P)+N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] IWORK */ | |||
| /* > \verbatim */ | |||
| /* > IWORK is INTEGER array, dimension (N) */ | |||
| /* > On exit, IWORK stores the sorting information. More */ | |||
| /* > precisely, the following loop will sort ALPHA */ | |||
| /* > for I = K+1, f2cmin(M,K+L) */ | |||
| /* > swap ALPHA(I) and ALPHA(IWORK(I)) */ | |||
| /* > endfor */ | |||
| /* > such that ALPHA(1) >= ALPHA(2) >= ... >= ALPHA(N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit. */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > > 0: if INFO = 1, the Jacobi-type procedure failed to */ | |||
| /* > converge. For further details, see subroutine CTGSJA. */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > TOLA REAL */ | |||
| /* > TOLB REAL */ | |||
| /* > TOLA and TOLB are the thresholds to determine the effective */ | |||
| /* > rank of (A**H,B**H)**H. Generally, they are set to */ | |||
| /* > TOLA = MAX(M,N)*norm(A)*MACHEPS, */ | |||
| /* > TOLB = MAX(P,N)*norm(B)*MACHEPS. */ | |||
| /* > The size of TOLA and TOLB may affect the size of backward */ | |||
| /* > errors of the decomposition. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexOTHERsing */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > Ming Gu and Huan Ren, Computer Science Division, University of */ | |||
| /* > California at Berkeley, USA */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cggsvd_(char *jobu, char *jobv, char *jobq, integer *m, | |||
| integer *n, integer *p, integer *k, integer *l, complex *a, integer * | |||
| lda, complex *b, integer *ldb, real *alpha, real *beta, complex *u, | |||
| integer *ldu, complex *v, integer *ldv, complex *q, integer *ldq, | |||
| complex *work, real *rwork, integer *iwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, q_dim1, q_offset, u_dim1, | |||
| u_offset, v_dim1, v_offset, i__1, i__2; | |||
| /* Local variables */ | |||
| integer ibnd; | |||
| real tola; | |||
| integer isub; | |||
| real tolb, unfl, temp, smax; | |||
| integer ncallmycycle, i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| real anorm, bnorm; | |||
| logical wantq; | |||
| extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, | |||
| integer *); | |||
| logical wantu, wantv; | |||
| extern real clange_(char *, integer *, integer *, complex *, integer *, | |||
| real *), slamch_(char *); | |||
| extern /* Subroutine */ int ctgsja_(char *, char *, char *, integer *, | |||
| integer *, integer *, integer *, integer *, complex *, integer *, | |||
| complex *, integer *, real *, real *, real *, real *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *, complex *, | |||
| integer *, integer *), xerbla_(char *, | |||
| integer *), cggsvp_(char *, char *, char *, integer *, | |||
| integer *, integer *, complex *, integer *, complex *, integer *, | |||
| real *, real *, integer *, integer *, complex *, integer *, | |||
| complex *, integer *, complex *, integer *, integer *, real *, | |||
| complex *, complex *, integer *); | |||
| real ulp; | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Decode and test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| --alpha; | |||
| --beta; | |||
| u_dim1 = *ldu; | |||
| u_offset = 1 + u_dim1 * 1; | |||
| u -= u_offset; | |||
| v_dim1 = *ldv; | |||
| v_offset = 1 + v_dim1 * 1; | |||
| v -= v_offset; | |||
| q_dim1 = *ldq; | |||
| q_offset = 1 + q_dim1 * 1; | |||
| q -= q_offset; | |||
| --work; | |||
| --rwork; | |||
| --iwork; | |||
| /* Function Body */ | |||
| wantu = lsame_(jobu, "U"); | |||
| wantv = lsame_(jobv, "V"); | |||
| wantq = lsame_(jobq, "Q"); | |||
| *info = 0; | |||
| if (! (wantu || lsame_(jobu, "N"))) { | |||
| *info = -1; | |||
| } else if (! (wantv || lsame_(jobv, "N"))) { | |||
| *info = -2; | |||
| } else if (! (wantq || lsame_(jobq, "N"))) { | |||
| *info = -3; | |||
| } else if (*m < 0) { | |||
| *info = -4; | |||
| } else if (*n < 0) { | |||
| *info = -5; | |||
| } else if (*p < 0) { | |||
| *info = -6; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -10; | |||
| } else if (*ldb < f2cmax(1,*p)) { | |||
| *info = -12; | |||
| } else if (*ldu < 1 || wantu && *ldu < *m) { | |||
| *info = -16; | |||
| } else if (*ldv < 1 || wantv && *ldv < *p) { | |||
| *info = -18; | |||
| } else if (*ldq < 1 || wantq && *ldq < *n) { | |||
| *info = -20; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGGSVD", &i__1); | |||
| return 0; | |||
| } | |||
| /* Compute the Frobenius norm of matrices A and B */ | |||
| anorm = clange_("1", m, n, &a[a_offset], lda, &rwork[1]); | |||
| bnorm = clange_("1", p, n, &b[b_offset], ldb, &rwork[1]); | |||
| /* Get machine precision and set up threshold for determining */ | |||
| /* the effective numerical rank of the matrices A and B. */ | |||
| ulp = slamch_("Precision"); | |||
| unfl = slamch_("Safe Minimum"); | |||
| tola = f2cmax(*m,*n) * f2cmax(anorm,unfl) * ulp; | |||
| tolb = f2cmax(*p,*n) * f2cmax(bnorm,unfl) * ulp; | |||
| cggsvp_(jobu, jobv, jobq, m, p, n, &a[a_offset], lda, &b[b_offset], ldb, & | |||
| tola, &tolb, k, l, &u[u_offset], ldu, &v[v_offset], ldv, &q[ | |||
| q_offset], ldq, &iwork[1], &rwork[1], &work[1], &work[*n + 1], | |||
| info); | |||
| /* Compute the GSVD of two upper "triangular" matrices */ | |||
| ctgsja_(jobu, jobv, jobq, m, p, n, k, l, &a[a_offset], lda, &b[b_offset], | |||
| ldb, &tola, &tolb, &alpha[1], &beta[1], &u[u_offset], ldu, &v[ | |||
| v_offset], ldv, &q[q_offset], ldq, &work[1], &ncallmycycle, info); | |||
| /* Sort the singular values and store the pivot indices in IWORK */ | |||
| /* Copy ALPHA to RWORK, then sort ALPHA in RWORK */ | |||
| scopy_(n, &alpha[1], &c__1, &rwork[1], &c__1); | |||
| /* Computing MIN */ | |||
| i__1 = *l, i__2 = *m - *k; | |||
| ibnd = f2cmin(i__1,i__2); | |||
| i__1 = ibnd; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Scan for largest ALPHA(K+I) */ | |||
| isub = i__; | |||
| smax = rwork[*k + i__]; | |||
| i__2 = ibnd; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| temp = rwork[*k + j]; | |||
| if (temp > smax) { | |||
| isub = j; | |||
| smax = temp; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| if (isub != i__) { | |||
| rwork[*k + isub] = rwork[*k + i__]; | |||
| rwork[*k + i__] = smax; | |||
| iwork[*k + i__] = *k + isub; | |||
| } else { | |||
| iwork[*k + i__] = *k + i__; | |||
| } | |||
| /* L20: */ | |||
| } | |||
| return 0; | |||
| /* End of CGGSVD */ | |||
| } /* cggsvd_ */ | |||
| @@ -0,0 +1,755 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b1 = {0.f,0.f}; | |||
| static complex c_b2 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CLAHRD reduces the first nb columns of a general rectangular matrix A so that elements below th | |||
| e k-th subdiagonal are zero, and returns auxiliary matrices which are needed to apply the transformati | |||
| on to the unreduced part of A. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CLAHRD + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clahrd. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clahrd. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clahrd. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CLAHRD( N, K, NB, A, LDA, TAU, T, LDT, Y, LDY ) */ | |||
| /* INTEGER K, LDA, LDT, LDY, N, NB */ | |||
| /* COMPLEX A( LDA, * ), T( LDT, NB ), TAU( NB ), */ | |||
| /* $ Y( LDY, NB ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine CLAHR2. */ | |||
| /* > */ | |||
| /* > CLAHRD reduces the first NB columns of a complex general n-by-(n-k+1) */ | |||
| /* > matrix A so that elements below the k-th subdiagonal are zero. The */ | |||
| /* > reduction is performed by a unitary similarity transformation */ | |||
| /* > Q**H * A * Q. The routine returns the matrices V and T which determine */ | |||
| /* > Q as a block reflector I - V*T*V**H, and also the matrix Y = A * V * T. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The offset for the reduction. Elements below the k-th */ | |||
| /* > subdiagonal in the first NB columns are reduced to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The number of columns to be reduced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N-K+1) */ | |||
| /* > On entry, the n-by-(n-k+1) general matrix A. */ | |||
| /* > On exit, the elements on and above the k-th subdiagonal in */ | |||
| /* > the first NB columns are overwritten with the corresponding */ | |||
| /* > elements of the reduced matrix; the elements below the k-th */ | |||
| /* > subdiagonal, with the array TAU, represent the matrix Q as a */ | |||
| /* > product of elementary reflectors. The other columns of A are */ | |||
| /* > unchanged. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (NB) */ | |||
| /* > The scalar factors of the elementary reflectors. See Further */ | |||
| /* > Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX array, dimension (LDT,NB) */ | |||
| /* > The upper triangular matrix T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= NB. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] Y */ | |||
| /* > \verbatim */ | |||
| /* > Y is COMPLEX array, dimension (LDY,NB) */ | |||
| /* > The n-by-nb matrix Y. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDY */ | |||
| /* > \verbatim */ | |||
| /* > LDY is INTEGER */ | |||
| /* > The leading dimension of the array Y. LDY >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexOTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of nb elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(nb). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a complex vector with */ | |||
| /* > v(1:i+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in */ | |||
| /* > A(i+k+1:n,i), and tau in TAU(i). */ | |||
| /* > */ | |||
| /* > The elements of the vectors v together form the (n-k+1)-by-nb matrix */ | |||
| /* > V which is needed, with T and Y, to apply the transformation to the */ | |||
| /* > unreduced part of the matrix, using an update of the form: */ | |||
| /* > A := (I - V*T*V**H) * (A - Y*V**H). */ | |||
| /* > */ | |||
| /* > The contents of A on exit are illustrated by the following example */ | |||
| /* > with n = 7, k = 3 and nb = 2: */ | |||
| /* > */ | |||
| /* > ( a h a a a ) */ | |||
| /* > ( a h a a a ) */ | |||
| /* > ( a h a a a ) */ | |||
| /* > ( h h a a a ) */ | |||
| /* > ( v1 h a a a ) */ | |||
| /* > ( v1 v2 a a a ) */ | |||
| /* > ( v1 v2 a a a ) */ | |||
| /* > */ | |||
| /* > where a denotes an element of the original matrix A, h denotes a */ | |||
| /* > modified element of the upper Hessenberg matrix H, and vi denotes an */ | |||
| /* > element of the vector defining H(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int clahrd_(integer *n, integer *k, integer *nb, complex *a, | |||
| integer *lda, complex *tau, complex *t, integer *ldt, complex *y, | |||
| integer *ldy) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, y_dim1, y_offset, i__1, i__2, | |||
| i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__; | |||
| extern /* Subroutine */ int cscal_(integer *, complex *, complex *, | |||
| integer *), cgemv_(char *, integer *, integer *, complex *, | |||
| complex *, integer *, complex *, integer *, complex *, complex *, | |||
| integer *), ccopy_(integer *, complex *, integer *, | |||
| complex *, integer *), caxpy_(integer *, complex *, complex *, | |||
| integer *, complex *, integer *), ctrmv_(char *, char *, char *, | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| complex ei; | |||
| extern /* Subroutine */ int clarfg_(integer *, complex *, complex *, | |||
| integer *, complex *), clacgv_(integer *, complex *, integer *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| --tau; | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| y_dim1 = *ldy; | |||
| y_offset = 1 + y_dim1 * 1; | |||
| y -= y_offset; | |||
| /* Function Body */ | |||
| if (*n <= 1) { | |||
| return 0; | |||
| } | |||
| i__1 = *nb; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (i__ > 1) { | |||
| /* Update A(1:n,i) */ | |||
| /* Compute i-th column of A - Y * V**H */ | |||
| i__2 = i__ - 1; | |||
| clacgv_(&i__2, &a[*k + i__ - 1 + a_dim1], lda); | |||
| i__2 = i__ - 1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemv_("No transpose", n, &i__2, &q__1, &y[y_offset], ldy, &a[*k | |||
| + i__ - 1 + a_dim1], lda, &c_b2, &a[i__ * a_dim1 + 1], & | |||
| c__1); | |||
| i__2 = i__ - 1; | |||
| clacgv_(&i__2, &a[*k + i__ - 1 + a_dim1], lda); | |||
| /* Apply I - V * T**H * V**H to this column (call it b) from the */ | |||
| /* left, using the last column of T as workspace */ | |||
| /* Let V = ( V1 ) and b = ( b1 ) (first I-1 rows) */ | |||
| /* ( V2 ) ( b2 ) */ | |||
| /* where V1 is unit lower triangular */ | |||
| /* w := V1**H * b1 */ | |||
| i__2 = i__ - 1; | |||
| ccopy_(&i__2, &a[*k + 1 + i__ * a_dim1], &c__1, &t[*nb * t_dim1 + | |||
| 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| ctrmv_("Lower", "Conjugate transpose", "Unit", &i__2, &a[*k + 1 + | |||
| a_dim1], lda, &t[*nb * t_dim1 + 1], &c__1); | |||
| /* w := w + V2**H *b2 */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| cgemv_("Conjugate transpose", &i__2, &i__3, &c_b2, &a[*k + i__ + | |||
| a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b2, & | |||
| t[*nb * t_dim1 + 1], &c__1); | |||
| /* w := T**H *w */ | |||
| i__2 = i__ - 1; | |||
| ctrmv_("Upper", "Conjugate transpose", "Non-unit", &i__2, &t[ | |||
| t_offset], ldt, &t[*nb * t_dim1 + 1], &c__1); | |||
| /* b2 := b2 - V2*w */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemv_("No transpose", &i__2, &i__3, &q__1, &a[*k + i__ + a_dim1], | |||
| lda, &t[*nb * t_dim1 + 1], &c__1, &c_b2, &a[*k + i__ + | |||
| i__ * a_dim1], &c__1); | |||
| /* b1 := b1 - V1*w */ | |||
| i__2 = i__ - 1; | |||
| ctrmv_("Lower", "No transpose", "Unit", &i__2, &a[*k + 1 + a_dim1] | |||
| , lda, &t[*nb * t_dim1 + 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| caxpy_(&i__2, &q__1, &t[*nb * t_dim1 + 1], &c__1, &a[*k + 1 + i__ | |||
| * a_dim1], &c__1); | |||
| i__2 = *k + i__ - 1 + (i__ - 1) * a_dim1; | |||
| a[i__2].r = ei.r, a[i__2].i = ei.i; | |||
| } | |||
| /* Generate the elementary reflector H(i) to annihilate */ | |||
| /* A(k+i+1:n,i) */ | |||
| i__2 = *k + i__ + i__ * a_dim1; | |||
| ei.r = a[i__2].r, ei.i = a[i__2].i; | |||
| i__2 = *n - *k - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = *k + i__ + 1; | |||
| clarfg_(&i__2, &ei, &a[f2cmin(i__3,*n) + i__ * a_dim1], &c__1, &tau[i__]) | |||
| ; | |||
| i__2 = *k + i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* Compute Y(1:n,i) */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| cgemv_("No transpose", n, &i__2, &c_b2, &a[(i__ + 1) * a_dim1 + 1], | |||
| lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b1, &y[i__ * | |||
| y_dim1 + 1], &c__1); | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| cgemv_("Conjugate transpose", &i__2, &i__3, &c_b2, &a[*k + i__ + | |||
| a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b1, &t[ | |||
| i__ * t_dim1 + 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemv_("No transpose", n, &i__2, &q__1, &y[y_offset], ldy, &t[i__ * | |||
| t_dim1 + 1], &c__1, &c_b2, &y[i__ * y_dim1 + 1], &c__1); | |||
| cscal_(n, &tau[i__], &y[i__ * y_dim1 + 1], &c__1); | |||
| /* Compute T(1:i,i) */ | |||
| i__2 = i__ - 1; | |||
| i__3 = i__; | |||
| q__1.r = -tau[i__3].r, q__1.i = -tau[i__3].i; | |||
| cscal_(&i__2, &q__1, &t[i__ * t_dim1 + 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| ctrmv_("Upper", "No transpose", "Non-unit", &i__2, &t[t_offset], ldt, | |||
| &t[i__ * t_dim1 + 1], &c__1) | |||
| ; | |||
| i__2 = i__ + i__ * t_dim1; | |||
| i__3 = i__; | |||
| t[i__2].r = tau[i__3].r, t[i__2].i = tau[i__3].i; | |||
| /* L10: */ | |||
| } | |||
| i__1 = *k + *nb + *nb * a_dim1; | |||
| a[i__1].r = ei.r, a[i__1].i = ei.i; | |||
| return 0; | |||
| /* End of CLAHRD */ | |||
| } /* clahrd_ */ | |||
| @@ -0,0 +1,650 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CLATZM */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CLATZM + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clatzm. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clatzm. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clatzm. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CLATZM( SIDE, M, N, V, INCV, TAU, C1, C2, LDC, WORK ) */ | |||
| /* CHARACTER SIDE */ | |||
| /* INTEGER INCV, LDC, M, N */ | |||
| /* COMPLEX TAU */ | |||
| /* COMPLEX C1( LDC, * ), C2( LDC, * ), V( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine CUNMRZ. */ | |||
| /* > */ | |||
| /* > CLATZM applies a Householder matrix generated by CTZRQF to a matrix. */ | |||
| /* > */ | |||
| /* > Let P = I - tau*u*u**H, u = ( 1 ), */ | |||
| /* > ( v ) */ | |||
| /* > where v is an (m-1) vector if SIDE = 'L', or a (n-1) vector if */ | |||
| /* > SIDE = 'R'. */ | |||
| /* > */ | |||
| /* > If SIDE equals 'L', let */ | |||
| /* > C = [ C1 ] 1 */ | |||
| /* > [ C2 ] m-1 */ | |||
| /* > n */ | |||
| /* > Then C is overwritten by P*C. */ | |||
| /* > */ | |||
| /* > If SIDE equals 'R', let */ | |||
| /* > C = [ C1, C2 ] m */ | |||
| /* > 1 n-1 */ | |||
| /* > Then C is overwritten by C*P. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': form P * C */ | |||
| /* > = 'R': form C * P */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX array, dimension */ | |||
| /* > (1 + (M-1)*abs(INCV)) if SIDE = 'L' */ | |||
| /* > (1 + (N-1)*abs(INCV)) if SIDE = 'R' */ | |||
| /* > The vector v in the representation of P. V is not used */ | |||
| /* > if TAU = 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCV */ | |||
| /* > \verbatim */ | |||
| /* > INCV is INTEGER */ | |||
| /* > The increment between elements of v. INCV <> 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX */ | |||
| /* > The value tau in the representation of P. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C1 */ | |||
| /* > \verbatim */ | |||
| /* > C1 is COMPLEX array, dimension */ | |||
| /* > (LDC,N) if SIDE = 'L' */ | |||
| /* > (M,1) if SIDE = 'R' */ | |||
| /* > On entry, the n-vector C1 if SIDE = 'L', or the m-vector C1 */ | |||
| /* > if SIDE = 'R'. */ | |||
| /* > */ | |||
| /* > On exit, the first row of P*C if SIDE = 'L', or the first */ | |||
| /* > column of C*P if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C2 */ | |||
| /* > \verbatim */ | |||
| /* > C2 is COMPLEX array, dimension */ | |||
| /* > (LDC, N) if SIDE = 'L' */ | |||
| /* > (LDC, N-1) if SIDE = 'R' */ | |||
| /* > On entry, the (m - 1) x n matrix C2 if SIDE = 'L', or the */ | |||
| /* > m x (n - 1) matrix C2 if SIDE = 'R'. */ | |||
| /* > */ | |||
| /* > On exit, rows 2:m of P*C if SIDE = 'L', or columns 2:m of C*P */ | |||
| /* > if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the arrays C1 and C2. */ | |||
| /* > LDC >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension */ | |||
| /* > (N) if SIDE = 'L' */ | |||
| /* > (M) if SIDE = 'R' */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexOTHERcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int clatzm_(char *side, integer *m, integer *n, complex *v, | |||
| integer *incv, complex *tau, complex *c1, complex *c2, integer *ldc, | |||
| complex *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer c1_dim1, c1_offset, c2_dim1, c2_offset, i__1; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int cgerc_(integer *, integer *, complex *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *), | |||
| cgemv_(char *, integer *, integer *, complex *, complex *, | |||
| integer *, complex *, integer *, complex *, complex *, integer *); | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int cgeru_(integer *, integer *, complex *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *), | |||
| ccopy_(integer *, complex *, integer *, complex *, integer *), | |||
| caxpy_(integer *, complex *, complex *, integer *, complex *, | |||
| integer *), clacgv_(integer *, complex *, integer *); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --v; | |||
| c2_dim1 = *ldc; | |||
| c2_offset = 1 + c2_dim1 * 1; | |||
| c2 -= c2_offset; | |||
| c1_dim1 = *ldc; | |||
| c1_offset = 1 + c1_dim1 * 1; | |||
| c1 -= c1_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (f2cmin(*m,*n) == 0 || tau->r == 0.f && tau->i == 0.f) { | |||
| return 0; | |||
| } | |||
| if (lsame_(side, "L")) { | |||
| /* w := ( C1 + v**H * C2 )**H */ | |||
| ccopy_(n, &c1[c1_offset], ldc, &work[1], &c__1); | |||
| clacgv_(n, &work[1], &c__1); | |||
| i__1 = *m - 1; | |||
| cgemv_("Conjugate transpose", &i__1, n, &c_b1, &c2[c2_offset], ldc, & | |||
| v[1], incv, &c_b1, &work[1], &c__1); | |||
| /* [ C1 ] := [ C1 ] - tau* [ 1 ] * w**H */ | |||
| /* [ C2 ] [ C2 ] [ v ] */ | |||
| clacgv_(n, &work[1], &c__1); | |||
| q__1.r = -tau->r, q__1.i = -tau->i; | |||
| caxpy_(n, &q__1, &work[1], &c__1, &c1[c1_offset], ldc); | |||
| i__1 = *m - 1; | |||
| q__1.r = -tau->r, q__1.i = -tau->i; | |||
| cgeru_(&i__1, n, &q__1, &v[1], incv, &work[1], &c__1, &c2[c2_offset], | |||
| ldc); | |||
| } else if (lsame_(side, "R")) { | |||
| /* w := C1 + C2 * v */ | |||
| ccopy_(m, &c1[c1_offset], &c__1, &work[1], &c__1); | |||
| i__1 = *n - 1; | |||
| cgemv_("No transpose", m, &i__1, &c_b1, &c2[c2_offset], ldc, &v[1], | |||
| incv, &c_b1, &work[1], &c__1); | |||
| /* [ C1, C2 ] := [ C1, C2 ] - tau* w * [ 1 , v**H] */ | |||
| q__1.r = -tau->r, q__1.i = -tau->i; | |||
| caxpy_(m, &q__1, &work[1], &c__1, &c1[c1_offset], &c__1); | |||
| i__1 = *n - 1; | |||
| q__1.r = -tau->r, q__1.i = -tau->i; | |||
| cgerc_(m, &i__1, &q__1, &work[1], &c__1, &v[1], incv, &c2[c2_offset], | |||
| ldc); | |||
| } | |||
| return 0; | |||
| /* End of CLATZM */ | |||
| } /* clatzm_ */ | |||
| @@ -0,0 +1,682 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CTZRQF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CTZRQF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctzrqf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctzrqf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctzrqf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CTZRQF( M, N, A, LDA, TAU, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine CTZRZF. */ | |||
| /* > */ | |||
| /* > CTZRQF reduces the M-by-N ( M<=N ) complex upper trapezoidal matrix A */ | |||
| /* > to upper triangular form by means of unitary transformations. */ | |||
| /* > */ | |||
| /* > The upper trapezoidal matrix A is factored as */ | |||
| /* > */ | |||
| /* > A = ( R 0 ) * Z, */ | |||
| /* > */ | |||
| /* > where Z is an N-by-N unitary matrix and R is an M-by-M upper */ | |||
| /* > triangular matrix. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= M. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the leading M-by-N upper trapezoidal part of the */ | |||
| /* > array A must contain the matrix to be factorized. */ | |||
| /* > On exit, the leading M-by-M upper triangular part of A */ | |||
| /* > contains the upper triangular matrix R, and elements M+1 to */ | |||
| /* > N of the first M rows of A, with the array TAU, represent the */ | |||
| /* > unitary matrix Z as a product of M elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (M) */ | |||
| /* > The scalar factors of the elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexOTHERcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The factorization is obtained by Householder's method. The kth */ | |||
| /* > transformation matrix, Z( k ), whose conjugate transpose is used to */ | |||
| /* > introduce zeros into the (m - k + 1)th row of A, is given in the form */ | |||
| /* > */ | |||
| /* > Z( k ) = ( I 0 ), */ | |||
| /* > ( 0 T( k ) ) */ | |||
| /* > */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > T( k ) = I - tau*u( k )*u( k )**H, u( k ) = ( 1 ), */ | |||
| /* > ( 0 ) */ | |||
| /* > ( z( k ) ) */ | |||
| /* > */ | |||
| /* > tau is a scalar and z( k ) is an ( n - m ) element vector. */ | |||
| /* > tau and z( k ) are chosen to annihilate the elements of the kth row */ | |||
| /* > of X. */ | |||
| /* > */ | |||
| /* > The scalar tau is returned in the kth element of TAU and the vector */ | |||
| /* > u( k ) in the kth row of A, such that the elements of z( k ) are */ | |||
| /* > in a( k, m + 1 ), ..., a( k, n ). The elements of R are returned in */ | |||
| /* > the upper triangular part of A. */ | |||
| /* > */ | |||
| /* > Z is given by */ | |||
| /* > */ | |||
| /* > Z = Z( 1 ) * Z( 2 ) * ... * Z( m ). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int ctzrqf_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| complex q__1, q__2; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| extern /* Subroutine */ int cgerc_(integer *, integer *, complex *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *); | |||
| complex alpha; | |||
| extern /* Subroutine */ int cgemv_(char *, integer *, integer *, complex * | |||
| , complex *, integer *, complex *, integer *, complex *, complex * | |||
| , integer *), ccopy_(integer *, complex *, integer *, | |||
| complex *, integer *), caxpy_(integer *, complex *, complex *, | |||
| integer *, complex *, integer *); | |||
| integer m1; | |||
| extern /* Subroutine */ int clarfg_(integer *, complex *, complex *, | |||
| integer *, complex *), clacgv_(integer *, complex *, integer *), | |||
| xerbla_(char *, integer *); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < *m) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CTZRQF", &i__1); | |||
| return 0; | |||
| } | |||
| /* Perform the factorization. */ | |||
| if (*m == 0) { | |||
| return 0; | |||
| } | |||
| if (*m == *n) { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| tau[i__2].r = 0.f, tau[i__2].i = 0.f; | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| /* Computing MIN */ | |||
| i__1 = *m + 1; | |||
| m1 = f2cmin(i__1,*n); | |||
| for (k = *m; k >= 1; --k) { | |||
| /* Use a Householder reflection to zero the kth row of A. */ | |||
| /* First set up the reflection. */ | |||
| i__1 = k + k * a_dim1; | |||
| r_cnjg(&q__1, &a[k + k * a_dim1]); | |||
| a[i__1].r = q__1.r, a[i__1].i = q__1.i; | |||
| i__1 = *n - *m; | |||
| clacgv_(&i__1, &a[k + m1 * a_dim1], lda); | |||
| i__1 = k + k * a_dim1; | |||
| alpha.r = a[i__1].r, alpha.i = a[i__1].i; | |||
| i__1 = *n - *m + 1; | |||
| clarfg_(&i__1, &alpha, &a[k + m1 * a_dim1], lda, &tau[k]); | |||
| i__1 = k + k * a_dim1; | |||
| a[i__1].r = alpha.r, a[i__1].i = alpha.i; | |||
| i__1 = k; | |||
| r_cnjg(&q__1, &tau[k]); | |||
| tau[i__1].r = q__1.r, tau[i__1].i = q__1.i; | |||
| i__1 = k; | |||
| if ((tau[i__1].r != 0.f || tau[i__1].i != 0.f) && k > 1) { | |||
| /* We now perform the operation A := A*P( k )**H. */ | |||
| /* Use the first ( k - 1 ) elements of TAU to store a( k ), */ | |||
| /* where a( k ) consists of the first ( k - 1 ) elements of */ | |||
| /* the kth column of A. Also let B denote the first */ | |||
| /* ( k - 1 ) rows of the last ( n - m ) columns of A. */ | |||
| i__1 = k - 1; | |||
| ccopy_(&i__1, &a[k * a_dim1 + 1], &c__1, &tau[1], &c__1); | |||
| /* Form w = a( k ) + B*z( k ) in TAU. */ | |||
| i__1 = k - 1; | |||
| i__2 = *n - *m; | |||
| cgemv_("No transpose", &i__1, &i__2, &c_b1, &a[m1 * a_dim1 + | |||
| 1], lda, &a[k + m1 * a_dim1], lda, &c_b1, &tau[1], & | |||
| c__1); | |||
| /* Now form a( k ) := a( k ) - conjg(tau)*w */ | |||
| /* and B := B - conjg(tau)*w*z( k )**H. */ | |||
| i__1 = k - 1; | |||
| r_cnjg(&q__2, &tau[k]); | |||
| q__1.r = -q__2.r, q__1.i = -q__2.i; | |||
| caxpy_(&i__1, &q__1, &tau[1], &c__1, &a[k * a_dim1 + 1], & | |||
| c__1); | |||
| i__1 = k - 1; | |||
| i__2 = *n - *m; | |||
| r_cnjg(&q__2, &tau[k]); | |||
| q__1.r = -q__2.r, q__1.i = -q__2.i; | |||
| cgerc_(&i__1, &i__2, &q__1, &tau[1], &c__1, &a[k + m1 * | |||
| a_dim1], lda, &a[m1 * a_dim1 + 1], lda); | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CTZRQF */ | |||
| } /* ctzrqf_ */ | |||
| @@ -0,0 +1,898 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__0 = 0; | |||
| static doublereal c_b13 = 0.; | |||
| static integer c__2 = 2; | |||
| static integer c__1 = 1; | |||
| static doublereal c_b36 = 1.; | |||
| /* > \brief <b> DGELSX solves overdetermined or underdetermined systems for GE matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download DGELSX + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgelsx. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgelsx. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgelsx. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE DGELSX( M, N, NRHS, A, LDA, B, LDB, JPVT, RCOND, RANK, */ | |||
| /* WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LDB, M, N, NRHS, RANK */ | |||
| /* DOUBLE PRECISION RCOND */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* DOUBLE PRECISION A( LDA, * ), B( LDB, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine DGELSY. */ | |||
| /* > */ | |||
| /* > DGELSX computes the minimum-norm solution to a real linear least */ | |||
| /* > squares problem: */ | |||
| /* > minimize || A * X - B || */ | |||
| /* > using a complete orthogonal factorization of A. A is an M-by-N */ | |||
| /* > matrix which may be rank-deficient. */ | |||
| /* > */ | |||
| /* > Several right hand side vectors b and solution vectors x can be */ | |||
| /* > handled in a single call; they are stored as the columns of the */ | |||
| /* > M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ | |||
| /* > matrix X. */ | |||
| /* > */ | |||
| /* > The routine first computes a QR factorization with column pivoting: */ | |||
| /* > A * P = Q * [ R11 R12 ] */ | |||
| /* > [ 0 R22 ] */ | |||
| /* > with R11 defined as the largest leading submatrix whose estimated */ | |||
| /* > condition number is less than 1/RCOND. The order of R11, RANK, */ | |||
| /* > is the effective rank of A. */ | |||
| /* > */ | |||
| /* > Then, R22 is considered to be negligible, and R12 is annihilated */ | |||
| /* > by orthogonal transformations from the right, arriving at the */ | |||
| /* > complete orthogonal factorization: */ | |||
| /* > A * P = Q * [ T11 0 ] * Z */ | |||
| /* > [ 0 0 ] */ | |||
| /* > The minimum-norm solution is then */ | |||
| /* > X = P * Z**T [ inv(T11)*Q1**T*B ] */ | |||
| /* > [ 0 ] */ | |||
| /* > where Q1 consists of the first RANK columns of Q. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of */ | |||
| /* > columns of matrices B and X. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is DOUBLE PRECISION array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, A has been overwritten by details of its */ | |||
| /* > complete orthogonal factorization. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is DOUBLE PRECISION array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the M-by-NRHS right hand side matrix B. */ | |||
| /* > On exit, the N-by-NRHS solution matrix X. */ | |||
| /* > If m >= n and RANK = n, the residual sum-of-squares for */ | |||
| /* > the solution in the i-th column is given by the sum of */ | |||
| /* > squares of elements N+1:M in that column. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,M,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] JPVT */ | |||
| /* > \verbatim */ | |||
| /* > JPVT is INTEGER array, dimension (N) */ | |||
| /* > On entry, if JPVT(i) .ne. 0, the i-th column of A is an */ | |||
| /* > initial column, otherwise it is a free column. Before */ | |||
| /* > the QR factorization of A, all initial columns are */ | |||
| /* > permuted to the leading positions; only the remaining */ | |||
| /* > free columns are moved as a result of column pivoting */ | |||
| /* > during the factorization. */ | |||
| /* > On exit, if JPVT(i) = k, then the i-th column of A*P */ | |||
| /* > was the k-th column of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] RCOND */ | |||
| /* > \verbatim */ | |||
| /* > RCOND is DOUBLE PRECISION */ | |||
| /* > RCOND is used to determine the effective rank of A, which */ | |||
| /* > is defined as the order of the largest leading triangular */ | |||
| /* > submatrix R11 in the QR factorization with pivoting of A, */ | |||
| /* > whose estimated condition number < 1/RCOND. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RANK */ | |||
| /* > \verbatim */ | |||
| /* > RANK is INTEGER */ | |||
| /* > The effective rank of A, i.e., the order of the submatrix */ | |||
| /* > R11. This is the same as the order of the submatrix T11 */ | |||
| /* > in the complete orthogonal factorization of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension */ | |||
| /* > (f2cmax( f2cmin(M,N)+3*N, 2*f2cmin(M,N)+NRHS )), */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup doubleGEsolve */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int dgelsx_(integer *m, integer *n, integer *nrhs, | |||
| doublereal *a, integer *lda, doublereal *b, integer *ldb, integer * | |||
| jpvt, doublereal *rcond, integer *rank, doublereal *work, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2; | |||
| doublereal d__1; | |||
| /* Local variables */ | |||
| doublereal anrm, bnrm, smin, smax; | |||
| integer i__, j, k, iascl, ibscl, ismin, ismax; | |||
| doublereal c1, c2; | |||
| extern /* Subroutine */ int dtrsm_(char *, char *, char *, char *, | |||
| integer *, integer *, doublereal *, doublereal *, integer *, | |||
| doublereal *, integer *), dlaic1_( | |||
| integer *, integer *, doublereal *, doublereal *, doublereal *, | |||
| doublereal *, doublereal *, doublereal *, doublereal *); | |||
| doublereal s1, s2, t1, t2; | |||
| extern /* Subroutine */ int dorm2r_(char *, char *, integer *, integer *, | |||
| integer *, doublereal *, integer *, doublereal *, doublereal *, | |||
| integer *, doublereal *, integer *), dlabad_( | |||
| doublereal *, doublereal *); | |||
| extern doublereal dlamch_(char *), dlange_(char *, integer *, | |||
| integer *, doublereal *, integer *, doublereal *); | |||
| integer mn; | |||
| extern /* Subroutine */ int dlascl_(char *, integer *, integer *, | |||
| doublereal *, doublereal *, integer *, integer *, doublereal *, | |||
| integer *, integer *), dgeqpf_(integer *, integer *, | |||
| doublereal *, integer *, integer *, doublereal *, doublereal *, | |||
| integer *), dlaset_(char *, integer *, integer *, doublereal *, | |||
| doublereal *, doublereal *, integer *), xerbla_(char *, | |||
| integer *); | |||
| doublereal bignum; | |||
| extern /* Subroutine */ int dlatzm_(char *, integer *, integer *, | |||
| doublereal *, integer *, doublereal *, doublereal *, doublereal *, | |||
| integer *, doublereal *); | |||
| doublereal sminpr, smaxpr, smlnum; | |||
| extern /* Subroutine */ int dtzrqf_(integer *, integer *, doublereal *, | |||
| integer *, doublereal *, integer *); | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| --jpvt; | |||
| --work; | |||
| /* Function Body */ | |||
| mn = f2cmin(*m,*n); | |||
| ismin = mn + 1; | |||
| ismax = (mn << 1) + 1; | |||
| /* Test the input arguments. */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*nrhs < 0) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -5; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(1,*m); | |||
| if (*ldb < f2cmax(i__1,*n)) { | |||
| *info = -7; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("DGELSX", &i__1); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*nrhs) == 0) { | |||
| *rank = 0; | |||
| return 0; | |||
| } | |||
| /* Get machine parameters */ | |||
| smlnum = dlamch_("S") / dlamch_("P"); | |||
| bignum = 1. / smlnum; | |||
| dlabad_(&smlnum, &bignum); | |||
| /* Scale A, B if f2cmax elements outside range [SMLNUM,BIGNUM] */ | |||
| anrm = dlange_("M", m, n, &a[a_offset], lda, &work[1]); | |||
| iascl = 0; | |||
| if (anrm > 0. && anrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| dlascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 1; | |||
| } else if (anrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| dlascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 2; | |||
| } else if (anrm == 0.) { | |||
| /* Matrix all zero. Return zero solution. */ | |||
| i__1 = f2cmax(*m,*n); | |||
| dlaset_("F", &i__1, nrhs, &c_b13, &c_b13, &b[b_offset], ldb); | |||
| *rank = 0; | |||
| goto L100; | |||
| } | |||
| bnrm = dlange_("M", m, nrhs, &b[b_offset], ldb, &work[1]); | |||
| ibscl = 0; | |||
| if (bnrm > 0. && bnrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| dlascl_("G", &c__0, &c__0, &bnrm, &smlnum, m, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| ibscl = 1; | |||
| } else if (bnrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| dlascl_("G", &c__0, &c__0, &bnrm, &bignum, m, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| ibscl = 2; | |||
| } | |||
| /* Compute QR factorization with column pivoting of A: */ | |||
| /* A * P = Q * R */ | |||
| dgeqpf_(m, n, &a[a_offset], lda, &jpvt[1], &work[1], &work[mn + 1], info); | |||
| /* workspace 3*N. Details of Householder rotations stored */ | |||
| /* in WORK(1:MN). */ | |||
| /* Determine RANK using incremental condition estimation */ | |||
| work[ismin] = 1.; | |||
| work[ismax] = 1.; | |||
| smax = (d__1 = a[a_dim1 + 1], abs(d__1)); | |||
| smin = smax; | |||
| if ((d__1 = a[a_dim1 + 1], abs(d__1)) == 0.) { | |||
| *rank = 0; | |||
| i__1 = f2cmax(*m,*n); | |||
| dlaset_("F", &i__1, nrhs, &c_b13, &c_b13, &b[b_offset], ldb); | |||
| goto L100; | |||
| } else { | |||
| *rank = 1; | |||
| } | |||
| L10: | |||
| if (*rank < mn) { | |||
| i__ = *rank + 1; | |||
| dlaic1_(&c__2, rank, &work[ismin], &smin, &a[i__ * a_dim1 + 1], &a[ | |||
| i__ + i__ * a_dim1], &sminpr, &s1, &c1); | |||
| dlaic1_(&c__1, rank, &work[ismax], &smax, &a[i__ * a_dim1 + 1], &a[ | |||
| i__ + i__ * a_dim1], &smaxpr, &s2, &c2); | |||
| if (smaxpr * *rcond <= sminpr) { | |||
| i__1 = *rank; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[ismin + i__ - 1] = s1 * work[ismin + i__ - 1]; | |||
| work[ismax + i__ - 1] = s2 * work[ismax + i__ - 1]; | |||
| /* L20: */ | |||
| } | |||
| work[ismin + *rank] = c1; | |||
| work[ismax + *rank] = c2; | |||
| smin = sminpr; | |||
| smax = smaxpr; | |||
| ++(*rank); | |||
| goto L10; | |||
| } | |||
| } | |||
| /* Logically partition R = [ R11 R12 ] */ | |||
| /* [ 0 R22 ] */ | |||
| /* where R11 = R(1:RANK,1:RANK) */ | |||
| /* [R11,R12] = [ T11, 0 ] * Y */ | |||
| if (*rank < *n) { | |||
| dtzrqf_(rank, n, &a[a_offset], lda, &work[mn + 1], info); | |||
| } | |||
| /* Details of Householder rotations stored in WORK(MN+1:2*MN) */ | |||
| /* B(1:M,1:NRHS) := Q**T * B(1:M,1:NRHS) */ | |||
| dorm2r_("Left", "Transpose", m, nrhs, &mn, &a[a_offset], lda, &work[1], & | |||
| b[b_offset], ldb, &work[(mn << 1) + 1], info); | |||
| /* workspace NRHS */ | |||
| /* B(1:RANK,1:NRHS) := inv(T11) * B(1:RANK,1:NRHS) */ | |||
| dtrsm_("Left", "Upper", "No transpose", "Non-unit", rank, nrhs, &c_b36, & | |||
| a[a_offset], lda, &b[b_offset], ldb); | |||
| i__1 = *n; | |||
| for (i__ = *rank + 1; i__ <= i__1; ++i__) { | |||
| i__2 = *nrhs; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| b[i__ + j * b_dim1] = 0.; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| /* B(1:N,1:NRHS) := Y**T * B(1:N,1:NRHS) */ | |||
| if (*rank < *n) { | |||
| i__1 = *rank; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = *n - *rank + 1; | |||
| dlatzm_("Left", &i__2, nrhs, &a[i__ + (*rank + 1) * a_dim1], lda, | |||
| &work[mn + i__], &b[i__ + b_dim1], &b[*rank + 1 + b_dim1], | |||
| ldb, &work[(mn << 1) + 1]); | |||
| /* L50: */ | |||
| } | |||
| } | |||
| /* workspace NRHS */ | |||
| /* B(1:N,1:NRHS) := P * B(1:N,1:NRHS) */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| work[(mn << 1) + i__] = 1.; | |||
| /* L60: */ | |||
| } | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| if (work[(mn << 1) + i__] == 1.) { | |||
| if (jpvt[i__] != i__) { | |||
| k = i__; | |||
| t1 = b[k + j * b_dim1]; | |||
| t2 = b[jpvt[k] + j * b_dim1]; | |||
| L70: | |||
| b[jpvt[k] + j * b_dim1] = t1; | |||
| work[(mn << 1) + k] = 0.; | |||
| t1 = t2; | |||
| k = jpvt[k]; | |||
| t2 = b[jpvt[k] + j * b_dim1]; | |||
| if (jpvt[k] != i__) { | |||
| goto L70; | |||
| } | |||
| b[i__ + j * b_dim1] = t1; | |||
| work[(mn << 1) + k] = 0.; | |||
| } | |||
| } | |||
| /* L80: */ | |||
| } | |||
| /* L90: */ | |||
| } | |||
| /* Undo scaling */ | |||
| if (iascl == 1) { | |||
| dlascl_("G", &c__0, &c__0, &anrm, &smlnum, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| dlascl_("U", &c__0, &c__0, &smlnum, &anrm, rank, rank, &a[a_offset], | |||
| lda, info); | |||
| } else if (iascl == 2) { | |||
| dlascl_("G", &c__0, &c__0, &anrm, &bignum, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| dlascl_("U", &c__0, &c__0, &bignum, &anrm, rank, rank, &a[a_offset], | |||
| lda, info); | |||
| } | |||
| if (ibscl == 1) { | |||
| dlascl_("G", &c__0, &c__0, &smlnum, &bnrm, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| } else if (ibscl == 2) { | |||
| dlascl_("G", &c__0, &c__0, &bignum, &bnrm, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| } | |||
| L100: | |||
| return 0; | |||
| /* End of DGELSX */ | |||
| } /* dgelsx_ */ | |||
| @@ -0,0 +1,753 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b DGEQPF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download DGEQPF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgeqpf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgeqpf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgeqpf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE DGEQPF( M, N, A, LDA, JPVT, TAU, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine DGEQP3. */ | |||
| /* > */ | |||
| /* > DGEQPF computes a QR factorization with column pivoting of a */ | |||
| /* > real M-by-N matrix A: A*P = Q*R. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is DOUBLE PRECISION array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the upper triangle of the array contains the */ | |||
| /* > f2cmin(M,N)-by-N upper triangular matrix R; the elements */ | |||
| /* > below the diagonal, together with the array TAU, */ | |||
| /* > represent the orthogonal matrix Q as a product of */ | |||
| /* > f2cmin(m,n) elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] JPVT */ | |||
| /* > \verbatim */ | |||
| /* > JPVT is INTEGER array, dimension (N) */ | |||
| /* > On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted */ | |||
| /* > to the front of A*P (a leading column); if JPVT(i) = 0, */ | |||
| /* > the i-th column of A is a free column. */ | |||
| /* > On exit, if JPVT(i) = k, then the i-th column of A*P */ | |||
| /* > was the k-th column of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is DOUBLE PRECISION array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension (3*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup doubleGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(n) */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H = I - tau * v * v**T */ | |||
| /* > */ | |||
| /* > where tau is a real scalar, and v is a real vector with */ | |||
| /* > v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i). */ | |||
| /* > */ | |||
| /* > The matrix P is represented in jpvt as follows: If */ | |||
| /* > jpvt(j) = i */ | |||
| /* > then the jth column of P is the ith canonical unit vector. */ | |||
| /* > */ | |||
| /* > Partial column norm updating strategy modified by */ | |||
| /* > Z. Drmac and Z. Bujanovic, Dept. of Mathematics, */ | |||
| /* > University of Zagreb, Croatia. */ | |||
| /* > -- April 2011 -- */ | |||
| /* > For more details see LAPACK Working Note 176. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int dgeqpf_(integer *m, integer *n, doublereal *a, integer * | |||
| lda, integer *jpvt, doublereal *tau, doublereal *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| doublereal d__1, d__2; | |||
| /* Local variables */ | |||
| doublereal temp; | |||
| extern doublereal dnrm2_(integer *, doublereal *, integer *); | |||
| doublereal temp2; | |||
| integer i__, j; | |||
| doublereal tol3z; | |||
| extern /* Subroutine */ int dlarf_(char *, integer *, integer *, | |||
| doublereal *, integer *, doublereal *, doublereal *, integer *, | |||
| doublereal *); | |||
| integer itemp; | |||
| extern /* Subroutine */ int dswap_(integer *, doublereal *, integer *, | |||
| doublereal *, integer *), dgeqr2_(integer *, integer *, | |||
| doublereal *, integer *, doublereal *, doublereal *, integer *), | |||
| dorm2r_(char *, char *, integer *, integer *, integer *, | |||
| doublereal *, integer *, doublereal *, doublereal *, integer *, | |||
| doublereal *, integer *); | |||
| integer ma; | |||
| extern doublereal dlamch_(char *); | |||
| integer mn; | |||
| extern /* Subroutine */ int dlarfg_(integer *, doublereal *, doublereal *, | |||
| integer *, doublereal *); | |||
| extern integer idamax_(integer *, doublereal *, integer *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *); | |||
| doublereal aii; | |||
| integer pvt; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --jpvt; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("DGEQPF", &i__1); | |||
| return 0; | |||
| } | |||
| mn = f2cmin(*m,*n); | |||
| tol3z = sqrt(dlamch_("Epsilon")); | |||
| /* Move initial columns up front */ | |||
| itemp = 1; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (jpvt[i__] != 0) { | |||
| if (i__ != itemp) { | |||
| dswap_(m, &a[i__ * a_dim1 + 1], &c__1, &a[itemp * a_dim1 + 1], | |||
| &c__1); | |||
| jpvt[i__] = jpvt[itemp]; | |||
| jpvt[itemp] = i__; | |||
| } else { | |||
| jpvt[i__] = i__; | |||
| } | |||
| ++itemp; | |||
| } else { | |||
| jpvt[i__] = i__; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| --itemp; | |||
| /* Compute the QR factorization and update remaining columns */ | |||
| if (itemp > 0) { | |||
| ma = f2cmin(itemp,*m); | |||
| dgeqr2_(m, &ma, &a[a_offset], lda, &tau[1], &work[1], info); | |||
| if (ma < *n) { | |||
| i__1 = *n - ma; | |||
| dorm2r_("Left", "Transpose", m, &i__1, &ma, &a[a_offset], lda, & | |||
| tau[1], &a[(ma + 1) * a_dim1 + 1], lda, &work[1], info); | |||
| } | |||
| } | |||
| if (itemp < mn) { | |||
| /* Initialize partial column norms. The first n elements of */ | |||
| /* work store the exact column norms. */ | |||
| i__1 = *n; | |||
| for (i__ = itemp + 1; i__ <= i__1; ++i__) { | |||
| i__2 = *m - itemp; | |||
| work[i__] = dnrm2_(&i__2, &a[itemp + 1 + i__ * a_dim1], &c__1); | |||
| work[*n + i__] = work[i__]; | |||
| /* L20: */ | |||
| } | |||
| /* Compute factorization */ | |||
| i__1 = mn; | |||
| for (i__ = itemp + 1; i__ <= i__1; ++i__) { | |||
| /* Determine ith pivot column and swap if necessary */ | |||
| i__2 = *n - i__ + 1; | |||
| pvt = i__ - 1 + idamax_(&i__2, &work[i__], &c__1); | |||
| if (pvt != i__) { | |||
| dswap_(m, &a[pvt * a_dim1 + 1], &c__1, &a[i__ * a_dim1 + 1], & | |||
| c__1); | |||
| itemp = jpvt[pvt]; | |||
| jpvt[pvt] = jpvt[i__]; | |||
| jpvt[i__] = itemp; | |||
| work[pvt] = work[i__]; | |||
| work[*n + pvt] = work[*n + i__]; | |||
| } | |||
| /* Generate elementary reflector H(i) */ | |||
| if (i__ < *m) { | |||
| i__2 = *m - i__ + 1; | |||
| dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + 1 + i__ * | |||
| a_dim1], &c__1, &tau[i__]); | |||
| } else { | |||
| dlarfg_(&c__1, &a[*m + *m * a_dim1], &a[*m + *m * a_dim1], & | |||
| c__1, &tau[*m]); | |||
| } | |||
| if (i__ < *n) { | |||
| /* Apply H(i) to A(i:m,i+1:n) from the left */ | |||
| aii = a[i__ + i__ * a_dim1]; | |||
| a[i__ + i__ * a_dim1] = 1.; | |||
| i__2 = *m - i__ + 1; | |||
| i__3 = *n - i__; | |||
| dlarf_("LEFT", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, & | |||
| tau[i__], &a[i__ + (i__ + 1) * a_dim1], lda, &work[(* | |||
| n << 1) + 1]); | |||
| a[i__ + i__ * a_dim1] = aii; | |||
| } | |||
| /* Update partial column norms */ | |||
| i__2 = *n; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| if (work[j] != 0.) { | |||
| /* NOTE: The following 4 lines follow from the analysis in */ | |||
| /* Lapack Working Note 176. */ | |||
| temp = (d__1 = a[i__ + j * a_dim1], abs(d__1)) / work[j]; | |||
| /* Computing MAX */ | |||
| d__1 = 0., d__2 = (temp + 1.) * (1. - temp); | |||
| temp = f2cmax(d__1,d__2); | |||
| /* Computing 2nd power */ | |||
| d__1 = work[j] / work[*n + j]; | |||
| temp2 = temp * (d__1 * d__1); | |||
| if (temp2 <= tol3z) { | |||
| if (*m - i__ > 0) { | |||
| i__3 = *m - i__; | |||
| work[j] = dnrm2_(&i__3, &a[i__ + 1 + j * a_dim1], | |||
| &c__1); | |||
| work[*n + j] = work[j]; | |||
| } else { | |||
| work[j] = 0.; | |||
| work[*n + j] = 0.; | |||
| } | |||
| } else { | |||
| work[j] *= sqrt(temp); | |||
| } | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of DGEQPF */ | |||
| } /* dgeqpf_ */ | |||
| @@ -0,0 +1,906 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief <b> DGGSVD computes the singular value decomposition (SVD) for OTHER matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download DGGSVD + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dggsvd. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dggsvd. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dggsvd. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE DGGSVD( JOBU, JOBV, JOBQ, M, N, P, K, L, A, LDA, B, */ | |||
| /* LDB, ALPHA, BETA, U, LDU, V, LDV, Q, LDQ, WORK, */ | |||
| /* IWORK, INFO ) */ | |||
| /* CHARACTER JOBQ, JOBU, JOBV */ | |||
| /* INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N, P */ | |||
| /* INTEGER IWORK( * ) */ | |||
| /* DOUBLE PRECISION A( LDA, * ), ALPHA( * ), B( LDB, * ), */ | |||
| /* $ BETA( * ), Q( LDQ, * ), U( LDU, * ), */ | |||
| /* $ V( LDV, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine DGGSVD3. */ | |||
| /* > */ | |||
| /* > DGGSVD computes the generalized singular value decomposition (GSVD) */ | |||
| /* > of an M-by-N real matrix A and P-by-N real matrix B: */ | |||
| /* > */ | |||
| /* > U**T*A*Q = D1*( 0 R ), V**T*B*Q = D2*( 0 R ) */ | |||
| /* > */ | |||
| /* > where U, V and Q are orthogonal matrices. */ | |||
| /* > Let K+L = the effective numerical rank of the matrix (A**T,B**T)**T, */ | |||
| /* > then R is a K+L-by-K+L nonsingular upper triangular matrix, D1 and */ | |||
| /* > D2 are M-by-(K+L) and P-by-(K+L) "diagonal" matrices and of the */ | |||
| /* > following structures, respectively: */ | |||
| /* > */ | |||
| /* > If M-K-L >= 0, */ | |||
| /* > */ | |||
| /* > K L */ | |||
| /* > D1 = K ( I 0 ) */ | |||
| /* > L ( 0 C ) */ | |||
| /* > M-K-L ( 0 0 ) */ | |||
| /* > */ | |||
| /* > K L */ | |||
| /* > D2 = L ( 0 S ) */ | |||
| /* > P-L ( 0 0 ) */ | |||
| /* > */ | |||
| /* > N-K-L K L */ | |||
| /* > ( 0 R ) = K ( 0 R11 R12 ) */ | |||
| /* > L ( 0 0 R22 ) */ | |||
| /* > */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > C = diag( ALPHA(K+1), ... , ALPHA(K+L) ), */ | |||
| /* > S = diag( BETA(K+1), ... , BETA(K+L) ), */ | |||
| /* > C**2 + S**2 = I. */ | |||
| /* > */ | |||
| /* > R is stored in A(1:K+L,N-K-L+1:N) on exit. */ | |||
| /* > */ | |||
| /* > If M-K-L < 0, */ | |||
| /* > */ | |||
| /* > K M-K K+L-M */ | |||
| /* > D1 = K ( I 0 0 ) */ | |||
| /* > M-K ( 0 C 0 ) */ | |||
| /* > */ | |||
| /* > K M-K K+L-M */ | |||
| /* > D2 = M-K ( 0 S 0 ) */ | |||
| /* > K+L-M ( 0 0 I ) */ | |||
| /* > P-L ( 0 0 0 ) */ | |||
| /* > */ | |||
| /* > N-K-L K M-K K+L-M */ | |||
| /* > ( 0 R ) = K ( 0 R11 R12 R13 ) */ | |||
| /* > M-K ( 0 0 R22 R23 ) */ | |||
| /* > K+L-M ( 0 0 0 R33 ) */ | |||
| /* > */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > C = diag( ALPHA(K+1), ... , ALPHA(M) ), */ | |||
| /* > S = diag( BETA(K+1), ... , BETA(M) ), */ | |||
| /* > C**2 + S**2 = I. */ | |||
| /* > */ | |||
| /* > (R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N), and R33 is stored */ | |||
| /* > ( 0 R22 R23 ) */ | |||
| /* > in B(M-K+1:L,N+M-K-L+1:N) on exit. */ | |||
| /* > */ | |||
| /* > The routine computes C, S, R, and optionally the orthogonal */ | |||
| /* > transformation matrices U, V and Q. */ | |||
| /* > */ | |||
| /* > In particular, if B is an N-by-N nonsingular matrix, then the GSVD of */ | |||
| /* > A and B implicitly gives the SVD of A*inv(B): */ | |||
| /* > A*inv(B) = U*(D1*inv(D2))*V**T. */ | |||
| /* > If ( A**T,B**T)**T has orthonormal columns, then the GSVD of A and B is */ | |||
| /* > also equal to the CS decomposition of A and B. Furthermore, the GSVD */ | |||
| /* > can be used to derive the solution of the eigenvalue problem: */ | |||
| /* > A**T*A x = lambda* B**T*B x. */ | |||
| /* > In some literature, the GSVD of A and B is presented in the form */ | |||
| /* > U**T*A*X = ( 0 D1 ), V**T*B*X = ( 0 D2 ) */ | |||
| /* > where U and V are orthogonal and X is nonsingular, D1 and D2 are */ | |||
| /* > ``diagonal''. The former GSVD form can be converted to the latter */ | |||
| /* > form by taking the nonsingular matrix X as */ | |||
| /* > */ | |||
| /* > X = Q*( I 0 ) */ | |||
| /* > ( 0 inv(R) ). */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOBU */ | |||
| /* > \verbatim */ | |||
| /* > JOBU is CHARACTER*1 */ | |||
| /* > = 'U': Orthogonal matrix U is computed; */ | |||
| /* > = 'N': U is not computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] JOBV */ | |||
| /* > \verbatim */ | |||
| /* > JOBV is CHARACTER*1 */ | |||
| /* > = 'V': Orthogonal matrix V is computed; */ | |||
| /* > = 'N': V is not computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] JOBQ */ | |||
| /* > \verbatim */ | |||
| /* > JOBQ is CHARACTER*1 */ | |||
| /* > = 'Q': Orthogonal matrix Q is computed; */ | |||
| /* > = 'N': Q is not computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrices A and B. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] P */ | |||
| /* > \verbatim */ | |||
| /* > P is INTEGER */ | |||
| /* > The number of rows of the matrix B. P >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] L */ | |||
| /* > \verbatim */ | |||
| /* > L is INTEGER */ | |||
| /* > */ | |||
| /* > On exit, K and L specify the dimension of the subblocks */ | |||
| /* > described in Purpose. */ | |||
| /* > K + L = effective numerical rank of (A**T,B**T)**T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is DOUBLE PRECISION array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, A contains the triangular matrix R, or part of R. */ | |||
| /* > See Purpose for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is DOUBLE PRECISION array, dimension (LDB,N) */ | |||
| /* > On entry, the P-by-N matrix B. */ | |||
| /* > On exit, B contains the triangular matrix R if M-K-L < 0. */ | |||
| /* > See Purpose for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,P). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ALPHA */ | |||
| /* > \verbatim */ | |||
| /* > ALPHA is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] BETA */ | |||
| /* > \verbatim */ | |||
| /* > BETA is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > */ | |||
| /* > On exit, ALPHA and BETA contain the generalized singular */ | |||
| /* > value pairs of A and B; */ | |||
| /* > ALPHA(1:K) = 1, */ | |||
| /* > BETA(1:K) = 0, */ | |||
| /* > and if M-K-L >= 0, */ | |||
| /* > ALPHA(K+1:K+L) = C, */ | |||
| /* > BETA(K+1:K+L) = S, */ | |||
| /* > or if M-K-L < 0, */ | |||
| /* > ALPHA(K+1:M)=C, ALPHA(M+1:K+L)=0 */ | |||
| /* > BETA(K+1:M) =S, BETA(M+1:K+L) =1 */ | |||
| /* > and */ | |||
| /* > ALPHA(K+L+1:N) = 0 */ | |||
| /* > BETA(K+L+1:N) = 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] U */ | |||
| /* > \verbatim */ | |||
| /* > U is DOUBLE PRECISION array, dimension (LDU,M) */ | |||
| /* > If JOBU = 'U', U contains the M-by-M orthogonal matrix U. */ | |||
| /* > If JOBU = 'N', U is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDU */ | |||
| /* > \verbatim */ | |||
| /* > LDU is INTEGER */ | |||
| /* > The leading dimension of the array U. LDU >= f2cmax(1,M) if */ | |||
| /* > JOBU = 'U'; LDU >= 1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] V */ | |||
| /* > \verbatim */ | |||
| /* > V is DOUBLE PRECISION array, dimension (LDV,P) */ | |||
| /* > If JOBV = 'V', V contains the P-by-P orthogonal matrix V. */ | |||
| /* > If JOBV = 'N', V is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. LDV >= f2cmax(1,P) if */ | |||
| /* > JOBV = 'V'; LDV >= 1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] Q */ | |||
| /* > \verbatim */ | |||
| /* > Q is DOUBLE PRECISION array, dimension (LDQ,N) */ | |||
| /* > If JOBQ = 'Q', Q contains the N-by-N orthogonal matrix Q. */ | |||
| /* > If JOBQ = 'N', Q is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDQ */ | |||
| /* > \verbatim */ | |||
| /* > LDQ is INTEGER */ | |||
| /* > The leading dimension of the array Q. LDQ >= f2cmax(1,N) if */ | |||
| /* > JOBQ = 'Q'; LDQ >= 1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, */ | |||
| /* > dimension (f2cmax(3*N,M,P)+N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] IWORK */ | |||
| /* > \verbatim */ | |||
| /* > IWORK is INTEGER array, dimension (N) */ | |||
| /* > On exit, IWORK stores the sorting information. More */ | |||
| /* > precisely, the following loop will sort ALPHA */ | |||
| /* > for I = K+1, f2cmin(M,K+L) */ | |||
| /* > swap ALPHA(I) and ALPHA(IWORK(I)) */ | |||
| /* > endfor */ | |||
| /* > such that ALPHA(1) >= ALPHA(2) >= ... >= ALPHA(N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > > 0: if INFO = 1, the Jacobi-type procedure failed to */ | |||
| /* > converge. For further details, see subroutine DTGSJA. */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > TOLA DOUBLE PRECISION */ | |||
| /* > TOLB DOUBLE PRECISION */ | |||
| /* > TOLA and TOLB are the thresholds to determine the effective */ | |||
| /* > rank of (A',B')**T. Generally, they are set to */ | |||
| /* > TOLA = MAX(M,N)*norm(A)*MAZHEPS, */ | |||
| /* > TOLB = MAX(P,N)*norm(B)*MAZHEPS. */ | |||
| /* > The size of TOLA and TOLB may affect the size of backward */ | |||
| /* > errors of the decomposition. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup doubleOTHERsing */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > Ming Gu and Huan Ren, Computer Science Division, University of */ | |||
| /* > California at Berkeley, USA */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int dggsvd_(char *jobu, char *jobv, char *jobq, integer *m, | |||
| integer *n, integer *p, integer *k, integer *l, doublereal *a, | |||
| integer *lda, doublereal *b, integer *ldb, doublereal *alpha, | |||
| doublereal *beta, doublereal *u, integer *ldu, doublereal *v, integer | |||
| *ldv, doublereal *q, integer *ldq, doublereal *work, integer *iwork, | |||
| integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, q_dim1, q_offset, u_dim1, | |||
| u_offset, v_dim1, v_offset, i__1, i__2; | |||
| /* Local variables */ | |||
| integer ibnd; | |||
| doublereal tola; | |||
| integer isub; | |||
| doublereal tolb, unfl, temp, smax; | |||
| integer ncallmycycle, i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal anorm, bnorm; | |||
| extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, | |||
| doublereal *, integer *); | |||
| logical wantq, wantu, wantv; | |||
| extern doublereal dlamch_(char *), dlange_(char *, integer *, | |||
| integer *, doublereal *, integer *, doublereal *); | |||
| extern /* Subroutine */ int dtgsja_(char *, char *, char *, integer *, | |||
| integer *, integer *, integer *, integer *, doublereal *, integer | |||
| *, doublereal *, integer *, doublereal *, doublereal *, | |||
| doublereal *, doublereal *, doublereal *, integer *, doublereal *, | |||
| integer *, doublereal *, integer *, doublereal *, integer *, | |||
| integer *), xerbla_(char *, integer *), dggsvp_(char *, char *, char *, integer *, integer *, | |||
| integer *, doublereal *, integer *, doublereal *, integer *, | |||
| doublereal *, doublereal *, integer *, integer *, doublereal *, | |||
| integer *, doublereal *, integer *, doublereal *, integer *, | |||
| integer *, doublereal *, doublereal *, integer *); | |||
| doublereal ulp; | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| --alpha; | |||
| --beta; | |||
| u_dim1 = *ldu; | |||
| u_offset = 1 + u_dim1 * 1; | |||
| u -= u_offset; | |||
| v_dim1 = *ldv; | |||
| v_offset = 1 + v_dim1 * 1; | |||
| v -= v_offset; | |||
| q_dim1 = *ldq; | |||
| q_offset = 1 + q_dim1 * 1; | |||
| q -= q_offset; | |||
| --work; | |||
| --iwork; | |||
| /* Function Body */ | |||
| wantu = lsame_(jobu, "U"); | |||
| wantv = lsame_(jobv, "V"); | |||
| wantq = lsame_(jobq, "Q"); | |||
| *info = 0; | |||
| if (! (wantu || lsame_(jobu, "N"))) { | |||
| *info = -1; | |||
| } else if (! (wantv || lsame_(jobv, "N"))) { | |||
| *info = -2; | |||
| } else if (! (wantq || lsame_(jobq, "N"))) { | |||
| *info = -3; | |||
| } else if (*m < 0) { | |||
| *info = -4; | |||
| } else if (*n < 0) { | |||
| *info = -5; | |||
| } else if (*p < 0) { | |||
| *info = -6; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -10; | |||
| } else if (*ldb < f2cmax(1,*p)) { | |||
| *info = -12; | |||
| } else if (*ldu < 1 || wantu && *ldu < *m) { | |||
| *info = -16; | |||
| } else if (*ldv < 1 || wantv && *ldv < *p) { | |||
| *info = -18; | |||
| } else if (*ldq < 1 || wantq && *ldq < *n) { | |||
| *info = -20; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("DGGSVD", &i__1); | |||
| return 0; | |||
| } | |||
| /* Compute the Frobenius norm of matrices A and B */ | |||
| anorm = dlange_("1", m, n, &a[a_offset], lda, &work[1]); | |||
| bnorm = dlange_("1", p, n, &b[b_offset], ldb, &work[1]); | |||
| /* Get machine precision and set up threshold for determining */ | |||
| /* the effective numerical rank of the matrices A and B. */ | |||
| ulp = dlamch_("Precision"); | |||
| unfl = dlamch_("Safe Minimum"); | |||
| tola = f2cmax(*m,*n) * f2cmax(anorm,unfl) * ulp; | |||
| tolb = f2cmax(*p,*n) * f2cmax(bnorm,unfl) * ulp; | |||
| /* Preprocessing */ | |||
| dggsvp_(jobu, jobv, jobq, m, p, n, &a[a_offset], lda, &b[b_offset], ldb, & | |||
| tola, &tolb, k, l, &u[u_offset], ldu, &v[v_offset], ldv, &q[ | |||
| q_offset], ldq, &iwork[1], &work[1], &work[*n + 1], info); | |||
| /* Compute the GSVD of two upper "triangular" matrices */ | |||
| dtgsja_(jobu, jobv, jobq, m, p, n, k, l, &a[a_offset], lda, &b[b_offset], | |||
| ldb, &tola, &tolb, &alpha[1], &beta[1], &u[u_offset], ldu, &v[ | |||
| v_offset], ldv, &q[q_offset], ldq, &work[1], &ncallmycycle, info); | |||
| /* Sort the singular values and store the pivot indices in IWORK */ | |||
| /* Copy ALPHA to WORK, then sort ALPHA in WORK */ | |||
| dcopy_(n, &alpha[1], &c__1, &work[1], &c__1); | |||
| /* Computing MIN */ | |||
| i__1 = *l, i__2 = *m - *k; | |||
| ibnd = f2cmin(i__1,i__2); | |||
| i__1 = ibnd; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Scan for largest ALPHA(K+I) */ | |||
| isub = i__; | |||
| smax = work[*k + i__]; | |||
| i__2 = ibnd; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| temp = work[*k + j]; | |||
| if (temp > smax) { | |||
| isub = j; | |||
| smax = temp; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| if (isub != i__) { | |||
| work[*k + isub] = work[*k + i__]; | |||
| work[*k + i__] = smax; | |||
| iwork[*k + i__] = *k + isub; | |||
| } else { | |||
| iwork[*k + i__] = *k + i__; | |||
| } | |||
| /* L20: */ | |||
| } | |||
| return 0; | |||
| /* End of DGGSVD */ | |||
| } /* dggsvd_ */ | |||
| @@ -0,0 +1,742 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublereal c_b4 = -1.; | |||
| static doublereal c_b5 = 1.; | |||
| static integer c__1 = 1; | |||
| static doublereal c_b38 = 0.; | |||
| /* > \brief \b DLAHRD reduces the first nb columns of a general rectangular matrix A so that elements below th | |||
| e k-th subdiagonal are zero, and returns auxiliary matrices which are needed to apply the transformati | |||
| on to the unreduced part of A. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download DLAHRD + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlahrd. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlahrd. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlahrd. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE DLAHRD( N, K, NB, A, LDA, TAU, T, LDT, Y, LDY ) */ | |||
| /* INTEGER K, LDA, LDT, LDY, N, NB */ | |||
| /* DOUBLE PRECISION A( LDA, * ), T( LDT, NB ), TAU( NB ), */ | |||
| /* $ Y( LDY, NB ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine DLAHR2. */ | |||
| /* > */ | |||
| /* > DLAHRD reduces the first NB columns of a real general n-by-(n-k+1) */ | |||
| /* > matrix A so that elements below the k-th subdiagonal are zero. The */ | |||
| /* > reduction is performed by an orthogonal similarity transformation */ | |||
| /* > Q**T * A * Q. The routine returns the matrices V and T which determine */ | |||
| /* > Q as a block reflector I - V*T*V**T, and also the matrix Y = A * V * T. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The offset for the reduction. Elements below the k-th */ | |||
| /* > subdiagonal in the first NB columns are reduced to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The number of columns to be reduced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is DOUBLE PRECISION array, dimension (LDA,N-K+1) */ | |||
| /* > On entry, the n-by-(n-k+1) general matrix A. */ | |||
| /* > On exit, the elements on and above the k-th subdiagonal in */ | |||
| /* > the first NB columns are overwritten with the corresponding */ | |||
| /* > elements of the reduced matrix; the elements below the k-th */ | |||
| /* > subdiagonal, with the array TAU, represent the matrix Q as a */ | |||
| /* > product of elementary reflectors. The other columns of A are */ | |||
| /* > unchanged. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is DOUBLE PRECISION array, dimension (NB) */ | |||
| /* > The scalar factors of the elementary reflectors. See Further */ | |||
| /* > Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] T */ | |||
| /* > \verbatim */ | |||
| /* > T is DOUBLE PRECISION array, dimension (LDT,NB) */ | |||
| /* > The upper triangular matrix T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= NB. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] Y */ | |||
| /* > \verbatim */ | |||
| /* > Y is DOUBLE PRECISION array, dimension (LDY,NB) */ | |||
| /* > The n-by-nb matrix Y. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDY */ | |||
| /* > \verbatim */ | |||
| /* > LDY is INTEGER */ | |||
| /* > The leading dimension of the array Y. LDY >= N. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup doubleOTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of nb elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(nb). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**T */ | |||
| /* > */ | |||
| /* > where tau is a real scalar, and v is a real vector with */ | |||
| /* > v(1:i+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in */ | |||
| /* > A(i+k+1:n,i), and tau in TAU(i). */ | |||
| /* > */ | |||
| /* > The elements of the vectors v together form the (n-k+1)-by-nb matrix */ | |||
| /* > V which is needed, with T and Y, to apply the transformation to the */ | |||
| /* > unreduced part of the matrix, using an update of the form: */ | |||
| /* > A := (I - V*T*V**T) * (A - Y*V**T). */ | |||
| /* > */ | |||
| /* > The contents of A on exit are illustrated by the following example */ | |||
| /* > with n = 7, k = 3 and nb = 2: */ | |||
| /* > */ | |||
| /* > ( a h a a a ) */ | |||
| /* > ( a h a a a ) */ | |||
| /* > ( a h a a a ) */ | |||
| /* > ( h h a a a ) */ | |||
| /* > ( v1 h a a a ) */ | |||
| /* > ( v1 v2 a a a ) */ | |||
| /* > ( v1 v2 a a a ) */ | |||
| /* > */ | |||
| /* > where a denotes an element of the original matrix A, h denotes a */ | |||
| /* > modified element of the upper Hessenberg matrix H, and vi denotes an */ | |||
| /* > element of the vector defining H(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int dlahrd_(integer *n, integer *k, integer *nb, doublereal * | |||
| a, integer *lda, doublereal *tau, doublereal *t, integer *ldt, | |||
| doublereal *y, integer *ldy) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, y_dim1, y_offset, i__1, i__2, | |||
| i__3; | |||
| doublereal d__1; | |||
| /* Local variables */ | |||
| integer i__; | |||
| extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, | |||
| integer *), dgemv_(char *, integer *, integer *, doublereal *, | |||
| doublereal *, integer *, doublereal *, integer *, doublereal *, | |||
| doublereal *, integer *), dcopy_(integer *, doublereal *, | |||
| integer *, doublereal *, integer *), daxpy_(integer *, doublereal | |||
| *, doublereal *, integer *, doublereal *, integer *), dtrmv_(char | |||
| *, char *, char *, integer *, doublereal *, integer *, doublereal | |||
| *, integer *); | |||
| doublereal ei; | |||
| extern /* Subroutine */ int dlarfg_(integer *, doublereal *, doublereal *, | |||
| integer *, doublereal *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| --tau; | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| y_dim1 = *ldy; | |||
| y_offset = 1 + y_dim1 * 1; | |||
| y -= y_offset; | |||
| /* Function Body */ | |||
| if (*n <= 1) { | |||
| return 0; | |||
| } | |||
| i__1 = *nb; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (i__ > 1) { | |||
| /* Update A(1:n,i) */ | |||
| /* Compute i-th column of A - Y * V**T */ | |||
| i__2 = i__ - 1; | |||
| dgemv_("No transpose", n, &i__2, &c_b4, &y[y_offset], ldy, &a[*k | |||
| + i__ - 1 + a_dim1], lda, &c_b5, &a[i__ * a_dim1 + 1], & | |||
| c__1); | |||
| /* Apply I - V * T**T * V**T to this column (call it b) from the */ | |||
| /* left, using the last column of T as workspace */ | |||
| /* Let V = ( V1 ) and b = ( b1 ) (first I-1 rows) */ | |||
| /* ( V2 ) ( b2 ) */ | |||
| /* where V1 is unit lower triangular */ | |||
| /* w := V1**T * b1 */ | |||
| i__2 = i__ - 1; | |||
| dcopy_(&i__2, &a[*k + 1 + i__ * a_dim1], &c__1, &t[*nb * t_dim1 + | |||
| 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| dtrmv_("Lower", "Transpose", "Unit", &i__2, &a[*k + 1 + a_dim1], | |||
| lda, &t[*nb * t_dim1 + 1], &c__1); | |||
| /* w := w + V2**T *b2 */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[*k + i__ + a_dim1], | |||
| lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b5, &t[*nb * | |||
| t_dim1 + 1], &c__1); | |||
| /* w := T**T *w */ | |||
| i__2 = i__ - 1; | |||
| dtrmv_("Upper", "Transpose", "Non-unit", &i__2, &t[t_offset], ldt, | |||
| &t[*nb * t_dim1 + 1], &c__1); | |||
| /* b2 := b2 - V2*w */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[*k + i__ + a_dim1], | |||
| lda, &t[*nb * t_dim1 + 1], &c__1, &c_b5, &a[*k + i__ + | |||
| i__ * a_dim1], &c__1); | |||
| /* b1 := b1 - V1*w */ | |||
| i__2 = i__ - 1; | |||
| dtrmv_("Lower", "No transpose", "Unit", &i__2, &a[*k + 1 + a_dim1] | |||
| , lda, &t[*nb * t_dim1 + 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| daxpy_(&i__2, &c_b4, &t[*nb * t_dim1 + 1], &c__1, &a[*k + 1 + i__ | |||
| * a_dim1], &c__1); | |||
| a[*k + i__ - 1 + (i__ - 1) * a_dim1] = ei; | |||
| } | |||
| /* Generate the elementary reflector H(i) to annihilate */ | |||
| /* A(k+i+1:n,i) */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = *k + i__ + 1; | |||
| dlarfg_(&i__2, &a[*k + i__ + i__ * a_dim1], &a[f2cmin(i__3,*n) + i__ * | |||
| a_dim1], &c__1, &tau[i__]); | |||
| ei = a[*k + i__ + i__ * a_dim1]; | |||
| a[*k + i__ + i__ * a_dim1] = 1.; | |||
| /* Compute Y(1:n,i) */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| dgemv_("No transpose", n, &i__2, &c_b5, &a[(i__ + 1) * a_dim1 + 1], | |||
| lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b38, &y[i__ * | |||
| y_dim1 + 1], &c__1); | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[*k + i__ + a_dim1], lda, & | |||
| a[*k + i__ + i__ * a_dim1], &c__1, &c_b38, &t[i__ * t_dim1 + | |||
| 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| dgemv_("No transpose", n, &i__2, &c_b4, &y[y_offset], ldy, &t[i__ * | |||
| t_dim1 + 1], &c__1, &c_b5, &y[i__ * y_dim1 + 1], &c__1); | |||
| dscal_(n, &tau[i__], &y[i__ * y_dim1 + 1], &c__1); | |||
| /* Compute T(1:i,i) */ | |||
| i__2 = i__ - 1; | |||
| d__1 = -tau[i__]; | |||
| dscal_(&i__2, &d__1, &t[i__ * t_dim1 + 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| dtrmv_("Upper", "No transpose", "Non-unit", &i__2, &t[t_offset], ldt, | |||
| &t[i__ * t_dim1 + 1], &c__1) | |||
| ; | |||
| t[i__ + i__ * t_dim1] = tau[i__]; | |||
| /* L10: */ | |||
| } | |||
| a[*k + *nb + *nb * a_dim1] = ei; | |||
| return 0; | |||
| /* End of DLAHRD */ | |||
| } /* dlahrd_ */ | |||
| @@ -0,0 +1,647 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static doublereal c_b5 = 1.; | |||
| /* > \brief \b DLATZM */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download DLATZM + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlatzm. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlatzm. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlatzm. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE DLATZM( SIDE, M, N, V, INCV, TAU, C1, C2, LDC, WORK ) */ | |||
| /* CHARACTER SIDE */ | |||
| /* INTEGER INCV, LDC, M, N */ | |||
| /* DOUBLE PRECISION TAU */ | |||
| /* DOUBLE PRECISION C1( LDC, * ), C2( LDC, * ), V( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine DORMRZ. */ | |||
| /* > */ | |||
| /* > DLATZM applies a Householder matrix generated by DTZRQF to a matrix. */ | |||
| /* > */ | |||
| /* > Let P = I - tau*u*u**T, u = ( 1 ), */ | |||
| /* > ( v ) */ | |||
| /* > where v is an (m-1) vector if SIDE = 'L', or a (n-1) vector if */ | |||
| /* > SIDE = 'R'. */ | |||
| /* > */ | |||
| /* > If SIDE equals 'L', let */ | |||
| /* > C = [ C1 ] 1 */ | |||
| /* > [ C2 ] m-1 */ | |||
| /* > n */ | |||
| /* > Then C is overwritten by P*C. */ | |||
| /* > */ | |||
| /* > If SIDE equals 'R', let */ | |||
| /* > C = [ C1, C2 ] m */ | |||
| /* > 1 n-1 */ | |||
| /* > Then C is overwritten by C*P. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': form P * C */ | |||
| /* > = 'R': form C * P */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is DOUBLE PRECISION array, dimension */ | |||
| /* > (1 + (M-1)*abs(INCV)) if SIDE = 'L' */ | |||
| /* > (1 + (N-1)*abs(INCV)) if SIDE = 'R' */ | |||
| /* > The vector v in the representation of P. V is not used */ | |||
| /* > if TAU = 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCV */ | |||
| /* > \verbatim */ | |||
| /* > INCV is INTEGER */ | |||
| /* > The increment between elements of v. INCV <> 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is DOUBLE PRECISION */ | |||
| /* > The value tau in the representation of P. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C1 */ | |||
| /* > \verbatim */ | |||
| /* > C1 is DOUBLE PRECISION array, dimension */ | |||
| /* > (LDC,N) if SIDE = 'L' */ | |||
| /* > (M,1) if SIDE = 'R' */ | |||
| /* > On entry, the n-vector C1 if SIDE = 'L', or the m-vector C1 */ | |||
| /* > if SIDE = 'R'. */ | |||
| /* > */ | |||
| /* > On exit, the first row of P*C if SIDE = 'L', or the first */ | |||
| /* > column of C*P if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C2 */ | |||
| /* > \verbatim */ | |||
| /* > C2 is DOUBLE PRECISION array, dimension */ | |||
| /* > (LDC, N) if SIDE = 'L' */ | |||
| /* > (LDC, N-1) if SIDE = 'R' */ | |||
| /* > On entry, the (m - 1) x n matrix C2 if SIDE = 'L', or the */ | |||
| /* > m x (n - 1) matrix C2 if SIDE = 'R'. */ | |||
| /* > */ | |||
| /* > On exit, rows 2:m of P*C if SIDE = 'L', or columns 2:m of C*P */ | |||
| /* > if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the arrays C1 and C2. LDC >= (1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is DOUBLE PRECISION array, dimension */ | |||
| /* > (N) if SIDE = 'L' */ | |||
| /* > (M) if SIDE = 'R' */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup doubleOTHERcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int dlatzm_(char *side, integer *m, integer *n, doublereal * | |||
| v, integer *incv, doublereal *tau, doublereal *c1, doublereal *c2, | |||
| integer *ldc, doublereal *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer c1_dim1, c1_offset, c2_dim1, c2_offset, i__1; | |||
| doublereal d__1; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int dger_(integer *, integer *, doublereal *, | |||
| doublereal *, integer *, doublereal *, integer *, doublereal *, | |||
| integer *); | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int dgemv_(char *, integer *, integer *, | |||
| doublereal *, doublereal *, integer *, doublereal *, integer *, | |||
| doublereal *, doublereal *, integer *), dcopy_(integer *, | |||
| doublereal *, integer *, doublereal *, integer *), daxpy_(integer | |||
| *, doublereal *, doublereal *, integer *, doublereal *, integer *) | |||
| ; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --v; | |||
| c2_dim1 = *ldc; | |||
| c2_offset = 1 + c2_dim1 * 1; | |||
| c2 -= c2_offset; | |||
| c1_dim1 = *ldc; | |||
| c1_offset = 1 + c1_dim1 * 1; | |||
| c1 -= c1_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (f2cmin(*m,*n) == 0 || *tau == 0.) { | |||
| return 0; | |||
| } | |||
| if (lsame_(side, "L")) { | |||
| /* w := (C1 + v**T * C2)**T */ | |||
| dcopy_(n, &c1[c1_offset], ldc, &work[1], &c__1); | |||
| i__1 = *m - 1; | |||
| dgemv_("Transpose", &i__1, n, &c_b5, &c2[c2_offset], ldc, &v[1], incv, | |||
| &c_b5, &work[1], &c__1); | |||
| /* [ C1 ] := [ C1 ] - tau* [ 1 ] * w**T */ | |||
| /* [ C2 ] [ C2 ] [ v ] */ | |||
| d__1 = -(*tau); | |||
| daxpy_(n, &d__1, &work[1], &c__1, &c1[c1_offset], ldc); | |||
| i__1 = *m - 1; | |||
| d__1 = -(*tau); | |||
| dger_(&i__1, n, &d__1, &v[1], incv, &work[1], &c__1, &c2[c2_offset], | |||
| ldc); | |||
| } else if (lsame_(side, "R")) { | |||
| /* w := C1 + C2 * v */ | |||
| dcopy_(m, &c1[c1_offset], &c__1, &work[1], &c__1); | |||
| i__1 = *n - 1; | |||
| dgemv_("No transpose", m, &i__1, &c_b5, &c2[c2_offset], ldc, &v[1], | |||
| incv, &c_b5, &work[1], &c__1); | |||
| /* [ C1, C2 ] := [ C1, C2 ] - tau* w * [ 1 , v**T] */ | |||
| d__1 = -(*tau); | |||
| daxpy_(m, &d__1, &work[1], &c__1, &c1[c1_offset], &c__1); | |||
| i__1 = *n - 1; | |||
| d__1 = -(*tau); | |||
| dger_(m, &i__1, &d__1, &work[1], &c__1, &v[1], incv, &c2[c2_offset], | |||
| ldc); | |||
| } | |||
| return 0; | |||
| /* End of DLATZM */ | |||
| } /* dlatzm_ */ | |||
| @@ -0,0 +1,667 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static doublereal c_b8 = 1.; | |||
| /* > \brief \b DTZRQF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download DTZRQF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtzrqf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtzrqf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtzrqf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE DTZRQF( M, N, A, LDA, TAU, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* DOUBLE PRECISION A( LDA, * ), TAU( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine DTZRZF. */ | |||
| /* > */ | |||
| /* > DTZRQF reduces the M-by-N ( M<=N ) real upper trapezoidal matrix A */ | |||
| /* > to upper triangular form by means of orthogonal transformations. */ | |||
| /* > */ | |||
| /* > The upper trapezoidal matrix A is factored as */ | |||
| /* > */ | |||
| /* > A = ( R 0 ) * Z, */ | |||
| /* > */ | |||
| /* > where Z is an N-by-N orthogonal matrix and R is an M-by-M upper */ | |||
| /* > triangular matrix. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= M. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is DOUBLE PRECISION array, dimension (LDA,N) */ | |||
| /* > On entry, the leading M-by-N upper trapezoidal part of the */ | |||
| /* > array A must contain the matrix to be factorized. */ | |||
| /* > On exit, the leading M-by-M upper triangular part of A */ | |||
| /* > contains the upper triangular matrix R, and elements M+1 to */ | |||
| /* > N of the first M rows of A, with the array TAU, represent the */ | |||
| /* > orthogonal matrix Z as a product of M elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is DOUBLE PRECISION array, dimension (M) */ | |||
| /* > The scalar factors of the elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup doubleOTHERcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The factorization is obtained by Householder's method. The kth */ | |||
| /* > transformation matrix, Z( k ), which is used to introduce zeros into */ | |||
| /* > the ( m - k + 1 )th row of A, is given in the form */ | |||
| /* > */ | |||
| /* > Z( k ) = ( I 0 ), */ | |||
| /* > ( 0 T( k ) ) */ | |||
| /* > */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > T( k ) = I - tau*u( k )*u( k )**T, u( k ) = ( 1 ), */ | |||
| /* > ( 0 ) */ | |||
| /* > ( z( k ) ) */ | |||
| /* > */ | |||
| /* > tau is a scalar and z( k ) is an ( n - m ) element vector. */ | |||
| /* > tau and z( k ) are chosen to annihilate the elements of the kth row */ | |||
| /* > of X. */ | |||
| /* > */ | |||
| /* > The scalar tau is returned in the kth element of TAU and the vector */ | |||
| /* > u( k ) in the kth row of A, such that the elements of z( k ) are */ | |||
| /* > in a( k, m + 1 ), ..., a( k, n ). The elements of R are returned in */ | |||
| /* > the upper triangular part of A. */ | |||
| /* > */ | |||
| /* > Z is given by */ | |||
| /* > */ | |||
| /* > Z = Z( 1 ) * Z( 2 ) * ... * Z( m ). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int dtzrqf_(integer *m, integer *n, doublereal *a, integer * | |||
| lda, doublereal *tau, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| doublereal d__1; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int dger_(integer *, integer *, doublereal *, | |||
| doublereal *, integer *, doublereal *, integer *, doublereal *, | |||
| integer *); | |||
| integer i__, k; | |||
| extern /* Subroutine */ int dgemv_(char *, integer *, integer *, | |||
| doublereal *, doublereal *, integer *, doublereal *, integer *, | |||
| doublereal *, doublereal *, integer *), dcopy_(integer *, | |||
| doublereal *, integer *, doublereal *, integer *), daxpy_(integer | |||
| *, doublereal *, doublereal *, integer *, doublereal *, integer *) | |||
| ; | |||
| integer m1; | |||
| extern /* Subroutine */ int dlarfg_(integer *, doublereal *, doublereal *, | |||
| integer *, doublereal *), xerbla_(char *, integer *); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < *m) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("DTZRQF", &i__1); | |||
| return 0; | |||
| } | |||
| /* Perform the factorization. */ | |||
| if (*m == 0) { | |||
| return 0; | |||
| } | |||
| if (*m == *n) { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| tau[i__] = 0.; | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| /* Computing MIN */ | |||
| i__1 = *m + 1; | |||
| m1 = f2cmin(i__1,*n); | |||
| for (k = *m; k >= 1; --k) { | |||
| /* Use a Householder reflection to zero the kth row of A. */ | |||
| /* First set up the reflection. */ | |||
| i__1 = *n - *m + 1; | |||
| dlarfg_(&i__1, &a[k + k * a_dim1], &a[k + m1 * a_dim1], lda, &tau[ | |||
| k]); | |||
| if (tau[k] != 0. && k > 1) { | |||
| /* We now perform the operation A := A*P( k ). */ | |||
| /* Use the first ( k - 1 ) elements of TAU to store a( k ), */ | |||
| /* where a( k ) consists of the first ( k - 1 ) elements of */ | |||
| /* the kth column of A. Also let B denote the first */ | |||
| /* ( k - 1 ) rows of the last ( n - m ) columns of A. */ | |||
| i__1 = k - 1; | |||
| dcopy_(&i__1, &a[k * a_dim1 + 1], &c__1, &tau[1], &c__1); | |||
| /* Form w = a( k ) + B*z( k ) in TAU. */ | |||
| i__1 = k - 1; | |||
| i__2 = *n - *m; | |||
| dgemv_("No transpose", &i__1, &i__2, &c_b8, &a[m1 * a_dim1 + | |||
| 1], lda, &a[k + m1 * a_dim1], lda, &c_b8, &tau[1], & | |||
| c__1); | |||
| /* Now form a( k ) := a( k ) - tau*w */ | |||
| /* and B := B - tau*w*z( k )**T. */ | |||
| i__1 = k - 1; | |||
| d__1 = -tau[k]; | |||
| daxpy_(&i__1, &d__1, &tau[1], &c__1, &a[k * a_dim1 + 1], & | |||
| c__1); | |||
| i__1 = k - 1; | |||
| i__2 = *n - *m; | |||
| d__1 = -tau[k]; | |||
| dger_(&i__1, &i__2, &d__1, &tau[1], &c__1, &a[k + m1 * a_dim1] | |||
| , lda, &a[m1 * a_dim1 + 1], lda); | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of DTZRQF */ | |||
| } /* dtzrqf_ */ | |||
| @@ -0,0 +1,891 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__0 = 0; | |||
| static real c_b13 = 0.f; | |||
| static integer c__2 = 2; | |||
| static integer c__1 = 1; | |||
| static real c_b36 = 1.f; | |||
| /* > \brief <b> SGELSX solves overdetermined or underdetermined systems for GE matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download SGELSX + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgelsx. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgelsx. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgelsx. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE SGELSX( M, N, NRHS, A, LDA, B, LDB, JPVT, RCOND, RANK, */ | |||
| /* WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LDB, M, N, NRHS, RANK */ | |||
| /* REAL RCOND */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* REAL A( LDA, * ), B( LDB, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine SGELSY. */ | |||
| /* > */ | |||
| /* > SGELSX computes the minimum-norm solution to a real linear least */ | |||
| /* > squares problem: */ | |||
| /* > minimize || A * X - B || */ | |||
| /* > using a complete orthogonal factorization of A. A is an M-by-N */ | |||
| /* > matrix which may be rank-deficient. */ | |||
| /* > */ | |||
| /* > Several right hand side vectors b and solution vectors x can be */ | |||
| /* > handled in a single call; they are stored as the columns of the */ | |||
| /* > M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ | |||
| /* > matrix X. */ | |||
| /* > */ | |||
| /* > The routine first computes a QR factorization with column pivoting: */ | |||
| /* > A * P = Q * [ R11 R12 ] */ | |||
| /* > [ 0 R22 ] */ | |||
| /* > with R11 defined as the largest leading submatrix whose estimated */ | |||
| /* > condition number is less than 1/RCOND. The order of R11, RANK, */ | |||
| /* > is the effective rank of A. */ | |||
| /* > */ | |||
| /* > Then, R22 is considered to be negligible, and R12 is annihilated */ | |||
| /* > by orthogonal transformations from the right, arriving at the */ | |||
| /* > complete orthogonal factorization: */ | |||
| /* > A * P = Q * [ T11 0 ] * Z */ | |||
| /* > [ 0 0 ] */ | |||
| /* > The minimum-norm solution is then */ | |||
| /* > X = P * Z**T [ inv(T11)*Q1**T*B ] */ | |||
| /* > [ 0 ] */ | |||
| /* > where Q1 consists of the first RANK columns of Q. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of */ | |||
| /* > columns of matrices B and X. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is REAL array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, A has been overwritten by details of its */ | |||
| /* > complete orthogonal factorization. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is REAL array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the M-by-NRHS right hand side matrix B. */ | |||
| /* > On exit, the N-by-NRHS solution matrix X. */ | |||
| /* > If m >= n and RANK = n, the residual sum-of-squares for */ | |||
| /* > the solution in the i-th column is given by the sum of */ | |||
| /* > squares of elements N+1:M in that column. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,M,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] JPVT */ | |||
| /* > \verbatim */ | |||
| /* > JPVT is INTEGER array, dimension (N) */ | |||
| /* > On entry, if JPVT(i) .ne. 0, the i-th column of A is an */ | |||
| /* > initial column, otherwise it is a free column. Before */ | |||
| /* > the QR factorization of A, all initial columns are */ | |||
| /* > permuted to the leading positions; only the remaining */ | |||
| /* > free columns are moved as a result of column pivoting */ | |||
| /* > during the factorization. */ | |||
| /* > On exit, if JPVT(i) = k, then the i-th column of A*P */ | |||
| /* > was the k-th column of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] RCOND */ | |||
| /* > \verbatim */ | |||
| /* > RCOND is REAL */ | |||
| /* > RCOND is used to determine the effective rank of A, which */ | |||
| /* > is defined as the order of the largest leading triangular */ | |||
| /* > submatrix R11 in the QR factorization with pivoting of A, */ | |||
| /* > whose estimated condition number < 1/RCOND. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RANK */ | |||
| /* > \verbatim */ | |||
| /* > RANK is INTEGER */ | |||
| /* > The effective rank of A, i.e., the order of the submatrix */ | |||
| /* > R11. This is the same as the order of the submatrix T11 */ | |||
| /* > in the complete orthogonal factorization of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is REAL array, dimension */ | |||
| /* > (f2cmax( f2cmin(M,N)+3*N, 2*f2cmin(M,N)+NRHS )), */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup realGEsolve */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int sgelsx_(integer *m, integer *n, integer *nrhs, real *a, | |||
| integer *lda, real *b, integer *ldb, integer *jpvt, real *rcond, | |||
| integer *rank, real *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2; | |||
| real r__1; | |||
| /* Local variables */ | |||
| real anrm, bnrm, smin, smax; | |||
| integer i__, j, k, iascl, ibscl, ismin, ismax; | |||
| real c1, c2, s1, s2, t1, t2; | |||
| extern /* Subroutine */ int strsm_(char *, char *, char *, char *, | |||
| integer *, integer *, real *, real *, integer *, real *, integer * | |||
| ), slaic1_(integer *, integer *, | |||
| real *, real *, real *, real *, real *, real *, real *), sorm2r_( | |||
| char *, char *, integer *, integer *, integer *, real *, integer * | |||
| , real *, real *, integer *, real *, integer *), | |||
| slabad_(real *, real *); | |||
| integer mn; | |||
| extern real slamch_(char *), slange_(char *, integer *, integer *, | |||
| real *, integer *, real *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *); | |||
| real bignum; | |||
| extern /* Subroutine */ int slascl_(char *, integer *, integer *, real *, | |||
| real *, integer *, integer *, real *, integer *, integer *), sgeqpf_(integer *, integer *, real *, integer *, integer | |||
| *, real *, real *, integer *), slaset_(char *, integer *, integer | |||
| *, real *, real *, real *, integer *); | |||
| real sminpr, smaxpr, smlnum; | |||
| extern /* Subroutine */ int slatzm_(char *, integer *, integer *, real *, | |||
| integer *, real *, real *, real *, integer *, real *), | |||
| stzrqf_(integer *, integer *, real *, integer *, real *, integer * | |||
| ); | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| --jpvt; | |||
| --work; | |||
| /* Function Body */ | |||
| mn = f2cmin(*m,*n); | |||
| ismin = mn + 1; | |||
| ismax = (mn << 1) + 1; | |||
| /* Test the input arguments. */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*nrhs < 0) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -5; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(1,*m); | |||
| if (*ldb < f2cmax(i__1,*n)) { | |||
| *info = -7; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("SGELSX", &i__1); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*nrhs) == 0) { | |||
| *rank = 0; | |||
| return 0; | |||
| } | |||
| /* Get machine parameters */ | |||
| smlnum = slamch_("S") / slamch_("P"); | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| /* Scale A, B if f2cmax elements outside range [SMLNUM,BIGNUM] */ | |||
| anrm = slange_("M", m, n, &a[a_offset], lda, &work[1]); | |||
| iascl = 0; | |||
| if (anrm > 0.f && anrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| slascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 1; | |||
| } else if (anrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| slascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 2; | |||
| } else if (anrm == 0.f) { | |||
| /* Matrix all zero. Return zero solution. */ | |||
| i__1 = f2cmax(*m,*n); | |||
| slaset_("F", &i__1, nrhs, &c_b13, &c_b13, &b[b_offset], ldb); | |||
| *rank = 0; | |||
| goto L100; | |||
| } | |||
| bnrm = slange_("M", m, nrhs, &b[b_offset], ldb, &work[1]); | |||
| ibscl = 0; | |||
| if (bnrm > 0.f && bnrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| slascl_("G", &c__0, &c__0, &bnrm, &smlnum, m, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| ibscl = 1; | |||
| } else if (bnrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| slascl_("G", &c__0, &c__0, &bnrm, &bignum, m, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| ibscl = 2; | |||
| } | |||
| /* Compute QR factorization with column pivoting of A: */ | |||
| /* A * P = Q * R */ | |||
| sgeqpf_(m, n, &a[a_offset], lda, &jpvt[1], &work[1], &work[mn + 1], info); | |||
| /* workspace 3*N. Details of Householder rotations stored */ | |||
| /* in WORK(1:MN). */ | |||
| /* Determine RANK using incremental condition estimation */ | |||
| work[ismin] = 1.f; | |||
| work[ismax] = 1.f; | |||
| smax = (r__1 = a[a_dim1 + 1], abs(r__1)); | |||
| smin = smax; | |||
| if ((r__1 = a[a_dim1 + 1], abs(r__1)) == 0.f) { | |||
| *rank = 0; | |||
| i__1 = f2cmax(*m,*n); | |||
| slaset_("F", &i__1, nrhs, &c_b13, &c_b13, &b[b_offset], ldb); | |||
| goto L100; | |||
| } else { | |||
| *rank = 1; | |||
| } | |||
| L10: | |||
| if (*rank < mn) { | |||
| i__ = *rank + 1; | |||
| slaic1_(&c__2, rank, &work[ismin], &smin, &a[i__ * a_dim1 + 1], &a[ | |||
| i__ + i__ * a_dim1], &sminpr, &s1, &c1); | |||
| slaic1_(&c__1, rank, &work[ismax], &smax, &a[i__ * a_dim1 + 1], &a[ | |||
| i__ + i__ * a_dim1], &smaxpr, &s2, &c2); | |||
| if (smaxpr * *rcond <= sminpr) { | |||
| i__1 = *rank; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| work[ismin + i__ - 1] = s1 * work[ismin + i__ - 1]; | |||
| work[ismax + i__ - 1] = s2 * work[ismax + i__ - 1]; | |||
| /* L20: */ | |||
| } | |||
| work[ismin + *rank] = c1; | |||
| work[ismax + *rank] = c2; | |||
| smin = sminpr; | |||
| smax = smaxpr; | |||
| ++(*rank); | |||
| goto L10; | |||
| } | |||
| } | |||
| /* Logically partition R = [ R11 R12 ] */ | |||
| /* [ 0 R22 ] */ | |||
| /* where R11 = R(1:RANK,1:RANK) */ | |||
| /* [R11,R12] = [ T11, 0 ] * Y */ | |||
| if (*rank < *n) { | |||
| stzrqf_(rank, n, &a[a_offset], lda, &work[mn + 1], info); | |||
| } | |||
| /* Details of Householder rotations stored in WORK(MN+1:2*MN) */ | |||
| /* B(1:M,1:NRHS) := Q**T * B(1:M,1:NRHS) */ | |||
| sorm2r_("Left", "Transpose", m, nrhs, &mn, &a[a_offset], lda, &work[1], & | |||
| b[b_offset], ldb, &work[(mn << 1) + 1], info); | |||
| /* workspace NRHS */ | |||
| /* B(1:RANK,1:NRHS) := inv(T11) * B(1:RANK,1:NRHS) */ | |||
| strsm_("Left", "Upper", "No transpose", "Non-unit", rank, nrhs, &c_b36, & | |||
| a[a_offset], lda, &b[b_offset], ldb); | |||
| i__1 = *n; | |||
| for (i__ = *rank + 1; i__ <= i__1; ++i__) { | |||
| i__2 = *nrhs; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| b[i__ + j * b_dim1] = 0.f; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| /* B(1:N,1:NRHS) := Y**T * B(1:N,1:NRHS) */ | |||
| if (*rank < *n) { | |||
| i__1 = *rank; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = *n - *rank + 1; | |||
| slatzm_("Left", &i__2, nrhs, &a[i__ + (*rank + 1) * a_dim1], lda, | |||
| &work[mn + i__], &b[i__ + b_dim1], &b[*rank + 1 + b_dim1], | |||
| ldb, &work[(mn << 1) + 1]); | |||
| /* L50: */ | |||
| } | |||
| } | |||
| /* workspace NRHS */ | |||
| /* B(1:N,1:NRHS) := P * B(1:N,1:NRHS) */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| work[(mn << 1) + i__] = 1.f; | |||
| /* L60: */ | |||
| } | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| if (work[(mn << 1) + i__] == 1.f) { | |||
| if (jpvt[i__] != i__) { | |||
| k = i__; | |||
| t1 = b[k + j * b_dim1]; | |||
| t2 = b[jpvt[k] + j * b_dim1]; | |||
| L70: | |||
| b[jpvt[k] + j * b_dim1] = t1; | |||
| work[(mn << 1) + k] = 0.f; | |||
| t1 = t2; | |||
| k = jpvt[k]; | |||
| t2 = b[jpvt[k] + j * b_dim1]; | |||
| if (jpvt[k] != i__) { | |||
| goto L70; | |||
| } | |||
| b[i__ + j * b_dim1] = t1; | |||
| work[(mn << 1) + k] = 0.f; | |||
| } | |||
| } | |||
| /* L80: */ | |||
| } | |||
| /* L90: */ | |||
| } | |||
| /* Undo scaling */ | |||
| if (iascl == 1) { | |||
| slascl_("G", &c__0, &c__0, &anrm, &smlnum, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| slascl_("U", &c__0, &c__0, &smlnum, &anrm, rank, rank, &a[a_offset], | |||
| lda, info); | |||
| } else if (iascl == 2) { | |||
| slascl_("G", &c__0, &c__0, &anrm, &bignum, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| slascl_("U", &c__0, &c__0, &bignum, &anrm, rank, rank, &a[a_offset], | |||
| lda, info); | |||
| } | |||
| if (ibscl == 1) { | |||
| slascl_("G", &c__0, &c__0, &smlnum, &bnrm, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| } else if (ibscl == 2) { | |||
| slascl_("G", &c__0, &c__0, &bignum, &bnrm, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| } | |||
| L100: | |||
| return 0; | |||
| /* End of SGELSX */ | |||
| } /* sgelsx_ */ | |||
| @@ -0,0 +1,750 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b SGEQPF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download SGEQPF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgeqpf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgeqpf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgeqpf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE SGEQPF( M, N, A, LDA, JPVT, TAU, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* REAL A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine SGEQP3. */ | |||
| /* > */ | |||
| /* > SGEQPF computes a QR factorization with column pivoting of a */ | |||
| /* > real M-by-N matrix A: A*P = Q*R. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is REAL array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the upper triangle of the array contains the */ | |||
| /* > f2cmin(M,N)-by-N upper triangular matrix R; the elements */ | |||
| /* > below the diagonal, together with the array TAU, */ | |||
| /* > represent the orthogonal matrix Q as a product of */ | |||
| /* > f2cmin(m,n) elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] JPVT */ | |||
| /* > \verbatim */ | |||
| /* > JPVT is INTEGER array, dimension (N) */ | |||
| /* > On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted */ | |||
| /* > to the front of A*P (a leading column); if JPVT(i) = 0, */ | |||
| /* > the i-th column of A is a free column. */ | |||
| /* > On exit, if JPVT(i) = k, then the i-th column of A*P */ | |||
| /* > was the k-th column of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is REAL array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is REAL array, dimension (3*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup realGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(n) */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H = I - tau * v * v**T */ | |||
| /* > */ | |||
| /* > where tau is a real scalar, and v is a real vector with */ | |||
| /* > v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i). */ | |||
| /* > */ | |||
| /* > The matrix P is represented in jpvt as follows: If */ | |||
| /* > jpvt(j) = i */ | |||
| /* > then the jth column of P is the ith canonical unit vector. */ | |||
| /* > */ | |||
| /* > Partial column norm updating strategy modified by */ | |||
| /* > Z. Drmac and Z. Bujanovic, Dept. of Mathematics, */ | |||
| /* > University of Zagreb, Croatia. */ | |||
| /* > -- April 2011 -- */ | |||
| /* > For more details see LAPACK Working Note 176. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int sgeqpf_(integer *m, integer *n, real *a, integer *lda, | |||
| integer *jpvt, real *tau, real *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| real r__1, r__2; | |||
| /* Local variables */ | |||
| real temp, temp2; | |||
| extern real snrm2_(integer *, real *, integer *); | |||
| integer i__, j; | |||
| real tol3z; | |||
| extern /* Subroutine */ int slarf_(char *, integer *, integer *, real *, | |||
| integer *, real *, real *, integer *, real *); | |||
| integer itemp; | |||
| extern /* Subroutine */ int sswap_(integer *, real *, integer *, real *, | |||
| integer *), sgeqr2_(integer *, integer *, real *, integer *, real | |||
| *, real *, integer *); | |||
| integer ma; | |||
| extern /* Subroutine */ int sorm2r_(char *, char *, integer *, integer *, | |||
| integer *, real *, integer *, real *, real *, integer *, real *, | |||
| integer *); | |||
| integer mn; | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *), slarfg_( | |||
| integer *, real *, real *, integer *, real *); | |||
| extern integer isamax_(integer *, real *, integer *); | |||
| real aii; | |||
| integer pvt; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --jpvt; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("SGEQPF", &i__1); | |||
| return 0; | |||
| } | |||
| mn = f2cmin(*m,*n); | |||
| tol3z = sqrt(slamch_("Epsilon")); | |||
| /* Move initial columns up front */ | |||
| itemp = 1; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (jpvt[i__] != 0) { | |||
| if (i__ != itemp) { | |||
| sswap_(m, &a[i__ * a_dim1 + 1], &c__1, &a[itemp * a_dim1 + 1], | |||
| &c__1); | |||
| jpvt[i__] = jpvt[itemp]; | |||
| jpvt[itemp] = i__; | |||
| } else { | |||
| jpvt[i__] = i__; | |||
| } | |||
| ++itemp; | |||
| } else { | |||
| jpvt[i__] = i__; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| --itemp; | |||
| /* Compute the QR factorization and update remaining columns */ | |||
| if (itemp > 0) { | |||
| ma = f2cmin(itemp,*m); | |||
| sgeqr2_(m, &ma, &a[a_offset], lda, &tau[1], &work[1], info); | |||
| if (ma < *n) { | |||
| i__1 = *n - ma; | |||
| sorm2r_("Left", "Transpose", m, &i__1, &ma, &a[a_offset], lda, & | |||
| tau[1], &a[(ma + 1) * a_dim1 + 1], lda, &work[1], info); | |||
| } | |||
| } | |||
| if (itemp < mn) { | |||
| /* Initialize partial column norms. The first n elements of */ | |||
| /* work store the exact column norms. */ | |||
| i__1 = *n; | |||
| for (i__ = itemp + 1; i__ <= i__1; ++i__) { | |||
| i__2 = *m - itemp; | |||
| work[i__] = snrm2_(&i__2, &a[itemp + 1 + i__ * a_dim1], &c__1); | |||
| work[*n + i__] = work[i__]; | |||
| /* L20: */ | |||
| } | |||
| /* Compute factorization */ | |||
| i__1 = mn; | |||
| for (i__ = itemp + 1; i__ <= i__1; ++i__) { | |||
| /* Determine ith pivot column and swap if necessary */ | |||
| i__2 = *n - i__ + 1; | |||
| pvt = i__ - 1 + isamax_(&i__2, &work[i__], &c__1); | |||
| if (pvt != i__) { | |||
| sswap_(m, &a[pvt * a_dim1 + 1], &c__1, &a[i__ * a_dim1 + 1], & | |||
| c__1); | |||
| itemp = jpvt[pvt]; | |||
| jpvt[pvt] = jpvt[i__]; | |||
| jpvt[i__] = itemp; | |||
| work[pvt] = work[i__]; | |||
| work[*n + pvt] = work[*n + i__]; | |||
| } | |||
| /* Generate elementary reflector H(i) */ | |||
| if (i__ < *m) { | |||
| i__2 = *m - i__ + 1; | |||
| slarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + 1 + i__ * | |||
| a_dim1], &c__1, &tau[i__]); | |||
| } else { | |||
| slarfg_(&c__1, &a[*m + *m * a_dim1], &a[*m + *m * a_dim1], & | |||
| c__1, &tau[*m]); | |||
| } | |||
| if (i__ < *n) { | |||
| /* Apply H(i) to A(i:m,i+1:n) from the left */ | |||
| aii = a[i__ + i__ * a_dim1]; | |||
| a[i__ + i__ * a_dim1] = 1.f; | |||
| i__2 = *m - i__ + 1; | |||
| i__3 = *n - i__; | |||
| slarf_("LEFT", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, & | |||
| tau[i__], &a[i__ + (i__ + 1) * a_dim1], lda, &work[(* | |||
| n << 1) + 1]); | |||
| a[i__ + i__ * a_dim1] = aii; | |||
| } | |||
| /* Update partial column norms */ | |||
| i__2 = *n; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| if (work[j] != 0.f) { | |||
| /* NOTE: The following 4 lines follow from the analysis in */ | |||
| /* Lapack Working Note 176. */ | |||
| temp = (r__1 = a[i__ + j * a_dim1], abs(r__1)) / work[j]; | |||
| /* Computing MAX */ | |||
| r__1 = 0.f, r__2 = (temp + 1.f) * (1.f - temp); | |||
| temp = f2cmax(r__1,r__2); | |||
| /* Computing 2nd power */ | |||
| r__1 = work[j] / work[*n + j]; | |||
| temp2 = temp * (r__1 * r__1); | |||
| if (temp2 <= tol3z) { | |||
| if (*m - i__ > 0) { | |||
| i__3 = *m - i__; | |||
| work[j] = snrm2_(&i__3, &a[i__ + 1 + j * a_dim1], | |||
| &c__1); | |||
| work[*n + j] = work[j]; | |||
| } else { | |||
| work[j] = 0.f; | |||
| work[*n + j] = 0.f; | |||
| } | |||
| } else { | |||
| work[j] *= sqrt(temp); | |||
| } | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of SGEQPF */ | |||
| } /* sgeqpf_ */ | |||
| @@ -0,0 +1,905 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief <b> SGGSVD computes the singular value decomposition (SVD) for OTHER matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download SGGSVD + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sggsvd. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sggsvd. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sggsvd. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE SGGSVD( JOBU, JOBV, JOBQ, M, N, P, K, L, A, LDA, B, */ | |||
| /* LDB, ALPHA, BETA, U, LDU, V, LDV, Q, LDQ, WORK, */ | |||
| /* IWORK, INFO ) */ | |||
| /* CHARACTER JOBQ, JOBU, JOBV */ | |||
| /* INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N, P */ | |||
| /* INTEGER IWORK( * ) */ | |||
| /* REAL A( LDA, * ), ALPHA( * ), B( LDB, * ), */ | |||
| /* $ BETA( * ), Q( LDQ, * ), U( LDU, * ), */ | |||
| /* $ V( LDV, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine SGGSVD3. */ | |||
| /* > */ | |||
| /* > SGGSVD computes the generalized singular value decomposition (GSVD) */ | |||
| /* > of an M-by-N real matrix A and P-by-N real matrix B: */ | |||
| /* > */ | |||
| /* > U**T*A*Q = D1*( 0 R ), V**T*B*Q = D2*( 0 R ) */ | |||
| /* > */ | |||
| /* > where U, V and Q are orthogonal matrices. */ | |||
| /* > Let K+L = the effective numerical rank of the matrix (A**T,B**T)**T, */ | |||
| /* > then R is a K+L-by-K+L nonsingular upper triangular matrix, D1 and */ | |||
| /* > D2 are M-by-(K+L) and P-by-(K+L) "diagonal" matrices and of the */ | |||
| /* > following structures, respectively: */ | |||
| /* > */ | |||
| /* > If M-K-L >= 0, */ | |||
| /* > */ | |||
| /* > K L */ | |||
| /* > D1 = K ( I 0 ) */ | |||
| /* > L ( 0 C ) */ | |||
| /* > M-K-L ( 0 0 ) */ | |||
| /* > */ | |||
| /* > K L */ | |||
| /* > D2 = L ( 0 S ) */ | |||
| /* > P-L ( 0 0 ) */ | |||
| /* > */ | |||
| /* > N-K-L K L */ | |||
| /* > ( 0 R ) = K ( 0 R11 R12 ) */ | |||
| /* > L ( 0 0 R22 ) */ | |||
| /* > */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > C = diag( ALPHA(K+1), ... , ALPHA(K+L) ), */ | |||
| /* > S = diag( BETA(K+1), ... , BETA(K+L) ), */ | |||
| /* > C**2 + S**2 = I. */ | |||
| /* > */ | |||
| /* > R is stored in A(1:K+L,N-K-L+1:N) on exit. */ | |||
| /* > */ | |||
| /* > If M-K-L < 0, */ | |||
| /* > */ | |||
| /* > K M-K K+L-M */ | |||
| /* > D1 = K ( I 0 0 ) */ | |||
| /* > M-K ( 0 C 0 ) */ | |||
| /* > */ | |||
| /* > K M-K K+L-M */ | |||
| /* > D2 = M-K ( 0 S 0 ) */ | |||
| /* > K+L-M ( 0 0 I ) */ | |||
| /* > P-L ( 0 0 0 ) */ | |||
| /* > */ | |||
| /* > N-K-L K M-K K+L-M */ | |||
| /* > ( 0 R ) = K ( 0 R11 R12 R13 ) */ | |||
| /* > M-K ( 0 0 R22 R23 ) */ | |||
| /* > K+L-M ( 0 0 0 R33 ) */ | |||
| /* > */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > C = diag( ALPHA(K+1), ... , ALPHA(M) ), */ | |||
| /* > S = diag( BETA(K+1), ... , BETA(M) ), */ | |||
| /* > C**2 + S**2 = I. */ | |||
| /* > */ | |||
| /* > (R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N), and R33 is stored */ | |||
| /* > ( 0 R22 R23 ) */ | |||
| /* > in B(M-K+1:L,N+M-K-L+1:N) on exit. */ | |||
| /* > */ | |||
| /* > The routine computes C, S, R, and optionally the orthogonal */ | |||
| /* > transformation matrices U, V and Q. */ | |||
| /* > */ | |||
| /* > In particular, if B is an N-by-N nonsingular matrix, then the GSVD of */ | |||
| /* > A and B implicitly gives the SVD of A*inv(B): */ | |||
| /* > A*inv(B) = U*(D1*inv(D2))*V**T. */ | |||
| /* > If ( A**T,B**T)**T has orthonormal columns, then the GSVD of A and B is */ | |||
| /* > also equal to the CS decomposition of A and B. Furthermore, the GSVD */ | |||
| /* > can be used to derive the solution of the eigenvalue problem: */ | |||
| /* > A**T*A x = lambda* B**T*B x. */ | |||
| /* > In some literature, the GSVD of A and B is presented in the form */ | |||
| /* > U**T*A*X = ( 0 D1 ), V**T*B*X = ( 0 D2 ) */ | |||
| /* > where U and V are orthogonal and X is nonsingular, D1 and D2 are */ | |||
| /* > ``diagonal''. The former GSVD form can be converted to the latter */ | |||
| /* > form by taking the nonsingular matrix X as */ | |||
| /* > */ | |||
| /* > X = Q*( I 0 ) */ | |||
| /* > ( 0 inv(R) ). */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOBU */ | |||
| /* > \verbatim */ | |||
| /* > JOBU is CHARACTER*1 */ | |||
| /* > = 'U': Orthogonal matrix U is computed; */ | |||
| /* > = 'N': U is not computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] JOBV */ | |||
| /* > \verbatim */ | |||
| /* > JOBV is CHARACTER*1 */ | |||
| /* > = 'V': Orthogonal matrix V is computed; */ | |||
| /* > = 'N': V is not computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] JOBQ */ | |||
| /* > \verbatim */ | |||
| /* > JOBQ is CHARACTER*1 */ | |||
| /* > = 'Q': Orthogonal matrix Q is computed; */ | |||
| /* > = 'N': Q is not computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrices A and B. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] P */ | |||
| /* > \verbatim */ | |||
| /* > P is INTEGER */ | |||
| /* > The number of rows of the matrix B. P >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] L */ | |||
| /* > \verbatim */ | |||
| /* > L is INTEGER */ | |||
| /* > */ | |||
| /* > On exit, K and L specify the dimension of the subblocks */ | |||
| /* > described in Purpose. */ | |||
| /* > K + L = effective numerical rank of (A**T,B**T)**T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is REAL array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, A contains the triangular matrix R, or part of R. */ | |||
| /* > See Purpose for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is REAL array, dimension (LDB,N) */ | |||
| /* > On entry, the P-by-N matrix B. */ | |||
| /* > On exit, B contains the triangular matrix R if M-K-L < 0. */ | |||
| /* > See Purpose for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,P). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ALPHA */ | |||
| /* > \verbatim */ | |||
| /* > ALPHA is REAL array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] BETA */ | |||
| /* > \verbatim */ | |||
| /* > BETA is REAL array, dimension (N) */ | |||
| /* > */ | |||
| /* > On exit, ALPHA and BETA contain the generalized singular */ | |||
| /* > value pairs of A and B; */ | |||
| /* > ALPHA(1:K) = 1, */ | |||
| /* > BETA(1:K) = 0, */ | |||
| /* > and if M-K-L >= 0, */ | |||
| /* > ALPHA(K+1:K+L) = C, */ | |||
| /* > BETA(K+1:K+L) = S, */ | |||
| /* > or if M-K-L < 0, */ | |||
| /* > ALPHA(K+1:M)=C, ALPHA(M+1:K+L)=0 */ | |||
| /* > BETA(K+1:M) =S, BETA(M+1:K+L) =1 */ | |||
| /* > and */ | |||
| /* > ALPHA(K+L+1:N) = 0 */ | |||
| /* > BETA(K+L+1:N) = 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] U */ | |||
| /* > \verbatim */ | |||
| /* > U is REAL array, dimension (LDU,M) */ | |||
| /* > If JOBU = 'U', U contains the M-by-M orthogonal matrix U. */ | |||
| /* > If JOBU = 'N', U is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDU */ | |||
| /* > \verbatim */ | |||
| /* > LDU is INTEGER */ | |||
| /* > The leading dimension of the array U. LDU >= f2cmax(1,M) if */ | |||
| /* > JOBU = 'U'; LDU >= 1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] V */ | |||
| /* > \verbatim */ | |||
| /* > V is REAL array, dimension (LDV,P) */ | |||
| /* > If JOBV = 'V', V contains the P-by-P orthogonal matrix V. */ | |||
| /* > If JOBV = 'N', V is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. LDV >= f2cmax(1,P) if */ | |||
| /* > JOBV = 'V'; LDV >= 1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] Q */ | |||
| /* > \verbatim */ | |||
| /* > Q is REAL array, dimension (LDQ,N) */ | |||
| /* > If JOBQ = 'Q', Q contains the N-by-N orthogonal matrix Q. */ | |||
| /* > If JOBQ = 'N', Q is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDQ */ | |||
| /* > \verbatim */ | |||
| /* > LDQ is INTEGER */ | |||
| /* > The leading dimension of the array Q. LDQ >= f2cmax(1,N) if */ | |||
| /* > JOBQ = 'Q'; LDQ >= 1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is REAL array, */ | |||
| /* > dimension (f2cmax(3*N,M,P)+N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] IWORK */ | |||
| /* > \verbatim */ | |||
| /* > IWORK is INTEGER array, dimension (N) */ | |||
| /* > On exit, IWORK stores the sorting information. More */ | |||
| /* > precisely, the following loop will sort ALPHA */ | |||
| /* > for I = K+1, f2cmin(M,K+L) */ | |||
| /* > swap ALPHA(I) and ALPHA(IWORK(I)) */ | |||
| /* > endfor */ | |||
| /* > such that ALPHA(1) >= ALPHA(2) >= ... >= ALPHA(N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > > 0: if INFO = 1, the Jacobi-type procedure failed to */ | |||
| /* > converge. For further details, see subroutine STGSJA. */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > TOLA REAL */ | |||
| /* > TOLB REAL */ | |||
| /* > TOLA and TOLB are the thresholds to determine the effective */ | |||
| /* > rank of (A**T,B**T)**T. Generally, they are set to */ | |||
| /* > TOLA = MAX(M,N)*norm(A)*MACHEPS, */ | |||
| /* > TOLB = MAX(P,N)*norm(B)*MACHEPS. */ | |||
| /* > The size of TOLA and TOLB may affect the size of backward */ | |||
| /* > errors of the decomposition. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup realOTHERsing */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > Ming Gu and Huan Ren, Computer Science Division, University of */ | |||
| /* > California at Berkeley, USA */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int sggsvd_(char *jobu, char *jobv, char *jobq, integer *m, | |||
| integer *n, integer *p, integer *k, integer *l, real *a, integer *lda, | |||
| real *b, integer *ldb, real *alpha, real *beta, real *u, integer * | |||
| ldu, real *v, integer *ldv, real *q, integer *ldq, real *work, | |||
| integer *iwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, q_dim1, q_offset, u_dim1, | |||
| u_offset, v_dim1, v_offset, i__1, i__2; | |||
| /* Local variables */ | |||
| integer ibnd; | |||
| real tola; | |||
| integer isub; | |||
| real tolb, unfl, temp, smax; | |||
| integer ncallmycycle, i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| real anorm, bnorm; | |||
| logical wantq; | |||
| extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, | |||
| integer *); | |||
| logical wantu, wantv; | |||
| extern real slamch_(char *), slange_(char *, integer *, integer *, | |||
| real *, integer *, real *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *), stgsja_( | |||
| char *, char *, char *, integer *, integer *, integer *, integer * | |||
| , integer *, real *, integer *, real *, integer *, real *, real *, | |||
| real *, real *, real *, integer *, real *, integer *, real *, | |||
| integer *, real *, integer *, integer *), | |||
| sggsvp_(char *, char *, char *, integer *, integer *, integer *, | |||
| real *, integer *, real *, integer *, real *, real *, integer *, | |||
| integer *, real *, integer *, real *, integer *, real *, integer * | |||
| , integer *, real *, real *, integer *); | |||
| real ulp; | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| --alpha; | |||
| --beta; | |||
| u_dim1 = *ldu; | |||
| u_offset = 1 + u_dim1 * 1; | |||
| u -= u_offset; | |||
| v_dim1 = *ldv; | |||
| v_offset = 1 + v_dim1 * 1; | |||
| v -= v_offset; | |||
| q_dim1 = *ldq; | |||
| q_offset = 1 + q_dim1 * 1; | |||
| q -= q_offset; | |||
| --work; | |||
| --iwork; | |||
| /* Function Body */ | |||
| wantu = lsame_(jobu, "U"); | |||
| wantv = lsame_(jobv, "V"); | |||
| wantq = lsame_(jobq, "Q"); | |||
| *info = 0; | |||
| if (! (wantu || lsame_(jobu, "N"))) { | |||
| *info = -1; | |||
| } else if (! (wantv || lsame_(jobv, "N"))) { | |||
| *info = -2; | |||
| } else if (! (wantq || lsame_(jobq, "N"))) { | |||
| *info = -3; | |||
| } else if (*m < 0) { | |||
| *info = -4; | |||
| } else if (*n < 0) { | |||
| *info = -5; | |||
| } else if (*p < 0) { | |||
| *info = -6; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -10; | |||
| } else if (*ldb < f2cmax(1,*p)) { | |||
| *info = -12; | |||
| } else if (*ldu < 1 || wantu && *ldu < *m) { | |||
| *info = -16; | |||
| } else if (*ldv < 1 || wantv && *ldv < *p) { | |||
| *info = -18; | |||
| } else if (*ldq < 1 || wantq && *ldq < *n) { | |||
| *info = -20; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("SGGSVD", &i__1); | |||
| return 0; | |||
| } | |||
| /* Compute the Frobenius norm of matrices A and B */ | |||
| anorm = slange_("1", m, n, &a[a_offset], lda, &work[1]); | |||
| bnorm = slange_("1", p, n, &b[b_offset], ldb, &work[1]); | |||
| /* Get machine precision and set up threshold for determining */ | |||
| /* the effective numerical rank of the matrices A and B. */ | |||
| ulp = slamch_("Precision"); | |||
| unfl = slamch_("Safe Minimum"); | |||
| tola = f2cmax(*m,*n) * f2cmax(anorm,unfl) * ulp; | |||
| tolb = f2cmax(*p,*n) * f2cmax(bnorm,unfl) * ulp; | |||
| /* Preprocessing */ | |||
| sggsvp_(jobu, jobv, jobq, m, p, n, &a[a_offset], lda, &b[b_offset], ldb, & | |||
| tola, &tolb, k, l, &u[u_offset], ldu, &v[v_offset], ldv, &q[ | |||
| q_offset], ldq, &iwork[1], &work[1], &work[*n + 1], info); | |||
| /* Compute the GSVD of two upper "triangular" matrices */ | |||
| stgsja_(jobu, jobv, jobq, m, p, n, k, l, &a[a_offset], lda, &b[b_offset], | |||
| ldb, &tola, &tolb, &alpha[1], &beta[1], &u[u_offset], ldu, &v[ | |||
| v_offset], ldv, &q[q_offset], ldq, &work[1], &ncallmycycle, info); | |||
| /* Sort the singular values and store the pivot indices in IWORK */ | |||
| /* Copy ALPHA to WORK, then sort ALPHA in WORK */ | |||
| scopy_(n, &alpha[1], &c__1, &work[1], &c__1); | |||
| /* Computing MIN */ | |||
| i__1 = *l, i__2 = *m - *k; | |||
| ibnd = f2cmin(i__1,i__2); | |||
| i__1 = ibnd; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Scan for largest ALPHA(K+I) */ | |||
| isub = i__; | |||
| smax = work[*k + i__]; | |||
| i__2 = ibnd; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| temp = work[*k + j]; | |||
| if (temp > smax) { | |||
| isub = j; | |||
| smax = temp; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| if (isub != i__) { | |||
| work[*k + isub] = work[*k + i__]; | |||
| work[*k + i__] = smax; | |||
| iwork[*k + i__] = *k + isub; | |||
| } else { | |||
| iwork[*k + i__] = *k + i__; | |||
| } | |||
| /* L20: */ | |||
| } | |||
| return 0; | |||
| /* End of SGGSVD */ | |||
| } /* sggsvd_ */ | |||
| @@ -0,0 +1,739 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static real c_b4 = -1.f; | |||
| static real c_b5 = 1.f; | |||
| static integer c__1 = 1; | |||
| static real c_b38 = 0.f; | |||
| /* > \brief \b SLAHRD reduces the first nb columns of a general rectangular matrix A so that elements below th | |||
| e k-th subdiagonal are zero, and returns auxiliary matrices which are needed to apply the transformati | |||
| on to the unreduced part of A. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download SLAHRD + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slahrd. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slahrd. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slahrd. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE SLAHRD( N, K, NB, A, LDA, TAU, T, LDT, Y, LDY ) */ | |||
| /* INTEGER K, LDA, LDT, LDY, N, NB */ | |||
| /* REAL A( LDA, * ), T( LDT, NB ), TAU( NB ), */ | |||
| /* $ Y( LDY, NB ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine SLAHR2. */ | |||
| /* > */ | |||
| /* > SLAHRD reduces the first NB columns of a real general n-by-(n-k+1) */ | |||
| /* > matrix A so that elements below the k-th subdiagonal are zero. The */ | |||
| /* > reduction is performed by an orthogonal similarity transformation */ | |||
| /* > Q**T * A * Q. The routine returns the matrices V and T which determine */ | |||
| /* > Q as a block reflector I - V*T*V**T, and also the matrix Y = A * V * T. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The offset for the reduction. Elements below the k-th */ | |||
| /* > subdiagonal in the first NB columns are reduced to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The number of columns to be reduced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is REAL array, dimension (LDA,N-K+1) */ | |||
| /* > On entry, the n-by-(n-k+1) general matrix A. */ | |||
| /* > On exit, the elements on and above the k-th subdiagonal in */ | |||
| /* > the first NB columns are overwritten with the corresponding */ | |||
| /* > elements of the reduced matrix; the elements below the k-th */ | |||
| /* > subdiagonal, with the array TAU, represent the matrix Q as a */ | |||
| /* > product of elementary reflectors. The other columns of A are */ | |||
| /* > unchanged. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is REAL array, dimension (NB) */ | |||
| /* > The scalar factors of the elementary reflectors. See Further */ | |||
| /* > Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] T */ | |||
| /* > \verbatim */ | |||
| /* > T is REAL array, dimension (LDT,NB) */ | |||
| /* > The upper triangular matrix T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= NB. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] Y */ | |||
| /* > \verbatim */ | |||
| /* > Y is REAL array, dimension (LDY,NB) */ | |||
| /* > The n-by-nb matrix Y. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDY */ | |||
| /* > \verbatim */ | |||
| /* > LDY is INTEGER */ | |||
| /* > The leading dimension of the array Y. LDY >= N. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup realOTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of nb elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(nb). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**T */ | |||
| /* > */ | |||
| /* > where tau is a real scalar, and v is a real vector with */ | |||
| /* > v(1:i+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in */ | |||
| /* > A(i+k+1:n,i), and tau in TAU(i). */ | |||
| /* > */ | |||
| /* > The elements of the vectors v together form the (n-k+1)-by-nb matrix */ | |||
| /* > V which is needed, with T and Y, to apply the transformation to the */ | |||
| /* > unreduced part of the matrix, using an update of the form: */ | |||
| /* > A := (I - V*T*V**T) * (A - Y*V**T). */ | |||
| /* > */ | |||
| /* > The contents of A on exit are illustrated by the following example */ | |||
| /* > with n = 7, k = 3 and nb = 2: */ | |||
| /* > */ | |||
| /* > ( a h a a a ) */ | |||
| /* > ( a h a a a ) */ | |||
| /* > ( a h a a a ) */ | |||
| /* > ( h h a a a ) */ | |||
| /* > ( v1 h a a a ) */ | |||
| /* > ( v1 v2 a a a ) */ | |||
| /* > ( v1 v2 a a a ) */ | |||
| /* > */ | |||
| /* > where a denotes an element of the original matrix A, h denotes a */ | |||
| /* > modified element of the upper Hessenberg matrix H, and vi denotes an */ | |||
| /* > element of the vector defining H(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int slahrd_(integer *n, integer *k, integer *nb, real *a, | |||
| integer *lda, real *tau, real *t, integer *ldt, real *y, integer *ldy) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, y_dim1, y_offset, i__1, i__2, | |||
| i__3; | |||
| real r__1; | |||
| /* Local variables */ | |||
| integer i__; | |||
| extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *), | |||
| sgemv_(char *, integer *, integer *, real *, real *, integer *, | |||
| real *, integer *, real *, real *, integer *), scopy_( | |||
| integer *, real *, integer *, real *, integer *), saxpy_(integer * | |||
| , real *, real *, integer *, real *, integer *), strmv_(char *, | |||
| char *, char *, integer *, real *, integer *, real *, integer *); | |||
| real ei; | |||
| extern /* Subroutine */ int slarfg_(integer *, real *, real *, integer *, | |||
| real *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| --tau; | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| y_dim1 = *ldy; | |||
| y_offset = 1 + y_dim1 * 1; | |||
| y -= y_offset; | |||
| /* Function Body */ | |||
| if (*n <= 1) { | |||
| return 0; | |||
| } | |||
| i__1 = *nb; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (i__ > 1) { | |||
| /* Update A(1:n,i) */ | |||
| /* Compute i-th column of A - Y * V**T */ | |||
| i__2 = i__ - 1; | |||
| sgemv_("No transpose", n, &i__2, &c_b4, &y[y_offset], ldy, &a[*k | |||
| + i__ - 1 + a_dim1], lda, &c_b5, &a[i__ * a_dim1 + 1], & | |||
| c__1); | |||
| /* Apply I - V * T**T * V**T to this column (call it b) from the */ | |||
| /* left, using the last column of T as workspace */ | |||
| /* Let V = ( V1 ) and b = ( b1 ) (first I-1 rows) */ | |||
| /* ( V2 ) ( b2 ) */ | |||
| /* where V1 is unit lower triangular */ | |||
| /* w := V1**T * b1 */ | |||
| i__2 = i__ - 1; | |||
| scopy_(&i__2, &a[*k + 1 + i__ * a_dim1], &c__1, &t[*nb * t_dim1 + | |||
| 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| strmv_("Lower", "Transpose", "Unit", &i__2, &a[*k + 1 + a_dim1], | |||
| lda, &t[*nb * t_dim1 + 1], &c__1); | |||
| /* w := w + V2**T *b2 */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| sgemv_("Transpose", &i__2, &i__3, &c_b5, &a[*k + i__ + a_dim1], | |||
| lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b5, &t[*nb * | |||
| t_dim1 + 1], &c__1); | |||
| /* w := T**T *w */ | |||
| i__2 = i__ - 1; | |||
| strmv_("Upper", "Transpose", "Non-unit", &i__2, &t[t_offset], ldt, | |||
| &t[*nb * t_dim1 + 1], &c__1); | |||
| /* b2 := b2 - V2*w */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| sgemv_("No transpose", &i__2, &i__3, &c_b4, &a[*k + i__ + a_dim1], | |||
| lda, &t[*nb * t_dim1 + 1], &c__1, &c_b5, &a[*k + i__ + | |||
| i__ * a_dim1], &c__1); | |||
| /* b1 := b1 - V1*w */ | |||
| i__2 = i__ - 1; | |||
| strmv_("Lower", "No transpose", "Unit", &i__2, &a[*k + 1 + a_dim1] | |||
| , lda, &t[*nb * t_dim1 + 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| saxpy_(&i__2, &c_b4, &t[*nb * t_dim1 + 1], &c__1, &a[*k + 1 + i__ | |||
| * a_dim1], &c__1); | |||
| a[*k + i__ - 1 + (i__ - 1) * a_dim1] = ei; | |||
| } | |||
| /* Generate the elementary reflector H(i) to annihilate */ | |||
| /* A(k+i+1:n,i) */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = *k + i__ + 1; | |||
| slarfg_(&i__2, &a[*k + i__ + i__ * a_dim1], &a[f2cmin(i__3,*n) + i__ * | |||
| a_dim1], &c__1, &tau[i__]); | |||
| ei = a[*k + i__ + i__ * a_dim1]; | |||
| a[*k + i__ + i__ * a_dim1] = 1.f; | |||
| /* Compute Y(1:n,i) */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| sgemv_("No transpose", n, &i__2, &c_b5, &a[(i__ + 1) * a_dim1 + 1], | |||
| lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b38, &y[i__ * | |||
| y_dim1 + 1], &c__1); | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| sgemv_("Transpose", &i__2, &i__3, &c_b5, &a[*k + i__ + a_dim1], lda, & | |||
| a[*k + i__ + i__ * a_dim1], &c__1, &c_b38, &t[i__ * t_dim1 + | |||
| 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| sgemv_("No transpose", n, &i__2, &c_b4, &y[y_offset], ldy, &t[i__ * | |||
| t_dim1 + 1], &c__1, &c_b5, &y[i__ * y_dim1 + 1], &c__1); | |||
| sscal_(n, &tau[i__], &y[i__ * y_dim1 + 1], &c__1); | |||
| /* Compute T(1:i,i) */ | |||
| i__2 = i__ - 1; | |||
| r__1 = -tau[i__]; | |||
| sscal_(&i__2, &r__1, &t[i__ * t_dim1 + 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| strmv_("Upper", "No transpose", "Non-unit", &i__2, &t[t_offset], ldt, | |||
| &t[i__ * t_dim1 + 1], &c__1) | |||
| ; | |||
| t[i__ + i__ * t_dim1] = tau[i__]; | |||
| /* L10: */ | |||
| } | |||
| a[*k + *nb + *nb * a_dim1] = ei; | |||
| return 0; | |||
| /* End of SLAHRD */ | |||
| } /* slahrd_ */ | |||
| @@ -0,0 +1,643 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static real c_b5 = 1.f; | |||
| /* > \brief \b SLATZM */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download SLATZM + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slatzm. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slatzm. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slatzm. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE SLATZM( SIDE, M, N, V, INCV, TAU, C1, C2, LDC, WORK ) */ | |||
| /* CHARACTER SIDE */ | |||
| /* INTEGER INCV, LDC, M, N */ | |||
| /* REAL TAU */ | |||
| /* REAL C1( LDC, * ), C2( LDC, * ), V( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine SORMRZ. */ | |||
| /* > */ | |||
| /* > SLATZM applies a Householder matrix generated by STZRQF to a matrix. */ | |||
| /* > */ | |||
| /* > Let P = I - tau*u*u**T, u = ( 1 ), */ | |||
| /* > ( v ) */ | |||
| /* > where v is an (m-1) vector if SIDE = 'L', or a (n-1) vector if */ | |||
| /* > SIDE = 'R'. */ | |||
| /* > */ | |||
| /* > If SIDE equals 'L', let */ | |||
| /* > C = [ C1 ] 1 */ | |||
| /* > [ C2 ] m-1 */ | |||
| /* > n */ | |||
| /* > Then C is overwritten by P*C. */ | |||
| /* > */ | |||
| /* > If SIDE equals 'R', let */ | |||
| /* > C = [ C1, C2 ] m */ | |||
| /* > 1 n-1 */ | |||
| /* > Then C is overwritten by C*P. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': form P * C */ | |||
| /* > = 'R': form C * P */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is REAL array, dimension */ | |||
| /* > (1 + (M-1)*abs(INCV)) if SIDE = 'L' */ | |||
| /* > (1 + (N-1)*abs(INCV)) if SIDE = 'R' */ | |||
| /* > The vector v in the representation of P. V is not used */ | |||
| /* > if TAU = 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCV */ | |||
| /* > \verbatim */ | |||
| /* > INCV is INTEGER */ | |||
| /* > The increment between elements of v. INCV <> 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is REAL */ | |||
| /* > The value tau in the representation of P. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C1 */ | |||
| /* > \verbatim */ | |||
| /* > C1 is REAL array, dimension */ | |||
| /* > (LDC,N) if SIDE = 'L' */ | |||
| /* > (M,1) if SIDE = 'R' */ | |||
| /* > On entry, the n-vector C1 if SIDE = 'L', or the m-vector C1 */ | |||
| /* > if SIDE = 'R'. */ | |||
| /* > */ | |||
| /* > On exit, the first row of P*C if SIDE = 'L', or the first */ | |||
| /* > column of C*P if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C2 */ | |||
| /* > \verbatim */ | |||
| /* > C2 is REAL array, dimension */ | |||
| /* > (LDC, N) if SIDE = 'L' */ | |||
| /* > (LDC, N-1) if SIDE = 'R' */ | |||
| /* > On entry, the (m - 1) x n matrix C2 if SIDE = 'L', or the */ | |||
| /* > m x (n - 1) matrix C2 if SIDE = 'R'. */ | |||
| /* > */ | |||
| /* > On exit, rows 2:m of P*C if SIDE = 'L', or columns 2:m of C*P */ | |||
| /* > if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the arrays C1 and C2. LDC >= (1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is REAL array, dimension */ | |||
| /* > (N) if SIDE = 'L' */ | |||
| /* > (M) if SIDE = 'R' */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup realOTHERcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int slatzm_(char *side, integer *m, integer *n, real *v, | |||
| integer *incv, real *tau, real *c1, real *c2, integer *ldc, real * | |||
| work) | |||
| { | |||
| /* System generated locals */ | |||
| integer c1_dim1, c1_offset, c2_dim1, c2_offset, i__1; | |||
| real r__1; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int sger_(integer *, integer *, real *, real *, | |||
| integer *, real *, integer *, real *, integer *); | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int sgemv_(char *, integer *, integer *, real *, | |||
| real *, integer *, real *, integer *, real *, real *, integer *), scopy_(integer *, real *, integer *, real *, integer *), | |||
| saxpy_(integer *, real *, real *, integer *, real *, integer *); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --v; | |||
| c2_dim1 = *ldc; | |||
| c2_offset = 1 + c2_dim1 * 1; | |||
| c2 -= c2_offset; | |||
| c1_dim1 = *ldc; | |||
| c1_offset = 1 + c1_dim1 * 1; | |||
| c1 -= c1_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (f2cmin(*m,*n) == 0 || *tau == 0.f) { | |||
| return 0; | |||
| } | |||
| if (lsame_(side, "L")) { | |||
| /* w := (C1 + v**T * C2)**T */ | |||
| scopy_(n, &c1[c1_offset], ldc, &work[1], &c__1); | |||
| i__1 = *m - 1; | |||
| sgemv_("Transpose", &i__1, n, &c_b5, &c2[c2_offset], ldc, &v[1], incv, | |||
| &c_b5, &work[1], &c__1); | |||
| /* [ C1 ] := [ C1 ] - tau* [ 1 ] * w**T */ | |||
| /* [ C2 ] [ C2 ] [ v ] */ | |||
| r__1 = -(*tau); | |||
| saxpy_(n, &r__1, &work[1], &c__1, &c1[c1_offset], ldc); | |||
| i__1 = *m - 1; | |||
| r__1 = -(*tau); | |||
| sger_(&i__1, n, &r__1, &v[1], incv, &work[1], &c__1, &c2[c2_offset], | |||
| ldc); | |||
| } else if (lsame_(side, "R")) { | |||
| /* w := C1 + C2 * v */ | |||
| scopy_(m, &c1[c1_offset], &c__1, &work[1], &c__1); | |||
| i__1 = *n - 1; | |||
| sgemv_("No transpose", m, &i__1, &c_b5, &c2[c2_offset], ldc, &v[1], | |||
| incv, &c_b5, &work[1], &c__1); | |||
| /* [ C1, C2 ] := [ C1, C2 ] - tau* w * [ 1 , v**T] */ | |||
| r__1 = -(*tau); | |||
| saxpy_(m, &r__1, &work[1], &c__1, &c1[c1_offset], &c__1); | |||
| i__1 = *n - 1; | |||
| r__1 = -(*tau); | |||
| sger_(m, &i__1, &r__1, &work[1], &c__1, &v[1], incv, &c2[c2_offset], | |||
| ldc); | |||
| } | |||
| return 0; | |||
| /* End of SLATZM */ | |||
| } /* slatzm_ */ | |||
| @@ -0,0 +1,663 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static real c_b8 = 1.f; | |||
| /* > \brief \b STZRQF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download STZRQF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/stzrqf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/stzrqf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/stzrqf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE STZRQF( M, N, A, LDA, TAU, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* REAL A( LDA, * ), TAU( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine STZRZF. */ | |||
| /* > */ | |||
| /* > STZRQF reduces the M-by-N ( M<=N ) real upper trapezoidal matrix A */ | |||
| /* > to upper triangular form by means of orthogonal transformations. */ | |||
| /* > */ | |||
| /* > The upper trapezoidal matrix A is factored as */ | |||
| /* > */ | |||
| /* > A = ( R 0 ) * Z, */ | |||
| /* > */ | |||
| /* > where Z is an N-by-N orthogonal matrix and R is an M-by-M upper */ | |||
| /* > triangular matrix. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= M. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is REAL array, dimension (LDA,N) */ | |||
| /* > On entry, the leading M-by-N upper trapezoidal part of the */ | |||
| /* > array A must contain the matrix to be factorized. */ | |||
| /* > On exit, the leading M-by-M upper triangular part of A */ | |||
| /* > contains the upper triangular matrix R, and elements M+1 to */ | |||
| /* > N of the first M rows of A, with the array TAU, represent the */ | |||
| /* > orthogonal matrix Z as a product of M elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is REAL array, dimension (M) */ | |||
| /* > The scalar factors of the elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup realOTHERcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The factorization is obtained by Householder's method. The kth */ | |||
| /* > transformation matrix, Z( k ), which is used to introduce zeros into */ | |||
| /* > the ( m - k + 1 )th row of A, is given in the form */ | |||
| /* > */ | |||
| /* > Z( k ) = ( I 0 ), */ | |||
| /* > ( 0 T( k ) ) */ | |||
| /* > */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > T( k ) = I - tau*u( k )*u( k )**T, u( k ) = ( 1 ), */ | |||
| /* > ( 0 ) */ | |||
| /* > ( z( k ) ) */ | |||
| /* > */ | |||
| /* > tau is a scalar and z( k ) is an ( n - m ) element vector. */ | |||
| /* > tau and z( k ) are chosen to annihilate the elements of the kth row */ | |||
| /* > of X. */ | |||
| /* > */ | |||
| /* > The scalar tau is returned in the kth element of TAU and the vector */ | |||
| /* > u( k ) in the kth row of A, such that the elements of z( k ) are */ | |||
| /* > in a( k, m + 1 ), ..., a( k, n ). The elements of R are returned in */ | |||
| /* > the upper triangular part of A. */ | |||
| /* > */ | |||
| /* > Z is given by */ | |||
| /* > */ | |||
| /* > Z = Z( 1 ) * Z( 2 ) * ... * Z( m ). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int stzrqf_(integer *m, integer *n, real *a, integer *lda, | |||
| real *tau, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| real r__1; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int sger_(integer *, integer *, real *, real *, | |||
| integer *, real *, integer *, real *, integer *); | |||
| integer i__, k; | |||
| extern /* Subroutine */ int sgemv_(char *, integer *, integer *, real *, | |||
| real *, integer *, real *, integer *, real *, real *, integer *), scopy_(integer *, real *, integer *, real *, integer *); | |||
| integer m1; | |||
| extern /* Subroutine */ int saxpy_(integer *, real *, real *, integer *, | |||
| real *, integer *), xerbla_(char *, integer *), slarfg_( | |||
| integer *, real *, real *, integer *, real *); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < *m) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("STZRQF", &i__1); | |||
| return 0; | |||
| } | |||
| /* Perform the factorization. */ | |||
| if (*m == 0) { | |||
| return 0; | |||
| } | |||
| if (*m == *n) { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| tau[i__] = 0.f; | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| /* Computing MIN */ | |||
| i__1 = *m + 1; | |||
| m1 = f2cmin(i__1,*n); | |||
| for (k = *m; k >= 1; --k) { | |||
| /* Use a Householder reflection to zero the kth row of A. */ | |||
| /* First set up the reflection. */ | |||
| i__1 = *n - *m + 1; | |||
| slarfg_(&i__1, &a[k + k * a_dim1], &a[k + m1 * a_dim1], lda, &tau[ | |||
| k]); | |||
| if (tau[k] != 0.f && k > 1) { | |||
| /* We now perform the operation A := A*P( k ). */ | |||
| /* Use the first ( k - 1 ) elements of TAU to store a( k ), */ | |||
| /* where a( k ) consists of the first ( k - 1 ) elements of */ | |||
| /* the kth column of A. Also let B denote the first */ | |||
| /* ( k - 1 ) rows of the last ( n - m ) columns of A. */ | |||
| i__1 = k - 1; | |||
| scopy_(&i__1, &a[k * a_dim1 + 1], &c__1, &tau[1], &c__1); | |||
| /* Form w = a( k ) + B*z( k ) in TAU. */ | |||
| i__1 = k - 1; | |||
| i__2 = *n - *m; | |||
| sgemv_("No transpose", &i__1, &i__2, &c_b8, &a[m1 * a_dim1 + | |||
| 1], lda, &a[k + m1 * a_dim1], lda, &c_b8, &tau[1], & | |||
| c__1); | |||
| /* Now form a( k ) := a( k ) - tau*w */ | |||
| /* and B := B - tau*w*z( k )**T. */ | |||
| i__1 = k - 1; | |||
| r__1 = -tau[k]; | |||
| saxpy_(&i__1, &r__1, &tau[1], &c__1, &a[k * a_dim1 + 1], & | |||
| c__1); | |||
| i__1 = k - 1; | |||
| i__2 = *n - *m; | |||
| r__1 = -tau[k]; | |||
| sger_(&i__1, &i__2, &r__1, &tau[1], &c__1, &a[k + m1 * a_dim1] | |||
| , lda, &a[m1 * a_dim1 + 1], lda); | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of STZRQF */ | |||
| } /* stzrqf_ */ | |||
| @@ -0,0 +1,929 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {0.,0.}; | |||
| static doublecomplex c_b2 = {1.,0.}; | |||
| static integer c__0 = 0; | |||
| static integer c__2 = 2; | |||
| static integer c__1 = 1; | |||
| /* > \brief <b> ZGELSX solves overdetermined or underdetermined systems for GE matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZGELSX + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgelsx. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgelsx. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgelsx. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZGELSX( M, N, NRHS, A, LDA, B, LDB, JPVT, RCOND, RANK, */ | |||
| /* WORK, RWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LDB, M, N, NRHS, RANK */ | |||
| /* DOUBLE PRECISION RCOND */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* DOUBLE PRECISION RWORK( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine ZGELSY. */ | |||
| /* > */ | |||
| /* > ZGELSX computes the minimum-norm solution to a complex linear least */ | |||
| /* > squares problem: */ | |||
| /* > minimize || A * X - B || */ | |||
| /* > using a complete orthogonal factorization of A. A is an M-by-N */ | |||
| /* > matrix which may be rank-deficient. */ | |||
| /* > */ | |||
| /* > Several right hand side vectors b and solution vectors x can be */ | |||
| /* > handled in a single call; they are stored as the columns of the */ | |||
| /* > M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ | |||
| /* > matrix X. */ | |||
| /* > */ | |||
| /* > The routine first computes a QR factorization with column pivoting: */ | |||
| /* > A * P = Q * [ R11 R12 ] */ | |||
| /* > [ 0 R22 ] */ | |||
| /* > with R11 defined as the largest leading submatrix whose estimated */ | |||
| /* > condition number is less than 1/RCOND. The order of R11, RANK, */ | |||
| /* > is the effective rank of A. */ | |||
| /* > */ | |||
| /* > Then, R22 is considered to be negligible, and R12 is annihilated */ | |||
| /* > by unitary transformations from the right, arriving at the */ | |||
| /* > complete orthogonal factorization: */ | |||
| /* > A * P = Q * [ T11 0 ] * Z */ | |||
| /* > [ 0 0 ] */ | |||
| /* > The minimum-norm solution is then */ | |||
| /* > X = P * Z**H [ inv(T11)*Q1**H*B ] */ | |||
| /* > [ 0 ] */ | |||
| /* > where Q1 consists of the first RANK columns of Q. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of */ | |||
| /* > columns of matrices B and X. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, A has been overwritten by details of its */ | |||
| /* > complete orthogonal factorization. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX*16 array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the M-by-NRHS right hand side matrix B. */ | |||
| /* > On exit, the N-by-NRHS solution matrix X. */ | |||
| /* > If m >= n and RANK = n, the residual sum-of-squares for */ | |||
| /* > the solution in the i-th column is given by the sum of */ | |||
| /* > squares of elements N+1:M in that column. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,M,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] JPVT */ | |||
| /* > \verbatim */ | |||
| /* > JPVT is INTEGER array, dimension (N) */ | |||
| /* > On entry, if JPVT(i) .ne. 0, the i-th column of A is an */ | |||
| /* > initial column, otherwise it is a free column. Before */ | |||
| /* > the QR factorization of A, all initial columns are */ | |||
| /* > permuted to the leading positions; only the remaining */ | |||
| /* > free columns are moved as a result of column pivoting */ | |||
| /* > during the factorization. */ | |||
| /* > On exit, if JPVT(i) = k, then the i-th column of A*P */ | |||
| /* > was the k-th column of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] RCOND */ | |||
| /* > \verbatim */ | |||
| /* > RCOND is DOUBLE PRECISION */ | |||
| /* > RCOND is used to determine the effective rank of A, which */ | |||
| /* > is defined as the order of the largest leading triangular */ | |||
| /* > submatrix R11 in the QR factorization with pivoting of A, */ | |||
| /* > whose estimated condition number < 1/RCOND. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RANK */ | |||
| /* > \verbatim */ | |||
| /* > RANK is INTEGER */ | |||
| /* > The effective rank of A, i.e., the order of the submatrix */ | |||
| /* > R11. This is the same as the order of the submatrix T11 */ | |||
| /* > in the complete orthogonal factorization of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX*16 array, dimension */ | |||
| /* > (f2cmin(M,N) + f2cmax( N, 2*f2cmin(M,N)+NRHS )), */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is DOUBLE PRECISION array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16GEsolve */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zgelsx_(integer *m, integer *n, integer *nrhs, | |||
| doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb, | |||
| integer *jpvt, doublereal *rcond, integer *rank, doublecomplex *work, | |||
| doublereal *rwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| doublereal anrm, bnrm, smin, smax; | |||
| integer i__, j, k, iascl, ibscl, ismin, ismax; | |||
| doublecomplex c1, c2, s1, s2, t1, t2; | |||
| extern /* Subroutine */ int ztrsm_(char *, char *, char *, char *, | |||
| integer *, integer *, doublecomplex *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *), | |||
| zlaic1_(integer *, integer *, doublecomplex *, doublereal *, | |||
| doublecomplex *, doublecomplex *, doublereal *, doublecomplex *, | |||
| doublecomplex *), dlabad_(doublereal *, doublereal *); | |||
| extern doublereal dlamch_(char *); | |||
| integer mn; | |||
| extern /* Subroutine */ int zunm2r_(char *, char *, integer *, integer *, | |||
| integer *, doublecomplex *, integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *), xerbla_(char *, integer *); | |||
| extern doublereal zlange_(char *, integer *, integer *, doublecomplex *, | |||
| integer *, doublereal *); | |||
| doublereal bignum; | |||
| extern /* Subroutine */ int zlascl_(char *, integer *, integer *, | |||
| doublereal *, doublereal *, integer *, integer *, doublecomplex *, | |||
| integer *, integer *), zgeqpf_(integer *, integer *, | |||
| doublecomplex *, integer *, integer *, doublecomplex *, | |||
| doublecomplex *, doublereal *, integer *), zlaset_(char *, | |||
| integer *, integer *, doublecomplex *, doublecomplex *, | |||
| doublecomplex *, integer *); | |||
| doublereal sminpr, smaxpr, smlnum; | |||
| extern /* Subroutine */ int zlatzm_(char *, integer *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *), ztzrqf_( | |||
| integer *, integer *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *); | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| --jpvt; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| mn = f2cmin(*m,*n); | |||
| ismin = mn + 1; | |||
| ismax = (mn << 1) + 1; | |||
| /* Test the input arguments. */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*nrhs < 0) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -5; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(1,*m); | |||
| if (*ldb < f2cmax(i__1,*n)) { | |||
| *info = -7; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("ZGELSX", &i__1); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*nrhs) == 0) { | |||
| *rank = 0; | |||
| return 0; | |||
| } | |||
| /* Get machine parameters */ | |||
| smlnum = dlamch_("S") / dlamch_("P"); | |||
| bignum = 1. / smlnum; | |||
| dlabad_(&smlnum, &bignum); | |||
| /* Scale A, B if f2cmax elements outside range [SMLNUM,BIGNUM] */ | |||
| anrm = zlange_("M", m, n, &a[a_offset], lda, &rwork[1]); | |||
| iascl = 0; | |||
| if (anrm > 0. && anrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| zlascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 1; | |||
| } else if (anrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| zlascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 2; | |||
| } else if (anrm == 0.) { | |||
| /* Matrix all zero. Return zero solution. */ | |||
| i__1 = f2cmax(*m,*n); | |||
| zlaset_("F", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| *rank = 0; | |||
| goto L100; | |||
| } | |||
| bnrm = zlange_("M", m, nrhs, &b[b_offset], ldb, &rwork[1]); | |||
| ibscl = 0; | |||
| if (bnrm > 0. && bnrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| zlascl_("G", &c__0, &c__0, &bnrm, &smlnum, m, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| ibscl = 1; | |||
| } else if (bnrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| zlascl_("G", &c__0, &c__0, &bnrm, &bignum, m, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| ibscl = 2; | |||
| } | |||
| /* Compute QR factorization with column pivoting of A: */ | |||
| /* A * P = Q * R */ | |||
| zgeqpf_(m, n, &a[a_offset], lda, &jpvt[1], &work[1], &work[mn + 1], & | |||
| rwork[1], info); | |||
| /* complex workspace MN+N. Real workspace 2*N. Details of Householder */ | |||
| /* rotations stored in WORK(1:MN). */ | |||
| /* Determine RANK using incremental condition estimation */ | |||
| i__1 = ismin; | |||
| work[i__1].r = 1., work[i__1].i = 0.; | |||
| i__1 = ismax; | |||
| work[i__1].r = 1., work[i__1].i = 0.; | |||
| smax = z_abs(&a[a_dim1 + 1]); | |||
| smin = smax; | |||
| if (z_abs(&a[a_dim1 + 1]) == 0.) { | |||
| *rank = 0; | |||
| i__1 = f2cmax(*m,*n); | |||
| zlaset_("F", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| goto L100; | |||
| } else { | |||
| *rank = 1; | |||
| } | |||
| L10: | |||
| if (*rank < mn) { | |||
| i__ = *rank + 1; | |||
| zlaic1_(&c__2, rank, &work[ismin], &smin, &a[i__ * a_dim1 + 1], &a[ | |||
| i__ + i__ * a_dim1], &sminpr, &s1, &c1); | |||
| zlaic1_(&c__1, rank, &work[ismax], &smax, &a[i__ * a_dim1 + 1], &a[ | |||
| i__ + i__ * a_dim1], &smaxpr, &s2, &c2); | |||
| if (smaxpr * *rcond <= sminpr) { | |||
| i__1 = *rank; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = ismin + i__ - 1; | |||
| i__3 = ismin + i__ - 1; | |||
| z__1.r = s1.r * work[i__3].r - s1.i * work[i__3].i, z__1.i = | |||
| s1.r * work[i__3].i + s1.i * work[i__3].r; | |||
| work[i__2].r = z__1.r, work[i__2].i = z__1.i; | |||
| i__2 = ismax + i__ - 1; | |||
| i__3 = ismax + i__ - 1; | |||
| z__1.r = s2.r * work[i__3].r - s2.i * work[i__3].i, z__1.i = | |||
| s2.r * work[i__3].i + s2.i * work[i__3].r; | |||
| work[i__2].r = z__1.r, work[i__2].i = z__1.i; | |||
| /* L20: */ | |||
| } | |||
| i__1 = ismin + *rank; | |||
| work[i__1].r = c1.r, work[i__1].i = c1.i; | |||
| i__1 = ismax + *rank; | |||
| work[i__1].r = c2.r, work[i__1].i = c2.i; | |||
| smin = sminpr; | |||
| smax = smaxpr; | |||
| ++(*rank); | |||
| goto L10; | |||
| } | |||
| } | |||
| /* Logically partition R = [ R11 R12 ] */ | |||
| /* [ 0 R22 ] */ | |||
| /* where R11 = R(1:RANK,1:RANK) */ | |||
| /* [R11,R12] = [ T11, 0 ] * Y */ | |||
| if (*rank < *n) { | |||
| ztzrqf_(rank, n, &a[a_offset], lda, &work[mn + 1], info); | |||
| } | |||
| /* Details of Householder rotations stored in WORK(MN+1:2*MN) */ | |||
| /* B(1:M,1:NRHS) := Q**H * B(1:M,1:NRHS) */ | |||
| zunm2r_("Left", "Conjugate transpose", m, nrhs, &mn, &a[a_offset], lda, & | |||
| work[1], &b[b_offset], ldb, &work[(mn << 1) + 1], info); | |||
| /* workspace NRHS */ | |||
| /* B(1:RANK,1:NRHS) := inv(T11) * B(1:RANK,1:NRHS) */ | |||
| ztrsm_("Left", "Upper", "No transpose", "Non-unit", rank, nrhs, &c_b2, &a[ | |||
| a_offset], lda, &b[b_offset], ldb); | |||
| i__1 = *n; | |||
| for (i__ = *rank + 1; i__ <= i__1; ++i__) { | |||
| i__2 = *nrhs; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = 0., b[i__3].i = 0.; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| /* B(1:N,1:NRHS) := Y**H * B(1:N,1:NRHS) */ | |||
| if (*rank < *n) { | |||
| i__1 = *rank; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = *n - *rank + 1; | |||
| d_cnjg(&z__1, &work[mn + i__]); | |||
| zlatzm_("Left", &i__2, nrhs, &a[i__ + (*rank + 1) * a_dim1], lda, | |||
| &z__1, &b[i__ + b_dim1], &b[*rank + 1 + b_dim1], ldb, & | |||
| work[(mn << 1) + 1]); | |||
| /* L50: */ | |||
| } | |||
| } | |||
| /* workspace NRHS */ | |||
| /* B(1:N,1:NRHS) := P * B(1:N,1:NRHS) */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = (mn << 1) + i__; | |||
| work[i__3].r = 1., work[i__3].i = 0.; | |||
| /* L60: */ | |||
| } | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = (mn << 1) + i__; | |||
| if (work[i__3].r == 1. && work[i__3].i == 0.) { | |||
| if (jpvt[i__] != i__) { | |||
| k = i__; | |||
| i__3 = k + j * b_dim1; | |||
| t1.r = b[i__3].r, t1.i = b[i__3].i; | |||
| i__3 = jpvt[k] + j * b_dim1; | |||
| t2.r = b[i__3].r, t2.i = b[i__3].i; | |||
| L70: | |||
| i__3 = jpvt[k] + j * b_dim1; | |||
| b[i__3].r = t1.r, b[i__3].i = t1.i; | |||
| i__3 = (mn << 1) + k; | |||
| work[i__3].r = 0., work[i__3].i = 0.; | |||
| t1.r = t2.r, t1.i = t2.i; | |||
| k = jpvt[k]; | |||
| i__3 = jpvt[k] + j * b_dim1; | |||
| t2.r = b[i__3].r, t2.i = b[i__3].i; | |||
| if (jpvt[k] != i__) { | |||
| goto L70; | |||
| } | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = t1.r, b[i__3].i = t1.i; | |||
| i__3 = (mn << 1) + k; | |||
| work[i__3].r = 0., work[i__3].i = 0.; | |||
| } | |||
| } | |||
| /* L80: */ | |||
| } | |||
| /* L90: */ | |||
| } | |||
| /* Undo scaling */ | |||
| if (iascl == 1) { | |||
| zlascl_("G", &c__0, &c__0, &anrm, &smlnum, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| zlascl_("U", &c__0, &c__0, &smlnum, &anrm, rank, rank, &a[a_offset], | |||
| lda, info); | |||
| } else if (iascl == 2) { | |||
| zlascl_("G", &c__0, &c__0, &anrm, &bignum, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| zlascl_("U", &c__0, &c__0, &bignum, &anrm, rank, rank, &a[a_offset], | |||
| lda, info); | |||
| } | |||
| if (ibscl == 1) { | |||
| zlascl_("G", &c__0, &c__0, &smlnum, &bnrm, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| } else if (ibscl == 2) { | |||
| zlascl_("G", &c__0, &c__0, &bignum, &bnrm, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| } | |||
| L100: | |||
| return 0; | |||
| /* End of ZGELSX */ | |||
| } /* zgelsx_ */ | |||
| @@ -0,0 +1,766 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZGEQPF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZGEQPF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgeqpf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgeqpf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgeqpf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZGEQPF( M, N, A, LDA, JPVT, TAU, WORK, RWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* DOUBLE PRECISION RWORK( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine ZGEQP3. */ | |||
| /* > */ | |||
| /* > ZGEQPF computes a QR factorization with column pivoting of a */ | |||
| /* > complex M-by-N matrix A: A*P = Q*R. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the upper triangle of the array contains the */ | |||
| /* > f2cmin(M,N)-by-N upper triangular matrix R; the elements */ | |||
| /* > below the diagonal, together with the array TAU, */ | |||
| /* > represent the unitary matrix Q as a product of */ | |||
| /* > f2cmin(m,n) elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] JPVT */ | |||
| /* > \verbatim */ | |||
| /* > JPVT is INTEGER array, dimension (N) */ | |||
| /* > On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted */ | |||
| /* > to the front of A*P (a leading column); if JPVT(i) = 0, */ | |||
| /* > the i-th column of A is a free column. */ | |||
| /* > On exit, if JPVT(i) = k, then the i-th column of A*P */ | |||
| /* > was the k-th column of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX*16 array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is DOUBLE PRECISION array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16GEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(n) */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a complex vector with */ | |||
| /* > v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i). */ | |||
| /* > */ | |||
| /* > The matrix P is represented in jpvt as follows: If */ | |||
| /* > jpvt(j) = i */ | |||
| /* > then the jth column of P is the ith canonical unit vector. */ | |||
| /* > */ | |||
| /* > Partial column norm updating strategy modified by */ | |||
| /* > Z. Drmac and Z. Bujanovic, Dept. of Mathematics, */ | |||
| /* > University of Zagreb, Croatia. */ | |||
| /* > -- April 2011 -- */ | |||
| /* > For more details see LAPACK Working Note 176. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zgeqpf_(integer *m, integer *n, doublecomplex *a, | |||
| integer *lda, integer *jpvt, doublecomplex *tau, doublecomplex *work, | |||
| doublereal *rwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| doublereal d__1, d__2; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| doublereal temp, temp2; | |||
| integer i__, j; | |||
| doublereal tol3z; | |||
| integer itemp; | |||
| extern /* Subroutine */ int zlarf_(char *, integer *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, doublecomplex *, | |||
| integer *, doublecomplex *), zswap_(integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *), zgeqr2_( | |||
| integer *, integer *, doublecomplex *, integer *, doublecomplex *, | |||
| doublecomplex *, integer *); | |||
| extern doublereal dznrm2_(integer *, doublecomplex *, integer *); | |||
| integer ma; | |||
| extern doublereal dlamch_(char *); | |||
| integer mn; | |||
| extern /* Subroutine */ int zunm2r_(char *, char *, integer *, integer *, | |||
| integer *, doublecomplex *, integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *); | |||
| extern integer idamax_(integer *, doublereal *, integer *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *), zlarfg_( | |||
| integer *, doublecomplex *, doublecomplex *, integer *, | |||
| doublecomplex *); | |||
| doublecomplex aii; | |||
| integer pvt; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --jpvt; | |||
| --tau; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("ZGEQPF", &i__1); | |||
| return 0; | |||
| } | |||
| mn = f2cmin(*m,*n); | |||
| tol3z = sqrt(dlamch_("Epsilon")); | |||
| /* Move initial columns up front */ | |||
| itemp = 1; | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (jpvt[i__] != 0) { | |||
| if (i__ != itemp) { | |||
| zswap_(m, &a[i__ * a_dim1 + 1], &c__1, &a[itemp * a_dim1 + 1], | |||
| &c__1); | |||
| jpvt[i__] = jpvt[itemp]; | |||
| jpvt[itemp] = i__; | |||
| } else { | |||
| jpvt[i__] = i__; | |||
| } | |||
| ++itemp; | |||
| } else { | |||
| jpvt[i__] = i__; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| --itemp; | |||
| /* Compute the QR factorization and update remaining columns */ | |||
| if (itemp > 0) { | |||
| ma = f2cmin(itemp,*m); | |||
| zgeqr2_(m, &ma, &a[a_offset], lda, &tau[1], &work[1], info); | |||
| if (ma < *n) { | |||
| i__1 = *n - ma; | |||
| zunm2r_("Left", "Conjugate transpose", m, &i__1, &ma, &a[a_offset] | |||
| , lda, &tau[1], &a[(ma + 1) * a_dim1 + 1], lda, &work[1], | |||
| info); | |||
| } | |||
| } | |||
| if (itemp < mn) { | |||
| /* Initialize partial column norms. The first n elements of */ | |||
| /* work store the exact column norms. */ | |||
| i__1 = *n; | |||
| for (i__ = itemp + 1; i__ <= i__1; ++i__) { | |||
| i__2 = *m - itemp; | |||
| rwork[i__] = dznrm2_(&i__2, &a[itemp + 1 + i__ * a_dim1], &c__1); | |||
| rwork[*n + i__] = rwork[i__]; | |||
| /* L20: */ | |||
| } | |||
| /* Compute factorization */ | |||
| i__1 = mn; | |||
| for (i__ = itemp + 1; i__ <= i__1; ++i__) { | |||
| /* Determine ith pivot column and swap if necessary */ | |||
| i__2 = *n - i__ + 1; | |||
| pvt = i__ - 1 + idamax_(&i__2, &rwork[i__], &c__1); | |||
| if (pvt != i__) { | |||
| zswap_(m, &a[pvt * a_dim1 + 1], &c__1, &a[i__ * a_dim1 + 1], & | |||
| c__1); | |||
| itemp = jpvt[pvt]; | |||
| jpvt[pvt] = jpvt[i__]; | |||
| jpvt[i__] = itemp; | |||
| rwork[pvt] = rwork[i__]; | |||
| rwork[*n + pvt] = rwork[*n + i__]; | |||
| } | |||
| /* Generate elementary reflector H(i) */ | |||
| i__2 = i__ + i__ * a_dim1; | |||
| aii.r = a[i__2].r, aii.i = a[i__2].i; | |||
| i__2 = *m - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 1; | |||
| zlarfg_(&i__2, &aii, &a[f2cmin(i__3,*m) + i__ * a_dim1], &c__1, &tau[ | |||
| i__]); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = aii.r, a[i__2].i = aii.i; | |||
| if (i__ < *n) { | |||
| /* Apply H(i) to A(i:m,i+1:n) from the left */ | |||
| i__2 = i__ + i__ * a_dim1; | |||
| aii.r = a[i__2].r, aii.i = a[i__2].i; | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1., a[i__2].i = 0.; | |||
| i__2 = *m - i__ + 1; | |||
| i__3 = *n - i__; | |||
| d_cnjg(&z__1, &tau[i__]); | |||
| zlarf_("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, & | |||
| z__1, &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = aii.r, a[i__2].i = aii.i; | |||
| } | |||
| /* Update partial column norms */ | |||
| i__2 = *n; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| if (rwork[j] != 0.) { | |||
| /* NOTE: The following 4 lines follow from the analysis in */ | |||
| /* Lapack Working Note 176. */ | |||
| temp = z_abs(&a[i__ + j * a_dim1]) / rwork[j]; | |||
| /* Computing MAX */ | |||
| d__1 = 0., d__2 = (temp + 1.) * (1. - temp); | |||
| temp = f2cmax(d__1,d__2); | |||
| /* Computing 2nd power */ | |||
| d__1 = rwork[j] / rwork[*n + j]; | |||
| temp2 = temp * (d__1 * d__1); | |||
| if (temp2 <= tol3z) { | |||
| if (*m - i__ > 0) { | |||
| i__3 = *m - i__; | |||
| rwork[j] = dznrm2_(&i__3, &a[i__ + 1 + j * a_dim1] | |||
| , &c__1); | |||
| rwork[*n + j] = rwork[j]; | |||
| } else { | |||
| rwork[j] = 0.; | |||
| rwork[*n + j] = 0.; | |||
| } | |||
| } else { | |||
| rwork[j] *= sqrt(temp); | |||
| } | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZGEQPF */ | |||
| } /* zgeqpf_ */ | |||
| @@ -0,0 +1,913 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief <b> ZGGSVD computes the singular value decomposition (SVD) for OTHER matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZGGSVD + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zggsvd. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zggsvd. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zggsvd. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZGGSVD( JOBU, JOBV, JOBQ, M, N, P, K, L, A, LDA, B, */ | |||
| /* LDB, ALPHA, BETA, U, LDU, V, LDV, Q, LDQ, WORK, */ | |||
| /* RWORK, IWORK, INFO ) */ | |||
| /* CHARACTER JOBQ, JOBU, JOBV */ | |||
| /* INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N, P */ | |||
| /* INTEGER IWORK( * ) */ | |||
| /* DOUBLE PRECISION ALPHA( * ), BETA( * ), RWORK( * ) */ | |||
| /* COMPLEX*16 A( LDA, * ), B( LDB, * ), Q( LDQ, * ), */ | |||
| /* $ U( LDU, * ), V( LDV, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine ZGGSVD3. */ | |||
| /* > */ | |||
| /* > ZGGSVD computes the generalized singular value decomposition (GSVD) */ | |||
| /* > of an M-by-N complex matrix A and P-by-N complex matrix B: */ | |||
| /* > */ | |||
| /* > U**H*A*Q = D1*( 0 R ), V**H*B*Q = D2*( 0 R ) */ | |||
| /* > */ | |||
| /* > where U, V and Q are unitary matrices. */ | |||
| /* > Let K+L = the effective numerical rank of the */ | |||
| /* > matrix (A**H,B**H)**H, then R is a (K+L)-by-(K+L) nonsingular upper */ | |||
| /* > triangular matrix, D1 and D2 are M-by-(K+L) and P-by-(K+L) "diagonal" */ | |||
| /* > matrices and of the following structures, respectively: */ | |||
| /* > */ | |||
| /* > If M-K-L >= 0, */ | |||
| /* > */ | |||
| /* > K L */ | |||
| /* > D1 = K ( I 0 ) */ | |||
| /* > L ( 0 C ) */ | |||
| /* > M-K-L ( 0 0 ) */ | |||
| /* > */ | |||
| /* > K L */ | |||
| /* > D2 = L ( 0 S ) */ | |||
| /* > P-L ( 0 0 ) */ | |||
| /* > */ | |||
| /* > N-K-L K L */ | |||
| /* > ( 0 R ) = K ( 0 R11 R12 ) */ | |||
| /* > L ( 0 0 R22 ) */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > C = diag( ALPHA(K+1), ... , ALPHA(K+L) ), */ | |||
| /* > S = diag( BETA(K+1), ... , BETA(K+L) ), */ | |||
| /* > C**2 + S**2 = I. */ | |||
| /* > */ | |||
| /* > R is stored in A(1:K+L,N-K-L+1:N) on exit. */ | |||
| /* > */ | |||
| /* > If M-K-L < 0, */ | |||
| /* > */ | |||
| /* > K M-K K+L-M */ | |||
| /* > D1 = K ( I 0 0 ) */ | |||
| /* > M-K ( 0 C 0 ) */ | |||
| /* > */ | |||
| /* > K M-K K+L-M */ | |||
| /* > D2 = M-K ( 0 S 0 ) */ | |||
| /* > K+L-M ( 0 0 I ) */ | |||
| /* > P-L ( 0 0 0 ) */ | |||
| /* > */ | |||
| /* > N-K-L K M-K K+L-M */ | |||
| /* > ( 0 R ) = K ( 0 R11 R12 R13 ) */ | |||
| /* > M-K ( 0 0 R22 R23 ) */ | |||
| /* > K+L-M ( 0 0 0 R33 ) */ | |||
| /* > */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > C = diag( ALPHA(K+1), ... , ALPHA(M) ), */ | |||
| /* > S = diag( BETA(K+1), ... , BETA(M) ), */ | |||
| /* > C**2 + S**2 = I. */ | |||
| /* > */ | |||
| /* > (R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N), and R33 is stored */ | |||
| /* > ( 0 R22 R23 ) */ | |||
| /* > in B(M-K+1:L,N+M-K-L+1:N) on exit. */ | |||
| /* > */ | |||
| /* > The routine computes C, S, R, and optionally the unitary */ | |||
| /* > transformation matrices U, V and Q. */ | |||
| /* > */ | |||
| /* > In particular, if B is an N-by-N nonsingular matrix, then the GSVD of */ | |||
| /* > A and B implicitly gives the SVD of A*inv(B): */ | |||
| /* > A*inv(B) = U*(D1*inv(D2))*V**H. */ | |||
| /* > If ( A**H,B**H)**H has orthnormal columns, then the GSVD of A and B is also */ | |||
| /* > equal to the CS decomposition of A and B. Furthermore, the GSVD can */ | |||
| /* > be used to derive the solution of the eigenvalue problem: */ | |||
| /* > A**H*A x = lambda* B**H*B x. */ | |||
| /* > In some literature, the GSVD of A and B is presented in the form */ | |||
| /* > U**H*A*X = ( 0 D1 ), V**H*B*X = ( 0 D2 ) */ | |||
| /* > where U and V are orthogonal and X is nonsingular, and D1 and D2 are */ | |||
| /* > ``diagonal''. The former GSVD form can be converted to the latter */ | |||
| /* > form by taking the nonsingular matrix X as */ | |||
| /* > */ | |||
| /* > X = Q*( I 0 ) */ | |||
| /* > ( 0 inv(R) ) */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOBU */ | |||
| /* > \verbatim */ | |||
| /* > JOBU is CHARACTER*1 */ | |||
| /* > = 'U': Unitary matrix U is computed; */ | |||
| /* > = 'N': U is not computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] JOBV */ | |||
| /* > \verbatim */ | |||
| /* > JOBV is CHARACTER*1 */ | |||
| /* > = 'V': Unitary matrix V is computed; */ | |||
| /* > = 'N': V is not computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] JOBQ */ | |||
| /* > \verbatim */ | |||
| /* > JOBQ is CHARACTER*1 */ | |||
| /* > = 'Q': Unitary matrix Q is computed; */ | |||
| /* > = 'N': Q is not computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrices A and B. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] P */ | |||
| /* > \verbatim */ | |||
| /* > P is INTEGER */ | |||
| /* > The number of rows of the matrix B. P >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] L */ | |||
| /* > \verbatim */ | |||
| /* > L is INTEGER */ | |||
| /* > */ | |||
| /* > On exit, K and L specify the dimension of the subblocks */ | |||
| /* > described in Purpose. */ | |||
| /* > K + L = effective numerical rank of (A**H,B**H)**H. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, A contains the triangular matrix R, or part of R. */ | |||
| /* > See Purpose for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX*16 array, dimension (LDB,N) */ | |||
| /* > On entry, the P-by-N matrix B. */ | |||
| /* > On exit, B contains part of the triangular matrix R if */ | |||
| /* > M-K-L < 0. See Purpose for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,P). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ALPHA */ | |||
| /* > \verbatim */ | |||
| /* > ALPHA is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] BETA */ | |||
| /* > \verbatim */ | |||
| /* > BETA is DOUBLE PRECISION array, dimension (N) */ | |||
| /* > */ | |||
| /* > On exit, ALPHA and BETA contain the generalized singular */ | |||
| /* > value pairs of A and B; */ | |||
| /* > ALPHA(1:K) = 1, */ | |||
| /* > BETA(1:K) = 0, */ | |||
| /* > and if M-K-L >= 0, */ | |||
| /* > ALPHA(K+1:K+L) = C, */ | |||
| /* > BETA(K+1:K+L) = S, */ | |||
| /* > or if M-K-L < 0, */ | |||
| /* > ALPHA(K+1:M)=C, ALPHA(M+1:K+L)=0 */ | |||
| /* > BETA(K+1:M) =S, BETA(M+1:K+L) =1 */ | |||
| /* > and */ | |||
| /* > ALPHA(K+L+1:N) = 0 */ | |||
| /* > BETA(K+L+1:N) = 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] U */ | |||
| /* > \verbatim */ | |||
| /* > U is COMPLEX*16 array, dimension (LDU,M) */ | |||
| /* > If JOBU = 'U', U contains the M-by-M unitary matrix U. */ | |||
| /* > If JOBU = 'N', U is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDU */ | |||
| /* > \verbatim */ | |||
| /* > LDU is INTEGER */ | |||
| /* > The leading dimension of the array U. LDU >= f2cmax(1,M) if */ | |||
| /* > JOBU = 'U'; LDU >= 1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX*16 array, dimension (LDV,P) */ | |||
| /* > If JOBV = 'V', V contains the P-by-P unitary matrix V. */ | |||
| /* > If JOBV = 'N', V is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. LDV >= f2cmax(1,P) if */ | |||
| /* > JOBV = 'V'; LDV >= 1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] Q */ | |||
| /* > \verbatim */ | |||
| /* > Q is COMPLEX*16 array, dimension (LDQ,N) */ | |||
| /* > If JOBQ = 'Q', Q contains the N-by-N unitary matrix Q. */ | |||
| /* > If JOBQ = 'N', Q is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDQ */ | |||
| /* > \verbatim */ | |||
| /* > LDQ is INTEGER */ | |||
| /* > The leading dimension of the array Q. LDQ >= f2cmax(1,N) if */ | |||
| /* > JOBQ = 'Q'; LDQ >= 1 otherwise. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX*16 array, dimension (f2cmax(3*N,M,P)+N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is DOUBLE PRECISION array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] IWORK */ | |||
| /* > \verbatim */ | |||
| /* > IWORK is INTEGER array, dimension (N) */ | |||
| /* > On exit, IWORK stores the sorting information. More */ | |||
| /* > precisely, the following loop will sort ALPHA */ | |||
| /* > for I = K+1, f2cmin(M,K+L) */ | |||
| /* > swap ALPHA(I) and ALPHA(IWORK(I)) */ | |||
| /* > endfor */ | |||
| /* > such that ALPHA(1) >= ALPHA(2) >= ... >= ALPHA(N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit. */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > > 0: if INFO = 1, the Jacobi-type procedure failed to */ | |||
| /* > converge. For further details, see subroutine ZTGSJA. */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > TOLA DOUBLE PRECISION */ | |||
| /* > TOLB DOUBLE PRECISION */ | |||
| /* > TOLA and TOLB are the thresholds to determine the effective */ | |||
| /* > rank of (A**H,B**H)**H. Generally, they are set to */ | |||
| /* > TOLA = MAX(M,N)*norm(A)*MAZHEPS, */ | |||
| /* > TOLB = MAX(P,N)*norm(B)*MAZHEPS. */ | |||
| /* > The size of TOLA and TOLB may affect the size of backward */ | |||
| /* > errors of the decomposition. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERsing */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > Ming Gu and Huan Ren, Computer Science Division, University of */ | |||
| /* > California at Berkeley, USA */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zggsvd_(char *jobu, char *jobv, char *jobq, integer *m, | |||
| integer *n, integer *p, integer *k, integer *l, doublecomplex *a, | |||
| integer *lda, doublecomplex *b, integer *ldb, doublereal *alpha, | |||
| doublereal *beta, doublecomplex *u, integer *ldu, doublecomplex *v, | |||
| integer *ldv, doublecomplex *q, integer *ldq, doublecomplex *work, | |||
| doublereal *rwork, integer *iwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, q_dim1, q_offset, u_dim1, | |||
| u_offset, v_dim1, v_offset, i__1, i__2; | |||
| /* Local variables */ | |||
| integer ibnd; | |||
| doublereal tola; | |||
| integer isub; | |||
| doublereal tolb, unfl, temp, smax; | |||
| integer ncallmycycle, i__, j; | |||
| extern logical lsame_(char *, char *); | |||
| doublereal anorm, bnorm; | |||
| extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, | |||
| doublereal *, integer *); | |||
| logical wantq, wantu, wantv; | |||
| extern doublereal dlamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *); | |||
| extern doublereal zlange_(char *, integer *, integer *, doublecomplex *, | |||
| integer *, doublereal *); | |||
| extern /* Subroutine */ int ztgsja_(char *, char *, char *, integer *, | |||
| integer *, integer *, integer *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, integer *, doublereal *, doublereal *, | |||
| doublereal *, doublereal *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *, integer *), | |||
| zggsvp_(char *, char *, char *, integer *, integer *, integer *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *, | |||
| doublereal *, doublereal *, integer *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, integer *, doublecomplex *, integer * | |||
| , integer *, doublereal *, doublecomplex *, doublecomplex *, | |||
| integer *); | |||
| doublereal ulp; | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Decode and test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| --alpha; | |||
| --beta; | |||
| u_dim1 = *ldu; | |||
| u_offset = 1 + u_dim1 * 1; | |||
| u -= u_offset; | |||
| v_dim1 = *ldv; | |||
| v_offset = 1 + v_dim1 * 1; | |||
| v -= v_offset; | |||
| q_dim1 = *ldq; | |||
| q_offset = 1 + q_dim1 * 1; | |||
| q -= q_offset; | |||
| --work; | |||
| --rwork; | |||
| --iwork; | |||
| /* Function Body */ | |||
| wantu = lsame_(jobu, "U"); | |||
| wantv = lsame_(jobv, "V"); | |||
| wantq = lsame_(jobq, "Q"); | |||
| *info = 0; | |||
| if (! (wantu || lsame_(jobu, "N"))) { | |||
| *info = -1; | |||
| } else if (! (wantv || lsame_(jobv, "N"))) { | |||
| *info = -2; | |||
| } else if (! (wantq || lsame_(jobq, "N"))) { | |||
| *info = -3; | |||
| } else if (*m < 0) { | |||
| *info = -4; | |||
| } else if (*n < 0) { | |||
| *info = -5; | |||
| } else if (*p < 0) { | |||
| *info = -6; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -10; | |||
| } else if (*ldb < f2cmax(1,*p)) { | |||
| *info = -12; | |||
| } else if (*ldu < 1 || wantu && *ldu < *m) { | |||
| *info = -16; | |||
| } else if (*ldv < 1 || wantv && *ldv < *p) { | |||
| *info = -18; | |||
| } else if (*ldq < 1 || wantq && *ldq < *n) { | |||
| *info = -20; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("ZGGSVD", &i__1); | |||
| return 0; | |||
| } | |||
| /* Compute the Frobenius norm of matrices A and B */ | |||
| anorm = zlange_("1", m, n, &a[a_offset], lda, &rwork[1]); | |||
| bnorm = zlange_("1", p, n, &b[b_offset], ldb, &rwork[1]); | |||
| /* Get machine precision and set up threshold for determining */ | |||
| /* the effective numerical rank of the matrices A and B. */ | |||
| ulp = dlamch_("Precision"); | |||
| unfl = dlamch_("Safe Minimum"); | |||
| tola = f2cmax(*m,*n) * f2cmax(anorm,unfl) * ulp; | |||
| tolb = f2cmax(*p,*n) * f2cmax(bnorm,unfl) * ulp; | |||
| zggsvp_(jobu, jobv, jobq, m, p, n, &a[a_offset], lda, &b[b_offset], ldb, & | |||
| tola, &tolb, k, l, &u[u_offset], ldu, &v[v_offset], ldv, &q[ | |||
| q_offset], ldq, &iwork[1], &rwork[1], &work[1], &work[*n + 1], | |||
| info); | |||
| /* Compute the GSVD of two upper "triangular" matrices */ | |||
| ztgsja_(jobu, jobv, jobq, m, p, n, k, l, &a[a_offset], lda, &b[b_offset], | |||
| ldb, &tola, &tolb, &alpha[1], &beta[1], &u[u_offset], ldu, &v[ | |||
| v_offset], ldv, &q[q_offset], ldq, &work[1], &ncallmycycle, info); | |||
| /* Sort the singular values and store the pivot indices in IWORK */ | |||
| /* Copy ALPHA to RWORK, then sort ALPHA in RWORK */ | |||
| dcopy_(n, &alpha[1], &c__1, &rwork[1], &c__1); | |||
| /* Computing MIN */ | |||
| i__1 = *l, i__2 = *m - *k; | |||
| ibnd = f2cmin(i__1,i__2); | |||
| i__1 = ibnd; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Scan for largest ALPHA(K+I) */ | |||
| isub = i__; | |||
| smax = rwork[*k + i__]; | |||
| i__2 = ibnd; | |||
| for (j = i__ + 1; j <= i__2; ++j) { | |||
| temp = rwork[*k + j]; | |||
| if (temp > smax) { | |||
| isub = j; | |||
| smax = temp; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| if (isub != i__) { | |||
| rwork[*k + isub] = rwork[*k + i__]; | |||
| rwork[*k + i__] = smax; | |||
| iwork[*k + i__] = *k + isub; | |||
| } else { | |||
| iwork[*k + i__] = *k + i__; | |||
| } | |||
| /* L20: */ | |||
| } | |||
| return 0; | |||
| /* End of ZGGSVD */ | |||
| } /* zggsvd_ */ | |||
| @@ -0,0 +1,758 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {0.,0.}; | |||
| static doublecomplex c_b2 = {1.,0.}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLAHRD reduces the first nb columns of a general rectangular matrix A so that elements below th | |||
| e k-th subdiagonal are zero, and returns auxiliary matrices which are needed to apply the transformati | |||
| on to the unreduced part of A. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLAHRD + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlahrd. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlahrd. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlahrd. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLAHRD( N, K, NB, A, LDA, TAU, T, LDT, Y, LDY ) */ | |||
| /* INTEGER K, LDA, LDT, LDY, N, NB */ | |||
| /* COMPLEX*16 A( LDA, * ), T( LDT, NB ), TAU( NB ), */ | |||
| /* $ Y( LDY, NB ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine ZLAHR2. */ | |||
| /* > */ | |||
| /* > ZLAHRD reduces the first NB columns of a complex general n-by-(n-k+1) */ | |||
| /* > matrix A so that elements below the k-th subdiagonal are zero. The */ | |||
| /* > reduction is performed by a unitary similarity transformation */ | |||
| /* > Q**H * A * Q. The routine returns the matrices V and T which determine */ | |||
| /* > Q as a block reflector I - V*T*V**H, and also the matrix Y = A * V * T. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The offset for the reduction. Elements below the k-th */ | |||
| /* > subdiagonal in the first NB columns are reduced to zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The number of columns to be reduced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N-K+1) */ | |||
| /* > On entry, the n-by-(n-k+1) general matrix A. */ | |||
| /* > On exit, the elements on and above the k-th subdiagonal in */ | |||
| /* > the first NB columns are overwritten with the corresponding */ | |||
| /* > elements of the reduced matrix; the elements below the k-th */ | |||
| /* > subdiagonal, with the array TAU, represent the matrix Q as a */ | |||
| /* > product of elementary reflectors. The other columns of A are */ | |||
| /* > unchanged. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 array, dimension (NB) */ | |||
| /* > The scalar factors of the elementary reflectors. See Further */ | |||
| /* > Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX*16 array, dimension (LDT,NB) */ | |||
| /* > The upper triangular matrix T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= NB. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] Y */ | |||
| /* > \verbatim */ | |||
| /* > Y is COMPLEX*16 array, dimension (LDY,NB) */ | |||
| /* > The n-by-nb matrix Y. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDY */ | |||
| /* > \verbatim */ | |||
| /* > LDY is INTEGER */ | |||
| /* > The leading dimension of the array Y. LDY >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERauxiliary */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of nb elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(nb). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a complex vector with */ | |||
| /* > v(1:i+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in */ | |||
| /* > A(i+k+1:n,i), and tau in TAU(i). */ | |||
| /* > */ | |||
| /* > The elements of the vectors v together form the (n-k+1)-by-nb matrix */ | |||
| /* > V which is needed, with T and Y, to apply the transformation to the */ | |||
| /* > unreduced part of the matrix, using an update of the form: */ | |||
| /* > A := (I - V*T*V**H) * (A - Y*V**H). */ | |||
| /* > */ | |||
| /* > The contents of A on exit are illustrated by the following example */ | |||
| /* > with n = 7, k = 3 and nb = 2: */ | |||
| /* > */ | |||
| /* > ( a h a a a ) */ | |||
| /* > ( a h a a a ) */ | |||
| /* > ( a h a a a ) */ | |||
| /* > ( h h a a a ) */ | |||
| /* > ( v1 h a a a ) */ | |||
| /* > ( v1 v2 a a a ) */ | |||
| /* > ( v1 v2 a a a ) */ | |||
| /* > */ | |||
| /* > where a denotes an element of the original matrix A, h denotes a */ | |||
| /* > modified element of the upper Hessenberg matrix H, and vi denotes an */ | |||
| /* > element of the vector defining H(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlahrd_(integer *n, integer *k, integer *nb, | |||
| doublecomplex *a, integer *lda, doublecomplex *tau, doublecomplex *t, | |||
| integer *ldt, doublecomplex *y, integer *ldy) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, y_dim1, y_offset, i__1, i__2, | |||
| i__3; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| integer i__; | |||
| extern /* Subroutine */ int zscal_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *), zgemv_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *), | |||
| zcopy_(integer *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *), zaxpy_(integer *, doublecomplex *, doublecomplex *, | |||
| integer *, doublecomplex *, integer *), ztrmv_(char *, char *, | |||
| char *, integer *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *); | |||
| doublecomplex ei; | |||
| extern /* Subroutine */ int zlarfg_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *), zlacgv_(integer *, | |||
| doublecomplex *, integer *); | |||
| /* -- LAPACK auxiliary routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Quick return if possible */ | |||
| /* Parameter adjustments */ | |||
| --tau; | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| y_dim1 = *ldy; | |||
| y_offset = 1 + y_dim1 * 1; | |||
| y -= y_offset; | |||
| /* Function Body */ | |||
| if (*n <= 1) { | |||
| return 0; | |||
| } | |||
| i__1 = *nb; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (i__ > 1) { | |||
| /* Update A(1:n,i) */ | |||
| /* Compute i-th column of A - Y * V**H */ | |||
| i__2 = i__ - 1; | |||
| zlacgv_(&i__2, &a[*k + i__ - 1 + a_dim1], lda); | |||
| i__2 = i__ - 1; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemv_("No transpose", n, &i__2, &z__1, &y[y_offset], ldy, &a[*k | |||
| + i__ - 1 + a_dim1], lda, &c_b2, &a[i__ * a_dim1 + 1], & | |||
| c__1); | |||
| i__2 = i__ - 1; | |||
| zlacgv_(&i__2, &a[*k + i__ - 1 + a_dim1], lda); | |||
| /* Apply I - V * T**H * V**H to this column (call it b) from the */ | |||
| /* left, using the last column of T as workspace */ | |||
| /* Let V = ( V1 ) and b = ( b1 ) (first I-1 rows) */ | |||
| /* ( V2 ) ( b2 ) */ | |||
| /* where V1 is unit lower triangular */ | |||
| /* w := V1**H * b1 */ | |||
| i__2 = i__ - 1; | |||
| zcopy_(&i__2, &a[*k + 1 + i__ * a_dim1], &c__1, &t[*nb * t_dim1 + | |||
| 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| ztrmv_("Lower", "Conjugate transpose", "Unit", &i__2, &a[*k + 1 + | |||
| a_dim1], lda, &t[*nb * t_dim1 + 1], &c__1); | |||
| /* w := w + V2**H *b2 */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| zgemv_("Conjugate transpose", &i__2, &i__3, &c_b2, &a[*k + i__ + | |||
| a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b2, & | |||
| t[*nb * t_dim1 + 1], &c__1); | |||
| /* w := T**H *w */ | |||
| i__2 = i__ - 1; | |||
| ztrmv_("Upper", "Conjugate transpose", "Non-unit", &i__2, &t[ | |||
| t_offset], ldt, &t[*nb * t_dim1 + 1], &c__1); | |||
| /* b2 := b2 - V2*w */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemv_("No transpose", &i__2, &i__3, &z__1, &a[*k + i__ + a_dim1], | |||
| lda, &t[*nb * t_dim1 + 1], &c__1, &c_b2, &a[*k + i__ + | |||
| i__ * a_dim1], &c__1); | |||
| /* b1 := b1 - V1*w */ | |||
| i__2 = i__ - 1; | |||
| ztrmv_("Lower", "No transpose", "Unit", &i__2, &a[*k + 1 + a_dim1] | |||
| , lda, &t[*nb * t_dim1 + 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zaxpy_(&i__2, &z__1, &t[*nb * t_dim1 + 1], &c__1, &a[*k + 1 + i__ | |||
| * a_dim1], &c__1); | |||
| i__2 = *k + i__ - 1 + (i__ - 1) * a_dim1; | |||
| a[i__2].r = ei.r, a[i__2].i = ei.i; | |||
| } | |||
| /* Generate the elementary reflector H(i) to annihilate */ | |||
| /* A(k+i+1:n,i) */ | |||
| i__2 = *k + i__ + i__ * a_dim1; | |||
| ei.r = a[i__2].r, ei.i = a[i__2].i; | |||
| i__2 = *n - *k - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = *k + i__ + 1; | |||
| zlarfg_(&i__2, &ei, &a[f2cmin(i__3,*n) + i__ * a_dim1], &c__1, &tau[i__]) | |||
| ; | |||
| i__2 = *k + i__ + i__ * a_dim1; | |||
| a[i__2].r = 1., a[i__2].i = 0.; | |||
| /* Compute Y(1:n,i) */ | |||
| i__2 = *n - *k - i__ + 1; | |||
| zgemv_("No transpose", n, &i__2, &c_b2, &a[(i__ + 1) * a_dim1 + 1], | |||
| lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b1, &y[i__ * | |||
| y_dim1 + 1], &c__1); | |||
| i__2 = *n - *k - i__ + 1; | |||
| i__3 = i__ - 1; | |||
| zgemv_("Conjugate transpose", &i__2, &i__3, &c_b2, &a[*k + i__ + | |||
| a_dim1], lda, &a[*k + i__ + i__ * a_dim1], &c__1, &c_b1, &t[ | |||
| i__ * t_dim1 + 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| z__1.r = -1., z__1.i = 0.; | |||
| zgemv_("No transpose", n, &i__2, &z__1, &y[y_offset], ldy, &t[i__ * | |||
| t_dim1 + 1], &c__1, &c_b2, &y[i__ * y_dim1 + 1], &c__1); | |||
| zscal_(n, &tau[i__], &y[i__ * y_dim1 + 1], &c__1); | |||
| /* Compute T(1:i,i) */ | |||
| i__2 = i__ - 1; | |||
| i__3 = i__; | |||
| z__1.r = -tau[i__3].r, z__1.i = -tau[i__3].i; | |||
| zscal_(&i__2, &z__1, &t[i__ * t_dim1 + 1], &c__1); | |||
| i__2 = i__ - 1; | |||
| ztrmv_("Upper", "No transpose", "Non-unit", &i__2, &t[t_offset], ldt, | |||
| &t[i__ * t_dim1 + 1], &c__1) | |||
| ; | |||
| i__2 = i__ + i__ * t_dim1; | |||
| i__3 = i__; | |||
| t[i__2].r = tau[i__3].r, t[i__2].i = tau[i__3].i; | |||
| /* L10: */ | |||
| } | |||
| i__1 = *k + *nb + *nb * a_dim1; | |||
| a[i__1].r = ei.r, a[i__1].i = ei.i; | |||
| return 0; | |||
| /* End of ZLAHRD */ | |||
| } /* zlahrd_ */ | |||
| @@ -0,0 +1,652 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {1.,0.}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZLATZM */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZLATZM + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlatzm. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlatzm. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlatzm. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZLATZM( SIDE, M, N, V, INCV, TAU, C1, C2, LDC, WORK ) */ | |||
| /* CHARACTER SIDE */ | |||
| /* INTEGER INCV, LDC, M, N */ | |||
| /* COMPLEX*16 TAU */ | |||
| /* COMPLEX*16 C1( LDC, * ), C2( LDC, * ), V( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine ZUNMRZ. */ | |||
| /* > */ | |||
| /* > ZLATZM applies a Householder matrix generated by ZTZRQF to a matrix. */ | |||
| /* > */ | |||
| /* > Let P = I - tau*u*u**H, u = ( 1 ), */ | |||
| /* > ( v ) */ | |||
| /* > where v is an (m-1) vector if SIDE = 'L', or a (n-1) vector if */ | |||
| /* > SIDE = 'R'. */ | |||
| /* > */ | |||
| /* > If SIDE equals 'L', let */ | |||
| /* > C = [ C1 ] 1 */ | |||
| /* > [ C2 ] m-1 */ | |||
| /* > n */ | |||
| /* > Then C is overwritten by P*C. */ | |||
| /* > */ | |||
| /* > If SIDE equals 'R', let */ | |||
| /* > C = [ C1, C2 ] m */ | |||
| /* > 1 n-1 */ | |||
| /* > Then C is overwritten by C*P. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': form P * C */ | |||
| /* > = 'R': form C * P */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX*16 array, dimension */ | |||
| /* > (1 + (M-1)*abs(INCV)) if SIDE = 'L' */ | |||
| /* > (1 + (N-1)*abs(INCV)) if SIDE = 'R' */ | |||
| /* > The vector v in the representation of P. V is not used */ | |||
| /* > if TAU = 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] INCV */ | |||
| /* > \verbatim */ | |||
| /* > INCV is INTEGER */ | |||
| /* > The increment between elements of v. INCV <> 0 */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 */ | |||
| /* > The value tau in the representation of P. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C1 */ | |||
| /* > \verbatim */ | |||
| /* > C1 is COMPLEX*16 array, dimension */ | |||
| /* > (LDC,N) if SIDE = 'L' */ | |||
| /* > (M,1) if SIDE = 'R' */ | |||
| /* > On entry, the n-vector C1 if SIDE = 'L', or the m-vector C1 */ | |||
| /* > if SIDE = 'R'. */ | |||
| /* > */ | |||
| /* > On exit, the first row of P*C if SIDE = 'L', or the first */ | |||
| /* > column of C*P if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C2 */ | |||
| /* > \verbatim */ | |||
| /* > C2 is COMPLEX*16 array, dimension */ | |||
| /* > (LDC, N) if SIDE = 'L' */ | |||
| /* > (LDC, N-1) if SIDE = 'R' */ | |||
| /* > On entry, the (m - 1) x n matrix C2 if SIDE = 'L', or the */ | |||
| /* > m x (n - 1) matrix C2 if SIDE = 'R'. */ | |||
| /* > */ | |||
| /* > On exit, rows 2:m of P*C if SIDE = 'L', or columns 2:m of C*P */ | |||
| /* > if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the arrays C1 and C2. */ | |||
| /* > LDC >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX*16 array, dimension */ | |||
| /* > (N) if SIDE = 'L' */ | |||
| /* > (M) if SIDE = 'R' */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int zlatzm_(char *side, integer *m, integer *n, | |||
| doublecomplex *v, integer *incv, doublecomplex *tau, doublecomplex * | |||
| c1, doublecomplex *c2, integer *ldc, doublecomplex *work) | |||
| { | |||
| /* System generated locals */ | |||
| integer c1_dim1, c1_offset, c2_dim1, c2_offset, i__1; | |||
| doublecomplex z__1; | |||
| /* Local variables */ | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int zgerc_(integer *, integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *), zgemv_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *), | |||
| zgeru_(integer *, integer *, doublecomplex *, doublecomplex *, | |||
| integer *, doublecomplex *, integer *, doublecomplex *, integer *) | |||
| , zcopy_(integer *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *), zaxpy_(integer *, doublecomplex *, doublecomplex *, | |||
| integer *, doublecomplex *, integer *), zlacgv_(integer *, | |||
| doublecomplex *, integer *); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| --v; | |||
| c2_dim1 = *ldc; | |||
| c2_offset = 1 + c2_dim1 * 1; | |||
| c2 -= c2_offset; | |||
| c1_dim1 = *ldc; | |||
| c1_offset = 1 + c1_dim1 * 1; | |||
| c1 -= c1_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| if (f2cmin(*m,*n) == 0 || tau->r == 0. && tau->i == 0.) { | |||
| return 0; | |||
| } | |||
| if (lsame_(side, "L")) { | |||
| /* w := ( C1 + v**H * C2 )**H */ | |||
| zcopy_(n, &c1[c1_offset], ldc, &work[1], &c__1); | |||
| zlacgv_(n, &work[1], &c__1); | |||
| i__1 = *m - 1; | |||
| zgemv_("Conjugate transpose", &i__1, n, &c_b1, &c2[c2_offset], ldc, & | |||
| v[1], incv, &c_b1, &work[1], &c__1); | |||
| /* [ C1 ] := [ C1 ] - tau* [ 1 ] * w**H */ | |||
| /* [ C2 ] [ C2 ] [ v ] */ | |||
| zlacgv_(n, &work[1], &c__1); | |||
| z__1.r = -tau->r, z__1.i = -tau->i; | |||
| zaxpy_(n, &z__1, &work[1], &c__1, &c1[c1_offset], ldc); | |||
| i__1 = *m - 1; | |||
| z__1.r = -tau->r, z__1.i = -tau->i; | |||
| zgeru_(&i__1, n, &z__1, &v[1], incv, &work[1], &c__1, &c2[c2_offset], | |||
| ldc); | |||
| } else if (lsame_(side, "R")) { | |||
| /* w := C1 + C2 * v */ | |||
| zcopy_(m, &c1[c1_offset], &c__1, &work[1], &c__1); | |||
| i__1 = *n - 1; | |||
| zgemv_("No transpose", m, &i__1, &c_b1, &c2[c2_offset], ldc, &v[1], | |||
| incv, &c_b1, &work[1], &c__1); | |||
| /* [ C1, C2 ] := [ C1, C2 ] - tau* w * [ 1 , v**H] */ | |||
| z__1.r = -tau->r, z__1.i = -tau->i; | |||
| zaxpy_(m, &z__1, &work[1], &c__1, &c1[c1_offset], &c__1); | |||
| i__1 = *n - 1; | |||
| z__1.r = -tau->r, z__1.i = -tau->i; | |||
| zgerc_(m, &i__1, &z__1, &work[1], &c__1, &v[1], incv, &c2[c2_offset], | |||
| ldc); | |||
| } | |||
| return 0; | |||
| /* End of ZLATZM */ | |||
| } /* zlatzm_ */ | |||
| @@ -0,0 +1,683 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| #define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static doublecomplex c_b1 = {1.,0.}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b ZTZRQF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download ZTZRQF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztzrqf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztzrqf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztzrqf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE ZTZRQF( M, N, A, LDA, TAU, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* COMPLEX*16 A( LDA, * ), TAU( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > This routine is deprecated and has been replaced by routine ZTZRZF. */ | |||
| /* > */ | |||
| /* > ZTZRQF reduces the M-by-N ( M<=N ) complex upper trapezoidal matrix A */ | |||
| /* > to upper triangular form by means of unitary transformations. */ | |||
| /* > */ | |||
| /* > The upper trapezoidal matrix A is factored as */ | |||
| /* > */ | |||
| /* > A = ( R 0 ) * Z, */ | |||
| /* > */ | |||
| /* > where Z is an N-by-N unitary matrix and R is an M-by-M upper */ | |||
| /* > triangular matrix. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= M. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX*16 array, dimension (LDA,N) */ | |||
| /* > On entry, the leading M-by-N upper trapezoidal part of the */ | |||
| /* > array A must contain the matrix to be factorized. */ | |||
| /* > On exit, the leading M-by-M upper triangular part of A */ | |||
| /* > contains the upper triangular matrix R, and elements M+1 to */ | |||
| /* > N of the first M rows of A, with the array TAU, represent the */ | |||
| /* > unitary matrix Z as a product of M elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX*16 array, dimension (M) */ | |||
| /* > The scalar factors of the elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complex16OTHERcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The factorization is obtained by Householder's method. The kth */ | |||
| /* > transformation matrix, Z( k ), whose conjugate transpose is used to */ | |||
| /* > introduce zeros into the (m - k + 1)th row of A, is given in the form */ | |||
| /* > */ | |||
| /* > Z( k ) = ( I 0 ), */ | |||
| /* > ( 0 T( k ) ) */ | |||
| /* > */ | |||
| /* > where */ | |||
| /* > */ | |||
| /* > T( k ) = I - tau*u( k )*u( k )**H, u( k ) = ( 1 ), */ | |||
| /* > ( 0 ) */ | |||
| /* > ( z( k ) ) */ | |||
| /* > */ | |||
| /* > tau is a scalar and z( k ) is an ( n - m ) element vector. */ | |||
| /* > tau and z( k ) are chosen to annihilate the elements of the kth row */ | |||
| /* > of X. */ | |||
| /* > */ | |||
| /* > The scalar tau is returned in the kth element of TAU and the vector */ | |||
| /* > u( k ) in the kth row of A, such that the elements of z( k ) are */ | |||
| /* > in a( k, m + 1 ), ..., a( k, n ). The elements of R are returned in */ | |||
| /* > the upper triangular part of A. */ | |||
| /* > */ | |||
| /* > Z is given by */ | |||
| /* > */ | |||
| /* > Z = Z( 1 ) * Z( 2 ) * ... * Z( m ). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int ztzrqf_(integer *m, integer *n, doublecomplex *a, | |||
| integer *lda, doublecomplex *tau, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| doublecomplex z__1, z__2; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| doublecomplex alpha; | |||
| extern /* Subroutine */ int zgerc_(integer *, integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *), zgemv_(char *, integer *, integer *, | |||
| doublecomplex *, doublecomplex *, integer *, doublecomplex *, | |||
| integer *, doublecomplex *, doublecomplex *, integer *); | |||
| integer m1; | |||
| extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, | |||
| doublecomplex *, integer *), zaxpy_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *, integer *), xerbla_( | |||
| char *, integer *), zlarfg_(integer *, doublecomplex *, | |||
| doublecomplex *, integer *, doublecomplex *), zlacgv_(integer *, | |||
| doublecomplex *, integer *); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < *m) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("ZTZRQF", &i__1); | |||
| return 0; | |||
| } | |||
| /* Perform the factorization. */ | |||
| if (*m == 0) { | |||
| return 0; | |||
| } | |||
| if (*m == *n) { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| tau[i__2].r = 0., tau[i__2].i = 0.; | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| /* Computing MIN */ | |||
| i__1 = *m + 1; | |||
| m1 = f2cmin(i__1,*n); | |||
| for (k = *m; k >= 1; --k) { | |||
| /* Use a Householder reflection to zero the kth row of A. */ | |||
| /* First set up the reflection. */ | |||
| i__1 = k + k * a_dim1; | |||
| d_cnjg(&z__1, &a[k + k * a_dim1]); | |||
| a[i__1].r = z__1.r, a[i__1].i = z__1.i; | |||
| i__1 = *n - *m; | |||
| zlacgv_(&i__1, &a[k + m1 * a_dim1], lda); | |||
| i__1 = k + k * a_dim1; | |||
| alpha.r = a[i__1].r, alpha.i = a[i__1].i; | |||
| i__1 = *n - *m + 1; | |||
| zlarfg_(&i__1, &alpha, &a[k + m1 * a_dim1], lda, &tau[k]); | |||
| i__1 = k + k * a_dim1; | |||
| a[i__1].r = alpha.r, a[i__1].i = alpha.i; | |||
| i__1 = k; | |||
| d_cnjg(&z__1, &tau[k]); | |||
| tau[i__1].r = z__1.r, tau[i__1].i = z__1.i; | |||
| i__1 = k; | |||
| if ((tau[i__1].r != 0. || tau[i__1].i != 0.) && k > 1) { | |||
| /* We now perform the operation A := A*P( k )**H. */ | |||
| /* Use the first ( k - 1 ) elements of TAU to store a( k ), */ | |||
| /* where a( k ) consists of the first ( k - 1 ) elements of */ | |||
| /* the kth column of A. Also let B denote the first */ | |||
| /* ( k - 1 ) rows of the last ( n - m ) columns of A. */ | |||
| i__1 = k - 1; | |||
| zcopy_(&i__1, &a[k * a_dim1 + 1], &c__1, &tau[1], &c__1); | |||
| /* Form w = a( k ) + B*z( k ) in TAU. */ | |||
| i__1 = k - 1; | |||
| i__2 = *n - *m; | |||
| zgemv_("No transpose", &i__1, &i__2, &c_b1, &a[m1 * a_dim1 + | |||
| 1], lda, &a[k + m1 * a_dim1], lda, &c_b1, &tau[1], & | |||
| c__1); | |||
| /* Now form a( k ) := a( k ) - conjg(tau)*w */ | |||
| /* and B := B - conjg(tau)*w*z( k )**H. */ | |||
| i__1 = k - 1; | |||
| d_cnjg(&z__2, &tau[k]); | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| zaxpy_(&i__1, &z__1, &tau[1], &c__1, &a[k * a_dim1 + 1], & | |||
| c__1); | |||
| i__1 = k - 1; | |||
| i__2 = *n - *m; | |||
| d_cnjg(&z__2, &tau[k]); | |||
| z__1.r = -z__2.r, z__1.i = -z__2.i; | |||
| zgerc_(&i__1, &i__2, &z__1, &tau[1], &c__1, &a[k + m1 * | |||
| a_dim1], lda, &a[m1 * a_dim1 + 1], lda); | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of ZTZRQF */ | |||
| } /* ztzrqf_ */ | |||
| @@ -57,9 +57,21 @@ | |||
| TOPSRCDIR = .. | |||
| include $(TOPSRCDIR)/make.inc | |||
| ifneq ($(C_LAPACK), 1) | |||
| $(info fortran... C_LAPACK ist $(C_LAPACK)) | |||
| .SUFFIXES: | |||
| .SUFFIXES: .f .o | |||
| .f.o: | |||
| $(FC) $(FFLAGS) -c -o $@ $< | |||
| .SUFFIXES: .F .o | |||
| .F.o: | |||
| $(FC) $(FFLAGS) -c -o $@ $< | |||
| else | |||
| $(info C_LAPACK ist $(C_LAPACK)) | |||
| .SUFFIXES: .c .o | |||
| .c.o: | |||
| $(CC) $(CFLAGS) -c -o $@ $< | |||
| endif | |||
| ALLAUX_O = ilaenv.o ilaenv2stage.o ieeeck.o lsamen.o xerbla.o xerbla_array.o \ | |||
| iparmq.o iparam2stage.o \ | |||
| @@ -560,14 +572,13 @@ DLAPACKOBJS = \ | |||
| CLAPACKOBJS = \ | |||
| cgetrf.o cgetrs.o cpotrf.o cgetf2.o \ | |||
| cpotf2.o claswp.o cgesv.o clauu2.o \ | |||
| clauum.o ctrti2.o ctrtri.o ctrtrs.o | |||
| clauum.o ctrti2.o ctrtri.o ctrtrs.o | |||
| ZLAPACKOBJS = \ | |||
| zgetrf.o zgetrs.o zpotrf.o zgetf2.o \ | |||
| zpotf2.o zlaswp.o zgesv.o zlauu2.o \ | |||
| zlauum.o ztrti2.o ztrtri.o ztrtrs.o | |||
| ALLAUX = $(filter-out $(ALL_AUX_OBJS),$(ALLAUX_O)) | |||
| SLASRC = $(filter-out $(SLAPACKOBJS),$(SLASRC_O)) | |||
| DLASRC = $(filter-out $(DLAPACKOBJS),$(DLASRC_O)) | |||
| @@ -643,9 +654,19 @@ cleanobj: | |||
| cleanlib: | |||
| rm -f $(LAPACKLIB) | |||
| ifneq ($(C_LAPACK), 1) | |||
| slaruv.o: slaruv.f ; $(FC) $(FFLAGS_NOOPT) -c -o $@ $< | |||
| dlaruv.o: dlaruv.f ; $(FC) $(FFLAGS_NOOPT) -c -o $@ $< | |||
| sla_wwaddw.o: sla_wwaddw.f ; $(FC) $(FFLAGS_NOOPT) -c -o $@ $< | |||
| dla_wwaddw.o: dla_wwaddw.f ; $(FC) $(FFLAGS_NOOPT) -c -o $@ $< | |||
| cla_wwaddw.o: cla_wwaddw.f ; $(FC) $(FFLAGS_NOOPT) -c -o $@ $< | |||
| zla_wwaddw.o: zla_wwaddw.f ; $(FC) $(FFLAGS_NOOPT) -c -o $@ $< | |||
| else | |||
| slaruv.o: slaruv.c ; $(CC) $(CFLAGS) -c -o $@ $< | |||
| dlaruv.o: dlaruv.c ; $(CC) $(CFLAGS) -c -o $@ $< | |||
| sla_wwaddw.o: sla_wwaddw.c ; $(CC) $(CFLAGS) -c -o $@ $< | |||
| dla_wwaddw.o: dla_wwaddw.c ; $(CC) $(CFLAGS) -c -o $@ $< | |||
| cla_wwaddw.o: cla_wwaddw.c ; $(CC) $(CFLAGS) -c -o $@ $< | |||
| zla_wwaddw.o: zla_wwaddw.c ; $(CC) $(CFLAGS) -c -o $@ $< | |||
| endif | |||
| @@ -0,0 +1,808 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifndef _MSC_VER | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| #ifdef _MSC_VER | |||
| static inline _Fcomplex Cf(complex *z) {return z->r + z->i*I;} | |||
| static inline _Dcomplex Cd(doublecomplex *z) {return z->r + z->i*I;} | |||
| static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;} | |||
| static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;} | |||
| #else | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #endif | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| #ifdef _MSC_VER | |||
| static _Fcomplex cpow_ui(complex x, integer n) { | |||
| complex pow={1.0,0.0}; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x->r = 1/x->r; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return _Fcomplex(pow->r,pow->i); | |||
| } | |||
| #else | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| #endif | |||
| #ifdef _MSC_VER | |||
| static _Dcomplex zpow_ui(_Dcomplex x, integer n) { | |||
| _Dcomplex pow=1.0, unsigned long int u; | |||
| #else | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| #endif | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| #ifdef _MSC_VER | |||
| _Fcomplex zdotc = 0.0; | |||
| #else | |||
| _Complex float zdotc = 0.0; | |||
| #endif | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| #ifdef _MSC_VER | |||
| _Dcomplex zdotc = 0.0; | |||
| #else | |||
| _Complex double zdotc = 0.0; | |||
| #endif | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| #ifdef _MSC_VER | |||
| _Fcomplex zdotc = 0.0; | |||
| #else | |||
| _Complex float zdotc = 0.0; | |||
| #endif | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| #ifdef _MSC_VER | |||
| _Dcomplex zdotc = 0.0; | |||
| #else | |||
| _Complex double zdotc = 0.0; | |||
| #endif | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGBCON */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBCON + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbcon. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbcon. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbcon. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBCON( NORM, N, KL, KU, AB, LDAB, IPIV, ANORM, RCOND, */ | |||
| /* WORK, RWORK, INFO ) */ | |||
| /* CHARACTER NORM */ | |||
| /* INTEGER INFO, KL, KU, LDAB, N */ | |||
| /* REAL ANORM, RCOND */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX AB( LDAB, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBCON estimates the reciprocal of the condition number of a complex */ | |||
| /* > general band matrix A, in either the 1-norm or the infinity-norm, */ | |||
| /* > using the LU factorization computed by CGBTRF. */ | |||
| /* > */ | |||
| /* > An estimate is obtained for norm(inv(A)), and the reciprocal of the */ | |||
| /* > condition number is computed as */ | |||
| /* > RCOND = 1 / ( norm(A) * norm(inv(A)) ). */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies whether the 1-norm condition number or the */ | |||
| /* > infinity-norm condition number is required: */ | |||
| /* > = '1' or 'O': 1-norm; */ | |||
| /* > = 'I': Infinity-norm. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KL */ | |||
| /* > \verbatim */ | |||
| /* > KL is INTEGER */ | |||
| /* > The number of subdiagonals within the band of A. KL >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KU */ | |||
| /* > \verbatim */ | |||
| /* > KU is INTEGER */ | |||
| /* > The number of superdiagonals within the band of A. KU >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX array, dimension (LDAB,N) */ | |||
| /* > Details of the LU factorization of the band matrix A, as */ | |||
| /* > computed by CGBTRF. U is stored as an upper triangular band */ | |||
| /* > matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */ | |||
| /* > the multipliers used during the factorization are stored in */ | |||
| /* > rows KL+KU+2 to 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N) */ | |||
| /* > The pivot indices; for 1 <= i <= N, row i of the matrix was */ | |||
| /* > interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ANORM */ | |||
| /* > \verbatim */ | |||
| /* > ANORM is REAL */ | |||
| /* > If NORM = '1' or 'O', the 1-norm of the original matrix A. */ | |||
| /* > If NORM = 'I', the infinity-norm of the original matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RCOND */ | |||
| /* > \verbatim */ | |||
| /* > RCOND is REAL */ | |||
| /* > The reciprocal of the condition number of the matrix A, */ | |||
| /* > computed as RCOND = 1/(norm(A) * norm(inv(A))). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGBcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbcon_(char *norm, integer *n, integer *kl, integer *ku, | |||
| complex *ab, integer *ldab, integer *ipiv, real *anorm, real *rcond, | |||
| complex *work, real *rwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3; | |||
| real r__1, r__2; | |||
| complex q__1, q__2; | |||
| /* Local variables */ | |||
| integer kase, kase1, j; | |||
| complex t; | |||
| real scale; | |||
| extern /* Complex */ VOID cdotc_(complex *, integer *, complex *, integer | |||
| *, complex *, integer *); | |||
| extern logical lsame_(char *, char *); | |||
| integer isave[3]; | |||
| extern /* Subroutine */ int caxpy_(integer *, complex *, complex *, | |||
| integer *, complex *, integer *); | |||
| logical lnoti; | |||
| extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real | |||
| *, integer *, integer *); | |||
| integer kd, lm, jp, ix; | |||
| extern integer icamax_(integer *, complex *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int clatbs_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, integer *, complex *, real *, | |||
| real *, integer *), xerbla_(char * | |||
| , integer *, ftnlen); | |||
| real ainvnm; | |||
| extern /* Subroutine */ int csrscl_(integer *, real *, complex *, integer | |||
| *); | |||
| logical onenrm; | |||
| char normin[1]; | |||
| real smlnum; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --ipiv; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O"); | |||
| if (! onenrm && ! lsame_(norm, "I")) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*kl < 0) { | |||
| *info = -3; | |||
| } else if (*ku < 0) { | |||
| *info = -4; | |||
| } else if (*ldab < (*kl << 1) + *ku + 1) { | |||
| *info = -6; | |||
| } else if (*anorm < 0.f) { | |||
| *info = -8; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBCON", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| *rcond = 0.f; | |||
| if (*n == 0) { | |||
| *rcond = 1.f; | |||
| return 0; | |||
| } else if (*anorm == 0.f) { | |||
| return 0; | |||
| } | |||
| smlnum = slamch_("Safe minimum"); | |||
| /* Estimate the norm of inv(A). */ | |||
| ainvnm = 0.f; | |||
| *(unsigned char *)normin = 'N'; | |||
| if (onenrm) { | |||
| kase1 = 1; | |||
| } else { | |||
| kase1 = 2; | |||
| } | |||
| kd = *kl + *ku + 1; | |||
| lnoti = *kl > 0; | |||
| kase = 0; | |||
| L10: | |||
| clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave); | |||
| if (kase != 0) { | |||
| if (kase == kase1) { | |||
| /* Multiply by inv(L). */ | |||
| if (lnoti) { | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__2 = *kl, i__3 = *n - j; | |||
| lm = f2cmin(i__2,i__3); | |||
| jp = ipiv[j]; | |||
| i__2 = jp; | |||
| t.r = work[i__2].r, t.i = work[i__2].i; | |||
| if (jp != j) { | |||
| i__2 = jp; | |||
| i__3 = j; | |||
| work[i__2].r = work[i__3].r, work[i__2].i = work[i__3] | |||
| .i; | |||
| i__2 = j; | |||
| work[i__2].r = t.r, work[i__2].i = t.i; | |||
| } | |||
| q__1.r = -t.r, q__1.i = -t.i; | |||
| caxpy_(&lm, &q__1, &ab[kd + 1 + j * ab_dim1], &c__1, & | |||
| work[j + 1], &c__1); | |||
| /* L20: */ | |||
| } | |||
| } | |||
| /* Multiply by inv(U). */ | |||
| i__1 = *kl + *ku; | |||
| clatbs_("Upper", "No transpose", "Non-unit", normin, n, &i__1, & | |||
| ab[ab_offset], ldab, &work[1], &scale, &rwork[1], info); | |||
| } else { | |||
| /* Multiply by inv(U**H). */ | |||
| i__1 = *kl + *ku; | |||
| clatbs_("Upper", "Conjugate transpose", "Non-unit", normin, n, & | |||
| i__1, &ab[ab_offset], ldab, &work[1], &scale, &rwork[1], | |||
| info); | |||
| /* Multiply by inv(L**H). */ | |||
| if (lnoti) { | |||
| for (j = *n - 1; j >= 1; --j) { | |||
| /* Computing MIN */ | |||
| i__1 = *kl, i__2 = *n - j; | |||
| lm = f2cmin(i__1,i__2); | |||
| i__1 = j; | |||
| i__2 = j; | |||
| cdotc_(&q__2, &lm, &ab[kd + 1 + j * ab_dim1], &c__1, & | |||
| work[j + 1], &c__1); | |||
| q__1.r = work[i__2].r - q__2.r, q__1.i = work[i__2].i - | |||
| q__2.i; | |||
| work[i__1].r = q__1.r, work[i__1].i = q__1.i; | |||
| jp = ipiv[j]; | |||
| if (jp != j) { | |||
| i__1 = jp; | |||
| t.r = work[i__1].r, t.i = work[i__1].i; | |||
| i__1 = jp; | |||
| i__2 = j; | |||
| work[i__1].r = work[i__2].r, work[i__1].i = work[i__2] | |||
| .i; | |||
| i__1 = j; | |||
| work[i__1].r = t.r, work[i__1].i = t.i; | |||
| } | |||
| /* L30: */ | |||
| } | |||
| } | |||
| } | |||
| /* Divide X by 1/SCALE if doing so will not cause overflow. */ | |||
| *(unsigned char *)normin = 'Y'; | |||
| if (scale != 1.f) { | |||
| ix = icamax_(n, &work[1], &c__1); | |||
| i__1 = ix; | |||
| if (scale < ((r__1 = work[i__1].r, abs(r__1)) + (r__2 = r_imag(& | |||
| work[ix]), abs(r__2))) * smlnum || scale == 0.f) { | |||
| goto L40; | |||
| } | |||
| csrscl_(n, &scale, &work[1], &c__1); | |||
| } | |||
| goto L10; | |||
| } | |||
| /* Compute the estimate of the reciprocal condition number. */ | |||
| if (ainvnm != 0.f) { | |||
| *rcond = 1.f / ainvnm / *anorm; | |||
| } | |||
| L40: | |||
| return 0; | |||
| /* End of CGBCON */ | |||
| } /* cgbcon_ */ | |||
| @@ -0,0 +1,788 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b CGBEQU */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBEQU + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbequ. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbequ. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbequ. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBEQU( M, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND, */ | |||
| /* AMAX, INFO ) */ | |||
| /* INTEGER INFO, KL, KU, LDAB, M, N */ | |||
| /* REAL AMAX, COLCND, ROWCND */ | |||
| /* REAL C( * ), R( * ) */ | |||
| /* COMPLEX AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBEQU computes row and column scalings intended to equilibrate an */ | |||
| /* > M-by-N band matrix A and reduce its condition number. R returns the */ | |||
| /* > row scale factors and C the column scale factors, chosen to try to */ | |||
| /* > make the largest element in each row and column of the matrix B with */ | |||
| /* > elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1. */ | |||
| /* > */ | |||
| /* > R(i) and C(j) are restricted to be between SMLNUM = smallest safe */ | |||
| /* > number and BIGNUM = largest safe number. Use of these scaling */ | |||
| /* > factors is not guaranteed to reduce the condition number of A but */ | |||
| /* > works well in practice. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KL */ | |||
| /* > \verbatim */ | |||
| /* > KL is INTEGER */ | |||
| /* > The number of subdiagonals within the band of A. KL >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KU */ | |||
| /* > \verbatim */ | |||
| /* > KU is INTEGER */ | |||
| /* > The number of superdiagonals within the band of A. KU >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX array, dimension (LDAB,N) */ | |||
| /* > The band matrix A, stored in rows 1 to KL+KU+1. The j-th */ | |||
| /* > column of A is stored in the j-th column of the array AB as */ | |||
| /* > follows: */ | |||
| /* > AB(ku+1+i-j,j) = A(i,j) for f2cmax(1,j-ku)<=i<=f2cmin(m,j+kl). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] R */ | |||
| /* > \verbatim */ | |||
| /* > R is REAL array, dimension (M) */ | |||
| /* > If INFO = 0, or INFO > M, R contains the row scale factors */ | |||
| /* > for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is REAL array, dimension (N) */ | |||
| /* > If INFO = 0, C contains the column scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ROWCND */ | |||
| /* > \verbatim */ | |||
| /* > ROWCND is REAL */ | |||
| /* > If INFO = 0 or INFO > M, ROWCND contains the ratio of the */ | |||
| /* > smallest R(i) to the largest R(i). If ROWCND >= 0.1 and */ | |||
| /* > AMAX is neither too large nor too small, it is not worth */ | |||
| /* > scaling by R. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] COLCND */ | |||
| /* > \verbatim */ | |||
| /* > COLCND is REAL */ | |||
| /* > If INFO = 0, COLCND contains the ratio of the smallest */ | |||
| /* > C(i) to the largest C(i). If COLCND >= 0.1, it is not */ | |||
| /* > worth scaling by C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is REAL */ | |||
| /* > Absolute value of largest matrix element. If AMAX is very */ | |||
| /* > close to overflow or very close to underflow, the matrix */ | |||
| /* > should be scaled. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > > 0: if INFO = i, and i is */ | |||
| /* > <= M: the i-th row of A is exactly zero */ | |||
| /* > > M: the (i-M)-th column of A is exactly zero */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGBcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbequ_(integer *m, integer *n, integer *kl, integer *ku, | |||
| complex *ab, integer *ldab, real *r__, real *c__, real *rowcnd, real | |||
| *colcnd, real *amax, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4; | |||
| real r__1, r__2, r__3, r__4; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| real rcmin, rcmax; | |||
| integer kd; | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| real bignum, smlnum; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --r__; | |||
| --c__; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*kl < 0) { | |||
| *info = -3; | |||
| } else if (*ku < 0) { | |||
| *info = -4; | |||
| } else if (*ldab < *kl + *ku + 1) { | |||
| *info = -6; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBEQU", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*m == 0 || *n == 0) { | |||
| *rowcnd = 1.f; | |||
| *colcnd = 1.f; | |||
| *amax = 0.f; | |||
| return 0; | |||
| } | |||
| /* Get machine constants. */ | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| /* Compute row scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| r__[i__] = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* Find the maximum element in each row. */ | |||
| kd = *ku + 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__2 = j - *ku; | |||
| /* Computing MIN */ | |||
| i__4 = j + *kl; | |||
| i__3 = f2cmin(i__4,*m); | |||
| for (i__ = f2cmax(i__2,1); i__ <= i__3; ++i__) { | |||
| /* Computing MAX */ | |||
| i__2 = kd + i__ - j + j * ab_dim1; | |||
| r__3 = r__[i__], r__4 = (r__1 = ab[i__2].r, abs(r__1)) + (r__2 = | |||
| r_imag(&ab[kd + i__ - j + j * ab_dim1]), abs(r__2)); | |||
| r__[i__] = f2cmax(r__3,r__4); | |||
| /* L20: */ | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = r__[i__]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = r__[i__]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* L40: */ | |||
| } | |||
| *amax = rcmax; | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (r__[i__] == 0.f) { | |||
| *info = i__; | |||
| return 0; | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = r__[i__]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| r__[i__] = 1.f / f2cmin(r__1,bignum); | |||
| /* L60: */ | |||
| } | |||
| /* Compute ROWCND = f2cmin(R(I)) / f2cmax(R(I)) */ | |||
| *rowcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| /* Compute column scale factors */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| c__[j] = 0.f; | |||
| /* L70: */ | |||
| } | |||
| /* Find the maximum element in each column, */ | |||
| /* assuming the row scaling computed above. */ | |||
| kd = *ku + 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__3 = j - *ku; | |||
| /* Computing MIN */ | |||
| i__4 = j + *kl; | |||
| i__2 = f2cmin(i__4,*m); | |||
| for (i__ = f2cmax(i__3,1); i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = kd + i__ - j + j * ab_dim1; | |||
| r__3 = c__[j], r__4 = ((r__1 = ab[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&ab[kd + i__ - j + j * ab_dim1]), abs(r__2))) * | |||
| r__[i__]; | |||
| c__[j] = f2cmax(r__3,r__4); | |||
| /* L80: */ | |||
| } | |||
| /* L90: */ | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = c__[j]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = c__[j]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* L100: */ | |||
| } | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (c__[j] == 0.f) { | |||
| *info = *m + j; | |||
| return 0; | |||
| } | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = c__[j]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| c__[j] = 1.f / f2cmin(r__1,bignum); | |||
| /* L120: */ | |||
| } | |||
| /* Compute COLCND = f2cmin(C(J)) / f2cmax(C(J)) */ | |||
| *colcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| return 0; | |||
| /* End of CGBEQU */ | |||
| } /* cgbequ_ */ | |||
| @@ -0,0 +1,807 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b CGBEQUB */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBEQUB + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbequb | |||
| .f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbequb | |||
| .f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbequb | |||
| .f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBEQUB( M, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND, */ | |||
| /* AMAX, INFO ) */ | |||
| /* INTEGER INFO, KL, KU, LDAB, M, N */ | |||
| /* REAL AMAX, COLCND, ROWCND */ | |||
| /* REAL C( * ), R( * ) */ | |||
| /* COMPLEX AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBEQUB computes row and column scalings intended to equilibrate an */ | |||
| /* > M-by-N matrix A and reduce its condition number. R returns the row */ | |||
| /* > scale factors and C the column scale factors, chosen to try to make */ | |||
| /* > the largest element in each row and column of the matrix B with */ | |||
| /* > elements B(i,j)=R(i)*A(i,j)*C(j) have an absolute value of at most */ | |||
| /* > the radix. */ | |||
| /* > */ | |||
| /* > R(i) and C(j) are restricted to be a power of the radix between */ | |||
| /* > SMLNUM = smallest safe number and BIGNUM = largest safe number. Use */ | |||
| /* > of these scaling factors is not guaranteed to reduce the condition */ | |||
| /* > number of A but works well in practice. */ | |||
| /* > */ | |||
| /* > This routine differs from CGEEQU by restricting the scaling factors */ | |||
| /* > to a power of the radix. Barring over- and underflow, scaling by */ | |||
| /* > these factors introduces no additional rounding errors. However, the */ | |||
| /* > scaled entries' magnitudes are no longer approximately 1 but lie */ | |||
| /* > between sqrt(radix) and 1/sqrt(radix). */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KL */ | |||
| /* > \verbatim */ | |||
| /* > KL is INTEGER */ | |||
| /* > The number of subdiagonals within the band of A. KL >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KU */ | |||
| /* > \verbatim */ | |||
| /* > KU is INTEGER */ | |||
| /* > The number of superdiagonals within the band of A. KU >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX array, dimension (LDAB,N) */ | |||
| /* > On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */ | |||
| /* > The j-th column of A is stored in the j-th column of the */ | |||
| /* > array AB as follows: */ | |||
| /* > AB(KU+1+i-j,j) = A(i,j) for f2cmax(1,j-KU)<=i<=f2cmin(N,j+kl) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array A. LDAB >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] R */ | |||
| /* > \verbatim */ | |||
| /* > R is REAL array, dimension (M) */ | |||
| /* > If INFO = 0 or INFO > M, R contains the row scale factors */ | |||
| /* > for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is REAL array, dimension (N) */ | |||
| /* > If INFO = 0, C contains the column scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ROWCND */ | |||
| /* > \verbatim */ | |||
| /* > ROWCND is REAL */ | |||
| /* > If INFO = 0 or INFO > M, ROWCND contains the ratio of the */ | |||
| /* > smallest R(i) to the largest R(i). If ROWCND >= 0.1 and */ | |||
| /* > AMAX is neither too large nor too small, it is not worth */ | |||
| /* > scaling by R. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] COLCND */ | |||
| /* > \verbatim */ | |||
| /* > COLCND is REAL */ | |||
| /* > If INFO = 0, COLCND contains the ratio of the smallest */ | |||
| /* > C(i) to the largest C(i). If COLCND >= 0.1, it is not */ | |||
| /* > worth scaling by C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is REAL */ | |||
| /* > Absolute value of largest matrix element. If AMAX is very */ | |||
| /* > close to overflow or very close to underflow, the matrix */ | |||
| /* > should be scaled. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > > 0: if INFO = i, and i is */ | |||
| /* > <= M: the i-th row of A is exactly zero */ | |||
| /* > > M: the (i-M)-th column of A is exactly zero */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complexGBcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbequb_(integer *m, integer *n, integer *kl, integer * | |||
| ku, complex *ab, integer *ldab, real *r__, real *c__, real *rowcnd, | |||
| real *colcnd, real *amax, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4; | |||
| real r__1, r__2, r__3, r__4; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| real radix, rcmin, rcmax; | |||
| integer kd; | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| real bignum, logrdx, smlnum; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --r__; | |||
| --c__; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*kl < 0) { | |||
| *info = -3; | |||
| } else if (*ku < 0) { | |||
| *info = -4; | |||
| } else if (*ldab < *kl + *ku + 1) { | |||
| *info = -6; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBEQUB", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible. */ | |||
| if (*m == 0 || *n == 0) { | |||
| *rowcnd = 1.f; | |||
| *colcnd = 1.f; | |||
| *amax = 0.f; | |||
| return 0; | |||
| } | |||
| /* Get machine constants. Assume SMLNUM is a power of the radix. */ | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| radix = slamch_("B"); | |||
| logrdx = log(radix); | |||
| /* Compute row scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| r__[i__] = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* Find the maximum element in each row. */ | |||
| kd = *ku + 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__2 = j - *ku; | |||
| /* Computing MIN */ | |||
| i__4 = j + *kl; | |||
| i__3 = f2cmin(i__4,*m); | |||
| for (i__ = f2cmax(i__2,1); i__ <= i__3; ++i__) { | |||
| /* Computing MAX */ | |||
| i__2 = kd + i__ - j + j * ab_dim1; | |||
| r__3 = r__[i__], r__4 = (r__1 = ab[i__2].r, abs(r__1)) + (r__2 = | |||
| r_imag(&ab[kd + i__ - j + j * ab_dim1]), abs(r__2)); | |||
| r__[i__] = f2cmax(r__3,r__4); | |||
| /* L20: */ | |||
| } | |||
| /* L30: */ | |||
| } | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (r__[i__] > 0.f) { | |||
| i__3 = (integer) (log(r__[i__]) / logrdx); | |||
| r__[i__] = pow_ri(&radix, &i__3); | |||
| } | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = r__[i__]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = r__[i__]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* L40: */ | |||
| } | |||
| *amax = rcmax; | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (r__[i__] == 0.f) { | |||
| *info = i__; | |||
| return 0; | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = r__[i__]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| r__[i__] = 1.f / f2cmin(r__1,bignum); | |||
| /* L60: */ | |||
| } | |||
| /* Compute ROWCND = f2cmin(R(I)) / f2cmax(R(I)). */ | |||
| *rowcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| /* Compute column scale factors. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| c__[j] = 0.f; | |||
| /* L70: */ | |||
| } | |||
| /* Find the maximum element in each column, */ | |||
| /* assuming the row scaling computed above. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MAX */ | |||
| i__3 = j - *ku; | |||
| /* Computing MIN */ | |||
| i__4 = j + *kl; | |||
| i__2 = f2cmin(i__4,*m); | |||
| for (i__ = f2cmax(i__3,1); i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = kd + i__ - j + j * ab_dim1; | |||
| r__3 = c__[j], r__4 = ((r__1 = ab[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&ab[kd + i__ - j + j * ab_dim1]), abs(r__2))) * | |||
| r__[i__]; | |||
| c__[j] = f2cmax(r__3,r__4); | |||
| /* L80: */ | |||
| } | |||
| if (c__[j] > 0.f) { | |||
| i__2 = (integer) (log(c__[j]) / logrdx); | |||
| c__[j] = pow_ri(&radix, &i__2); | |||
| } | |||
| /* L90: */ | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = c__[j]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = c__[j]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* L100: */ | |||
| } | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (c__[j] == 0.f) { | |||
| *info = *m + j; | |||
| return 0; | |||
| } | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = c__[j]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| c__[j] = 1.f / f2cmin(r__1,bignum); | |||
| /* L120: */ | |||
| } | |||
| /* Compute COLCND = f2cmin(C(J)) / f2cmax(C(J)). */ | |||
| *colcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| return 0; | |||
| /* End of CGBEQUB */ | |||
| } /* cgbequb_ */ | |||
| @@ -0,0 +1,971 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGBRFS */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBRFS + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbrfs. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbrfs. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbrfs. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBRFS( TRANS, N, KL, KU, NRHS, AB, LDAB, AFB, LDAFB, */ | |||
| /* IPIV, B, LDB, X, LDX, FERR, BERR, WORK, RWORK, */ | |||
| /* INFO ) */ | |||
| /* CHARACTER TRANS */ | |||
| /* INTEGER INFO, KL, KU, LDAB, LDAFB, LDB, LDX, N, NRHS */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* REAL BERR( * ), FERR( * ), RWORK( * ) */ | |||
| /* COMPLEX AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ), */ | |||
| /* $ WORK( * ), X( LDX, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBRFS improves the computed solution to a system of linear */ | |||
| /* > equations when the coefficient matrix is banded, and provides */ | |||
| /* > error bounds and backward error estimates for the solution. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > Specifies the form of the system of equations: */ | |||
| /* > = 'N': A * X = B (No transpose) */ | |||
| /* > = 'T': A**T * X = B (Transpose) */ | |||
| /* > = 'C': A**H * X = B (Conjugate transpose) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KL */ | |||
| /* > \verbatim */ | |||
| /* > KL is INTEGER */ | |||
| /* > The number of subdiagonals within the band of A. KL >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KU */ | |||
| /* > \verbatim */ | |||
| /* > KU is INTEGER */ | |||
| /* > The number of superdiagonals within the band of A. KU >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of columns */ | |||
| /* > of the matrices B and X. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX array, dimension (LDAB,N) */ | |||
| /* > The original band matrix A, stored in rows 1 to KL+KU+1. */ | |||
| /* > The j-th column of A is stored in the j-th column of the */ | |||
| /* > array AB as follows: */ | |||
| /* > AB(ku+1+i-j,j) = A(i,j) for f2cmax(1,j-ku)<=i<=f2cmin(n,j+kl). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AFB */ | |||
| /* > \verbatim */ | |||
| /* > AFB is COMPLEX array, dimension (LDAFB,N) */ | |||
| /* > Details of the LU factorization of the band matrix A, as */ | |||
| /* > computed by CGBTRF. U is stored as an upper triangular band */ | |||
| /* > matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */ | |||
| /* > the multipliers used during the factorization are stored in */ | |||
| /* > rows KL+KU+2 to 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAFB */ | |||
| /* > \verbatim */ | |||
| /* > LDAFB is INTEGER */ | |||
| /* > The leading dimension of the array AFB. LDAFB >= 2*KL*KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N) */ | |||
| /* > The pivot indices from CGBTRF; for 1<=i<=N, row i of the */ | |||
| /* > matrix was interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > The right hand side matrix B. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] X */ | |||
| /* > \verbatim */ | |||
| /* > X is COMPLEX array, dimension (LDX,NRHS) */ | |||
| /* > On entry, the solution matrix X, as computed by CGBTRS. */ | |||
| /* > On exit, the improved solution matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDX */ | |||
| /* > \verbatim */ | |||
| /* > LDX is INTEGER */ | |||
| /* > The leading dimension of the array X. LDX >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] FERR */ | |||
| /* > \verbatim */ | |||
| /* > FERR is REAL array, dimension (NRHS) */ | |||
| /* > The estimated forward error bound for each solution vector */ | |||
| /* > X(j) (the j-th column of the solution matrix X). */ | |||
| /* > If XTRUE is the true solution corresponding to X(j), FERR(j) */ | |||
| /* > is an estimated upper bound for the magnitude of the largest */ | |||
| /* > element in (X(j) - XTRUE) divided by the magnitude of the */ | |||
| /* > largest element in X(j). The estimate is as reliable as */ | |||
| /* > the estimate for RCOND, and is almost always a slight */ | |||
| /* > overestimate of the true error. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] BERR */ | |||
| /* > \verbatim */ | |||
| /* > BERR is REAL array, dimension (NRHS) */ | |||
| /* > The componentwise relative backward error of each solution */ | |||
| /* > vector X(j) (i.e., the smallest relative change in */ | |||
| /* > any element of A or B that makes X(j) an exact solution). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* > \par Internal Parameters: */ | |||
| /* ========================= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > ITMAX is the maximum number of steps of iterative refinement. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGBcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbrfs_(char *trans, integer *n, integer *kl, integer * | |||
| ku, integer *nrhs, complex *ab, integer *ldab, complex *afb, integer * | |||
| ldafb, integer *ipiv, complex *b, integer *ldb, complex *x, integer * | |||
| ldx, real *ferr, real *berr, complex *work, real *rwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset, | |||
| x_dim1, x_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7; | |||
| real r__1, r__2, r__3, r__4; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer kase; | |||
| real safe1, safe2; | |||
| integer i__, j, k; | |||
| real s; | |||
| extern /* Subroutine */ int cgbmv_(char *, integer *, integer *, integer * | |||
| , integer *, complex *, complex *, integer *, complex *, integer * | |||
| , complex *, complex *, integer *); | |||
| extern logical lsame_(char *, char *); | |||
| integer isave[3]; | |||
| extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, | |||
| complex *, integer *), caxpy_(integer *, complex *, complex *, | |||
| integer *, complex *, integer *); | |||
| integer count; | |||
| extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real | |||
| *, integer *, integer *); | |||
| integer kk; | |||
| real xk; | |||
| extern real slamch_(char *); | |||
| integer nz; | |||
| real safmin; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), cgbtrs_( | |||
| char *, integer *, integer *, integer *, integer *, complex *, | |||
| integer *, integer *, complex *, integer *, integer *); | |||
| logical notran; | |||
| char transn[1], transt[1]; | |||
| real lstres, eps; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| afb_dim1 = *ldafb; | |||
| afb_offset = 1 + afb_dim1 * 1; | |||
| afb -= afb_offset; | |||
| --ipiv; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| x_dim1 = *ldx; | |||
| x_offset = 1 + x_dim1 * 1; | |||
| x -= x_offset; | |||
| --ferr; | |||
| --berr; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| notran = lsame_(trans, "N"); | |||
| if (! notran && ! lsame_(trans, "T") && ! lsame_( | |||
| trans, "C")) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*kl < 0) { | |||
| *info = -3; | |||
| } else if (*ku < 0) { | |||
| *info = -4; | |||
| } else if (*nrhs < 0) { | |||
| *info = -5; | |||
| } else if (*ldab < *kl + *ku + 1) { | |||
| *info = -7; | |||
| } else if (*ldafb < (*kl << 1) + *ku + 1) { | |||
| *info = -9; | |||
| } else if (*ldb < f2cmax(1,*n)) { | |||
| *info = -12; | |||
| } else if (*ldx < f2cmax(1,*n)) { | |||
| *info = -14; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBRFS", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0 || *nrhs == 0) { | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| ferr[j] = 0.f; | |||
| berr[j] = 0.f; | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| } | |||
| if (notran) { | |||
| *(unsigned char *)transn = 'N'; | |||
| *(unsigned char *)transt = 'C'; | |||
| } else { | |||
| *(unsigned char *)transn = 'C'; | |||
| *(unsigned char *)transt = 'N'; | |||
| } | |||
| /* NZ = maximum number of nonzero elements in each row of A, plus 1 */ | |||
| /* Computing MIN */ | |||
| i__1 = *kl + *ku + 2, i__2 = *n + 1; | |||
| nz = f2cmin(i__1,i__2); | |||
| eps = slamch_("Epsilon"); | |||
| safmin = slamch_("Safe minimum"); | |||
| safe1 = nz * safmin; | |||
| safe2 = safe1 / eps; | |||
| /* Do for each right hand side */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| count = 1; | |||
| lstres = 3.f; | |||
| L20: | |||
| /* Loop until stopping criterion is satisfied. */ | |||
| /* Compute residual R = B - op(A) * X, */ | |||
| /* where op(A) = A, A**T, or A**H, depending on TRANS. */ | |||
| ccopy_(n, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1); | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgbmv_(trans, n, n, kl, ku, &q__1, &ab[ab_offset], ldab, &x[j * | |||
| x_dim1 + 1], &c__1, &c_b1, &work[1], &c__1); | |||
| /* Compute componentwise relative backward error from formula */ | |||
| /* f2cmax(i) ( abs(R(i)) / ( abs(op(A))*abs(X) + abs(B) )(i) ) */ | |||
| /* where abs(Z) is the componentwise absolute value of the matrix */ | |||
| /* or vector Z. If the i-th component of the denominator is less */ | |||
| /* than SAFE2, then SAFE1 is added to the i-th components of the */ | |||
| /* numerator and denominator before dividing. */ | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| rwork[i__] = (r__1 = b[i__3].r, abs(r__1)) + (r__2 = r_imag(&b[ | |||
| i__ + j * b_dim1]), abs(r__2)); | |||
| /* L30: */ | |||
| } | |||
| /* Compute abs(op(A))*abs(X) + abs(B). */ | |||
| if (notran) { | |||
| i__2 = *n; | |||
| for (k = 1; k <= i__2; ++k) { | |||
| kk = *ku + 1 - k; | |||
| i__3 = k + j * x_dim1; | |||
| xk = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[k + j * | |||
| x_dim1]), abs(r__2)); | |||
| /* Computing MAX */ | |||
| i__3 = 1, i__4 = k - *ku; | |||
| /* Computing MIN */ | |||
| i__6 = *n, i__7 = k + *kl; | |||
| i__5 = f2cmin(i__6,i__7); | |||
| for (i__ = f2cmax(i__3,i__4); i__ <= i__5; ++i__) { | |||
| i__3 = kk + i__ + k * ab_dim1; | |||
| rwork[i__] += ((r__1 = ab[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&ab[kk + i__ + k * ab_dim1]), abs(r__2))) * | |||
| xk; | |||
| /* L40: */ | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } else { | |||
| i__2 = *n; | |||
| for (k = 1; k <= i__2; ++k) { | |||
| s = 0.f; | |||
| kk = *ku + 1 - k; | |||
| /* Computing MAX */ | |||
| i__5 = 1, i__3 = k - *ku; | |||
| /* Computing MIN */ | |||
| i__6 = *n, i__7 = k + *kl; | |||
| i__4 = f2cmin(i__6,i__7); | |||
| for (i__ = f2cmax(i__5,i__3); i__ <= i__4; ++i__) { | |||
| i__5 = kk + i__ + k * ab_dim1; | |||
| i__3 = i__ + j * x_dim1; | |||
| s += ((r__1 = ab[i__5].r, abs(r__1)) + (r__2 = r_imag(&ab[ | |||
| kk + i__ + k * ab_dim1]), abs(r__2))) * ((r__3 = | |||
| x[i__3].r, abs(r__3)) + (r__4 = r_imag(&x[i__ + j | |||
| * x_dim1]), abs(r__4))); | |||
| /* L60: */ | |||
| } | |||
| rwork[k] += s; | |||
| /* L70: */ | |||
| } | |||
| } | |||
| s = 0.f; | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| if (rwork[i__] > safe2) { | |||
| /* Computing MAX */ | |||
| i__4 = i__; | |||
| r__3 = s, r__4 = ((r__1 = work[i__4].r, abs(r__1)) + (r__2 = | |||
| r_imag(&work[i__]), abs(r__2))) / rwork[i__]; | |||
| s = f2cmax(r__3,r__4); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__4 = i__; | |||
| r__3 = s, r__4 = ((r__1 = work[i__4].r, abs(r__1)) + (r__2 = | |||
| r_imag(&work[i__]), abs(r__2)) + safe1) / (rwork[i__] | |||
| + safe1); | |||
| s = f2cmax(r__3,r__4); | |||
| } | |||
| /* L80: */ | |||
| } | |||
| berr[j] = s; | |||
| /* Test stopping criterion. Continue iterating if */ | |||
| /* 1) The residual BERR(J) is larger than machine epsilon, and */ | |||
| /* 2) BERR(J) decreased by at least a factor of 2 during the */ | |||
| /* last iteration, and */ | |||
| /* 3) At most ITMAX iterations tried. */ | |||
| if (berr[j] > eps && berr[j] * 2.f <= lstres && count <= 5) { | |||
| /* Update solution and try again. */ | |||
| cgbtrs_(trans, n, kl, ku, &c__1, &afb[afb_offset], ldafb, &ipiv[1] | |||
| , &work[1], n, info); | |||
| caxpy_(n, &c_b1, &work[1], &c__1, &x[j * x_dim1 + 1], &c__1); | |||
| lstres = berr[j]; | |||
| ++count; | |||
| goto L20; | |||
| } | |||
| /* Bound error from formula */ | |||
| /* norm(X - XTRUE) / norm(X) .le. FERR = */ | |||
| /* norm( abs(inv(op(A)))* */ | |||
| /* ( abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) / norm(X) */ | |||
| /* where */ | |||
| /* norm(Z) is the magnitude of the largest component of Z */ | |||
| /* inv(op(A)) is the inverse of op(A) */ | |||
| /* abs(Z) is the componentwise absolute value of the matrix or */ | |||
| /* vector Z */ | |||
| /* NZ is the maximum number of nonzeros in any row of A, plus 1 */ | |||
| /* EPS is machine epsilon */ | |||
| /* The i-th component of abs(R)+NZ*EPS*(abs(op(A))*abs(X)+abs(B)) */ | |||
| /* is incremented by SAFE1 if the i-th component of */ | |||
| /* abs(op(A))*abs(X) + abs(B) is less than SAFE2. */ | |||
| /* Use CLACN2 to estimate the infinity-norm of the matrix */ | |||
| /* inv(op(A)) * diag(W), */ | |||
| /* where W = abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) */ | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| if (rwork[i__] > safe2) { | |||
| i__4 = i__; | |||
| rwork[i__] = (r__1 = work[i__4].r, abs(r__1)) + (r__2 = | |||
| r_imag(&work[i__]), abs(r__2)) + nz * eps * rwork[i__] | |||
| ; | |||
| } else { | |||
| i__4 = i__; | |||
| rwork[i__] = (r__1 = work[i__4].r, abs(r__1)) + (r__2 = | |||
| r_imag(&work[i__]), abs(r__2)) + nz * eps * rwork[i__] | |||
| + safe1; | |||
| } | |||
| /* L90: */ | |||
| } | |||
| kase = 0; | |||
| L100: | |||
| clacn2_(n, &work[*n + 1], &work[1], &ferr[j], &kase, isave); | |||
| if (kase != 0) { | |||
| if (kase == 1) { | |||
| /* Multiply by diag(W)*inv(op(A)**H). */ | |||
| cgbtrs_(transt, n, kl, ku, &c__1, &afb[afb_offset], ldafb, & | |||
| ipiv[1], &work[1], n, info); | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__4 = i__; | |||
| i__5 = i__; | |||
| i__3 = i__; | |||
| q__1.r = rwork[i__5] * work[i__3].r, q__1.i = rwork[i__5] | |||
| * work[i__3].i; | |||
| work[i__4].r = q__1.r, work[i__4].i = q__1.i; | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| /* Multiply by inv(op(A))*diag(W). */ | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__4 = i__; | |||
| i__5 = i__; | |||
| i__3 = i__; | |||
| q__1.r = rwork[i__5] * work[i__3].r, q__1.i = rwork[i__5] | |||
| * work[i__3].i; | |||
| work[i__4].r = q__1.r, work[i__4].i = q__1.i; | |||
| /* L120: */ | |||
| } | |||
| cgbtrs_(transn, n, kl, ku, &c__1, &afb[afb_offset], ldafb, & | |||
| ipiv[1], &work[1], n, info); | |||
| } | |||
| goto L100; | |||
| } | |||
| /* Normalize error. */ | |||
| lstres = 0.f; | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__4 = i__ + j * x_dim1; | |||
| r__3 = lstres, r__4 = (r__1 = x[i__4].r, abs(r__1)) + (r__2 = | |||
| r_imag(&x[i__ + j * x_dim1]), abs(r__2)); | |||
| lstres = f2cmax(r__3,r__4); | |||
| /* L130: */ | |||
| } | |||
| if (lstres != 0.f) { | |||
| ferr[j] /= lstres; | |||
| } | |||
| /* L140: */ | |||
| } | |||
| return 0; | |||
| /* End of CGBRFS */ | |||
| } /* cgbrfs_ */ | |||
| @@ -0,0 +1,402 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| @@ -0,0 +1,643 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief <b> CGBSV computes the solution to system of linear equations A * X = B for GB matrices</b> (simpl | |||
| e driver) */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBSV + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbsv.f | |||
| "> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbsv.f | |||
| "> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbsv.f | |||
| "> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBSV( N, KL, KU, NRHS, AB, LDAB, IPIV, B, LDB, INFO ) */ | |||
| /* INTEGER INFO, KL, KU, LDAB, LDB, N, NRHS */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX AB( LDAB, * ), B( LDB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBSV computes the solution to a complex system of linear equations */ | |||
| /* > A * X = B, where A is a band matrix of order N with KL subdiagonals */ | |||
| /* > and KU superdiagonals, and X and B are N-by-NRHS matrices. */ | |||
| /* > */ | |||
| /* > The LU decomposition with partial pivoting and row interchanges is */ | |||
| /* > used to factor A as A = L * U, where L is a product of permutation */ | |||
| /* > and unit lower triangular matrices with KL subdiagonals, and U is */ | |||
| /* > upper triangular with KL+KU superdiagonals. The factored form of A */ | |||
| /* > is then used to solve the system of equations A * X = B. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of linear equations, i.e., the order of the */ | |||
| /* > matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KL */ | |||
| /* > \verbatim */ | |||
| /* > KL is INTEGER */ | |||
| /* > The number of subdiagonals within the band of A. KL >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KU */ | |||
| /* > \verbatim */ | |||
| /* > KU is INTEGER */ | |||
| /* > The number of superdiagonals within the band of A. KU >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of columns */ | |||
| /* > of the matrix B. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX array, dimension (LDAB,N) */ | |||
| /* > On entry, the matrix A in band storage, in rows KL+1 to */ | |||
| /* > 2*KL+KU+1; rows 1 to KL of the array need not be set. */ | |||
| /* > The j-th column of A is stored in the j-th column of the */ | |||
| /* > array AB as follows: */ | |||
| /* > AB(KL+KU+1+i-j,j) = A(i,j) for f2cmax(1,j-KU)<=i<=f2cmin(N,j+KL) */ | |||
| /* > On exit, details of the factorization: U is stored as an */ | |||
| /* > upper triangular band matrix with KL+KU superdiagonals in */ | |||
| /* > rows 1 to KL+KU+1, and the multipliers used during the */ | |||
| /* > factorization are stored in rows KL+KU+2 to 2*KL+KU+1. */ | |||
| /* > See below for further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N) */ | |||
| /* > The pivot indices that define the permutation matrix P; */ | |||
| /* > row i of the matrix was interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the N-by-NRHS right hand side matrix B. */ | |||
| /* > On exit, if INFO = 0, the N-by-NRHS solution matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > > 0: if INFO = i, U(i,i) is exactly zero. The factorization */ | |||
| /* > has been completed, but the factor U is exactly */ | |||
| /* > singular, and the solution has not been computed. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGBsolve */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The band storage scheme is illustrated by the following example, when */ | |||
| /* > M = N = 6, KL = 2, KU = 1: */ | |||
| /* > */ | |||
| /* > On entry: On exit: */ | |||
| /* > */ | |||
| /* > * * * + + + * * * u14 u25 u36 */ | |||
| /* > * * + + + + * * u13 u24 u35 u46 */ | |||
| /* > * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56 */ | |||
| /* > a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66 */ | |||
| /* > a21 a32 a43 a54 a65 * m21 m32 m43 m54 m65 * */ | |||
| /* > a31 a42 a53 a64 * * m31 m42 m53 m64 * * */ | |||
| /* > */ | |||
| /* > Array elements marked * are not used by the routine; elements marked */ | |||
| /* > + need not be set on entry, but are required by the routine to store */ | |||
| /* > elements of U because of fill-in resulting from the row interchanges. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbsv_(integer *n, integer *kl, integer *ku, integer * | |||
| nrhs, complex *ab, integer *ldab, integer *ipiv, complex *b, integer * | |||
| ldb, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, b_dim1, b_offset, i__1; | |||
| /* Local variables */ | |||
| extern /* Subroutine */ int cgbtrf_(integer *, integer *, integer *, | |||
| integer *, complex *, integer *, integer *, integer *), xerbla_( | |||
| char *, integer *, ftnlen), cgbtrs_(char *, integer *, integer *, | |||
| integer *, integer *, complex *, integer *, integer *, complex *, | |||
| integer *, integer *); | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --ipiv; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*n < 0) { | |||
| *info = -1; | |||
| } else if (*kl < 0) { | |||
| *info = -2; | |||
| } else if (*ku < 0) { | |||
| *info = -3; | |||
| } else if (*nrhs < 0) { | |||
| *info = -4; | |||
| } else if (*ldab < (*kl << 1) + *ku + 1) { | |||
| *info = -6; | |||
| } else if (*ldb < f2cmax(*n,1)) { | |||
| *info = -9; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBSV ", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Compute the LU factorization of the band matrix A. */ | |||
| cgbtrf_(n, n, kl, ku, &ab[ab_offset], ldab, &ipiv[1], info); | |||
| if (*info == 0) { | |||
| /* Solve the system A*X = B, overwriting B with X. */ | |||
| cgbtrs_("No transpose", n, kl, ku, nrhs, &ab[ab_offset], ldab, &ipiv[ | |||
| 1], &b[b_offset], ldb, info); | |||
| } | |||
| return 0; | |||
| /* End of CGBSV */ | |||
| } /* cgbsv_ */ | |||
| @@ -0,0 +1,720 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGBTF2 computes the LU factorization of a general band matrix using the unblocked version of th | |||
| e algorithm. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBTF2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbtf2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbtf2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbtf2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBTF2( M, N, KL, KU, AB, LDAB, IPIV, INFO ) */ | |||
| /* INTEGER INFO, KL, KU, LDAB, M, N */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX AB( LDAB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBTF2 computes an LU factorization of a complex m-by-n band matrix */ | |||
| /* > A using partial pivoting with row interchanges. */ | |||
| /* > */ | |||
| /* > This is the unblocked version of the algorithm, calling Level 2 BLAS. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KL */ | |||
| /* > \verbatim */ | |||
| /* > KL is INTEGER */ | |||
| /* > The number of subdiagonals within the band of A. KL >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KU */ | |||
| /* > \verbatim */ | |||
| /* > KU is INTEGER */ | |||
| /* > The number of superdiagonals within the band of A. KU >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX array, dimension (LDAB,N) */ | |||
| /* > On entry, the matrix A in band storage, in rows KL+1 to */ | |||
| /* > 2*KL+KU+1; rows 1 to KL of the array need not be set. */ | |||
| /* > The j-th column of A is stored in the j-th column of the */ | |||
| /* > array AB as follows: */ | |||
| /* > AB(kl+ku+1+i-j,j) = A(i,j) for f2cmax(1,j-ku)<=i<=f2cmin(m,j+kl) */ | |||
| /* > */ | |||
| /* > On exit, details of the factorization: U is stored as an */ | |||
| /* > upper triangular band matrix with KL+KU superdiagonals in */ | |||
| /* > rows 1 to KL+KU+1, and the multipliers used during the */ | |||
| /* > factorization are stored in rows KL+KU+2 to 2*KL+KU+1. */ | |||
| /* > See below for further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (f2cmin(M,N)) */ | |||
| /* > The pivot indices; for 1 <= i <= f2cmin(M,N), row i of the */ | |||
| /* > matrix was interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > > 0: if INFO = +i, U(i,i) is exactly zero. The factorization */ | |||
| /* > has been completed, but the factor U is exactly */ | |||
| /* > singular, and division by zero will occur if it is used */ | |||
| /* > to solve a system of equations. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGBcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The band storage scheme is illustrated by the following example, when */ | |||
| /* > M = N = 6, KL = 2, KU = 1: */ | |||
| /* > */ | |||
| /* > On entry: On exit: */ | |||
| /* > */ | |||
| /* > * * * + + + * * * u14 u25 u36 */ | |||
| /* > * * + + + + * * u13 u24 u35 u46 */ | |||
| /* > * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56 */ | |||
| /* > a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66 */ | |||
| /* > a21 a32 a43 a54 a65 * m21 m32 m43 m54 m65 * */ | |||
| /* > a31 a42 a53 a64 * * m31 m42 m53 m64 * * */ | |||
| /* > */ | |||
| /* > Array elements marked * are not used by the routine; elements marked */ | |||
| /* > + need not be set on entry, but are required by the routine to store */ | |||
| /* > elements of U, because of fill-in resulting from the row */ | |||
| /* > interchanges. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbtf2_(integer *m, integer *n, integer *kl, integer *ku, | |||
| complex *ab, integer *ldab, integer *ipiv, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cscal_(integer *, complex *, complex *, | |||
| integer *), cgeru_(integer *, integer *, complex *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *), cswap_( | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| integer km, jp, ju, kv; | |||
| extern integer icamax_(integer *, complex *, integer *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* KV is the number of superdiagonals in the factor U, allowing for */ | |||
| /* fill-in. */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --ipiv; | |||
| /* Function Body */ | |||
| kv = *ku + *kl; | |||
| /* Test the input parameters. */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*kl < 0) { | |||
| *info = -3; | |||
| } else if (*ku < 0) { | |||
| *info = -4; | |||
| } else if (*ldab < *kl + kv + 1) { | |||
| *info = -6; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBTF2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*m == 0 || *n == 0) { | |||
| return 0; | |||
| } | |||
| /* Gaussian elimination with partial pivoting */ | |||
| /* Set fill-in elements in columns KU+2 to KV to zero. */ | |||
| i__1 = f2cmin(kv,*n); | |||
| for (j = *ku + 2; j <= i__1; ++j) { | |||
| i__2 = *kl; | |||
| for (i__ = kv - j + 2; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * ab_dim1; | |||
| ab[i__3].r = 0.f, ab[i__3].i = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| /* JU is the index of the last column affected by the current stage */ | |||
| /* of the factorization. */ | |||
| ju = 1; | |||
| i__1 = f2cmin(*m,*n); | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Set fill-in elements in column J+KV to zero. */ | |||
| if (j + kv <= *n) { | |||
| i__2 = *kl; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + (j + kv) * ab_dim1; | |||
| ab[i__3].r = 0.f, ab[i__3].i = 0.f; | |||
| /* L30: */ | |||
| } | |||
| } | |||
| /* Find pivot and test for singularity. KM is the number of */ | |||
| /* subdiagonal elements in the current column. */ | |||
| /* Computing MIN */ | |||
| i__2 = *kl, i__3 = *m - j; | |||
| km = f2cmin(i__2,i__3); | |||
| i__2 = km + 1; | |||
| jp = icamax_(&i__2, &ab[kv + 1 + j * ab_dim1], &c__1); | |||
| ipiv[j] = jp + j - 1; | |||
| i__2 = kv + jp + j * ab_dim1; | |||
| if (ab[i__2].r != 0.f || ab[i__2].i != 0.f) { | |||
| /* Computing MAX */ | |||
| /* Computing MIN */ | |||
| i__4 = j + *ku + jp - 1; | |||
| i__2 = ju, i__3 = f2cmin(i__4,*n); | |||
| ju = f2cmax(i__2,i__3); | |||
| /* Apply interchange to columns J to JU. */ | |||
| if (jp != 1) { | |||
| i__2 = ju - j + 1; | |||
| i__3 = *ldab - 1; | |||
| i__4 = *ldab - 1; | |||
| cswap_(&i__2, &ab[kv + jp + j * ab_dim1], &i__3, &ab[kv + 1 + | |||
| j * ab_dim1], &i__4); | |||
| } | |||
| if (km > 0) { | |||
| /* Compute multipliers. */ | |||
| c_div(&q__1, &c_b1, &ab[kv + 1 + j * ab_dim1]); | |||
| cscal_(&km, &q__1, &ab[kv + 2 + j * ab_dim1], &c__1); | |||
| /* Update trailing submatrix within the band. */ | |||
| if (ju > j) { | |||
| i__2 = ju - j; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| i__3 = *ldab - 1; | |||
| i__4 = *ldab - 1; | |||
| cgeru_(&km, &i__2, &q__1, &ab[kv + 2 + j * ab_dim1], & | |||
| c__1, &ab[kv + (j + 1) * ab_dim1], &i__3, &ab[kv | |||
| + 1 + (j + 1) * ab_dim1], &i__4); | |||
| } | |||
| } | |||
| } else { | |||
| /* If pivot is zero, set INFO to the index of the pivot */ | |||
| /* unless a zero pivot has already been found. */ | |||
| if (*info == 0) { | |||
| *info = j; | |||
| } | |||
| } | |||
| /* L40: */ | |||
| } | |||
| return 0; | |||
| /* End of CGBTF2 */ | |||
| } /* cgbtf2_ */ | |||
| @@ -0,0 +1,744 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGBTRS */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGBTRS + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbtrs. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbtrs. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbtrs. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGBTRS( TRANS, N, KL, KU, NRHS, AB, LDAB, IPIV, B, LDB, */ | |||
| /* INFO ) */ | |||
| /* CHARACTER TRANS */ | |||
| /* INTEGER INFO, KL, KU, LDAB, LDB, N, NRHS */ | |||
| /* INTEGER IPIV( * ) */ | |||
| /* COMPLEX AB( LDAB, * ), B( LDB, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGBTRS solves a system of linear equations */ | |||
| /* > A * X = B, A**T * X = B, or A**H * X = B */ | |||
| /* > with a general band matrix A using the LU factorization computed */ | |||
| /* > by CGBTRF. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > Specifies the form of the system of equations. */ | |||
| /* > = 'N': A * X = B (No transpose) */ | |||
| /* > = 'T': A**T * X = B (Transpose) */ | |||
| /* > = 'C': A**H * X = B (Conjugate transpose) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KL */ | |||
| /* > \verbatim */ | |||
| /* > KL is INTEGER */ | |||
| /* > The number of subdiagonals within the band of A. KL >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] KU */ | |||
| /* > \verbatim */ | |||
| /* > KU is INTEGER */ | |||
| /* > The number of superdiagonals within the band of A. KU >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of columns */ | |||
| /* > of the matrix B. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] AB */ | |||
| /* > \verbatim */ | |||
| /* > AB is COMPLEX array, dimension (LDAB,N) */ | |||
| /* > Details of the LU factorization of the band matrix A, as */ | |||
| /* > computed by CGBTRF. U is stored as an upper triangular band */ | |||
| /* > matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */ | |||
| /* > the multipliers used during the factorization are stored in */ | |||
| /* > rows KL+KU+2 to 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDAB */ | |||
| /* > \verbatim */ | |||
| /* > LDAB is INTEGER */ | |||
| /* > The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IPIV */ | |||
| /* > \verbatim */ | |||
| /* > IPIV is INTEGER array, dimension (N) */ | |||
| /* > The pivot indices; for 1 <= i <= N, row i of the matrix was */ | |||
| /* > interchanged with row IPIV(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the right hand side matrix B. */ | |||
| /* > On exit, the solution matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGBcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgbtrs_(char *trans, integer *n, integer *kl, integer * | |||
| ku, integer *nrhs, complex *ab, integer *ldab, integer *ipiv, complex | |||
| *b, integer *ldb, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer ab_dim1, ab_offset, b_dim1, b_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j, l; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int cgemv_(char *, integer *, integer *, complex * | |||
| , complex *, integer *, complex *, integer *, complex *, complex * | |||
| , integer *), cgeru_(integer *, integer *, complex *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *), | |||
| cswap_(integer *, complex *, integer *, complex *, integer *), | |||
| ctbsv_(char *, char *, char *, integer *, integer *, complex *, | |||
| integer *, complex *, integer *); | |||
| logical lnoti; | |||
| integer kd, lm; | |||
| extern /* Subroutine */ int clacgv_(integer *, complex *, integer *), | |||
| xerbla_(char *, integer *, ftnlen); | |||
| logical notran; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| ab_dim1 = *ldab; | |||
| ab_offset = 1 + ab_dim1 * 1; | |||
| ab -= ab_offset; | |||
| --ipiv; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| notran = lsame_(trans, "N"); | |||
| if (! notran && ! lsame_(trans, "T") && ! lsame_( | |||
| trans, "C")) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*kl < 0) { | |||
| *info = -3; | |||
| } else if (*ku < 0) { | |||
| *info = -4; | |||
| } else if (*nrhs < 0) { | |||
| *info = -5; | |||
| } else if (*ldab < (*kl << 1) + *ku + 1) { | |||
| *info = -7; | |||
| } else if (*ldb < f2cmax(1,*n)) { | |||
| *info = -10; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGBTRS", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0 || *nrhs == 0) { | |||
| return 0; | |||
| } | |||
| kd = *ku + *kl + 1; | |||
| lnoti = *kl > 0; | |||
| if (notran) { | |||
| /* Solve A*X = B. */ | |||
| /* Solve L*X = B, overwriting B with X. */ | |||
| /* L is represented as a product of permutations and unit lower */ | |||
| /* triangular matrices L = P(1) * L(1) * ... * P(n-1) * L(n-1), */ | |||
| /* where each transformation L(i) is a rank-one modification of */ | |||
| /* the identity matrix. */ | |||
| if (lnoti) { | |||
| i__1 = *n - 1; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| i__2 = *kl, i__3 = *n - j; | |||
| lm = f2cmin(i__2,i__3); | |||
| l = ipiv[j]; | |||
| if (l != j) { | |||
| cswap_(nrhs, &b[l + b_dim1], ldb, &b[j + b_dim1], ldb); | |||
| } | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgeru_(&lm, nrhs, &q__1, &ab[kd + 1 + j * ab_dim1], &c__1, &b[ | |||
| j + b_dim1], ldb, &b[j + 1 + b_dim1], ldb); | |||
| /* L10: */ | |||
| } | |||
| } | |||
| i__1 = *nrhs; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Solve U*X = B, overwriting B with X. */ | |||
| i__2 = *kl + *ku; | |||
| ctbsv_("Upper", "No transpose", "Non-unit", n, &i__2, &ab[ | |||
| ab_offset], ldab, &b[i__ * b_dim1 + 1], &c__1); | |||
| /* L20: */ | |||
| } | |||
| } else if (lsame_(trans, "T")) { | |||
| /* Solve A**T * X = B. */ | |||
| i__1 = *nrhs; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Solve U**T * X = B, overwriting B with X. */ | |||
| i__2 = *kl + *ku; | |||
| ctbsv_("Upper", "Transpose", "Non-unit", n, &i__2, &ab[ab_offset], | |||
| ldab, &b[i__ * b_dim1 + 1], &c__1); | |||
| /* L30: */ | |||
| } | |||
| /* Solve L**T * X = B, overwriting B with X. */ | |||
| if (lnoti) { | |||
| for (j = *n - 1; j >= 1; --j) { | |||
| /* Computing MIN */ | |||
| i__1 = *kl, i__2 = *n - j; | |||
| lm = f2cmin(i__1,i__2); | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemv_("Transpose", &lm, nrhs, &q__1, &b[j + 1 + b_dim1], ldb, | |||
| &ab[kd + 1 + j * ab_dim1], &c__1, &c_b1, &b[j + | |||
| b_dim1], ldb); | |||
| l = ipiv[j]; | |||
| if (l != j) { | |||
| cswap_(nrhs, &b[l + b_dim1], ldb, &b[j + b_dim1], ldb); | |||
| } | |||
| /* L40: */ | |||
| } | |||
| } | |||
| } else { | |||
| /* Solve A**H * X = B. */ | |||
| i__1 = *nrhs; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Solve U**H * X = B, overwriting B with X. */ | |||
| i__2 = *kl + *ku; | |||
| ctbsv_("Upper", "Conjugate transpose", "Non-unit", n, &i__2, &ab[ | |||
| ab_offset], ldab, &b[i__ * b_dim1 + 1], &c__1); | |||
| /* L50: */ | |||
| } | |||
| /* Solve L**H * X = B, overwriting B with X. */ | |||
| if (lnoti) { | |||
| for (j = *n - 1; j >= 1; --j) { | |||
| /* Computing MIN */ | |||
| i__1 = *kl, i__2 = *n - j; | |||
| lm = f2cmin(i__1,i__2); | |||
| clacgv_(nrhs, &b[j + b_dim1], ldb); | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemv_("Conjugate transpose", &lm, nrhs, &q__1, &b[j + 1 + | |||
| b_dim1], ldb, &ab[kd + 1 + j * ab_dim1], &c__1, &c_b1, | |||
| &b[j + b_dim1], ldb); | |||
| clacgv_(nrhs, &b[j + b_dim1], ldb); | |||
| l = ipiv[j]; | |||
| if (l != j) { | |||
| cswap_(nrhs, &b[l + b_dim1], ldb, &b[j + b_dim1], ldb); | |||
| } | |||
| /* L60: */ | |||
| } | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGBTRS */ | |||
| } /* cgbtrs_ */ | |||
| @@ -0,0 +1,696 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b CGEBAK */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEBAK + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgebak. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgebak. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgebak. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEBAK( JOB, SIDE, N, ILO, IHI, SCALE, M, V, LDV, */ | |||
| /* INFO ) */ | |||
| /* CHARACTER JOB, SIDE */ | |||
| /* INTEGER IHI, ILO, INFO, LDV, M, N */ | |||
| /* REAL SCALE( * ) */ | |||
| /* COMPLEX V( LDV, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEBAK forms the right or left eigenvectors of a complex general */ | |||
| /* > matrix by backward transformation on the computed eigenvectors of the */ | |||
| /* > balanced matrix output by CGEBAL. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOB */ | |||
| /* > \verbatim */ | |||
| /* > JOB is CHARACTER*1 */ | |||
| /* > Specifies the type of backward transformation required: */ | |||
| /* > = 'N': do nothing, return immediately; */ | |||
| /* > = 'P': do backward transformation for permutation only; */ | |||
| /* > = 'S': do backward transformation for scaling only; */ | |||
| /* > = 'B': do backward transformations for both permutation and */ | |||
| /* > scaling. */ | |||
| /* > JOB must be the same as the argument JOB supplied to CGEBAL. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'R': V contains right eigenvectors; */ | |||
| /* > = 'L': V contains left eigenvectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of rows of the matrix V. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ILO */ | |||
| /* > \verbatim */ | |||
| /* > ILO is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IHI */ | |||
| /* > \verbatim */ | |||
| /* > IHI is INTEGER */ | |||
| /* > The integers ILO and IHI determined by CGEBAL. */ | |||
| /* > 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SCALE */ | |||
| /* > \verbatim */ | |||
| /* > SCALE is REAL array, dimension (N) */ | |||
| /* > Details of the permutation and scaling factors, as returned */ | |||
| /* > by CGEBAL. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of columns of the matrix V. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX array, dimension (LDV,M) */ | |||
| /* > On entry, the matrix of right or left eigenvectors to be */ | |||
| /* > transformed, as returned by CHSEIN or CTREVC. */ | |||
| /* > On exit, V is overwritten by the transformed eigenvectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. LDV >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgebak_(char *job, char *side, integer *n, integer *ilo, | |||
| integer *ihi, real *scale, integer *m, complex *v, integer *ldv, | |||
| integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer v_dim1, v_offset, i__1; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| real s; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int cswap_(integer *, complex *, integer *, | |||
| complex *, integer *); | |||
| logical leftv; | |||
| integer ii; | |||
| extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer | |||
| *), xerbla_(char *, integer *, ftnlen); | |||
| logical rightv; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Decode and Test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| --scale; | |||
| v_dim1 = *ldv; | |||
| v_offset = 1 + v_dim1 * 1; | |||
| v -= v_offset; | |||
| /* Function Body */ | |||
| rightv = lsame_(side, "R"); | |||
| leftv = lsame_(side, "L"); | |||
| *info = 0; | |||
| if (! lsame_(job, "N") && ! lsame_(job, "P") && ! lsame_(job, "S") | |||
| && ! lsame_(job, "B")) { | |||
| *info = -1; | |||
| } else if (! rightv && ! leftv) { | |||
| *info = -2; | |||
| } else if (*n < 0) { | |||
| *info = -3; | |||
| } else if (*ilo < 1 || *ilo > f2cmax(1,*n)) { | |||
| *info = -4; | |||
| } else if (*ihi < f2cmin(*ilo,*n) || *ihi > *n) { | |||
| *info = -5; | |||
| } else if (*m < 0) { | |||
| *info = -7; | |||
| } else if (*ldv < f2cmax(1,*n)) { | |||
| *info = -9; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEBAK", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| return 0; | |||
| } | |||
| if (*m == 0) { | |||
| return 0; | |||
| } | |||
| if (lsame_(job, "N")) { | |||
| return 0; | |||
| } | |||
| if (*ilo == *ihi) { | |||
| goto L30; | |||
| } | |||
| /* Backward balance */ | |||
| if (lsame_(job, "S") || lsame_(job, "B")) { | |||
| if (rightv) { | |||
| i__1 = *ihi; | |||
| for (i__ = *ilo; i__ <= i__1; ++i__) { | |||
| s = scale[i__]; | |||
| csscal_(m, &s, &v[i__ + v_dim1], ldv); | |||
| /* L10: */ | |||
| } | |||
| } | |||
| if (leftv) { | |||
| i__1 = *ihi; | |||
| for (i__ = *ilo; i__ <= i__1; ++i__) { | |||
| s = 1.f / scale[i__]; | |||
| csscal_(m, &s, &v[i__ + v_dim1], ldv); | |||
| /* L20: */ | |||
| } | |||
| } | |||
| } | |||
| /* Backward permutation */ | |||
| /* For I = ILO-1 step -1 until 1, */ | |||
| /* IHI+1 step 1 until N do -- */ | |||
| L30: | |||
| if (lsame_(job, "P") || lsame_(job, "B")) { | |||
| if (rightv) { | |||
| i__1 = *n; | |||
| for (ii = 1; ii <= i__1; ++ii) { | |||
| i__ = ii; | |||
| if (i__ >= *ilo && i__ <= *ihi) { | |||
| goto L40; | |||
| } | |||
| if (i__ < *ilo) { | |||
| i__ = *ilo - ii; | |||
| } | |||
| k = scale[i__]; | |||
| if (k == i__) { | |||
| goto L40; | |||
| } | |||
| cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); | |||
| L40: | |||
| ; | |||
| } | |||
| } | |||
| if (leftv) { | |||
| i__1 = *n; | |||
| for (ii = 1; ii <= i__1; ++ii) { | |||
| i__ = ii; | |||
| if (i__ >= *ilo && i__ <= *ihi) { | |||
| goto L50; | |||
| } | |||
| if (i__ < *ilo) { | |||
| i__ = *ilo - ii; | |||
| } | |||
| k = scale[i__]; | |||
| if (k == i__) { | |||
| goto L50; | |||
| } | |||
| cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv); | |||
| L50: | |||
| ; | |||
| } | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGEBAK */ | |||
| } /* cgebak_ */ | |||
| @@ -0,0 +1,864 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGEBAL */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEBAL + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgebal. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgebal. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgebal. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEBAL( JOB, N, A, LDA, ILO, IHI, SCALE, INFO ) */ | |||
| /* CHARACTER JOB */ | |||
| /* INTEGER IHI, ILO, INFO, LDA, N */ | |||
| /* REAL SCALE( * ) */ | |||
| /* COMPLEX A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEBAL balances a general complex matrix A. This involves, first, */ | |||
| /* > permuting A by a similarity transformation to isolate eigenvalues */ | |||
| /* > in the first 1 to ILO-1 and last IHI+1 to N elements on the */ | |||
| /* > diagonal; and second, applying a diagonal similarity transformation */ | |||
| /* > to rows and columns ILO to IHI to make the rows and columns as */ | |||
| /* > close in norm as possible. Both steps are optional. */ | |||
| /* > */ | |||
| /* > Balancing may reduce the 1-norm of the matrix, and improve the */ | |||
| /* > accuracy of the computed eigenvalues and/or eigenvectors. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOB */ | |||
| /* > \verbatim */ | |||
| /* > JOB is CHARACTER*1 */ | |||
| /* > Specifies the operations to be performed on A: */ | |||
| /* > = 'N': none: simply set ILO = 1, IHI = N, SCALE(I) = 1.0 */ | |||
| /* > for i = 1,...,N; */ | |||
| /* > = 'P': permute only; */ | |||
| /* > = 'S': scale only; */ | |||
| /* > = 'B': both permute and scale. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the input matrix A. */ | |||
| /* > On exit, A is overwritten by the balanced matrix. */ | |||
| /* > If JOB = 'N', A is not referenced. */ | |||
| /* > See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ILO */ | |||
| /* > \verbatim */ | |||
| /* > ILO is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > \param[out] IHI */ | |||
| /* > \verbatim */ | |||
| /* > IHI is INTEGER */ | |||
| /* > ILO and IHI are set to integers such that on exit */ | |||
| /* > A(i,j) = 0 if i > j and j = 1,...,ILO-1 or I = IHI+1,...,N. */ | |||
| /* > If JOB = 'N' or 'S', ILO = 1 and IHI = N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SCALE */ | |||
| /* > \verbatim */ | |||
| /* > SCALE is REAL array, dimension (N) */ | |||
| /* > Details of the permutations and scaling factors applied to */ | |||
| /* > A. If P(j) is the index of the row and column interchanged */ | |||
| /* > with row and column j and D(j) is the scaling factor */ | |||
| /* > applied to row and column j, then */ | |||
| /* > SCALE(j) = P(j) for j = 1,...,ILO-1 */ | |||
| /* > = D(j) for j = ILO,...,IHI */ | |||
| /* > = P(j) for j = IHI+1,...,N. */ | |||
| /* > The order in which the interchanges are made is N to IHI+1, */ | |||
| /* > then 1 to ILO-1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit. */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The permutations consist of row and column interchanges which put */ | |||
| /* > the matrix in the form */ | |||
| /* > */ | |||
| /* > ( T1 X Y ) */ | |||
| /* > P A P = ( 0 B Z ) */ | |||
| /* > ( 0 0 T2 ) */ | |||
| /* > */ | |||
| /* > where T1 and T2 are upper triangular matrices whose eigenvalues lie */ | |||
| /* > along the diagonal. The column indices ILO and IHI mark the starting */ | |||
| /* > and ending columns of the submatrix B. Balancing consists of applying */ | |||
| /* > a diagonal similarity transformation inv(D) * B * D to make the */ | |||
| /* > 1-norms of each row of B and its corresponding column nearly equal. */ | |||
| /* > The output matrix is */ | |||
| /* > */ | |||
| /* > ( T1 X*D Y ) */ | |||
| /* > ( 0 inv(D)*B*D inv(D)*Z ). */ | |||
| /* > ( 0 0 T2 ) */ | |||
| /* > */ | |||
| /* > Information about the permutations P and the diagonal matrix D is */ | |||
| /* > returned in the vector SCALE. */ | |||
| /* > */ | |||
| /* > This subroutine is based on the EISPACK routine CBAL. */ | |||
| /* > */ | |||
| /* > Modified by Tzu-Yi Chen, Computer Science Division, University of */ | |||
| /* > California at Berkeley, USA */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgebal_(char *job, integer *n, complex *a, integer *lda, | |||
| integer *ilo, integer *ihi, real *scale, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| real r__1, r__2; | |||
| /* Local variables */ | |||
| integer iexc; | |||
| real c__, f, g; | |||
| integer i__, j, k, l, m; | |||
| real r__, s; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int cswap_(integer *, complex *, integer *, | |||
| complex *, integer *); | |||
| real sfmin1, sfmin2, sfmax1, sfmax2, ca; | |||
| extern real scnrm2_(integer *, complex *, integer *); | |||
| real ra; | |||
| extern integer icamax_(integer *, complex *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer | |||
| *), xerbla_(char *, integer *, ftnlen); | |||
| extern logical sisnan_(real *); | |||
| logical noconv; | |||
| integer ica, ira; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --scale; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (! lsame_(job, "N") && ! lsame_(job, "P") && ! lsame_(job, "S") | |||
| && ! lsame_(job, "B")) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEBAL", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| k = 1; | |||
| l = *n; | |||
| if (*n == 0) { | |||
| goto L210; | |||
| } | |||
| if (lsame_(job, "N")) { | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| scale[i__] = 1.f; | |||
| /* L10: */ | |||
| } | |||
| goto L210; | |||
| } | |||
| if (lsame_(job, "S")) { | |||
| goto L120; | |||
| } | |||
| /* Permutation to isolate eigenvalues if possible */ | |||
| goto L50; | |||
| /* Row and column exchange. */ | |||
| L20: | |||
| scale[m] = (real) j; | |||
| if (j == m) { | |||
| goto L30; | |||
| } | |||
| cswap_(&l, &a[j * a_dim1 + 1], &c__1, &a[m * a_dim1 + 1], &c__1); | |||
| i__1 = *n - k + 1; | |||
| cswap_(&i__1, &a[j + k * a_dim1], lda, &a[m + k * a_dim1], lda); | |||
| L30: | |||
| switch (iexc) { | |||
| case 1: goto L40; | |||
| case 2: goto L80; | |||
| } | |||
| /* Search for rows isolating an eigenvalue and push them down. */ | |||
| L40: | |||
| if (l == 1) { | |||
| goto L210; | |||
| } | |||
| --l; | |||
| L50: | |||
| for (j = l; j >= 1; --j) { | |||
| i__1 = l; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (i__ == j) { | |||
| goto L60; | |||
| } | |||
| i__2 = j + i__ * a_dim1; | |||
| if (a[i__2].r != 0.f || r_imag(&a[j + i__ * a_dim1]) != 0.f) { | |||
| goto L70; | |||
| } | |||
| L60: | |||
| ; | |||
| } | |||
| m = l; | |||
| iexc = 1; | |||
| goto L20; | |||
| L70: | |||
| ; | |||
| } | |||
| goto L90; | |||
| /* Search for columns isolating an eigenvalue and push them left. */ | |||
| L80: | |||
| ++k; | |||
| L90: | |||
| i__1 = l; | |||
| for (j = k; j <= i__1; ++j) { | |||
| i__2 = l; | |||
| for (i__ = k; i__ <= i__2; ++i__) { | |||
| if (i__ == j) { | |||
| goto L100; | |||
| } | |||
| i__3 = i__ + j * a_dim1; | |||
| if (a[i__3].r != 0.f || r_imag(&a[i__ + j * a_dim1]) != 0.f) { | |||
| goto L110; | |||
| } | |||
| L100: | |||
| ; | |||
| } | |||
| m = k; | |||
| iexc = 2; | |||
| goto L20; | |||
| L110: | |||
| ; | |||
| } | |||
| L120: | |||
| i__1 = l; | |||
| for (i__ = k; i__ <= i__1; ++i__) { | |||
| scale[i__] = 1.f; | |||
| /* L130: */ | |||
| } | |||
| if (lsame_(job, "P")) { | |||
| goto L210; | |||
| } | |||
| /* Balance the submatrix in rows K to L. */ | |||
| /* Iterative loop for norm reduction */ | |||
| sfmin1 = slamch_("S") / slamch_("P"); | |||
| sfmax1 = 1.f / sfmin1; | |||
| sfmin2 = sfmin1 * 2.f; | |||
| sfmax2 = 1.f / sfmin2; | |||
| L140: | |||
| noconv = FALSE_; | |||
| i__1 = l; | |||
| for (i__ = k; i__ <= i__1; ++i__) { | |||
| i__2 = l - k + 1; | |||
| c__ = scnrm2_(&i__2, &a[k + i__ * a_dim1], &c__1); | |||
| i__2 = l - k + 1; | |||
| r__ = scnrm2_(&i__2, &a[i__ + k * a_dim1], lda); | |||
| ica = icamax_(&l, &a[i__ * a_dim1 + 1], &c__1); | |||
| ca = c_abs(&a[ica + i__ * a_dim1]); | |||
| i__2 = *n - k + 1; | |||
| ira = icamax_(&i__2, &a[i__ + k * a_dim1], lda); | |||
| ra = c_abs(&a[i__ + (ira + k - 1) * a_dim1]); | |||
| /* Guard against zero C or R due to underflow. */ | |||
| if (c__ == 0.f || r__ == 0.f) { | |||
| goto L200; | |||
| } | |||
| g = r__ / 2.f; | |||
| f = 1.f; | |||
| s = c__ + r__; | |||
| L160: | |||
| /* Computing MAX */ | |||
| r__1 = f2cmax(f,c__); | |||
| /* Computing MIN */ | |||
| r__2 = f2cmin(r__,g); | |||
| if (c__ >= g || f2cmax(r__1,ca) >= sfmax2 || f2cmin(r__2,ra) <= sfmin2) { | |||
| goto L170; | |||
| } | |||
| r__1 = c__ + f + ca + r__ + g + ra; | |||
| if (sisnan_(&r__1)) { | |||
| /* Exit if NaN to avoid infinite loop */ | |||
| *info = -3; | |||
| i__2 = -(*info); | |||
| xerbla_("CGEBAL", &i__2, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| f *= 2.f; | |||
| c__ *= 2.f; | |||
| ca *= 2.f; | |||
| r__ /= 2.f; | |||
| g /= 2.f; | |||
| ra /= 2.f; | |||
| goto L160; | |||
| L170: | |||
| g = c__ / 2.f; | |||
| L180: | |||
| /* Computing MIN */ | |||
| r__1 = f2cmin(f,c__), r__1 = f2cmin(r__1,g); | |||
| if (g < r__ || f2cmax(r__,ra) >= sfmax2 || f2cmin(r__1,ca) <= sfmin2) { | |||
| goto L190; | |||
| } | |||
| f /= 2.f; | |||
| c__ /= 2.f; | |||
| g /= 2.f; | |||
| ca /= 2.f; | |||
| r__ *= 2.f; | |||
| ra *= 2.f; | |||
| goto L180; | |||
| /* Now balance. */ | |||
| L190: | |||
| if (c__ + r__ >= s * .95f) { | |||
| goto L200; | |||
| } | |||
| if (f < 1.f && scale[i__] < 1.f) { | |||
| if (f * scale[i__] <= sfmin1) { | |||
| goto L200; | |||
| } | |||
| } | |||
| if (f > 1.f && scale[i__] > 1.f) { | |||
| if (scale[i__] >= sfmax1 / f) { | |||
| goto L200; | |||
| } | |||
| } | |||
| g = 1.f / f; | |||
| scale[i__] *= f; | |||
| noconv = TRUE_; | |||
| i__2 = *n - k + 1; | |||
| csscal_(&i__2, &g, &a[i__ + k * a_dim1], lda); | |||
| csscal_(&l, &f, &a[i__ * a_dim1 + 1], &c__1); | |||
| L200: | |||
| ; | |||
| } | |||
| if (noconv) { | |||
| goto L140; | |||
| } | |||
| L210: | |||
| *ilo = k; | |||
| *ihi = l; | |||
| return 0; | |||
| /* End of CGEBAL */ | |||
| } /* cgebal_ */ | |||
| @@ -0,0 +1,805 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGEBD2 reduces a general matrix to bidiagonal form using an unblocked algorithm. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEBD2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgebd2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgebd2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgebd2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEBD2( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* REAL D( * ), E( * ) */ | |||
| /* COMPLEX A( LDA, * ), TAUP( * ), TAUQ( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEBD2 reduces a complex general m by n matrix A to upper or lower */ | |||
| /* > real bidiagonal form B by a unitary transformation: Q**H * A * P = B. */ | |||
| /* > */ | |||
| /* > If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows in the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns in the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the m by n general matrix to be reduced. */ | |||
| /* > On exit, */ | |||
| /* > if m >= n, the diagonal and the first superdiagonal are */ | |||
| /* > overwritten with the upper bidiagonal matrix B; the */ | |||
| /* > elements below the diagonal, with the array TAUQ, represent */ | |||
| /* > the unitary matrix Q as a product of elementary */ | |||
| /* > reflectors, and the elements above the first superdiagonal, */ | |||
| /* > with the array TAUP, represent the unitary matrix P as */ | |||
| /* > a product of elementary reflectors; */ | |||
| /* > if m < n, the diagonal and the first subdiagonal are */ | |||
| /* > overwritten with the lower bidiagonal matrix B; the */ | |||
| /* > elements below the first subdiagonal, with the array TAUQ, */ | |||
| /* > represent the unitary matrix Q as a product of */ | |||
| /* > elementary reflectors, and the elements above the diagonal, */ | |||
| /* > with the array TAUP, represent the unitary matrix P as */ | |||
| /* > a product of elementary reflectors. */ | |||
| /* > See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] D */ | |||
| /* > \verbatim */ | |||
| /* > D is REAL array, dimension (f2cmin(M,N)) */ | |||
| /* > The diagonal elements of the bidiagonal matrix B: */ | |||
| /* > D(i) = A(i,i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] E */ | |||
| /* > \verbatim */ | |||
| /* > E is REAL array, dimension (f2cmin(M,N)-1) */ | |||
| /* > The off-diagonal elements of the bidiagonal matrix B: */ | |||
| /* > if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1; */ | |||
| /* > if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAUQ */ | |||
| /* > \verbatim */ | |||
| /* > TAUQ is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors which */ | |||
| /* > represent the unitary matrix Q. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAUP */ | |||
| /* > \verbatim */ | |||
| /* > TAUP is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors which */ | |||
| /* > represent the unitary matrix P. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (f2cmax(M,N)) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2017 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* @precisions normal c -> s d z */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrices Q and P are represented as products of elementary */ | |||
| /* > reflectors: */ | |||
| /* > */ | |||
| /* > If m >= n, */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1) */ | |||
| /* > */ | |||
| /* > Each H(i) and G(i) has the form: */ | |||
| /* > */ | |||
| /* > H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H */ | |||
| /* > */ | |||
| /* > where tauq and taup are complex scalars, and v and u are complex */ | |||
| /* > vectors; v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in */ | |||
| /* > A(i+1:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in */ | |||
| /* > A(i,i+2:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */ | |||
| /* > */ | |||
| /* > If m < n, */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m) */ | |||
| /* > */ | |||
| /* > Each H(i) and G(i) has the form: */ | |||
| /* > */ | |||
| /* > H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H */ | |||
| /* > */ | |||
| /* > where tauq and taup are complex scalars, v and u are complex vectors; */ | |||
| /* > v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i); */ | |||
| /* > u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n); */ | |||
| /* > tauq is stored in TAUQ(i) and taup in TAUP(i). */ | |||
| /* > */ | |||
| /* > The contents of A on exit are illustrated by the following examples: */ | |||
| /* > */ | |||
| /* > m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n): */ | |||
| /* > */ | |||
| /* > ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 ) */ | |||
| /* > ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 ) */ | |||
| /* > ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 ) */ | |||
| /* > ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 ) */ | |||
| /* > ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 ) */ | |||
| /* > ( v1 v2 v3 v4 v5 ) */ | |||
| /* > */ | |||
| /* > where d and e denote diagonal and off-diagonal elements of B, vi */ | |||
| /* > denotes an element of the vector defining H(i), and ui an element of */ | |||
| /* > the vector defining G(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgebd2_(integer *m, integer *n, complex *a, integer *lda, | |||
| real *d__, real *e, complex *tauq, complex *taup, complex *work, | |||
| integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__; | |||
| complex alpha; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| clarfg_(integer *, complex *, complex *, integer *, complex *), | |||
| clacgv_(integer *, complex *, integer *), xerbla_(char *, integer | |||
| *, ftnlen); | |||
| /* -- LAPACK computational routine (version 3.7.1) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --d__; | |||
| --e; | |||
| --tauq; | |||
| --taup; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info < 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEBD2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| if (*m >= *n) { | |||
| /* Reduce to upper bidiagonal form */ | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Generate elementary reflector H(i) to annihilate A(i+1:m,i) */ | |||
| i__2 = i__ + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = *m - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 1; | |||
| clarfg_(&i__2, &alpha, &a[f2cmin(i__3,*m) + i__ * a_dim1], &c__1, & | |||
| tauq[i__]); | |||
| i__2 = i__; | |||
| d__[i__2] = alpha.r; | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* Apply H(i)**H to A(i:m,i+1:n) from the left */ | |||
| if (i__ < *n) { | |||
| i__2 = *m - i__ + 1; | |||
| i__3 = *n - i__; | |||
| r_cnjg(&q__1, &tauq[i__]); | |||
| clarf_("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, & | |||
| q__1, &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]); | |||
| } | |||
| i__2 = i__ + i__ * a_dim1; | |||
| i__3 = i__; | |||
| a[i__2].r = d__[i__3], a[i__2].i = 0.f; | |||
| if (i__ < *n) { | |||
| /* Generate elementary reflector G(i) to annihilate */ | |||
| /* A(i,i+2:n) */ | |||
| i__2 = *n - i__; | |||
| clacgv_(&i__2, &a[i__ + (i__ + 1) * a_dim1], lda); | |||
| i__2 = i__ + (i__ + 1) * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = *n - i__; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 2; | |||
| clarfg_(&i__2, &alpha, &a[i__ + f2cmin(i__3,*n) * a_dim1], lda, & | |||
| taup[i__]); | |||
| i__2 = i__; | |||
| e[i__2] = alpha.r; | |||
| i__2 = i__ + (i__ + 1) * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* Apply G(i) to A(i+1:m,i+1:n) from the right */ | |||
| i__2 = *m - i__; | |||
| i__3 = *n - i__; | |||
| clarf_("Right", &i__2, &i__3, &a[i__ + (i__ + 1) * a_dim1], | |||
| lda, &taup[i__], &a[i__ + 1 + (i__ + 1) * a_dim1], | |||
| lda, &work[1]); | |||
| i__2 = *n - i__; | |||
| clacgv_(&i__2, &a[i__ + (i__ + 1) * a_dim1], lda); | |||
| i__2 = i__ + (i__ + 1) * a_dim1; | |||
| i__3 = i__; | |||
| a[i__2].r = e[i__3], a[i__2].i = 0.f; | |||
| } else { | |||
| i__2 = i__; | |||
| taup[i__2].r = 0.f, taup[i__2].i = 0.f; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| /* Reduce to lower bidiagonal form */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Generate elementary reflector G(i) to annihilate A(i,i+1:n) */ | |||
| i__2 = *n - i__ + 1; | |||
| clacgv_(&i__2, &a[i__ + i__ * a_dim1], lda); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = *n - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 1; | |||
| clarfg_(&i__2, &alpha, &a[i__ + f2cmin(i__3,*n) * a_dim1], lda, & | |||
| taup[i__]); | |||
| i__2 = i__; | |||
| d__[i__2] = alpha.r; | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* Apply G(i) to A(i+1:m,i:n) from the right */ | |||
| if (i__ < *m) { | |||
| i__2 = *m - i__; | |||
| i__3 = *n - i__ + 1; | |||
| clarf_("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, & | |||
| taup[i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]); | |||
| } | |||
| i__2 = *n - i__ + 1; | |||
| clacgv_(&i__2, &a[i__ + i__ * a_dim1], lda); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| i__3 = i__; | |||
| a[i__2].r = d__[i__3], a[i__2].i = 0.f; | |||
| if (i__ < *m) { | |||
| /* Generate elementary reflector H(i) to annihilate */ | |||
| /* A(i+2:m,i) */ | |||
| i__2 = i__ + 1 + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = *m - i__; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 2; | |||
| clarfg_(&i__2, &alpha, &a[f2cmin(i__3,*m) + i__ * a_dim1], &c__1, | |||
| &tauq[i__]); | |||
| i__2 = i__; | |||
| e[i__2] = alpha.r; | |||
| i__2 = i__ + 1 + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* Apply H(i)**H to A(i+1:m,i+1:n) from the left */ | |||
| i__2 = *m - i__; | |||
| i__3 = *n - i__; | |||
| r_cnjg(&q__1, &tauq[i__]); | |||
| clarf_("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], & | |||
| c__1, &q__1, &a[i__ + 1 + (i__ + 1) * a_dim1], lda, & | |||
| work[1]); | |||
| i__2 = i__ + 1 + i__ * a_dim1; | |||
| i__3 = i__; | |||
| a[i__2].r = e[i__3], a[i__2].i = 0.f; | |||
| } else { | |||
| i__2 = i__; | |||
| tauq[i__2].r = 0.f, tauq[i__2].i = 0.f; | |||
| } | |||
| /* L20: */ | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGEBD2 */ | |||
| } /* cgebd2_ */ | |||
| @@ -0,0 +1,819 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b1 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGEBRD */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEBRD + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgebrd. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgebrd. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgebrd. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEBRD( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK, */ | |||
| /* INFO ) */ | |||
| /* INTEGER INFO, LDA, LWORK, M, N */ | |||
| /* REAL D( * ), E( * ) */ | |||
| /* COMPLEX A( LDA, * ), TAUP( * ), TAUQ( * ), */ | |||
| /* $ WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEBRD reduces a general complex M-by-N matrix A to upper or lower */ | |||
| /* > bidiagonal form B by a unitary transformation: Q**H * A * P = B. */ | |||
| /* > */ | |||
| /* > If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows in the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns in the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N general matrix to be reduced. */ | |||
| /* > On exit, */ | |||
| /* > if m >= n, the diagonal and the first superdiagonal are */ | |||
| /* > overwritten with the upper bidiagonal matrix B; the */ | |||
| /* > elements below the diagonal, with the array TAUQ, represent */ | |||
| /* > the unitary matrix Q as a product of elementary */ | |||
| /* > reflectors, and the elements above the first superdiagonal, */ | |||
| /* > with the array TAUP, represent the unitary matrix P as */ | |||
| /* > a product of elementary reflectors; */ | |||
| /* > if m < n, the diagonal and the first subdiagonal are */ | |||
| /* > overwritten with the lower bidiagonal matrix B; the */ | |||
| /* > elements below the first subdiagonal, with the array TAUQ, */ | |||
| /* > represent the unitary matrix Q as a product of */ | |||
| /* > elementary reflectors, and the elements above the diagonal, */ | |||
| /* > with the array TAUP, represent the unitary matrix P as */ | |||
| /* > a product of elementary reflectors. */ | |||
| /* > See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] D */ | |||
| /* > \verbatim */ | |||
| /* > D is REAL array, dimension (f2cmin(M,N)) */ | |||
| /* > The diagonal elements of the bidiagonal matrix B: */ | |||
| /* > D(i) = A(i,i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] E */ | |||
| /* > \verbatim */ | |||
| /* > E is REAL array, dimension (f2cmin(M,N)-1) */ | |||
| /* > The off-diagonal elements of the bidiagonal matrix B: */ | |||
| /* > if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1; */ | |||
| /* > if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAUQ */ | |||
| /* > \verbatim */ | |||
| /* > TAUQ is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors which */ | |||
| /* > represent the unitary matrix Q. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAUP */ | |||
| /* > \verbatim */ | |||
| /* > TAUP is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors which */ | |||
| /* > represent the unitary matrix P. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The length of the array WORK. LWORK >= f2cmax(1,M,N). */ | |||
| /* > For optimum performance LWORK >= (M+N)*NB, where NB */ | |||
| /* > is the optimal blocksize. */ | |||
| /* > */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates the optimal size of the WORK array, returns */ | |||
| /* > this value as the first entry of the WORK array, and no error */ | |||
| /* > message related to LWORK is issued by XERBLA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit. */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2017 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrices Q and P are represented as products of elementary */ | |||
| /* > reflectors: */ | |||
| /* > */ | |||
| /* > If m >= n, */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1) */ | |||
| /* > */ | |||
| /* > Each H(i) and G(i) has the form: */ | |||
| /* > */ | |||
| /* > H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H */ | |||
| /* > */ | |||
| /* > where tauq and taup are complex scalars, and v and u are complex */ | |||
| /* > vectors; v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in */ | |||
| /* > A(i+1:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in */ | |||
| /* > A(i,i+2:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */ | |||
| /* > */ | |||
| /* > If m < n, */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m) */ | |||
| /* > */ | |||
| /* > Each H(i) and G(i) has the form: */ | |||
| /* > */ | |||
| /* > H(i) = I - tauq * v * v**H and G(i) = I - taup * u * u**H */ | |||
| /* > */ | |||
| /* > where tauq and taup are complex scalars, and v and u are complex */ | |||
| /* > vectors; v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in */ | |||
| /* > A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in */ | |||
| /* > A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */ | |||
| /* > */ | |||
| /* > The contents of A on exit are illustrated by the following examples: */ | |||
| /* > */ | |||
| /* > m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n): */ | |||
| /* > */ | |||
| /* > ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 ) */ | |||
| /* > ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 ) */ | |||
| /* > ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 ) */ | |||
| /* > ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 ) */ | |||
| /* > ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 ) */ | |||
| /* > ( v1 v2 v3 v4 v5 ) */ | |||
| /* > */ | |||
| /* > where d and e denote diagonal and off-diagonal elements of B, vi */ | |||
| /* > denotes an element of the vector defining H(i), and ui an element of */ | |||
| /* > the vector defining G(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgebrd_(integer *m, integer *n, complex *a, integer *lda, | |||
| real *d__, real *e, complex *tauq, complex *taup, complex *work, | |||
| integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5; | |||
| real r__1; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, | |||
| integer *, complex *, complex *, integer *, complex *, integer *, | |||
| complex *, complex *, integer *); | |||
| integer nbmin, iinfo, minmn; | |||
| extern /* Subroutine */ int cgebd2_(integer *, integer *, complex *, | |||
| integer *, real *, real *, complex *, complex *, complex *, | |||
| integer *); | |||
| integer nb; | |||
| extern /* Subroutine */ int clabrd_(integer *, integer *, integer *, | |||
| complex *, integer *, real *, real *, complex *, complex *, | |||
| complex *, integer *, complex *, integer *); | |||
| integer nx, ws; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer ldwrkx, ldwrky, lwkopt; | |||
| logical lquery; | |||
| /* -- LAPACK computational routine (version 3.8.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* November 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --d__; | |||
| --e; | |||
| --tauq; | |||
| --taup; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = ilaenv_(&c__1, "CGEBRD", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nb = f2cmax(i__1,i__2); | |||
| lwkopt = (*m + *n) * nb; | |||
| r__1 = (real) lwkopt; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(1,*m); | |||
| if (*lwork < f2cmax(i__1,*n) && ! lquery) { | |||
| *info = -10; | |||
| } | |||
| } | |||
| if (*info < 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEBRD", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| minmn = f2cmin(*m,*n); | |||
| if (minmn == 0) { | |||
| work[1].r = 1.f, work[1].i = 0.f; | |||
| return 0; | |||
| } | |||
| ws = f2cmax(*m,*n); | |||
| ldwrkx = *m; | |||
| ldwrky = *n; | |||
| if (nb > 1 && nb < minmn) { | |||
| /* Set the crossover point NX. */ | |||
| /* Computing MAX */ | |||
| i__1 = nb, i__2 = ilaenv_(&c__3, "CGEBRD", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| /* Determine when to switch from blocked to unblocked code. */ | |||
| if (nx < minmn) { | |||
| ws = (*m + *n) * nb; | |||
| if (*lwork < ws) { | |||
| /* Not enough work space for the optimal NB, consider using */ | |||
| /* a smaller block size. */ | |||
| nbmin = ilaenv_(&c__2, "CGEBRD", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| if (*lwork >= (*m + *n) * nbmin) { | |||
| nb = *lwork / (*m + *n); | |||
| } else { | |||
| nb = 1; | |||
| nx = minmn; | |||
| } | |||
| } | |||
| } | |||
| } else { | |||
| nx = minmn; | |||
| } | |||
| i__1 = minmn - nx; | |||
| i__2 = nb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Reduce rows and columns i:i+ib-1 to bidiagonal form and return */ | |||
| /* the matrices X and Y which are needed to update the unreduced */ | |||
| /* part of the matrix */ | |||
| i__3 = *m - i__ + 1; | |||
| i__4 = *n - i__ + 1; | |||
| clabrd_(&i__3, &i__4, &nb, &a[i__ + i__ * a_dim1], lda, &d__[i__], &e[ | |||
| i__], &tauq[i__], &taup[i__], &work[1], &ldwrkx, &work[ldwrkx | |||
| * nb + 1], &ldwrky); | |||
| /* Update the trailing submatrix A(i+ib:m,i+ib:n), using */ | |||
| /* an update of the form A := A - V*Y**H - X*U**H */ | |||
| i__3 = *m - i__ - nb + 1; | |||
| i__4 = *n - i__ - nb + 1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemm_("No transpose", "Conjugate transpose", &i__3, &i__4, &nb, & | |||
| q__1, &a[i__ + nb + i__ * a_dim1], lda, &work[ldwrkx * nb + | |||
| nb + 1], &ldwrky, &c_b1, &a[i__ + nb + (i__ + nb) * a_dim1], | |||
| lda); | |||
| i__3 = *m - i__ - nb + 1; | |||
| i__4 = *n - i__ - nb + 1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemm_("No transpose", "No transpose", &i__3, &i__4, &nb, &q__1, & | |||
| work[nb + 1], &ldwrkx, &a[i__ + (i__ + nb) * a_dim1], lda, & | |||
| c_b1, &a[i__ + nb + (i__ + nb) * a_dim1], lda); | |||
| /* Copy diagonal and off-diagonal elements of B back into A */ | |||
| if (*m >= *n) { | |||
| i__3 = i__ + nb - 1; | |||
| for (j = i__; j <= i__3; ++j) { | |||
| i__4 = j + j * a_dim1; | |||
| i__5 = j; | |||
| a[i__4].r = d__[i__5], a[i__4].i = 0.f; | |||
| i__4 = j + (j + 1) * a_dim1; | |||
| i__5 = j; | |||
| a[i__4].r = e[i__5], a[i__4].i = 0.f; | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| i__3 = i__ + nb - 1; | |||
| for (j = i__; j <= i__3; ++j) { | |||
| i__4 = j + j * a_dim1; | |||
| i__5 = j; | |||
| a[i__4].r = d__[i__5], a[i__4].i = 0.f; | |||
| i__4 = j + 1 + j * a_dim1; | |||
| i__5 = j; | |||
| a[i__4].r = e[i__5], a[i__4].i = 0.f; | |||
| /* L20: */ | |||
| } | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* Use unblocked code to reduce the remainder of the matrix */ | |||
| i__2 = *m - i__ + 1; | |||
| i__1 = *n - i__ + 1; | |||
| cgebd2_(&i__2, &i__1, &a[i__ + i__ * a_dim1], lda, &d__[i__], &e[i__], & | |||
| tauq[i__], &taup[i__], &work[1], &iinfo); | |||
| work[1].r = (real) ws, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEBRD */ | |||
| } /* cgebrd_ */ | |||
| @@ -0,0 +1,679 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGECON */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGECON + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgecon. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgecon. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgecon. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGECON( NORM, N, A, LDA, ANORM, RCOND, WORK, RWORK, */ | |||
| /* INFO ) */ | |||
| /* CHARACTER NORM */ | |||
| /* INTEGER INFO, LDA, N */ | |||
| /* REAL ANORM, RCOND */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGECON estimates the reciprocal of the condition number of a general */ | |||
| /* > complex matrix A, in either the 1-norm or the infinity-norm, using */ | |||
| /* > the LU factorization computed by CGETRF. */ | |||
| /* > */ | |||
| /* > An estimate is obtained for norm(inv(A)), and the reciprocal of the */ | |||
| /* > condition number is computed as */ | |||
| /* > RCOND = 1 / ( norm(A) * norm(inv(A)) ). */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] NORM */ | |||
| /* > \verbatim */ | |||
| /* > NORM is CHARACTER*1 */ | |||
| /* > Specifies whether the 1-norm condition number or the */ | |||
| /* > infinity-norm condition number is required: */ | |||
| /* > = '1' or 'O': 1-norm; */ | |||
| /* > = 'I': Infinity-norm. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > The factors L and U from the factorization A = P*L*U */ | |||
| /* > as computed by CGETRF. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ANORM */ | |||
| /* > \verbatim */ | |||
| /* > ANORM is REAL */ | |||
| /* > If NORM = '1' or 'O', the 1-norm of the original matrix A. */ | |||
| /* > If NORM = 'I', the infinity-norm of the original matrix A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RCOND */ | |||
| /* > \verbatim */ | |||
| /* > RCOND is REAL */ | |||
| /* > The reciprocal of the condition number of the matrix A, */ | |||
| /* > computed as RCOND = 1/(norm(A) * norm(inv(A))). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgecon_(char *norm, integer *n, complex *a, integer *lda, | |||
| real *anorm, real *rcond, complex *work, real *rwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1; | |||
| real r__1, r__2; | |||
| /* Local variables */ | |||
| integer kase, kase1; | |||
| real scale; | |||
| extern logical lsame_(char *, char *); | |||
| integer isave[3]; | |||
| extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real | |||
| *, integer *, integer *); | |||
| real sl; | |||
| integer ix; | |||
| extern integer icamax_(integer *, complex *, integer *); | |||
| extern real slamch_(char *); | |||
| real su; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| real ainvnm; | |||
| extern /* Subroutine */ int clatrs_(char *, char *, char *, char *, | |||
| integer *, complex *, integer *, complex *, real *, real *, | |||
| integer *), csrscl_(integer *, | |||
| real *, complex *, integer *); | |||
| logical onenrm; | |||
| char normin[1]; | |||
| real smlnum; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O"); | |||
| if (! onenrm && ! lsame_(norm, "I")) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -4; | |||
| } else if (*anorm < 0.f) { | |||
| *info = -5; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGECON", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| *rcond = 0.f; | |||
| if (*n == 0) { | |||
| *rcond = 1.f; | |||
| return 0; | |||
| } else if (*anorm == 0.f) { | |||
| return 0; | |||
| } | |||
| smlnum = slamch_("Safe minimum"); | |||
| /* Estimate the norm of inv(A). */ | |||
| ainvnm = 0.f; | |||
| *(unsigned char *)normin = 'N'; | |||
| if (onenrm) { | |||
| kase1 = 1; | |||
| } else { | |||
| kase1 = 2; | |||
| } | |||
| kase = 0; | |||
| L10: | |||
| clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave); | |||
| if (kase != 0) { | |||
| if (kase == kase1) { | |||
| /* Multiply by inv(L). */ | |||
| clatrs_("Lower", "No transpose", "Unit", normin, n, &a[a_offset], | |||
| lda, &work[1], &sl, &rwork[1], info); | |||
| /* Multiply by inv(U). */ | |||
| clatrs_("Upper", "No transpose", "Non-unit", normin, n, &a[ | |||
| a_offset], lda, &work[1], &su, &rwork[*n + 1], info); | |||
| } else { | |||
| /* Multiply by inv(U**H). */ | |||
| clatrs_("Upper", "Conjugate transpose", "Non-unit", normin, n, &a[ | |||
| a_offset], lda, &work[1], &su, &rwork[*n + 1], info); | |||
| /* Multiply by inv(L**H). */ | |||
| clatrs_("Lower", "Conjugate transpose", "Unit", normin, n, &a[ | |||
| a_offset], lda, &work[1], &sl, &rwork[1], info); | |||
| } | |||
| /* Divide X by 1/(SL*SU) if doing so will not cause overflow. */ | |||
| scale = sl * su; | |||
| *(unsigned char *)normin = 'Y'; | |||
| if (scale != 1.f) { | |||
| ix = icamax_(n, &work[1], &c__1); | |||
| i__1 = ix; | |||
| if (scale < ((r__1 = work[i__1].r, abs(r__1)) + (r__2 = r_imag(& | |||
| work[ix]), abs(r__2))) * smlnum || scale == 0.f) { | |||
| goto L20; | |||
| } | |||
| csrscl_(n, &scale, &work[1], &c__1); | |||
| } | |||
| goto L10; | |||
| } | |||
| /* Compute the estimate of the reciprocal condition number. */ | |||
| if (ainvnm != 0.f) { | |||
| *rcond = 1.f / ainvnm / *anorm; | |||
| } | |||
| L20: | |||
| return 0; | |||
| /* End of CGECON */ | |||
| } /* cgecon_ */ | |||
| @@ -0,0 +1,758 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b CGEEQU */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEEQU + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeequ. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeequ. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeequ. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEEQU( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX, */ | |||
| /* INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* REAL AMAX, COLCND, ROWCND */ | |||
| /* REAL C( * ), R( * ) */ | |||
| /* COMPLEX A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEEQU computes row and column scalings intended to equilibrate an */ | |||
| /* > M-by-N matrix A and reduce its condition number. R returns the row */ | |||
| /* > scale factors and C the column scale factors, chosen to try to make */ | |||
| /* > the largest element in each row and column of the matrix B with */ | |||
| /* > elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1. */ | |||
| /* > */ | |||
| /* > R(i) and C(j) are restricted to be between SMLNUM = smallest safe */ | |||
| /* > number and BIGNUM = largest safe number. Use of these scaling */ | |||
| /* > factors is not guaranteed to reduce the condition number of A but */ | |||
| /* > works well in practice. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > The M-by-N matrix whose equilibration factors are */ | |||
| /* > to be computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] R */ | |||
| /* > \verbatim */ | |||
| /* > R is REAL array, dimension (M) */ | |||
| /* > If INFO = 0 or INFO > M, R contains the row scale factors */ | |||
| /* > for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is REAL array, dimension (N) */ | |||
| /* > If INFO = 0, C contains the column scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ROWCND */ | |||
| /* > \verbatim */ | |||
| /* > ROWCND is REAL */ | |||
| /* > If INFO = 0 or INFO > M, ROWCND contains the ratio of the */ | |||
| /* > smallest R(i) to the largest R(i). If ROWCND >= 0.1 and */ | |||
| /* > AMAX is neither too large nor too small, it is not worth */ | |||
| /* > scaling by R. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] COLCND */ | |||
| /* > \verbatim */ | |||
| /* > COLCND is REAL */ | |||
| /* > If INFO = 0, COLCND contains the ratio of the smallest */ | |||
| /* > C(i) to the largest C(i). If COLCND >= 0.1, it is not */ | |||
| /* > worth scaling by C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is REAL */ | |||
| /* > Absolute value of largest matrix element. If AMAX is very */ | |||
| /* > close to overflow or very close to underflow, the matrix */ | |||
| /* > should be scaled. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > > 0: if INFO = i, and i is */ | |||
| /* > <= M: the i-th row of A is exactly zero */ | |||
| /* > > M: the (i-M)-th column of A is exactly zero */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeequ_(integer *m, integer *n, complex *a, integer *lda, | |||
| real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, | |||
| integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| real r__1, r__2, r__3, r__4; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| real rcmin, rcmax; | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| real bignum, smlnum; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --r__; | |||
| --c__; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEEQU", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*m == 0 || *n == 0) { | |||
| *rowcnd = 1.f; | |||
| *colcnd = 1.f; | |||
| *amax = 0.f; | |||
| return 0; | |||
| } | |||
| /* Get machine constants. */ | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| /* Compute row scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| r__[i__] = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* Find the maximum element in each row. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = i__ + j * a_dim1; | |||
| r__3 = r__[i__], r__4 = (r__1 = a[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&a[i__ + j * a_dim1]), abs(r__2)); | |||
| r__[i__] = f2cmax(r__3,r__4); | |||
| /* L20: */ | |||
| } | |||
| /* L30: */ | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = r__[i__]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = r__[i__]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* L40: */ | |||
| } | |||
| *amax = rcmax; | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (r__[i__] == 0.f) { | |||
| *info = i__; | |||
| return 0; | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = r__[i__]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| r__[i__] = 1.f / f2cmin(r__1,bignum); | |||
| /* L60: */ | |||
| } | |||
| /* Compute ROWCND = f2cmin(R(I)) / f2cmax(R(I)) */ | |||
| *rowcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| /* Compute column scale factors */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| c__[j] = 0.f; | |||
| /* L70: */ | |||
| } | |||
| /* Find the maximum element in each column, */ | |||
| /* assuming the row scaling computed above. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = i__ + j * a_dim1; | |||
| r__3 = c__[j], r__4 = ((r__1 = a[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&a[i__ + j * a_dim1]), abs(r__2))) * r__[i__]; | |||
| c__[j] = f2cmax(r__3,r__4); | |||
| /* L80: */ | |||
| } | |||
| /* L90: */ | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = c__[j]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = c__[j]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* L100: */ | |||
| } | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (c__[j] == 0.f) { | |||
| *info = *m + j; | |||
| return 0; | |||
| } | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = c__[j]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| c__[j] = 1.f / f2cmin(r__1,bignum); | |||
| /* L120: */ | |||
| } | |||
| /* Compute COLCND = f2cmin(C(J)) / f2cmax(C(J)) */ | |||
| *colcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| return 0; | |||
| /* End of CGEEQU */ | |||
| } /* cgeequ_ */ | |||
| @@ -0,0 +1,778 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b CGEEQUB */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEEQUB + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeequb | |||
| .f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeequb | |||
| .f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeequb | |||
| .f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEEQUB( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX, */ | |||
| /* INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* REAL AMAX, COLCND, ROWCND */ | |||
| /* REAL C( * ), R( * ) */ | |||
| /* COMPLEX A( LDA, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEEQUB computes row and column scalings intended to equilibrate an */ | |||
| /* > M-by-N matrix A and reduce its condition number. R returns the row */ | |||
| /* > scale factors and C the column scale factors, chosen to try to make */ | |||
| /* > the largest element in each row and column of the matrix B with */ | |||
| /* > elements B(i,j)=R(i)*A(i,j)*C(j) have an absolute value of at most */ | |||
| /* > the radix. */ | |||
| /* > */ | |||
| /* > R(i) and C(j) are restricted to be a power of the radix between */ | |||
| /* > SMLNUM = smallest safe number and BIGNUM = largest safe number. Use */ | |||
| /* > of these scaling factors is not guaranteed to reduce the condition */ | |||
| /* > number of A but works well in practice. */ | |||
| /* > */ | |||
| /* > This routine differs from CGEEQU by restricting the scaling factors */ | |||
| /* > to a power of the radix. Barring over- and underflow, scaling by */ | |||
| /* > these factors introduces no additional rounding errors. However, the */ | |||
| /* > scaled entries' magnitudes are no longer approximately 1 but lie */ | |||
| /* > between sqrt(radix) and 1/sqrt(radix). */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > The M-by-N matrix whose equilibration factors are */ | |||
| /* > to be computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] R */ | |||
| /* > \verbatim */ | |||
| /* > R is REAL array, dimension (M) */ | |||
| /* > If INFO = 0 or INFO > M, R contains the row scale factors */ | |||
| /* > for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is REAL array, dimension (N) */ | |||
| /* > If INFO = 0, C contains the column scale factors for A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] ROWCND */ | |||
| /* > \verbatim */ | |||
| /* > ROWCND is REAL */ | |||
| /* > If INFO = 0 or INFO > M, ROWCND contains the ratio of the */ | |||
| /* > smallest R(i) to the largest R(i). If ROWCND >= 0.1 and */ | |||
| /* > AMAX is neither too large nor too small, it is not worth */ | |||
| /* > scaling by R. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] COLCND */ | |||
| /* > \verbatim */ | |||
| /* > COLCND is REAL */ | |||
| /* > If INFO = 0, COLCND contains the ratio of the smallest */ | |||
| /* > C(i) to the largest C(i). If COLCND >= 0.1, it is not */ | |||
| /* > worth scaling by C. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] AMAX */ | |||
| /* > \verbatim */ | |||
| /* > AMAX is REAL */ | |||
| /* > Absolute value of largest matrix element. If AMAX is very */ | |||
| /* > close to overflow or very close to underflow, the matrix */ | |||
| /* > should be scaled. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > > 0: if INFO = i, and i is */ | |||
| /* > <= M: the i-th row of A is exactly zero */ | |||
| /* > > M: the (i-M)-th column of A is exactly zero */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeequb_(integer *m, integer *n, complex *a, integer * | |||
| lda, real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, | |||
| integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| real r__1, r__2, r__3, r__4; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| real radix, rcmin, rcmax; | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| real bignum, logrdx, smlnum; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --r__; | |||
| --c__; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEEQUB", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible. */ | |||
| if (*m == 0 || *n == 0) { | |||
| *rowcnd = 1.f; | |||
| *colcnd = 1.f; | |||
| *amax = 0.f; | |||
| return 0; | |||
| } | |||
| /* Get machine constants. Assume SMLNUM is a power of the radix. */ | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| radix = slamch_("B"); | |||
| logrdx = log(radix); | |||
| /* Compute row scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| r__[i__] = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* Find the maximum element in each row. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = i__ + j * a_dim1; | |||
| r__3 = r__[i__], r__4 = (r__1 = a[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&a[i__ + j * a_dim1]), abs(r__2)); | |||
| r__[i__] = f2cmax(r__3,r__4); | |||
| /* L20: */ | |||
| } | |||
| /* L30: */ | |||
| } | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (r__[i__] > 0.f) { | |||
| i__2 = (integer) (log(r__[i__]) / logrdx); | |||
| r__[i__] = pow_ri(&radix, &i__2); | |||
| } | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = r__[i__]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = r__[i__]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* L40: */ | |||
| } | |||
| *amax = rcmax; | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| if (r__[i__] == 0.f) { | |||
| *info = i__; | |||
| return 0; | |||
| } | |||
| /* L50: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *m; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = r__[i__]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| r__[i__] = 1.f / f2cmin(r__1,bignum); | |||
| /* L60: */ | |||
| } | |||
| /* Compute ROWCND = f2cmin(R(I)) / f2cmax(R(I)). */ | |||
| *rowcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| /* Compute column scale factors. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| c__[j] = 0.f; | |||
| /* L70: */ | |||
| } | |||
| /* Find the maximum element in each column, */ | |||
| /* assuming the row scaling computed above. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| /* Computing MAX */ | |||
| i__3 = i__ + j * a_dim1; | |||
| r__3 = c__[j], r__4 = ((r__1 = a[i__3].r, abs(r__1)) + (r__2 = | |||
| r_imag(&a[i__ + j * a_dim1]), abs(r__2))) * r__[i__]; | |||
| c__[j] = f2cmax(r__3,r__4); | |||
| /* L80: */ | |||
| } | |||
| if (c__[j] > 0.f) { | |||
| i__2 = (integer) (log(c__[j]) / logrdx); | |||
| c__[j] = pow_ri(&radix, &i__2); | |||
| } | |||
| /* L90: */ | |||
| } | |||
| /* Find the maximum and minimum scale factors. */ | |||
| rcmin = bignum; | |||
| rcmax = 0.f; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| r__1 = rcmin, r__2 = c__[j]; | |||
| rcmin = f2cmin(r__1,r__2); | |||
| /* Computing MAX */ | |||
| r__1 = rcmax, r__2 = c__[j]; | |||
| rcmax = f2cmax(r__1,r__2); | |||
| /* L100: */ | |||
| } | |||
| if (rcmin == 0.f) { | |||
| /* Find the first zero scale factor and return an error code. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (c__[j] == 0.f) { | |||
| *info = *m + j; | |||
| return 0; | |||
| } | |||
| /* L110: */ | |||
| } | |||
| } else { | |||
| /* Invert the scale factors. */ | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| /* Computing MIN */ | |||
| /* Computing MAX */ | |||
| r__2 = c__[j]; | |||
| r__1 = f2cmax(r__2,smlnum); | |||
| c__[j] = 1.f / f2cmin(r__1,bignum); | |||
| /* L120: */ | |||
| } | |||
| /* Compute COLCND = f2cmin(C(J)) / f2cmax(C(J)). */ | |||
| *colcnd = f2cmax(rcmin,smlnum) / f2cmin(rcmax,bignum); | |||
| } | |||
| return 0; | |||
| /* End of CGEEQUB */ | |||
| } /* cgeequb_ */ | |||
| @@ -0,0 +1,876 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static integer c__0 = 0; | |||
| static integer c_n1 = -1; | |||
| /* > \brief <b> CGEES computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors f | |||
| or GE matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEES + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgees.f | |||
| "> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgees.f | |||
| "> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgees.f | |||
| "> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEES( JOBVS, SORT, SELECT, N, A, LDA, SDIM, W, VS, */ | |||
| /* LDVS, WORK, LWORK, RWORK, BWORK, INFO ) */ | |||
| /* CHARACTER JOBVS, SORT */ | |||
| /* INTEGER INFO, LDA, LDVS, LWORK, N, SDIM */ | |||
| /* LOGICAL BWORK( * ) */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), VS( LDVS, * ), W( * ), WORK( * ) */ | |||
| /* LOGICAL SELECT */ | |||
| /* EXTERNAL SELECT */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEES computes for an N-by-N complex nonsymmetric matrix A, the */ | |||
| /* > eigenvalues, the Schur form T, and, optionally, the matrix of Schur */ | |||
| /* > vectors Z. This gives the Schur factorization A = Z*T*(Z**H). */ | |||
| /* > */ | |||
| /* > Optionally, it also orders the eigenvalues on the diagonal of the */ | |||
| /* > Schur form so that selected eigenvalues are at the top left. */ | |||
| /* > The leading columns of Z then form an orthonormal basis for the */ | |||
| /* > invariant subspace corresponding to the selected eigenvalues. */ | |||
| /* > */ | |||
| /* > A complex matrix is in Schur form if it is upper triangular. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOBVS */ | |||
| /* > \verbatim */ | |||
| /* > JOBVS is CHARACTER*1 */ | |||
| /* > = 'N': Schur vectors are not computed; */ | |||
| /* > = 'V': Schur vectors are computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SORT */ | |||
| /* > \verbatim */ | |||
| /* > SORT is CHARACTER*1 */ | |||
| /* > Specifies whether or not to order the eigenvalues on the */ | |||
| /* > diagonal of the Schur form. */ | |||
| /* > = 'N': Eigenvalues are not ordered: */ | |||
| /* > = 'S': Eigenvalues are ordered (see SELECT). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SELECT */ | |||
| /* > \verbatim */ | |||
| /* > SELECT is a LOGICAL FUNCTION of one COMPLEX argument */ | |||
| /* > SELECT must be declared EXTERNAL in the calling subroutine. */ | |||
| /* > If SORT = 'S', SELECT is used to select eigenvalues to order */ | |||
| /* > to the top left of the Schur form. */ | |||
| /* > IF SORT = 'N', SELECT is not referenced. */ | |||
| /* > The eigenvalue W(j) is selected if SELECT(W(j)) is true. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the N-by-N matrix A. */ | |||
| /* > On exit, A has been overwritten by its Schur form T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SDIM */ | |||
| /* > \verbatim */ | |||
| /* > SDIM is INTEGER */ | |||
| /* > If SORT = 'N', SDIM = 0. */ | |||
| /* > If SORT = 'S', SDIM = number of eigenvalues for which */ | |||
| /* > SELECT is true. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] W */ | |||
| /* > \verbatim */ | |||
| /* > W is COMPLEX array, dimension (N) */ | |||
| /* > W contains the computed eigenvalues, in the same order that */ | |||
| /* > they appear on the diagonal of the output Schur form T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] VS */ | |||
| /* > \verbatim */ | |||
| /* > VS is COMPLEX array, dimension (LDVS,N) */ | |||
| /* > If JOBVS = 'V', VS contains the unitary matrix Z of Schur */ | |||
| /* > vectors. */ | |||
| /* > If JOBVS = 'N', VS is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDVS */ | |||
| /* > \verbatim */ | |||
| /* > LDVS is INTEGER */ | |||
| /* > The leading dimension of the array VS. LDVS >= 1; if */ | |||
| /* > JOBVS = 'V', LDVS >= N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,2*N). */ | |||
| /* > For good performance, LWORK must generally be larger. */ | |||
| /* > */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates the optimal size of the WORK array, returns */ | |||
| /* > this value as the first entry of the WORK array, and no error */ | |||
| /* > message related to LWORK is issued by XERBLA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] BWORK */ | |||
| /* > \verbatim */ | |||
| /* > BWORK is LOGICAL array, dimension (N) */ | |||
| /* > Not referenced if SORT = 'N'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > > 0: if INFO = i, and i is */ | |||
| /* > <= N: the QR algorithm failed to compute all the */ | |||
| /* > eigenvalues; elements 1:ILO-1 and i+1:N of W */ | |||
| /* > contain those eigenvalues which have converged; */ | |||
| /* > if JOBVS = 'V', VS contains the matrix which */ | |||
| /* > reduces A to its partially converged Schur form. */ | |||
| /* > = N+1: the eigenvalues could not be reordered because */ | |||
| /* > some eigenvalues were too close to separate (the */ | |||
| /* > problem is very ill-conditioned); */ | |||
| /* > = N+2: after reordering, roundoff changed values of */ | |||
| /* > some complex eigenvalues so that leading */ | |||
| /* > eigenvalues in the Schur form no longer satisfy */ | |||
| /* > SELECT = .TRUE.. This could also be caused by */ | |||
| /* > underflow due to scaling. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEeigen */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgees_(char *jobvs, char *sort, L_fp select, integer *n, | |||
| complex *a, integer *lda, integer *sdim, complex *w, complex *vs, | |||
| integer *ldvs, complex *work, integer *lwork, real *rwork, logical * | |||
| bwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, vs_dim1, vs_offset, i__1, i__2; | |||
| /* Local variables */ | |||
| integer ibal; | |||
| real anrm; | |||
| integer ierr, itau, iwrk, i__; | |||
| real s; | |||
| integer icond, ieval; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, | |||
| complex *, integer *), cgebak_(char *, char *, integer *, integer | |||
| *, integer *, real *, integer *, complex *, integer *, integer *), cgebal_(char *, integer *, complex *, integer *, | |||
| integer *, integer *, real *, integer *), slabad_(real *, | |||
| real *); | |||
| logical scalea; | |||
| extern real clange_(char *, integer *, integer *, complex *, integer *, | |||
| real *); | |||
| real cscale; | |||
| extern /* Subroutine */ int cgehrd_(integer *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *, integer *), | |||
| clascl_(char *, integer *, integer *, real *, real *, integer *, | |||
| integer *, complex *, integer *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex | |||
| *, integer *, complex *, integer *), xerbla_(char *, | |||
| integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| real bignum; | |||
| extern /* Subroutine */ int chseqr_(char *, char *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, complex *, integer *, | |||
| complex *, integer *, integer *), cunghr_(integer | |||
| *, integer *, integer *, complex *, integer *, complex *, complex | |||
| *, integer *, integer *), ctrsen_(char *, char *, logical *, | |||
| integer *, complex *, integer *, complex *, integer *, complex *, | |||
| integer *, real *, real *, complex *, integer *, integer *); | |||
| integer minwrk, maxwrk; | |||
| real smlnum; | |||
| integer hswork; | |||
| logical wantst, lquery, wantvs; | |||
| integer ihi, ilo; | |||
| real dum[1], eps, sep; | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --w; | |||
| vs_dim1 = *ldvs; | |||
| vs_offset = 1 + vs_dim1 * 1; | |||
| vs -= vs_offset; | |||
| --work; | |||
| --rwork; | |||
| --bwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *lwork == -1; | |||
| wantvs = lsame_(jobvs, "V"); | |||
| wantst = lsame_(sort, "S"); | |||
| if (! wantvs && ! lsame_(jobvs, "N")) { | |||
| *info = -1; | |||
| } else if (! wantst && ! lsame_(sort, "N")) { | |||
| *info = -2; | |||
| } else if (*n < 0) { | |||
| *info = -4; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -6; | |||
| } else if (*ldvs < 1 || wantvs && *ldvs < *n) { | |||
| *info = -10; | |||
| } | |||
| /* Compute workspace */ | |||
| /* (Note: Comments in the code beginning "Workspace:" describe the */ | |||
| /* minimal amount of workspace needed at that point in the code, */ | |||
| /* as well as the preferred amount for good performance. */ | |||
| /* CWorkspace refers to complex workspace, and RWorkspace to real */ | |||
| /* workspace. NB refers to the optimal block size for the */ | |||
| /* immediately following subroutine, as returned by ILAENV. */ | |||
| /* HSWORK refers to the workspace preferred by CHSEQR, as */ | |||
| /* calculated below. HSWORK is computed assuming ILO=1 and IHI=N, */ | |||
| /* the worst case.) */ | |||
| if (*info == 0) { | |||
| if (*n == 0) { | |||
| minwrk = 1; | |||
| maxwrk = 1; | |||
| } else { | |||
| maxwrk = *n + *n * ilaenv_(&c__1, "CGEHRD", " ", n, &c__1, n, & | |||
| c__0, (ftnlen)6, (ftnlen)1); | |||
| minwrk = *n << 1; | |||
| chseqr_("S", jobvs, n, &c__1, n, &a[a_offset], lda, &w[1], &vs[ | |||
| vs_offset], ldvs, &work[1], &c_n1, &ieval); | |||
| hswork = work[1].r; | |||
| if (! wantvs) { | |||
| maxwrk = f2cmax(maxwrk,hswork); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__1 = maxwrk, i__2 = *n + (*n - 1) * ilaenv_(&c__1, "CUNGHR", | |||
| " ", n, &c__1, n, &c_n1, (ftnlen)6, (ftnlen)1); | |||
| maxwrk = f2cmax(i__1,i__2); | |||
| maxwrk = f2cmax(maxwrk,hswork); | |||
| } | |||
| } | |||
| work[1].r = (real) maxwrk, work[1].i = 0.f; | |||
| if (*lwork < minwrk && ! lquery) { | |||
| *info = -12; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEES ", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| *sdim = 0; | |||
| return 0; | |||
| } | |||
| /* Get machine constants */ | |||
| eps = slamch_("P"); | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| smlnum = sqrt(smlnum) / eps; | |||
| bignum = 1.f / smlnum; | |||
| /* Scale A if f2cmax element outside range [SMLNUM,BIGNUM] */ | |||
| anrm = clange_("M", n, n, &a[a_offset], lda, dum); | |||
| scalea = FALSE_; | |||
| if (anrm > 0.f && anrm < smlnum) { | |||
| scalea = TRUE_; | |||
| cscale = smlnum; | |||
| } else if (anrm > bignum) { | |||
| scalea = TRUE_; | |||
| cscale = bignum; | |||
| } | |||
| if (scalea) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &cscale, n, n, &a[a_offset], lda, & | |||
| ierr); | |||
| } | |||
| /* Permute the matrix to make it more nearly triangular */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: need N) */ | |||
| ibal = 1; | |||
| cgebal_("P", n, &a[a_offset], lda, &ilo, &ihi, &rwork[ibal], &ierr); | |||
| /* Reduce to upper Hessenberg form */ | |||
| /* (CWorkspace: need 2*N, prefer N+N*NB) */ | |||
| /* (RWorkspace: none) */ | |||
| itau = 1; | |||
| iwrk = *n + itau; | |||
| i__1 = *lwork - iwrk + 1; | |||
| cgehrd_(n, &ilo, &ihi, &a[a_offset], lda, &work[itau], &work[iwrk], &i__1, | |||
| &ierr); | |||
| if (wantvs) { | |||
| /* Copy Householder vectors to VS */ | |||
| clacpy_("L", n, n, &a[a_offset], lda, &vs[vs_offset], ldvs) | |||
| ; | |||
| /* Generate unitary matrix in VS */ | |||
| /* (CWorkspace: need 2*N-1, prefer N+(N-1)*NB) */ | |||
| /* (RWorkspace: none) */ | |||
| i__1 = *lwork - iwrk + 1; | |||
| cunghr_(n, &ilo, &ihi, &vs[vs_offset], ldvs, &work[itau], &work[iwrk], | |||
| &i__1, &ierr); | |||
| } | |||
| *sdim = 0; | |||
| /* Perform QR iteration, accumulating Schur vectors in VS if desired */ | |||
| /* (CWorkspace: need 1, prefer HSWORK (see comments) ) */ | |||
| /* (RWorkspace: none) */ | |||
| iwrk = itau; | |||
| i__1 = *lwork - iwrk + 1; | |||
| chseqr_("S", jobvs, n, &ilo, &ihi, &a[a_offset], lda, &w[1], &vs[ | |||
| vs_offset], ldvs, &work[iwrk], &i__1, &ieval); | |||
| if (ieval > 0) { | |||
| *info = ieval; | |||
| } | |||
| /* Sort eigenvalues if desired */ | |||
| if (wantst && *info == 0) { | |||
| if (scalea) { | |||
| clascl_("G", &c__0, &c__0, &cscale, &anrm, n, &c__1, &w[1], n, & | |||
| ierr); | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| bwork[i__] = (*select)(&w[i__]); | |||
| /* L10: */ | |||
| } | |||
| /* Reorder eigenvalues and transform Schur vectors */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: none) */ | |||
| i__1 = *lwork - iwrk + 1; | |||
| ctrsen_("N", jobvs, &bwork[1], n, &a[a_offset], lda, &vs[vs_offset], | |||
| ldvs, &w[1], sdim, &s, &sep, &work[iwrk], &i__1, &icond); | |||
| } | |||
| if (wantvs) { | |||
| /* Undo balancing */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: need N) */ | |||
| cgebak_("P", "R", n, &ilo, &ihi, &rwork[ibal], n, &vs[vs_offset], | |||
| ldvs, &ierr); | |||
| } | |||
| if (scalea) { | |||
| /* Undo scaling for the Schur form of A */ | |||
| clascl_("U", &c__0, &c__0, &cscale, &anrm, n, n, &a[a_offset], lda, & | |||
| ierr); | |||
| i__1 = *lda + 1; | |||
| ccopy_(n, &a[a_offset], &i__1, &w[1], &c__1); | |||
| } | |||
| work[1].r = (real) maxwrk, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEES */ | |||
| } /* cgees_ */ | |||
| @@ -0,0 +1,958 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static integer c__0 = 0; | |||
| static integer c_n1 = -1; | |||
| /* > \brief <b> CGEESX computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors | |||
| for GE matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEESX + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeesx. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeesx. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeesx. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEESX( JOBVS, SORT, SELECT, SENSE, N, A, LDA, SDIM, W, */ | |||
| /* VS, LDVS, RCONDE, RCONDV, WORK, LWORK, RWORK, */ | |||
| /* BWORK, INFO ) */ | |||
| /* CHARACTER JOBVS, SENSE, SORT */ | |||
| /* INTEGER INFO, LDA, LDVS, LWORK, N, SDIM */ | |||
| /* REAL RCONDE, RCONDV */ | |||
| /* LOGICAL BWORK( * ) */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), VS( LDVS, * ), W( * ), WORK( * ) */ | |||
| /* LOGICAL SELECT */ | |||
| /* EXTERNAL SELECT */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEESX computes for an N-by-N complex nonsymmetric matrix A, the */ | |||
| /* > eigenvalues, the Schur form T, and, optionally, the matrix of Schur */ | |||
| /* > vectors Z. This gives the Schur factorization A = Z*T*(Z**H). */ | |||
| /* > */ | |||
| /* > Optionally, it also orders the eigenvalues on the diagonal of the */ | |||
| /* > Schur form so that selected eigenvalues are at the top left; */ | |||
| /* > computes a reciprocal condition number for the average of the */ | |||
| /* > selected eigenvalues (RCONDE); and computes a reciprocal condition */ | |||
| /* > number for the right invariant subspace corresponding to the */ | |||
| /* > selected eigenvalues (RCONDV). The leading columns of Z form an */ | |||
| /* > orthonormal basis for this invariant subspace. */ | |||
| /* > */ | |||
| /* > For further explanation of the reciprocal condition numbers RCONDE */ | |||
| /* > and RCONDV, see Section 4.10 of the LAPACK Users' Guide (where */ | |||
| /* > these quantities are called s and sep respectively). */ | |||
| /* > */ | |||
| /* > A complex matrix is in Schur form if it is upper triangular. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] JOBVS */ | |||
| /* > \verbatim */ | |||
| /* > JOBVS is CHARACTER*1 */ | |||
| /* > = 'N': Schur vectors are not computed; */ | |||
| /* > = 'V': Schur vectors are computed. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SORT */ | |||
| /* > \verbatim */ | |||
| /* > SORT is CHARACTER*1 */ | |||
| /* > Specifies whether or not to order the eigenvalues on the */ | |||
| /* > diagonal of the Schur form. */ | |||
| /* > = 'N': Eigenvalues are not ordered; */ | |||
| /* > = 'S': Eigenvalues are ordered (see SELECT). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SELECT */ | |||
| /* > \verbatim */ | |||
| /* > SELECT is a LOGICAL FUNCTION of one COMPLEX argument */ | |||
| /* > SELECT must be declared EXTERNAL in the calling subroutine. */ | |||
| /* > If SORT = 'S', SELECT is used to select eigenvalues to order */ | |||
| /* > to the top left of the Schur form. */ | |||
| /* > If SORT = 'N', SELECT is not referenced. */ | |||
| /* > An eigenvalue W(j) is selected if SELECT(W(j)) is true. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] SENSE */ | |||
| /* > \verbatim */ | |||
| /* > SENSE is CHARACTER*1 */ | |||
| /* > Determines which reciprocal condition numbers are computed. */ | |||
| /* > = 'N': None are computed; */ | |||
| /* > = 'E': Computed for average of selected eigenvalues only; */ | |||
| /* > = 'V': Computed for selected right invariant subspace only; */ | |||
| /* > = 'B': Computed for both. */ | |||
| /* > If SENSE = 'E', 'V' or 'B', SORT must equal 'S'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA, N) */ | |||
| /* > On entry, the N-by-N matrix A. */ | |||
| /* > On exit, A is overwritten by its Schur form T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] SDIM */ | |||
| /* > \verbatim */ | |||
| /* > SDIM is INTEGER */ | |||
| /* > If SORT = 'N', SDIM = 0. */ | |||
| /* > If SORT = 'S', SDIM = number of eigenvalues for which */ | |||
| /* > SELECT is true. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] W */ | |||
| /* > \verbatim */ | |||
| /* > W is COMPLEX array, dimension (N) */ | |||
| /* > W contains the computed eigenvalues, in the same order */ | |||
| /* > that they appear on the diagonal of the output Schur form T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] VS */ | |||
| /* > \verbatim */ | |||
| /* > VS is COMPLEX array, dimension (LDVS,N) */ | |||
| /* > If JOBVS = 'V', VS contains the unitary matrix Z of Schur */ | |||
| /* > vectors. */ | |||
| /* > If JOBVS = 'N', VS is not referenced. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDVS */ | |||
| /* > \verbatim */ | |||
| /* > LDVS is INTEGER */ | |||
| /* > The leading dimension of the array VS. LDVS >= 1, and if */ | |||
| /* > JOBVS = 'V', LDVS >= N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RCONDE */ | |||
| /* > \verbatim */ | |||
| /* > RCONDE is REAL */ | |||
| /* > If SENSE = 'E' or 'B', RCONDE contains the reciprocal */ | |||
| /* > condition number for the average of the selected eigenvalues. */ | |||
| /* > Not referenced if SENSE = 'N' or 'V'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RCONDV */ | |||
| /* > \verbatim */ | |||
| /* > RCONDV is REAL */ | |||
| /* > If SENSE = 'V' or 'B', RCONDV contains the reciprocal */ | |||
| /* > condition number for the selected right invariant subspace. */ | |||
| /* > Not referenced if SENSE = 'N' or 'E'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,2*N). */ | |||
| /* > Also, if SENSE = 'E' or 'V' or 'B', LWORK >= 2*SDIM*(N-SDIM), */ | |||
| /* > where SDIM is the number of selected eigenvalues computed by */ | |||
| /* > this routine. Note that 2*SDIM*(N-SDIM) <= N*N/2. Note also */ | |||
| /* > that an error is only returned if LWORK < f2cmax(1,2*N), but if */ | |||
| /* > SENSE = 'E' or 'V' or 'B' this may not be large enough. */ | |||
| /* > For good performance, LWORK must generally be larger. */ | |||
| /* > */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates upper bound on the optimal size of the */ | |||
| /* > array WORK, returns this value as the first entry of the WORK */ | |||
| /* > array, and no error message related to LWORK is issued by */ | |||
| /* > XERBLA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] BWORK */ | |||
| /* > \verbatim */ | |||
| /* > BWORK is LOGICAL array, dimension (N) */ | |||
| /* > Not referenced if SORT = 'N'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > > 0: if INFO = i, and i is */ | |||
| /* > <= N: the QR algorithm failed to compute all the */ | |||
| /* > eigenvalues; elements 1:ILO-1 and i+1:N of W */ | |||
| /* > contain those eigenvalues which have converged; if */ | |||
| /* > JOBVS = 'V', VS contains the transformation which */ | |||
| /* > reduces A to its partially converged Schur form. */ | |||
| /* > = N+1: the eigenvalues could not be reordered because some */ | |||
| /* > eigenvalues were too close to separate (the problem */ | |||
| /* > is very ill-conditioned); */ | |||
| /* > = N+2: after reordering, roundoff changed values of some */ | |||
| /* > complex eigenvalues so that leading eigenvalues in */ | |||
| /* > the Schur form no longer satisfy SELECT=.TRUE. This */ | |||
| /* > could also be caused by underflow due to scaling. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2016 */ | |||
| /* > \ingroup complexGEeigen */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeesx_(char *jobvs, char *sort, L_fp select, char * | |||
| sense, integer *n, complex *a, integer *lda, integer *sdim, complex * | |||
| w, complex *vs, integer *ldvs, real *rconde, real *rcondv, complex * | |||
| work, integer *lwork, real *rwork, logical *bwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, vs_dim1, vs_offset, i__1, i__2; | |||
| /* Local variables */ | |||
| integer ibal; | |||
| real anrm; | |||
| integer ierr, itau, iwrk, lwrk, i__, icond, ieval; | |||
| extern logical lsame_(char *, char *); | |||
| extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, | |||
| complex *, integer *), cgebak_(char *, char *, integer *, integer | |||
| *, integer *, real *, integer *, complex *, integer *, integer *), cgebal_(char *, integer *, complex *, integer *, | |||
| integer *, integer *, real *, integer *), slabad_(real *, | |||
| real *); | |||
| logical scalea; | |||
| extern real clange_(char *, integer *, integer *, complex *, integer *, | |||
| real *); | |||
| real cscale; | |||
| extern /* Subroutine */ int cgehrd_(integer *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *, integer *), | |||
| clascl_(char *, integer *, integer *, real *, real *, integer *, | |||
| integer *, complex *, integer *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex | |||
| *, integer *, complex *, integer *), xerbla_(char *, | |||
| integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| real bignum; | |||
| extern /* Subroutine */ int slascl_(char *, integer *, integer *, real *, | |||
| real *, integer *, integer *, real *, integer *, integer *), chseqr_(char *, char *, integer *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *, integer *), cunghr_(integer *, integer | |||
| *, integer *, complex *, integer *, complex *, complex *, integer | |||
| *, integer *); | |||
| logical wantsb; | |||
| extern /* Subroutine */ int ctrsen_(char *, char *, logical *, integer *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *, | |||
| real *, real *, complex *, integer *, integer *); | |||
| logical wantse; | |||
| integer minwrk, maxwrk; | |||
| logical wantsn; | |||
| real smlnum; | |||
| integer hswork; | |||
| logical wantst, lquery, wantsv, wantvs; | |||
| integer ihi, ilo; | |||
| real dum[1], eps; | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --w; | |||
| vs_dim1 = *ldvs; | |||
| vs_offset = 1 + vs_dim1 * 1; | |||
| vs -= vs_offset; | |||
| --work; | |||
| --rwork; | |||
| --bwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| wantvs = lsame_(jobvs, "V"); | |||
| wantst = lsame_(sort, "S"); | |||
| wantsn = lsame_(sense, "N"); | |||
| wantse = lsame_(sense, "E"); | |||
| wantsv = lsame_(sense, "V"); | |||
| wantsb = lsame_(sense, "B"); | |||
| lquery = *lwork == -1; | |||
| if (! wantvs && ! lsame_(jobvs, "N")) { | |||
| *info = -1; | |||
| } else if (! wantst && ! lsame_(sort, "N")) { | |||
| *info = -2; | |||
| } else if (! (wantsn || wantse || wantsv || wantsb) || ! wantst && ! | |||
| wantsn) { | |||
| *info = -4; | |||
| } else if (*n < 0) { | |||
| *info = -5; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -7; | |||
| } else if (*ldvs < 1 || wantvs && *ldvs < *n) { | |||
| *info = -11; | |||
| } | |||
| /* Compute workspace */ | |||
| /* (Note: Comments in the code beginning "Workspace:" describe the */ | |||
| /* minimal amount of real workspace needed at that point in the */ | |||
| /* code, as well as the preferred amount for good performance. */ | |||
| /* CWorkspace refers to complex workspace, and RWorkspace to real */ | |||
| /* workspace. NB refers to the optimal block size for the */ | |||
| /* immediately following subroutine, as returned by ILAENV. */ | |||
| /* HSWORK refers to the workspace preferred by CHSEQR, as */ | |||
| /* calculated below. HSWORK is computed assuming ILO=1 and IHI=N, */ | |||
| /* the worst case. */ | |||
| /* If SENSE = 'E', 'V' or 'B', then the amount of workspace needed */ | |||
| /* depends on SDIM, which is computed by the routine CTRSEN later */ | |||
| /* in the code.) */ | |||
| if (*info == 0) { | |||
| if (*n == 0) { | |||
| minwrk = 1; | |||
| lwrk = 1; | |||
| } else { | |||
| maxwrk = *n + *n * ilaenv_(&c__1, "CGEHRD", " ", n, &c__1, n, & | |||
| c__0, (ftnlen)6, (ftnlen)1); | |||
| minwrk = *n << 1; | |||
| chseqr_("S", jobvs, n, &c__1, n, &a[a_offset], lda, &w[1], &vs[ | |||
| vs_offset], ldvs, &work[1], &c_n1, &ieval); | |||
| hswork = work[1].r; | |||
| if (! wantvs) { | |||
| maxwrk = f2cmax(maxwrk,hswork); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__1 = maxwrk, i__2 = *n + (*n - 1) * ilaenv_(&c__1, "CUNGHR", | |||
| " ", n, &c__1, n, &c_n1, (ftnlen)6, (ftnlen)1); | |||
| maxwrk = f2cmax(i__1,i__2); | |||
| maxwrk = f2cmax(maxwrk,hswork); | |||
| } | |||
| lwrk = maxwrk; | |||
| if (! wantsn) { | |||
| /* Computing MAX */ | |||
| i__1 = lwrk, i__2 = *n * *n / 2; | |||
| lwrk = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| work[1].r = (real) lwrk, work[1].i = 0.f; | |||
| if (*lwork < minwrk && ! lquery) { | |||
| *info = -15; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEESX", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (*n == 0) { | |||
| *sdim = 0; | |||
| return 0; | |||
| } | |||
| /* Get machine constants */ | |||
| eps = slamch_("P"); | |||
| smlnum = slamch_("S"); | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| smlnum = sqrt(smlnum) / eps; | |||
| bignum = 1.f / smlnum; | |||
| /* Scale A if f2cmax element outside range [SMLNUM,BIGNUM] */ | |||
| anrm = clange_("M", n, n, &a[a_offset], lda, dum); | |||
| scalea = FALSE_; | |||
| if (anrm > 0.f && anrm < smlnum) { | |||
| scalea = TRUE_; | |||
| cscale = smlnum; | |||
| } else if (anrm > bignum) { | |||
| scalea = TRUE_; | |||
| cscale = bignum; | |||
| } | |||
| if (scalea) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &cscale, n, n, &a[a_offset], lda, & | |||
| ierr); | |||
| } | |||
| /* Permute the matrix to make it more nearly triangular */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: need N) */ | |||
| ibal = 1; | |||
| cgebal_("P", n, &a[a_offset], lda, &ilo, &ihi, &rwork[ibal], &ierr); | |||
| /* Reduce to upper Hessenberg form */ | |||
| /* (CWorkspace: need 2*N, prefer N+N*NB) */ | |||
| /* (RWorkspace: none) */ | |||
| itau = 1; | |||
| iwrk = *n + itau; | |||
| i__1 = *lwork - iwrk + 1; | |||
| cgehrd_(n, &ilo, &ihi, &a[a_offset], lda, &work[itau], &work[iwrk], &i__1, | |||
| &ierr); | |||
| if (wantvs) { | |||
| /* Copy Householder vectors to VS */ | |||
| clacpy_("L", n, n, &a[a_offset], lda, &vs[vs_offset], ldvs) | |||
| ; | |||
| /* Generate unitary matrix in VS */ | |||
| /* (CWorkspace: need 2*N-1, prefer N+(N-1)*NB) */ | |||
| /* (RWorkspace: none) */ | |||
| i__1 = *lwork - iwrk + 1; | |||
| cunghr_(n, &ilo, &ihi, &vs[vs_offset], ldvs, &work[itau], &work[iwrk], | |||
| &i__1, &ierr); | |||
| } | |||
| *sdim = 0; | |||
| /* Perform QR iteration, accumulating Schur vectors in VS if desired */ | |||
| /* (CWorkspace: need 1, prefer HSWORK (see comments) ) */ | |||
| /* (RWorkspace: none) */ | |||
| iwrk = itau; | |||
| i__1 = *lwork - iwrk + 1; | |||
| chseqr_("S", jobvs, n, &ilo, &ihi, &a[a_offset], lda, &w[1], &vs[ | |||
| vs_offset], ldvs, &work[iwrk], &i__1, &ieval); | |||
| if (ieval > 0) { | |||
| *info = ieval; | |||
| } | |||
| /* Sort eigenvalues if desired */ | |||
| if (wantst && *info == 0) { | |||
| if (scalea) { | |||
| clascl_("G", &c__0, &c__0, &cscale, &anrm, n, &c__1, &w[1], n, & | |||
| ierr); | |||
| } | |||
| i__1 = *n; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| bwork[i__] = (*select)(&w[i__]); | |||
| /* L10: */ | |||
| } | |||
| /* Reorder eigenvalues, transform Schur vectors, and compute */ | |||
| /* reciprocal condition numbers */ | |||
| /* (CWorkspace: if SENSE is not 'N', need 2*SDIM*(N-SDIM) */ | |||
| /* otherwise, need none ) */ | |||
| /* (RWorkspace: none) */ | |||
| i__1 = *lwork - iwrk + 1; | |||
| ctrsen_(sense, jobvs, &bwork[1], n, &a[a_offset], lda, &vs[vs_offset], | |||
| ldvs, &w[1], sdim, rconde, rcondv, &work[iwrk], &i__1, & | |||
| icond); | |||
| if (! wantsn) { | |||
| /* Computing MAX */ | |||
| i__1 = maxwrk, i__2 = (*sdim << 1) * (*n - *sdim); | |||
| maxwrk = f2cmax(i__1,i__2); | |||
| } | |||
| if (icond == -14) { | |||
| /* Not enough complex workspace */ | |||
| *info = -15; | |||
| } | |||
| } | |||
| if (wantvs) { | |||
| /* Undo balancing */ | |||
| /* (CWorkspace: none) */ | |||
| /* (RWorkspace: need N) */ | |||
| cgebak_("P", "R", n, &ilo, &ihi, &rwork[ibal], n, &vs[vs_offset], | |||
| ldvs, &ierr); | |||
| } | |||
| if (scalea) { | |||
| /* Undo scaling for the Schur form of A */ | |||
| clascl_("U", &c__0, &c__0, &cscale, &anrm, n, n, &a[a_offset], lda, & | |||
| ierr); | |||
| i__1 = *lda + 1; | |||
| ccopy_(n, &a[a_offset], &i__1, &w[1], &c__1); | |||
| if ((wantsv || wantsb) && *info == 0) { | |||
| dum[0] = *rcondv; | |||
| slascl_("G", &c__0, &c__0, &cscale, &anrm, &c__1, &c__1, dum, & | |||
| c__1, &ierr); | |||
| *rcondv = dum[0]; | |||
| } | |||
| } | |||
| work[1].r = (real) maxwrk, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEESX */ | |||
| } /* cgeesx_ */ | |||
| @@ -0,0 +1,653 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGEHD2 reduces a general square matrix to upper Hessenberg form using an unblocked algorithm. | |||
| */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEHD2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgehd2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgehd2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgehd2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEHD2( N, ILO, IHI, A, LDA, TAU, WORK, INFO ) */ | |||
| /* INTEGER IHI, ILO, INFO, LDA, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEHD2 reduces a complex general matrix A to upper Hessenberg form H */ | |||
| /* > by a unitary similarity transformation: Q**H * A * Q = H . */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ILO */ | |||
| /* > \verbatim */ | |||
| /* > ILO is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IHI */ | |||
| /* > \verbatim */ | |||
| /* > IHI is INTEGER */ | |||
| /* > */ | |||
| /* > It is assumed that A is already upper triangular in rows */ | |||
| /* > and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally */ | |||
| /* > set by a previous call to CGEBAL; otherwise they should be */ | |||
| /* > set to 1 and N respectively. See Further Details. */ | |||
| /* > 1 <= ILO <= IHI <= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the n by n general matrix to be reduced. */ | |||
| /* > On exit, the upper triangle and the first subdiagonal of A */ | |||
| /* > are overwritten with the upper Hessenberg matrix H, and the */ | |||
| /* > elements below the first subdiagonal, with the array TAU, */ | |||
| /* > represent the unitary matrix Q as a product of elementary */ | |||
| /* > reflectors. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (N-1) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of (ihi-ilo) elementary */ | |||
| /* > reflectors */ | |||
| /* > */ | |||
| /* > Q = H(ilo) H(ilo+1) . . . H(ihi-1). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a complex vector with */ | |||
| /* > v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on */ | |||
| /* > exit in A(i+2:ihi,i), and tau in TAU(i). */ | |||
| /* > */ | |||
| /* > The contents of A are illustrated by the following example, with */ | |||
| /* > n = 7, ilo = 2 and ihi = 6: */ | |||
| /* > */ | |||
| /* > on entry, on exit, */ | |||
| /* > */ | |||
| /* > ( a a a a a a a ) ( a a h h h h a ) */ | |||
| /* > ( a a a a a a ) ( a h h h h a ) */ | |||
| /* > ( a a a a a a ) ( h h h h h h ) */ | |||
| /* > ( a a a a a a ) ( v2 h h h h h ) */ | |||
| /* > ( a a a a a a ) ( v2 v3 h h h h ) */ | |||
| /* > ( a a a a a a ) ( v2 v3 v4 h h h ) */ | |||
| /* > ( a ) ( a ) */ | |||
| /* > */ | |||
| /* > where a denotes an element of the original matrix A, h denotes a */ | |||
| /* > modified element of the upper Hessenberg matrix H, and vi denotes an */ | |||
| /* > element of the vector defining H(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgehd2_(integer *n, integer *ilo, integer *ihi, complex * | |||
| a, integer *lda, complex *tau, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__; | |||
| complex alpha; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| clarfg_(integer *, complex *, complex *, integer *, complex *), | |||
| xerbla_(char *, integer *, ftnlen); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*n < 0) { | |||
| *info = -1; | |||
| } else if (*ilo < 1 || *ilo > f2cmax(1,*n)) { | |||
| *info = -2; | |||
| } else if (*ihi < f2cmin(*ilo,*n) || *ihi > *n) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -5; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEHD2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| i__1 = *ihi - 1; | |||
| for (i__ = *ilo; i__ <= i__1; ++i__) { | |||
| /* Compute elementary reflector H(i) to annihilate A(i+2:ihi,i) */ | |||
| i__2 = i__ + 1 + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = *ihi - i__; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 2; | |||
| clarfg_(&i__2, &alpha, &a[f2cmin(i__3,*n) + i__ * a_dim1], &c__1, &tau[ | |||
| i__]); | |||
| i__2 = i__ + 1 + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| /* Apply H(i) to A(1:ihi,i+1:ihi) from the right */ | |||
| i__2 = *ihi - i__; | |||
| clarf_("Right", ihi, &i__2, &a[i__ + 1 + i__ * a_dim1], &c__1, &tau[ | |||
| i__], &a[(i__ + 1) * a_dim1 + 1], lda, &work[1]); | |||
| /* Apply H(i)**H to A(i+1:ihi,i+1:n) from the left */ | |||
| i__2 = *ihi - i__; | |||
| i__3 = *n - i__; | |||
| r_cnjg(&q__1, &tau[i__]); | |||
| clarf_("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], &c__1, &q__1, | |||
| &a[i__ + 1 + (i__ + 1) * a_dim1], lda, &work[1]); | |||
| i__2 = i__ + 1 + i__ * a_dim1; | |||
| a[i__2].r = alpha.r, a[i__2].i = alpha.i; | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of CGEHD2 */ | |||
| } /* cgehd2_ */ | |||
| @@ -0,0 +1,817 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b2 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| static integer c__65 = 65; | |||
| /* > \brief \b CGEHRD */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEHRD + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgehrd. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgehrd. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgehrd. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEHRD( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO ) */ | |||
| /* INTEGER IHI, ILO, INFO, LDA, LWORK, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEHRD reduces a complex general matrix A to upper Hessenberg form H by */ | |||
| /* > an unitary similarity transformation: Q**H * A * Q = H . */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The order of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] ILO */ | |||
| /* > \verbatim */ | |||
| /* > ILO is INTEGER */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] IHI */ | |||
| /* > \verbatim */ | |||
| /* > IHI is INTEGER */ | |||
| /* > */ | |||
| /* > It is assumed that A is already upper triangular in rows */ | |||
| /* > and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally */ | |||
| /* > set by a previous call to CGEBAL; otherwise they should be */ | |||
| /* > set to 1 and N respectively. See Further Details. */ | |||
| /* > 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the N-by-N general matrix to be reduced. */ | |||
| /* > On exit, the upper triangle and the first subdiagonal of A */ | |||
| /* > are overwritten with the upper Hessenberg matrix H, and the */ | |||
| /* > elements below the first subdiagonal, with the array TAU, */ | |||
| /* > represent the unitary matrix Q as a product of elementary */ | |||
| /* > reflectors. See Further Details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (N-1) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). Elements 1:ILO-1 and IHI:N-1 of TAU are set to */ | |||
| /* > zero. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (LWORK) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The length of the array WORK. LWORK >= f2cmax(1,N). */ | |||
| /* > For good performance, LWORK should generally be larger. */ | |||
| /* > */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates the optimal size of the WORK array, returns */ | |||
| /* > this value as the first entry of the WORK array, and no error */ | |||
| /* > message related to LWORK is issued by XERBLA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of (ihi-ilo) elementary */ | |||
| /* > reflectors */ | |||
| /* > */ | |||
| /* > Q = H(ilo) H(ilo+1) . . . H(ihi-1). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a complex vector with */ | |||
| /* > v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on */ | |||
| /* > exit in A(i+2:ihi,i), and tau in TAU(i). */ | |||
| /* > */ | |||
| /* > The contents of A are illustrated by the following example, with */ | |||
| /* > n = 7, ilo = 2 and ihi = 6: */ | |||
| /* > */ | |||
| /* > on entry, on exit, */ | |||
| /* > */ | |||
| /* > ( a a a a a a a ) ( a a h h h h a ) */ | |||
| /* > ( a a a a a a ) ( a h h h h a ) */ | |||
| /* > ( a a a a a a ) ( h h h h h h ) */ | |||
| /* > ( a a a a a a ) ( v2 h h h h h ) */ | |||
| /* > ( a a a a a a ) ( v2 v3 h h h h ) */ | |||
| /* > ( a a a a a a ) ( v2 v3 v4 h h h ) */ | |||
| /* > ( a ) ( a ) */ | |||
| /* > */ | |||
| /* > where a denotes an element of the original matrix A, h denotes a */ | |||
| /* > modified element of the upper Hessenberg matrix H, and vi denotes an */ | |||
| /* > element of the vector defining H(i). */ | |||
| /* > */ | |||
| /* > This file is a slight modification of LAPACK-3.0's DGEHRD */ | |||
| /* > subroutine incorporating improvements proposed by Quintana-Orti and */ | |||
| /* > Van de Geijn (2006). (See DLAHR2.) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgehrd_(integer *n, integer *ilo, integer *ihi, complex * | |||
| a, integer *lda, complex *tau, complex *work, integer *lwork, integer | |||
| *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, | |||
| integer *, complex *, complex *, integer *, complex *, integer *, | |||
| complex *, complex *, integer *); | |||
| integer nbmin, iinfo; | |||
| extern /* Subroutine */ int ctrmm_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *), caxpy_(integer *, | |||
| complex *, complex *, integer *, complex *, integer *), cgehd2_( | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| complex *, integer *), clahr2_(integer *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *); | |||
| integer ib; | |||
| complex ei; | |||
| integer nb, nh; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| integer nx; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer ldwork, lwkopt; | |||
| logical lquery; | |||
| integer iwt; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input parameters */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *lwork == -1; | |||
| if (*n < 0) { | |||
| *info = -1; | |||
| } else if (*ilo < 1 || *ilo > f2cmax(1,*n)) { | |||
| *info = -2; | |||
| } else if (*ihi < f2cmin(*ilo,*n) || *ihi > *n) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*n)) { | |||
| *info = -5; | |||
| } else if (*lwork < f2cmax(1,*n) && ! lquery) { | |||
| *info = -8; | |||
| } | |||
| if (*info == 0) { | |||
| /* Compute the workspace requirements */ | |||
| /* Computing MIN */ | |||
| i__1 = 64, i__2 = ilaenv_(&c__1, "CGEHRD", " ", n, ilo, ihi, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nb = f2cmin(i__1,i__2); | |||
| lwkopt = *n * nb + 4160; | |||
| work[1].r = (real) lwkopt, work[1].i = 0.f; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEHRD", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Set elements 1:ILO-1 and IHI:N-1 of TAU to zero */ | |||
| i__1 = *ilo - 1; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| tau[i__2].r = 0.f, tau[i__2].i = 0.f; | |||
| /* L10: */ | |||
| } | |||
| i__1 = *n - 1; | |||
| for (i__ = f2cmax(1,*ihi); i__ <= i__1; ++i__) { | |||
| i__2 = i__; | |||
| tau[i__2].r = 0.f, tau[i__2].i = 0.f; | |||
| /* L20: */ | |||
| } | |||
| /* Quick return if possible */ | |||
| nh = *ihi - *ilo + 1; | |||
| if (nh <= 1) { | |||
| work[1].r = 1.f, work[1].i = 0.f; | |||
| return 0; | |||
| } | |||
| /* Determine the block size */ | |||
| /* Computing MIN */ | |||
| i__1 = 64, i__2 = ilaenv_(&c__1, "CGEHRD", " ", n, ilo, ihi, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nb = f2cmin(i__1,i__2); | |||
| nbmin = 2; | |||
| if (nb > 1 && nb < nh) { | |||
| /* Determine when to cross over from blocked to unblocked code */ | |||
| /* (last block is always handled by unblocked code) */ | |||
| /* Computing MAX */ | |||
| i__1 = nb, i__2 = ilaenv_(&c__3, "CGEHRD", " ", n, ilo, ihi, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| if (nx < nh) { | |||
| /* Determine if workspace is large enough for blocked code */ | |||
| if (*lwork < *n * nb + 4160) { | |||
| /* Not enough workspace to use optimal NB: determine the */ | |||
| /* minimum value of NB, and reduce NB or force use of */ | |||
| /* unblocked code */ | |||
| /* Computing MAX */ | |||
| i__1 = 2, i__2 = ilaenv_(&c__2, "CGEHRD", " ", n, ilo, ihi, & | |||
| c_n1, (ftnlen)6, (ftnlen)1); | |||
| nbmin = f2cmax(i__1,i__2); | |||
| if (*lwork >= *n * nbmin + 4160) { | |||
| nb = (*lwork - 4160) / *n; | |||
| } else { | |||
| nb = 1; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| ldwork = *n; | |||
| if (nb < nbmin || nb >= nh) { | |||
| /* Use unblocked code below */ | |||
| i__ = *ilo; | |||
| } else { | |||
| /* Use blocked code */ | |||
| iwt = *n * nb + 1; | |||
| i__1 = *ihi - 1 - nx; | |||
| i__2 = nb; | |||
| for (i__ = *ilo; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = nb, i__4 = *ihi - i__; | |||
| ib = f2cmin(i__3,i__4); | |||
| /* Reduce columns i:i+ib-1 to Hessenberg form, returning the */ | |||
| /* matrices V and T of the block reflector H = I - V*T*V**H */ | |||
| /* which performs the reduction, and also the matrix Y = A*V*T */ | |||
| clahr2_(ihi, &i__, &ib, &a[i__ * a_dim1 + 1], lda, &tau[i__], & | |||
| work[iwt], &c__65, &work[1], &ldwork); | |||
| /* Apply the block reflector H to A(1:ihi,i+ib:ihi) from the */ | |||
| /* right, computing A := A - Y * V**H. V(i+ib,ib-1) must be set */ | |||
| /* to 1 */ | |||
| i__3 = i__ + ib + (i__ + ib - 1) * a_dim1; | |||
| ei.r = a[i__3].r, ei.i = a[i__3].i; | |||
| i__3 = i__ + ib + (i__ + ib - 1) * a_dim1; | |||
| a[i__3].r = 1.f, a[i__3].i = 0.f; | |||
| i__3 = *ihi - i__ - ib + 1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemm_("No transpose", "Conjugate transpose", ihi, &i__3, &ib, & | |||
| q__1, &work[1], &ldwork, &a[i__ + ib + i__ * a_dim1], lda, | |||
| &c_b2, &a[(i__ + ib) * a_dim1 + 1], lda); | |||
| i__3 = i__ + ib + (i__ + ib - 1) * a_dim1; | |||
| a[i__3].r = ei.r, a[i__3].i = ei.i; | |||
| /* Apply the block reflector H to A(1:i,i+1:i+ib-1) from the */ | |||
| /* right */ | |||
| i__3 = ib - 1; | |||
| ctrmm_("Right", "Lower", "Conjugate transpose", "Unit", &i__, & | |||
| i__3, &c_b2, &a[i__ + 1 + i__ * a_dim1], lda, &work[1], & | |||
| ldwork); | |||
| i__3 = ib - 2; | |||
| for (j = 0; j <= i__3; ++j) { | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| caxpy_(&i__, &q__1, &work[ldwork * j + 1], &c__1, &a[(i__ + j | |||
| + 1) * a_dim1 + 1], &c__1); | |||
| /* L30: */ | |||
| } | |||
| /* Apply the block reflector H to A(i+1:ihi,i+ib:n) from the */ | |||
| /* left */ | |||
| i__3 = *ihi - i__; | |||
| i__4 = *n - i__ - ib + 1; | |||
| clarfb_("Left", "Conjugate transpose", "Forward", "Columnwise", & | |||
| i__3, &i__4, &ib, &a[i__ + 1 + i__ * a_dim1], lda, &work[ | |||
| iwt], &c__65, &a[i__ + 1 + (i__ + ib) * a_dim1], lda, & | |||
| work[1], &ldwork); | |||
| /* L40: */ | |||
| } | |||
| } | |||
| /* Use unblocked code to reduce the rest of the matrix */ | |||
| cgehd2_(n, &i__, ihi, &a[a_offset], lda, &tau[1], &work[1], &iinfo); | |||
| work[1].r = (real) lwkopt, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEHRD */ | |||
| } /* cgehrd_ */ | |||
| @@ -0,0 +1,766 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGELQ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELQ( M, N, A, LDA, T, TSIZE, WORK, LWORK, */ | |||
| /* INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N, TSIZE, LWORK */ | |||
| /* COMPLEX A( LDA, * ), T( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELQ computes an LQ factorization of a complex M-by-N matrix A: */ | |||
| /* > */ | |||
| /* > A = ( L 0 ) * Q */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a N-by-N orthogonal matrix; */ | |||
| /* > L is a lower-triangular M-by-M matrix; */ | |||
| /* > 0 is a M-by-(N-M) zero matrix, if M < N. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the elements on and below the diagonal of the array */ | |||
| /* > contain the M-by-f2cmin(M,N) lower trapezoidal matrix L */ | |||
| /* > (L is lower triangular if M <= N); */ | |||
| /* > the elements above the diagonal are used to store part of the */ | |||
| /* > data structure to represent Q. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX array, dimension (MAX(5,TSIZE)) */ | |||
| /* > On exit, if INFO = 0, T(1) returns optimal (or either minimal */ | |||
| /* > or optimal, if query is assumed) TSIZE. See TSIZE for details. */ | |||
| /* > Remaining T contains part of the data structure used to represent Q. */ | |||
| /* > If one wants to apply or construct Q, then one needs to keep T */ | |||
| /* > (in addition to A) and pass it to further subroutines. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TSIZE */ | |||
| /* > \verbatim */ | |||
| /* > TSIZE is INTEGER */ | |||
| /* > If TSIZE >= 5, the dimension of the array T. */ | |||
| /* > If TSIZE = -1 or -2, then a workspace query is assumed. The routine */ | |||
| /* > only calculates the sizes of the T and WORK arrays, returns these */ | |||
| /* > values as the first entries of the T and WORK arrays, and no error */ | |||
| /* > message related to T or WORK is issued by XERBLA. */ | |||
| /* > If TSIZE = -1, the routine calculates optimal size of T for the */ | |||
| /* > optimum performance and returns this value in T(1). */ | |||
| /* > If TSIZE = -2, the routine calculates minimal size of T and */ | |||
| /* > returns this value in T(1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > (workspace) COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) contains optimal (or either minimal */ | |||
| /* > or optimal, if query was assumed) LWORK. */ | |||
| /* > See LWORK for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > If LWORK = -1 or -2, then a workspace query is assumed. The routine */ | |||
| /* > only calculates the sizes of the T and WORK arrays, returns these */ | |||
| /* > values as the first entries of the T and WORK arrays, and no error */ | |||
| /* > message related to T or WORK is issued by XERBLA. */ | |||
| /* > If LWORK = -1, the routine calculates optimal size of WORK for the */ | |||
| /* > optimal performance and returns this value in WORK(1). */ | |||
| /* > If LWORK = -2, the routine calculates minimal size of WORK and */ | |||
| /* > returns this value in WORK(1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \par Further Details */ | |||
| /* ==================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The goal of the interface is to give maximum freedom to the developers for */ | |||
| /* > creating any LQ factorization algorithm they wish. The triangular */ | |||
| /* > (trapezoidal) L has to be stored in the lower part of A. The lower part of A */ | |||
| /* > and the array T can be used to store any relevant information for applying or */ | |||
| /* > constructing the Q factor. The WORK array can safely be discarded after exit. */ | |||
| /* > */ | |||
| /* > Caution: One should not expect the sizes of T and WORK to be the same from one */ | |||
| /* > LAPACK implementation to the other, or even from one execution to the other. */ | |||
| /* > A workspace query (for T and WORK) is needed at each execution. However, */ | |||
| /* > for a given execution, the size of T and WORK are fixed and will not change */ | |||
| /* > from one query to the next. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \par Further Details particular to this LAPACK implementation: */ | |||
| /* ============================================================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > These details are particular for this LAPACK implementation. Users should not */ | |||
| /* > take them for granted. These details may change in the future, and are not likely */ | |||
| /* > true for another LAPACK implementation. These details are relevant if one wants */ | |||
| /* > to try to understand the code. They are not part of the interface. */ | |||
| /* > */ | |||
| /* > In this version, */ | |||
| /* > */ | |||
| /* > T(2): row block size (MB) */ | |||
| /* > T(3): column block size (NB) */ | |||
| /* > T(6:TSIZE): data structure needed for Q, computed by */ | |||
| /* > CLASWLQ or CGELQT */ | |||
| /* > */ | |||
| /* > Depending on the matrix dimensions M and N, and row and column */ | |||
| /* > block sizes MB and NB returned by ILAENV, CGELQ will use either */ | |||
| /* > CLASWLQ (if the matrix is short-and-wide) or CGELQT to compute */ | |||
| /* > the LQ factorization. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelq_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *t, integer *tsize, complex *work, integer *lwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| /* Local variables */ | |||
| logical mint, minw; | |||
| integer lwmin, lwreq, lwopt, mb, nb, nblcks; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| extern /* Subroutine */ int cgelqt_(integer *, integer *, integer *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *); | |||
| logical lminws, lquery; | |||
| integer mintsz; | |||
| extern /* Subroutine */ int claswlq_(integer *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, integer *, complex *, | |||
| integer *, integer *); | |||
| /* -- LAPACK computational routine (version 3.9.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd. -- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --t; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *tsize == -1 || *tsize == -2 || *lwork == -1 || *lwork == -2; | |||
| mint = FALSE_; | |||
| minw = FALSE_; | |||
| if (*tsize == -2 || *lwork == -2) { | |||
| if (*tsize != -1) { | |||
| mint = TRUE_; | |||
| } | |||
| if (*lwork != -1) { | |||
| minw = TRUE_; | |||
| } | |||
| } | |||
| /* Determine the block size */ | |||
| if (f2cmin(*m,*n) > 0) { | |||
| mb = ilaenv_(&c__1, "CGELQ ", " ", m, n, &c__1, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| nb = ilaenv_(&c__1, "CGELQ ", " ", m, n, &c__2, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| } else { | |||
| mb = 1; | |||
| nb = *n; | |||
| } | |||
| if (mb > f2cmin(*m,*n) || mb < 1) { | |||
| mb = 1; | |||
| } | |||
| if (nb > *n || nb <= *m) { | |||
| nb = *n; | |||
| } | |||
| mintsz = *m + 5; | |||
| if (nb > *m && *n > *m) { | |||
| if ((*n - *m) % (nb - *m) == 0) { | |||
| nblcks = (*n - *m) / (nb - *m); | |||
| } else { | |||
| nblcks = (*n - *m) / (nb - *m) + 1; | |||
| } | |||
| } else { | |||
| nblcks = 1; | |||
| } | |||
| /* Determine if the workspace size satisfies minimal size */ | |||
| if (*n <= *m || nb <= *m || nb >= *n) { | |||
| lwmin = f2cmax(1,*n); | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *n; | |||
| lwopt = f2cmax(i__1,i__2); | |||
| } else { | |||
| lwmin = f2cmax(1,*m); | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *m; | |||
| lwopt = f2cmax(i__1,i__2); | |||
| } | |||
| lminws = FALSE_; | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *m * nblcks + 5; | |||
| if ((*tsize < f2cmax(i__1,i__2) || *lwork < lwopt) && *lwork >= lwmin && * | |||
| tsize >= mintsz && ! lquery) { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *m * nblcks + 5; | |||
| if (*tsize < f2cmax(i__1,i__2)) { | |||
| lminws = TRUE_; | |||
| mb = 1; | |||
| nb = *n; | |||
| } | |||
| if (*lwork < lwopt) { | |||
| lminws = TRUE_; | |||
| mb = 1; | |||
| } | |||
| } | |||
| if (*n <= *m || nb <= *m || nb >= *n) { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *n; | |||
| lwreq = f2cmax(i__1,i__2); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *m; | |||
| lwreq = f2cmax(i__1,i__2); | |||
| } | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mb * *m * nblcks + 5; | |||
| if (*tsize < f2cmax(i__1,i__2) && ! lquery && ! lminws) { | |||
| *info = -6; | |||
| } else if (*lwork < lwreq && ! lquery && ! lminws) { | |||
| *info = -8; | |||
| } | |||
| } | |||
| if (*info == 0) { | |||
| if (mint) { | |||
| t[1].r = (real) mintsz, t[1].i = 0.f; | |||
| } else { | |||
| i__1 = mb * *m * nblcks + 5; | |||
| t[1].r = (real) i__1, t[1].i = 0.f; | |||
| } | |||
| t[2].r = (real) mb, t[2].i = 0.f; | |||
| t[3].r = (real) nb, t[3].i = 0.f; | |||
| if (minw) { | |||
| work[1].r = (real) lwmin, work[1].i = 0.f; | |||
| } else { | |||
| work[1].r = (real) lwreq, work[1].i = 0.f; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELQ", &i__1, (ftnlen)5); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (f2cmin(*m,*n) == 0) { | |||
| return 0; | |||
| } | |||
| /* The LQ Decomposition */ | |||
| if (*n <= *m || nb <= *m || nb >= *n) { | |||
| cgelqt_(m, n, &mb, &a[a_offset], lda, &t[6], &mb, &work[1], info); | |||
| } else { | |||
| claswlq_(m, n, &mb, &nb, &a[a_offset], lda, &t[6], &mb, &work[1], | |||
| lwork, info); | |||
| } | |||
| work[1].r = (real) lwreq, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGELQ */ | |||
| } /* cgelq_ */ | |||
| @@ -0,0 +1,626 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b CGELQ2 computes the LQ factorization of a general rectangular matrix using an unblocked algorit | |||
| hm. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGELQ2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgelq2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgelq2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgelq2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELQ2( M, N, A, LDA, TAU, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELQ2 computes an LQ factorization of a complex m-by-n matrix A: */ | |||
| /* > */ | |||
| /* > A = ( L 0 ) * Q */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a n-by-n orthogonal matrix; */ | |||
| /* > L is an lower-triangular m-by-m matrix; */ | |||
| /* > 0 is a m-by-(n-m) zero matrix, if m < n. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the m by n matrix A. */ | |||
| /* > On exit, the elements on and below the diagonal of the array */ | |||
| /* > contain the m by f2cmin(m,n) lower trapezoidal matrix L (L is */ | |||
| /* > lower triangular if m <= n); the elements above the diagonal, */ | |||
| /* > with the array TAU, represent the unitary matrix Q as a */ | |||
| /* > product of elementary reflectors (see Further Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (M) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2019 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(k)**H . . . H(2)**H H(1)**H, where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a complex vector with */ | |||
| /* > v(1:i-1) = 0 and v(i) = 1; conjg(v(i+1:n)) is stored on exit in */ | |||
| /* > A(i,i+1:n), and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelq2_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| complex alpha; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| clarfg_(integer *, complex *, complex *, integer *, complex *), | |||
| clacgv_(integer *, complex *, integer *), xerbla_(char *, integer | |||
| *, ftnlen); | |||
| /* -- LAPACK computational routine (version 3.9.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELQ2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| k = f2cmin(*m,*n); | |||
| i__1 = k; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Generate elementary reflector H(i) to annihilate A(i,i+1:n) */ | |||
| i__2 = *n - i__ + 1; | |||
| clacgv_(&i__2, &a[i__ + i__ * a_dim1], lda); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = *n - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 1; | |||
| clarfg_(&i__2, &alpha, &a[i__ + f2cmin(i__3,*n) * a_dim1], lda, &tau[i__] | |||
| ); | |||
| if (i__ < *m) { | |||
| /* Apply H(i) to A(i+1:m,i:n) from the right */ | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| i__2 = *m - i__; | |||
| i__3 = *n - i__ + 1; | |||
| clarf_("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, &tau[ | |||
| i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]); | |||
| } | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = alpha.r, a[i__2].i = alpha.i; | |||
| i__2 = *n - i__ + 1; | |||
| clacgv_(&i__2, &a[i__ + i__ * a_dim1], lda); | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of CGELQ2 */ | |||
| } /* cgelq2_ */ | |||
| @@ -0,0 +1,720 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGELQF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGELQF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgelqf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgelqf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgelqf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELQF( M, N, A, LDA, TAU, WORK, LWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LWORK, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELQF computes an LQ factorization of a complex M-by-N matrix A: */ | |||
| /* > */ | |||
| /* > A = ( L 0 ) * Q */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a N-by-N orthogonal matrix; */ | |||
| /* > L is an lower-triangular M-by-M matrix; */ | |||
| /* > 0 is a M-by-(N-M) zero matrix, if M < N. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the elements on and below the diagonal of the array */ | |||
| /* > contain the m-by-f2cmin(m,n) lower trapezoidal matrix L (L is */ | |||
| /* > lower triangular if m <= n); the elements above the diagonal, */ | |||
| /* > with the array TAU, represent the unitary matrix Q as a */ | |||
| /* > product of elementary reflectors (see Further Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,M). */ | |||
| /* > For optimum performance LWORK >= M*NB, where NB is the */ | |||
| /* > optimal blocksize. */ | |||
| /* > */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates the optimal size of the WORK array, returns */ | |||
| /* > this value as the first entry of the WORK array, and no error */ | |||
| /* > message related to LWORK is issued by XERBLA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2019 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(k)**H . . . H(2)**H H(1)**H, where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a complex vector with */ | |||
| /* > v(1:i-1) = 0 and v(i) = 1; conjg(v(i+1:n)) is stored on exit in */ | |||
| /* > A(i,i+1:n), and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelqf_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| integer i__, k, nbmin, iinfo; | |||
| extern /* Subroutine */ int cgelq2_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *); | |||
| integer ib, nb; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| integer nx; | |||
| extern /* Subroutine */ int clarft_(char *, char *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *), xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer ldwork, lwkopt; | |||
| logical lquery; | |||
| integer iws; | |||
| /* -- LAPACK computational routine (version 3.9.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| nb = ilaenv_(&c__1, "CGELQF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, (ftnlen) | |||
| 1); | |||
| lwkopt = *m * nb; | |||
| work[1].r = (real) lwkopt, work[1].i = 0.f; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else if (*lwork < f2cmax(1,*m) && ! lquery) { | |||
| *info = -7; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELQF", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| k = f2cmin(*m,*n); | |||
| if (k == 0) { | |||
| work[1].r = 1.f, work[1].i = 0.f; | |||
| return 0; | |||
| } | |||
| nbmin = 2; | |||
| nx = 0; | |||
| iws = *m; | |||
| if (nb > 1 && nb < k) { | |||
| /* Determine when to cross over from blocked to unblocked code. */ | |||
| /* Computing MAX */ | |||
| i__1 = 0, i__2 = ilaenv_(&c__3, "CGELQF", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| if (nx < k) { | |||
| /* Determine if workspace is large enough for blocked code. */ | |||
| ldwork = *m; | |||
| iws = ldwork * nb; | |||
| if (*lwork < iws) { | |||
| /* Not enough workspace to use optimal NB: reduce NB and */ | |||
| /* determine the minimum value of NB. */ | |||
| nb = *lwork / ldwork; | |||
| /* Computing MAX */ | |||
| i__1 = 2, i__2 = ilaenv_(&c__2, "CGELQF", " ", m, n, &c_n1, & | |||
| c_n1, (ftnlen)6, (ftnlen)1); | |||
| nbmin = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| } | |||
| if (nb >= nbmin && nb < k && nx < k) { | |||
| /* Use blocked code initially */ | |||
| i__1 = k - nx; | |||
| i__2 = nb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = k - i__ + 1; | |||
| ib = f2cmin(i__3,nb); | |||
| /* Compute the LQ factorization of the current block */ | |||
| /* A(i:i+ib-1,i:n) */ | |||
| i__3 = *n - i__ + 1; | |||
| cgelq2_(&ib, &i__3, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[ | |||
| 1], &iinfo); | |||
| if (i__ + ib <= *m) { | |||
| /* Form the triangular factor of the block reflector */ | |||
| /* H = H(i) H(i+1) . . . H(i+ib-1) */ | |||
| i__3 = *n - i__ + 1; | |||
| clarft_("Forward", "Rowwise", &i__3, &ib, &a[i__ + i__ * | |||
| a_dim1], lda, &tau[i__], &work[1], &ldwork); | |||
| /* Apply H to A(i+ib:m,i:n) from the right */ | |||
| i__3 = *m - i__ - ib + 1; | |||
| i__4 = *n - i__ + 1; | |||
| clarfb_("Right", "No transpose", "Forward", "Rowwise", &i__3, | |||
| &i__4, &ib, &a[i__ + i__ * a_dim1], lda, &work[1], & | |||
| ldwork, &a[i__ + ib + i__ * a_dim1], lda, &work[ib + | |||
| 1], &ldwork); | |||
| } | |||
| /* L10: */ | |||
| } | |||
| } else { | |||
| i__ = 1; | |||
| } | |||
| /* Use unblocked code to factor the last or only block. */ | |||
| if (i__ <= k) { | |||
| i__2 = *m - i__ + 1; | |||
| i__1 = *n - i__ + 1; | |||
| cgelq2_(&i__2, &i__1, &a[i__ + i__ * a_dim1], lda, &tau[i__], &work[1] | |||
| , &iinfo); | |||
| } | |||
| work[1].r = (real) iws, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGELQF */ | |||
| } /* cgelqf_ */ | |||
| @@ -0,0 +1,622 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b CGELQT */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELQT( M, N, MB, A, LDA, T, LDT, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LDT, M, N, MB */ | |||
| /* COMPLEX A( LDA, * ), T( LDT, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELQT computes a blocked LQ factorization of a complex M-by-N matrix A */ | |||
| /* > using the compact WY representation of Q. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] MB */ | |||
| /* > \verbatim */ | |||
| /* > MB is INTEGER */ | |||
| /* > The block size to be used in the blocked QR. MIN(M,N) >= MB >= 1. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the elements on and below the diagonal of the array */ | |||
| /* > contain the M-by-MIN(M,N) lower trapezoidal matrix L (L is */ | |||
| /* > lower triangular if M <= N); the elements above the diagonal */ | |||
| /* > are the rows of V. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX array, dimension (LDT,MIN(M,N)) */ | |||
| /* > The upper triangular block reflectors stored in compact form */ | |||
| /* > as a sequence of upper triangular blocks. See below */ | |||
| /* > for further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= MB. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MB*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date June 2017 */ | |||
| /* > \ingroup doubleGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix V stores the elementary reflectors H(i) in the i-th row */ | |||
| /* > above the diagonal. For example, if M=5 and N=3, the matrix V is */ | |||
| /* > */ | |||
| /* > V = ( 1 v1 v1 v1 v1 ) */ | |||
| /* > ( 1 v2 v2 v2 ) */ | |||
| /* > ( 1 v3 v3 ) */ | |||
| /* > */ | |||
| /* > */ | |||
| /* > where the vi's represent the vectors which define H(i), which are returned */ | |||
| /* > in the matrix A. The 1's along the diagonal of V are not stored in A. */ | |||
| /* > Let K=MIN(M,N). The number of blocks is B = ceiling(K/MB), where each */ | |||
| /* > block is of order MB except for the last block, which is of order */ | |||
| /* > IB = K - (B-1)*MB. For each of the B blocks, a upper triangular block */ | |||
| /* > reflector factor is computed: T1, T2, ..., TB. The MB-by-MB (and IB-by-IB */ | |||
| /* > for the last block) T's are stored in the MB-by-K matrix T as */ | |||
| /* > */ | |||
| /* > T = (T1 T2 ... TB). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelqt_(integer *m, integer *n, integer *mb, complex *a, | |||
| integer *lda, complex *t, integer *ldt, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, i__1, i__2, i__3, i__4, i__5; | |||
| /* Local variables */ | |||
| integer i__, k, iinfo, ib; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *), xerbla_(char *, integer *, ftnlen), | |||
| cgelqt3_(integer *, integer *, complex *, integer *, complex *, | |||
| integer *, integer *); | |||
| /* -- LAPACK computational routine (version 3.7.1) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* June 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*mb < 1 || *mb > f2cmin(*m,*n) && f2cmin(*m,*n) > 0) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -5; | |||
| } else if (*ldt < *mb) { | |||
| *info = -7; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELQT", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| k = f2cmin(*m,*n); | |||
| if (k == 0) { | |||
| return 0; | |||
| } | |||
| /* Blocked loop of length K */ | |||
| i__1 = k; | |||
| i__2 = *mb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = k - i__ + 1; | |||
| ib = f2cmin(i__3,*mb); | |||
| /* Compute the LQ factorization of the current block A(I:M,I:I+IB-1) */ | |||
| i__3 = *n - i__ + 1; | |||
| cgelqt3_(&ib, &i__3, &a[i__ + i__ * a_dim1], lda, &t[i__ * t_dim1 + 1] | |||
| , ldt, &iinfo); | |||
| if (i__ + ib <= *m) { | |||
| /* Update by applying H**T to A(I:M,I+IB:N) from the right */ | |||
| i__3 = *m - i__ - ib + 1; | |||
| i__4 = *n - i__ + 1; | |||
| i__5 = *m - i__ - ib + 1; | |||
| clarfb_("R", "N", "F", "R", &i__3, &i__4, &ib, &a[i__ + i__ * | |||
| a_dim1], lda, &t[i__ * t_dim1 + 1], ldt, &a[i__ + ib + | |||
| i__ * a_dim1], lda, &work[1], &i__5); | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGELQT */ | |||
| } /* cgelqt_ */ | |||
| @@ -0,0 +1,697 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b1 = {1.f,0.f}; | |||
| /* > \brief \b CGELQT3 */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELQT3( M, N, A, LDA, T, LDT, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N, LDT */ | |||
| /* COMPLEX A( LDA, * ), T( LDT, * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELQT3 recursively computes a LQ factorization of a complex M-by-N */ | |||
| /* > matrix A, using the compact WY representation of Q. */ | |||
| /* > */ | |||
| /* > Based on the algorithm of Elmroth and Gustavson, */ | |||
| /* > IBM J. Res. Develop. Vol 44 No. 4 July 2000. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M =< N. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the real M-by-N matrix A. On exit, the elements on and */ | |||
| /* > below the diagonal contain the N-by-N lower triangular matrix L; the */ | |||
| /* > elements above the diagonal are the rows of V. See below for */ | |||
| /* > further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX array, dimension (LDT,N) */ | |||
| /* > The N-by-N upper triangular factor of the block reflector. */ | |||
| /* > The elements on and above the diagonal contain the block */ | |||
| /* > reflector T; the elements below the diagonal are not used. */ | |||
| /* > See below for further details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2017 */ | |||
| /* > \ingroup doubleGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix V stores the elementary reflectors H(i) in the i-th row */ | |||
| /* > above the diagonal. For example, if M=5 and N=3, the matrix V is */ | |||
| /* > */ | |||
| /* > V = ( 1 v1 v1 v1 v1 ) */ | |||
| /* > ( 1 v2 v2 v2 ) */ | |||
| /* > ( 1 v3 v3 v3 ) */ | |||
| /* > */ | |||
| /* > */ | |||
| /* > where the vi's represent the vectors which define H(i), which are returned */ | |||
| /* > in the matrix A. The 1's along the diagonal of V are not stored in A. The */ | |||
| /* > block reflector H is then given by */ | |||
| /* > */ | |||
| /* > H = I - V * T * V**T */ | |||
| /* > */ | |||
| /* > where V**T is the transpose of V. */ | |||
| /* > */ | |||
| /* > For details of the algorithm, see Elmroth and Gustavson (cited above). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelqt3_(integer *m, integer *n, complex *a, integer * | |||
| lda, complex *t, integer *ldt, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, t_dim1, t_offset, i__1, i__2, i__3, i__4, i__5; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, j; | |||
| extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, | |||
| integer *, complex *, complex *, integer *, complex *, integer *, | |||
| complex *, complex *, integer *); | |||
| integer iinfo; | |||
| extern /* Subroutine */ int ctrmm_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *); | |||
| integer i1, j1, m1, m2; | |||
| extern /* Subroutine */ int clarfg_(integer *, complex *, complex *, | |||
| integer *, complex *), xerbla_(char *, integer *, ftnlen); | |||
| /* -- LAPACK computational routine (version 3.8.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* November 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < *m) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else if (*ldt < f2cmax(1,*m)) { | |||
| *info = -6; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELQT3", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| if (*m == 1) { | |||
| /* Compute Householder transform when N=1 */ | |||
| clarfg_(n, &a[a_offset], &a[f2cmin(2,*n) * a_dim1 + 1], lda, &t[t_offset] | |||
| ); | |||
| i__1 = t_dim1 + 1; | |||
| r_cnjg(&q__1, &t[t_dim1 + 1]); | |||
| t[i__1].r = q__1.r, t[i__1].i = q__1.i; | |||
| } else { | |||
| /* Otherwise, split A into blocks... */ | |||
| m1 = *m / 2; | |||
| m2 = *m - m1; | |||
| /* Computing MIN */ | |||
| i__1 = m1 + 1; | |||
| i1 = f2cmin(i__1,*m); | |||
| /* Computing MIN */ | |||
| i__1 = *m + 1; | |||
| j1 = f2cmin(i__1,*n); | |||
| /* Compute A(1:M1,1:N) <- (Y1,R1,T1), where Q1 = I - Y1 T1 Y1^H */ | |||
| cgelqt3_(&m1, n, &a[a_offset], lda, &t[t_offset], ldt, &iinfo); | |||
| /* Compute A(J1:M,1:N) = A(J1:M,1:N) Q1^H [workspace: T(1:N1,J1:N)] */ | |||
| i__1 = m2; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = m1; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| i__3 = i__ + m1 + j * t_dim1; | |||
| i__4 = i__ + m1 + j * a_dim1; | |||
| t[i__3].r = a[i__4].r, t[i__3].i = a[i__4].i; | |||
| } | |||
| } | |||
| ctrmm_("R", "U", "C", "U", &m2, &m1, &c_b1, &a[a_offset], lda, &t[i1 | |||
| + t_dim1], ldt); | |||
| i__1 = *n - m1; | |||
| cgemm_("N", "C", &m2, &m1, &i__1, &c_b1, &a[i1 + i1 * a_dim1], lda, & | |||
| a[i1 * a_dim1 + 1], lda, &c_b1, &t[i1 + t_dim1], ldt); | |||
| ctrmm_("R", "U", "N", "N", &m2, &m1, &c_b1, &t[t_offset], ldt, &t[i1 | |||
| + t_dim1], ldt); | |||
| i__1 = *n - m1; | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| cgemm_("N", "N", &m2, &i__1, &m1, &q__1, &t[i1 + t_dim1], ldt, &a[i1 * | |||
| a_dim1 + 1], lda, &c_b1, &a[i1 + i1 * a_dim1], lda); | |||
| ctrmm_("R", "U", "N", "U", &m2, &m1, &c_b1, &a[a_offset], lda, &t[i1 | |||
| + t_dim1], ldt); | |||
| i__1 = m2; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = m1; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| i__3 = i__ + m1 + j * a_dim1; | |||
| i__4 = i__ + m1 + j * a_dim1; | |||
| i__5 = i__ + m1 + j * t_dim1; | |||
| q__1.r = a[i__4].r - t[i__5].r, q__1.i = a[i__4].i - t[i__5] | |||
| .i; | |||
| a[i__3].r = q__1.r, a[i__3].i = q__1.i; | |||
| i__3 = i__ + m1 + j * t_dim1; | |||
| t[i__3].r = 0.f, t[i__3].i = 0.f; | |||
| } | |||
| } | |||
| /* Compute A(J1:M,J1:N) <- (Y2,R2,T2) where Q2 = I - Y2 T2 Y2^H */ | |||
| i__1 = *n - m1; | |||
| cgelqt3_(&m2, &i__1, &a[i1 + i1 * a_dim1], lda, &t[i1 + i1 * t_dim1], | |||
| ldt, &iinfo); | |||
| /* Compute T3 = T(J1:N1,1:N) = -T1 Y1^H Y2 T2 */ | |||
| i__1 = m2; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = m1; | |||
| for (j = 1; j <= i__2; ++j) { | |||
| i__3 = j + (i__ + m1) * t_dim1; | |||
| i__4 = j + (i__ + m1) * a_dim1; | |||
| t[i__3].r = a[i__4].r, t[i__3].i = a[i__4].i; | |||
| } | |||
| } | |||
| ctrmm_("R", "U", "C", "U", &m1, &m2, &c_b1, &a[i1 + i1 * a_dim1], lda, | |||
| &t[i1 * t_dim1 + 1], ldt); | |||
| i__1 = *n - *m; | |||
| cgemm_("N", "C", &m1, &m2, &i__1, &c_b1, &a[j1 * a_dim1 + 1], lda, &a[ | |||
| i1 + j1 * a_dim1], lda, &c_b1, &t[i1 * t_dim1 + 1], ldt); | |||
| q__1.r = -1.f, q__1.i = 0.f; | |||
| ctrmm_("L", "U", "N", "N", &m1, &m2, &q__1, &t[t_offset], ldt, &t[i1 * | |||
| t_dim1 + 1], ldt) | |||
| ; | |||
| ctrmm_("R", "U", "N", "N", &m1, &m2, &c_b1, &t[i1 + i1 * t_dim1], ldt, | |||
| &t[i1 * t_dim1 + 1], ldt); | |||
| /* Y = (Y1,Y2); L = [ L1 0 ]; T = [T1 T3] */ | |||
| /* [ A(1:N1,J1:N) L2 ] [ 0 T2] */ | |||
| } | |||
| return 0; | |||
| /* End of CGELQT3 */ | |||
| } /* cgelqt3_ */ | |||
| @@ -0,0 +1,982 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b1 = {0.f,0.f}; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__0 = 0; | |||
| /* > \brief <b> CGELS solves overdetermined or underdetermined systems for GE matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGELS + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgels.f | |||
| "> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgels.f | |||
| "> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgels.f | |||
| "> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELS( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK, */ | |||
| /* INFO ) */ | |||
| /* CHARACTER TRANS */ | |||
| /* INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS */ | |||
| /* COMPLEX A( LDA, * ), B( LDB, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELS solves overdetermined or underdetermined complex linear systems */ | |||
| /* > involving an M-by-N matrix A, or its conjugate-transpose, using a QR */ | |||
| /* > or LQ factorization of A. It is assumed that A has full rank. */ | |||
| /* > */ | |||
| /* > The following options are provided: */ | |||
| /* > */ | |||
| /* > 1. If TRANS = 'N' and m >= n: find the least squares solution of */ | |||
| /* > an overdetermined system, i.e., solve the least squares problem */ | |||
| /* > minimize || B - A*X ||. */ | |||
| /* > */ | |||
| /* > 2. If TRANS = 'N' and m < n: find the minimum norm solution of */ | |||
| /* > an underdetermined system A * X = B. */ | |||
| /* > */ | |||
| /* > 3. If TRANS = 'C' and m >= n: find the minimum norm solution of */ | |||
| /* > an underdetermined system A**H * X = B. */ | |||
| /* > */ | |||
| /* > 4. If TRANS = 'C' and m < n: find the least squares solution of */ | |||
| /* > an overdetermined system, i.e., solve the least squares problem */ | |||
| /* > minimize || B - A**H * X ||. */ | |||
| /* > */ | |||
| /* > Several right hand side vectors b and solution vectors x can be */ | |||
| /* > handled in a single call; they are stored as the columns of the */ | |||
| /* > M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ | |||
| /* > matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > = 'N': the linear system involves A; */ | |||
| /* > = 'C': the linear system involves A**H. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of */ | |||
| /* > columns of the matrices B and X. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > if M >= N, A is overwritten by details of its QR */ | |||
| /* > factorization as returned by CGEQRF; */ | |||
| /* > if M < N, A is overwritten by details of its LQ */ | |||
| /* > factorization as returned by CGELQF. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the matrix B of right hand side vectors, stored */ | |||
| /* > columnwise; B is M-by-NRHS if TRANS = 'N', or N-by-NRHS */ | |||
| /* > if TRANS = 'C'. */ | |||
| /* > On exit, if INFO = 0, B is overwritten by the solution */ | |||
| /* > vectors, stored columnwise: */ | |||
| /* > if TRANS = 'N' and m >= n, rows 1 to n of B contain the least */ | |||
| /* > squares solution vectors; the residual sum of squares for the */ | |||
| /* > solution in each column is given by the sum of squares of the */ | |||
| /* > modulus of elements N+1 to M in that column; */ | |||
| /* > if TRANS = 'N' and m < n, rows 1 to N of B contain the */ | |||
| /* > minimum norm solution vectors; */ | |||
| /* > if TRANS = 'C' and m >= n, rows 1 to M of B contain the */ | |||
| /* > minimum norm solution vectors; */ | |||
| /* > if TRANS = 'C' and m < n, rows 1 to M of B contain the */ | |||
| /* > least squares solution vectors; the residual sum of squares */ | |||
| /* > for the solution in each column is given by the sum of */ | |||
| /* > squares of the modulus of elements M+1 to N in that column. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= MAX(1,M,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > LWORK >= f2cmax( 1, MN + f2cmax( MN, NRHS ) ). */ | |||
| /* > For optimal performance, */ | |||
| /* > LWORK >= f2cmax( 1, MN + f2cmax( MN, NRHS )*NB ). */ | |||
| /* > where MN = f2cmin(M,N) and NB is the optimum block size. */ | |||
| /* > */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates the optimal size of the WORK array, returns */ | |||
| /* > this value as the first entry of the WORK array, and no error */ | |||
| /* > message related to LWORK is issued by XERBLA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > > 0: if INFO = i, the i-th diagonal element of the */ | |||
| /* > triangular factor of A is zero, so that A does not have */ | |||
| /* > full rank; the least squares solution could not be */ | |||
| /* > computed. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEsolve */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgels_(char *trans, integer *m, integer *n, integer * | |||
| nrhs, complex *a, integer *lda, complex *b, integer *ldb, complex * | |||
| work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3; | |||
| real r__1; | |||
| /* Local variables */ | |||
| real anrm, bnrm; | |||
| integer brow; | |||
| logical tpsd; | |||
| integer i__, j, iascl, ibscl; | |||
| extern logical lsame_(char *, char *); | |||
| integer wsize; | |||
| real rwork[1]; | |||
| integer nb; | |||
| extern /* Subroutine */ int slabad_(real *, real *); | |||
| extern real clange_(char *, integer *, integer *, complex *, integer *, | |||
| real *); | |||
| integer mn; | |||
| extern /* Subroutine */ int cgelqf_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *, integer *), clascl_( | |||
| char *, integer *, integer *, real *, real *, integer *, integer * | |||
| , complex *, integer *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int cgeqrf_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *, integer *), claset_( | |||
| char *, integer *, integer *, complex *, complex *, complex *, | |||
| integer *), xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer scllen; | |||
| real bignum; | |||
| extern /* Subroutine */ int cunmlq_(char *, char *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, complex *, integer *, | |||
| complex *, integer *, integer *), cunmqr_(char *, | |||
| char *, integer *, integer *, integer *, complex *, integer *, | |||
| complex *, complex *, integer *, complex *, integer *, integer *); | |||
| real smlnum; | |||
| logical lquery; | |||
| extern /* Subroutine */ int ctrtrs_(char *, char *, char *, integer *, | |||
| integer *, complex *, integer *, complex *, integer *, integer *); | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments. */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| mn = f2cmin(*m,*n); | |||
| lquery = *lwork == -1; | |||
| if (! (lsame_(trans, "N") || lsame_(trans, "C"))) { | |||
| *info = -1; | |||
| } else if (*m < 0) { | |||
| *info = -2; | |||
| } else if (*n < 0) { | |||
| *info = -3; | |||
| } else if (*nrhs < 0) { | |||
| *info = -4; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -6; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(1,*m); | |||
| if (*ldb < f2cmax(i__1,*n)) { | |||
| *info = -8; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mn + f2cmax(mn,*nrhs); | |||
| if (*lwork < f2cmax(i__1,i__2) && ! lquery) { | |||
| *info = -10; | |||
| } | |||
| } | |||
| } | |||
| /* Figure out optimal block size */ | |||
| if (*info == 0 || *info == -10) { | |||
| tpsd = TRUE_; | |||
| if (lsame_(trans, "N")) { | |||
| tpsd = FALSE_; | |||
| } | |||
| if (*m >= *n) { | |||
| nb = ilaenv_(&c__1, "CGEQRF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, | |||
| (ftnlen)1); | |||
| if (tpsd) { | |||
| /* Computing MAX */ | |||
| i__1 = nb, i__2 = ilaenv_(&c__1, "CUNMQR", "LN", m, nrhs, n, & | |||
| c_n1, (ftnlen)6, (ftnlen)2); | |||
| nb = f2cmax(i__1,i__2); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__1 = nb, i__2 = ilaenv_(&c__1, "CUNMQR", "LC", m, nrhs, n, & | |||
| c_n1, (ftnlen)6, (ftnlen)2); | |||
| nb = f2cmax(i__1,i__2); | |||
| } | |||
| } else { | |||
| nb = ilaenv_(&c__1, "CGELQF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, | |||
| (ftnlen)1); | |||
| if (tpsd) { | |||
| /* Computing MAX */ | |||
| i__1 = nb, i__2 = ilaenv_(&c__1, "CUNMLQ", "LC", n, nrhs, m, & | |||
| c_n1, (ftnlen)6, (ftnlen)2); | |||
| nb = f2cmax(i__1,i__2); | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__1 = nb, i__2 = ilaenv_(&c__1, "CUNMLQ", "LN", n, nrhs, m, & | |||
| c_n1, (ftnlen)6, (ftnlen)2); | |||
| nb = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mn + f2cmax(mn,*nrhs) * nb; | |||
| wsize = f2cmax(i__1,i__2); | |||
| r__1 = (real) wsize; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELS ", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*nrhs) == 0) { | |||
| i__1 = f2cmax(*m,*n); | |||
| claset_("Full", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| return 0; | |||
| } | |||
| /* Get machine parameters */ | |||
| smlnum = slamch_("S") / slamch_("P"); | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| /* Scale A, B if f2cmax element outside range [SMLNUM,BIGNUM] */ | |||
| anrm = clange_("M", m, n, &a[a_offset], lda, rwork); | |||
| iascl = 0; | |||
| if (anrm > 0.f && anrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| clascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 1; | |||
| } else if (anrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| clascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 2; | |||
| } else if (anrm == 0.f) { | |||
| /* Matrix all zero. Return zero solution. */ | |||
| i__1 = f2cmax(*m,*n); | |||
| claset_("F", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| goto L50; | |||
| } | |||
| brow = *m; | |||
| if (tpsd) { | |||
| brow = *n; | |||
| } | |||
| bnrm = clange_("M", &brow, nrhs, &b[b_offset], ldb, rwork); | |||
| ibscl = 0; | |||
| if (bnrm > 0.f && bnrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| clascl_("G", &c__0, &c__0, &bnrm, &smlnum, &brow, nrhs, &b[b_offset], | |||
| ldb, info); | |||
| ibscl = 1; | |||
| } else if (bnrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| clascl_("G", &c__0, &c__0, &bnrm, &bignum, &brow, nrhs, &b[b_offset], | |||
| ldb, info); | |||
| ibscl = 2; | |||
| } | |||
| if (*m >= *n) { | |||
| /* compute QR factorization of A */ | |||
| i__1 = *lwork - mn; | |||
| cgeqrf_(m, n, &a[a_offset], lda, &work[1], &work[mn + 1], &i__1, info) | |||
| ; | |||
| /* workspace at least N, optimally N*NB */ | |||
| if (! tpsd) { | |||
| /* Least-Squares Problem f2cmin || A * X - B || */ | |||
| /* B(1:M,1:NRHS) := Q**H * B(1:M,1:NRHS) */ | |||
| i__1 = *lwork - mn; | |||
| cunmqr_("Left", "Conjugate transpose", m, nrhs, n, &a[a_offset], | |||
| lda, &work[1], &b[b_offset], ldb, &work[mn + 1], &i__1, | |||
| info); | |||
| /* workspace at least NRHS, optimally NRHS*NB */ | |||
| /* B(1:N,1:NRHS) := inv(R) * B(1:N,1:NRHS) */ | |||
| ctrtrs_("Upper", "No transpose", "Non-unit", n, nrhs, &a[a_offset] | |||
| , lda, &b[b_offset], ldb, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| scllen = *n; | |||
| } else { | |||
| /* Underdetermined system of equations A**T * X = B */ | |||
| /* B(1:N,1:NRHS) := inv(R**H) * B(1:N,1:NRHS) */ | |||
| ctrtrs_("Upper", "Conjugate transpose", "Non-unit", n, nrhs, &a[ | |||
| a_offset], lda, &b[b_offset], ldb, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| /* B(N+1:M,1:NRHS) = ZERO */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *m; | |||
| for (i__ = *n + 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = 0.f, b[i__3].i = 0.f; | |||
| /* L10: */ | |||
| } | |||
| /* L20: */ | |||
| } | |||
| /* B(1:M,1:NRHS) := Q(1:N,:) * B(1:N,1:NRHS) */ | |||
| i__1 = *lwork - mn; | |||
| cunmqr_("Left", "No transpose", m, nrhs, n, &a[a_offset], lda, & | |||
| work[1], &b[b_offset], ldb, &work[mn + 1], &i__1, info); | |||
| /* workspace at least NRHS, optimally NRHS*NB */ | |||
| scllen = *m; | |||
| } | |||
| } else { | |||
| /* Compute LQ factorization of A */ | |||
| i__1 = *lwork - mn; | |||
| cgelqf_(m, n, &a[a_offset], lda, &work[1], &work[mn + 1], &i__1, info) | |||
| ; | |||
| /* workspace at least M, optimally M*NB. */ | |||
| if (! tpsd) { | |||
| /* underdetermined system of equations A * X = B */ | |||
| /* B(1:M,1:NRHS) := inv(L) * B(1:M,1:NRHS) */ | |||
| ctrtrs_("Lower", "No transpose", "Non-unit", m, nrhs, &a[a_offset] | |||
| , lda, &b[b_offset], ldb, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| /* B(M+1:N,1:NRHS) = 0 */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = *m + 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = 0.f, b[i__3].i = 0.f; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| /* B(1:N,1:NRHS) := Q(1:N,:)**H * B(1:M,1:NRHS) */ | |||
| i__1 = *lwork - mn; | |||
| cunmlq_("Left", "Conjugate transpose", n, nrhs, m, &a[a_offset], | |||
| lda, &work[1], &b[b_offset], ldb, &work[mn + 1], &i__1, | |||
| info); | |||
| /* workspace at least NRHS, optimally NRHS*NB */ | |||
| scllen = *n; | |||
| } else { | |||
| /* overdetermined system f2cmin || A**H * X - B || */ | |||
| /* B(1:N,1:NRHS) := Q * B(1:N,1:NRHS) */ | |||
| i__1 = *lwork - mn; | |||
| cunmlq_("Left", "No transpose", n, nrhs, m, &a[a_offset], lda, & | |||
| work[1], &b[b_offset], ldb, &work[mn + 1], &i__1, info); | |||
| /* workspace at least NRHS, optimally NRHS*NB */ | |||
| /* B(1:M,1:NRHS) := inv(L**H) * B(1:M,1:NRHS) */ | |||
| ctrtrs_("Lower", "Conjugate transpose", "Non-unit", m, nrhs, &a[ | |||
| a_offset], lda, &b[b_offset], ldb, info); | |||
| if (*info > 0) { | |||
| return 0; | |||
| } | |||
| scllen = *m; | |||
| } | |||
| } | |||
| /* Undo scaling */ | |||
| if (iascl == 1) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &smlnum, &scllen, nrhs, &b[b_offset] | |||
| , ldb, info); | |||
| } else if (iascl == 2) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &bignum, &scllen, nrhs, &b[b_offset] | |||
| , ldb, info); | |||
| } | |||
| if (ibscl == 1) { | |||
| clascl_("G", &c__0, &c__0, &smlnum, &bnrm, &scllen, nrhs, &b[b_offset] | |||
| , ldb, info); | |||
| } else if (ibscl == 2) { | |||
| clascl_("G", &c__0, &c__0, &bignum, &bnrm, &scllen, nrhs, &b[b_offset] | |||
| , ldb, info); | |||
| } | |||
| L50: | |||
| r__1 = (real) wsize; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGELS */ | |||
| } /* cgels_ */ | |||
| @@ -0,0 +1,987 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static complex c_b1 = {0.f,0.f}; | |||
| static complex c_b2 = {1.f,0.f}; | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__0 = 0; | |||
| static integer c__2 = 2; | |||
| /* > \brief <b> CGELSY solves overdetermined or underdetermined systems for GE matrices</b> */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGELSY + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgelsy. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgelsy. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgelsy. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGELSY( M, N, NRHS, A, LDA, B, LDB, JPVT, RCOND, RANK, */ | |||
| /* WORK, LWORK, RWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS, RANK */ | |||
| /* REAL RCOND */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), B( LDB, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGELSY computes the minimum-norm solution to a complex linear least */ | |||
| /* > squares problem: */ | |||
| /* > minimize || A * X - B || */ | |||
| /* > using a complete orthogonal factorization of A. A is an M-by-N */ | |||
| /* > matrix which may be rank-deficient. */ | |||
| /* > */ | |||
| /* > Several right hand side vectors b and solution vectors x can be */ | |||
| /* > handled in a single call; they are stored as the columns of the */ | |||
| /* > M-by-NRHS right hand side matrix B and the N-by-NRHS solution */ | |||
| /* > matrix X. */ | |||
| /* > */ | |||
| /* > The routine first computes a QR factorization with column pivoting: */ | |||
| /* > A * P = Q * [ R11 R12 ] */ | |||
| /* > [ 0 R22 ] */ | |||
| /* > with R11 defined as the largest leading submatrix whose estimated */ | |||
| /* > condition number is less than 1/RCOND. The order of R11, RANK, */ | |||
| /* > is the effective rank of A. */ | |||
| /* > */ | |||
| /* > Then, R22 is considered to be negligible, and R12 is annihilated */ | |||
| /* > by unitary transformations from the right, arriving at the */ | |||
| /* > complete orthogonal factorization: */ | |||
| /* > A * P = Q * [ T11 0 ] * Z */ | |||
| /* > [ 0 0 ] */ | |||
| /* > The minimum-norm solution is then */ | |||
| /* > X = P * Z**H [ inv(T11)*Q1**H*B ] */ | |||
| /* > [ 0 ] */ | |||
| /* > where Q1 consists of the first RANK columns of Q. */ | |||
| /* > */ | |||
| /* > This routine is basically identical to the original xGELSX except */ | |||
| /* > three differences: */ | |||
| /* > o The permutation of matrix B (the right hand side) is faster and */ | |||
| /* > more simple. */ | |||
| /* > o The call to the subroutine xGEQPF has been substituted by the */ | |||
| /* > the call to the subroutine xGEQP3. This subroutine is a Blas-3 */ | |||
| /* > version of the QR factorization with column pivoting. */ | |||
| /* > o Matrix B (the right hand side) is updated with Blas-3. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NRHS */ | |||
| /* > \verbatim */ | |||
| /* > NRHS is INTEGER */ | |||
| /* > The number of right hand sides, i.e., the number of */ | |||
| /* > columns of matrices B and X. NRHS >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, A has been overwritten by details of its */ | |||
| /* > complete orthogonal factorization. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] B */ | |||
| /* > \verbatim */ | |||
| /* > B is COMPLEX array, dimension (LDB,NRHS) */ | |||
| /* > On entry, the M-by-NRHS right hand side matrix B. */ | |||
| /* > On exit, the N-by-NRHS solution matrix X. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDB */ | |||
| /* > \verbatim */ | |||
| /* > LDB is INTEGER */ | |||
| /* > The leading dimension of the array B. LDB >= f2cmax(1,M,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] JPVT */ | |||
| /* > \verbatim */ | |||
| /* > JPVT is INTEGER array, dimension (N) */ | |||
| /* > On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted */ | |||
| /* > to the front of AP, otherwise column i is a free column. */ | |||
| /* > On exit, if JPVT(i) = k, then the i-th column of A*P */ | |||
| /* > was the k-th column of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] RCOND */ | |||
| /* > \verbatim */ | |||
| /* > RCOND is REAL */ | |||
| /* > RCOND is used to determine the effective rank of A, which */ | |||
| /* > is defined as the order of the largest leading triangular */ | |||
| /* > submatrix R11 in the QR factorization with pivoting of A, */ | |||
| /* > whose estimated condition number < 1/RCOND. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RANK */ | |||
| /* > \verbatim */ | |||
| /* > RANK is INTEGER */ | |||
| /* > The effective rank of A, i.e., the order of the submatrix */ | |||
| /* > R11. This is the same as the order of the submatrix T11 */ | |||
| /* > in the complete orthogonal factorization of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > The unblocked strategy requires that: */ | |||
| /* > LWORK >= MN + MAX( 2*MN, N+1, MN+NRHS ) */ | |||
| /* > where MN = f2cmin(M,N). */ | |||
| /* > The block algorithm requires that: */ | |||
| /* > LWORK >= MN + MAX( 2*MN, NB*(N+1), MN+MN*NB, MN+NB*NRHS ) */ | |||
| /* > where NB is an upper bound on the blocksize returned */ | |||
| /* > by ILAENV for the routines CGEQP3, CTZRZF, CTZRQF, CUNMQR, */ | |||
| /* > and CUNMRZ. */ | |||
| /* > */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates the optimal size of the WORK array, returns */ | |||
| /* > this value as the first entry of the WORK array, and no error */ | |||
| /* > message related to LWORK is issued by XERBLA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEsolve */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA \n */ | |||
| /* > E. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain \n */ | |||
| /* > G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain \n */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgelsy_(integer *m, integer *n, integer *nrhs, complex * | |||
| a, integer *lda, complex *b, integer *ldb, integer *jpvt, real *rcond, | |||
| integer *rank, complex *work, integer *lwork, real *rwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3, i__4; | |||
| real r__1, r__2; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| real anrm, bnrm, smin, smax; | |||
| integer i__, j, iascl, ibscl; | |||
| extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, | |||
| complex *, integer *); | |||
| integer ismin, ismax; | |||
| complex c1, c2; | |||
| extern /* Subroutine */ int ctrsm_(char *, char *, char *, char *, | |||
| integer *, integer *, complex *, complex *, integer *, complex *, | |||
| integer *), claic1_(integer *, | |||
| integer *, complex *, real *, complex *, complex *, real *, | |||
| complex *, complex *); | |||
| real wsize; | |||
| complex s1, s2; | |||
| extern /* Subroutine */ int cgeqp3_(integer *, integer *, complex *, | |||
| integer *, integer *, complex *, complex *, integer *, real *, | |||
| integer *); | |||
| integer nb; | |||
| extern /* Subroutine */ int slabad_(real *, real *); | |||
| extern real clange_(char *, integer *, integer *, complex *, integer *, | |||
| real *); | |||
| integer mn; | |||
| extern /* Subroutine */ int clascl_(char *, integer *, integer *, real *, | |||
| real *, integer *, integer *, complex *, integer *, integer *); | |||
| extern real slamch_(char *); | |||
| extern /* Subroutine */ int claset_(char *, integer *, integer *, complex | |||
| *, complex *, complex *, integer *), xerbla_(char *, | |||
| integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| real bignum; | |||
| integer nb1, nb2, nb3, nb4; | |||
| extern /* Subroutine */ int cunmqr_(char *, char *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, complex *, integer *, | |||
| complex *, integer *, integer *); | |||
| real sminpr, smaxpr, smlnum; | |||
| extern /* Subroutine */ int cunmrz_(char *, char *, integer *, integer *, | |||
| integer *, integer *, complex *, integer *, complex *, complex *, | |||
| integer *, complex *, integer *, integer *); | |||
| integer lwkopt; | |||
| logical lquery; | |||
| extern /* Subroutine */ int ctzrzf_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *, integer *); | |||
| /* -- LAPACK driver routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| b_dim1 = *ldb; | |||
| b_offset = 1 + b_dim1 * 1; | |||
| b -= b_offset; | |||
| --jpvt; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| mn = f2cmin(*m,*n); | |||
| ismin = mn + 1; | |||
| ismax = (mn << 1) + 1; | |||
| /* Test the input arguments. */ | |||
| *info = 0; | |||
| nb1 = ilaenv_(&c__1, "CGEQRF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| nb2 = ilaenv_(&c__1, "CGERQF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| nb3 = ilaenv_(&c__1, "CUNMQR", " ", m, n, nrhs, &c_n1, (ftnlen)6, (ftnlen) | |||
| 1); | |||
| nb4 = ilaenv_(&c__1, "CUNMRQ", " ", m, n, nrhs, &c_n1, (ftnlen)6, (ftnlen) | |||
| 1); | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(nb1,nb2), i__1 = f2cmax(i__1,nb3); | |||
| nb = f2cmax(i__1,nb4); | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = mn + (*n << 1) + nb * (*n + 1), i__1 = f2cmax(i__1,i__2), | |||
| i__2 = (mn << 1) + nb * *nrhs; | |||
| lwkopt = f2cmax(i__1,i__2); | |||
| q__1.r = (real) lwkopt, q__1.i = 0.f; | |||
| work[1].r = q__1.r, work[1].i = q__1.i; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*nrhs < 0) { | |||
| *info = -3; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -5; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(1,*m); | |||
| if (*ldb < f2cmax(i__1,*n)) { | |||
| *info = -7; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = mn << 1, i__2 = *n + 1, i__1 = f2cmax(i__1,i__2), i__2 = mn + | |||
| *nrhs; | |||
| if (*lwork < mn + f2cmax(i__1,i__2) && ! lquery) { | |||
| *info = -12; | |||
| } | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGELSY", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*nrhs) == 0) { | |||
| *rank = 0; | |||
| return 0; | |||
| } | |||
| /* Get machine parameters */ | |||
| smlnum = slamch_("S") / slamch_("P"); | |||
| bignum = 1.f / smlnum; | |||
| slabad_(&smlnum, &bignum); | |||
| /* Scale A, B if f2cmax entries outside range [SMLNUM,BIGNUM] */ | |||
| anrm = clange_("M", m, n, &a[a_offset], lda, &rwork[1]); | |||
| iascl = 0; | |||
| if (anrm > 0.f && anrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| clascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 1; | |||
| } else if (anrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| clascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &a[a_offset], lda, | |||
| info); | |||
| iascl = 2; | |||
| } else if (anrm == 0.f) { | |||
| /* Matrix all zero. Return zero solution. */ | |||
| i__1 = f2cmax(*m,*n); | |||
| claset_("F", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| *rank = 0; | |||
| goto L70; | |||
| } | |||
| bnrm = clange_("M", m, nrhs, &b[b_offset], ldb, &rwork[1]); | |||
| ibscl = 0; | |||
| if (bnrm > 0.f && bnrm < smlnum) { | |||
| /* Scale matrix norm up to SMLNUM */ | |||
| clascl_("G", &c__0, &c__0, &bnrm, &smlnum, m, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| ibscl = 1; | |||
| } else if (bnrm > bignum) { | |||
| /* Scale matrix norm down to BIGNUM */ | |||
| clascl_("G", &c__0, &c__0, &bnrm, &bignum, m, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| ibscl = 2; | |||
| } | |||
| /* Compute QR factorization with column pivoting of A: */ | |||
| /* A * P = Q * R */ | |||
| i__1 = *lwork - mn; | |||
| cgeqp3_(m, n, &a[a_offset], lda, &jpvt[1], &work[1], &work[mn + 1], &i__1, | |||
| &rwork[1], info); | |||
| i__1 = mn + 1; | |||
| wsize = mn + work[i__1].r; | |||
| /* complex workspace: MN+NB*(N+1). real workspace 2*N. */ | |||
| /* Details of Householder rotations stored in WORK(1:MN). */ | |||
| /* Determine RANK using incremental condition estimation */ | |||
| i__1 = ismin; | |||
| work[i__1].r = 1.f, work[i__1].i = 0.f; | |||
| i__1 = ismax; | |||
| work[i__1].r = 1.f, work[i__1].i = 0.f; | |||
| smax = c_abs(&a[a_dim1 + 1]); | |||
| smin = smax; | |||
| if (c_abs(&a[a_dim1 + 1]) == 0.f) { | |||
| *rank = 0; | |||
| i__1 = f2cmax(*m,*n); | |||
| claset_("F", &i__1, nrhs, &c_b1, &c_b1, &b[b_offset], ldb); | |||
| goto L70; | |||
| } else { | |||
| *rank = 1; | |||
| } | |||
| L10: | |||
| if (*rank < mn) { | |||
| i__ = *rank + 1; | |||
| claic1_(&c__2, rank, &work[ismin], &smin, &a[i__ * a_dim1 + 1], &a[ | |||
| i__ + i__ * a_dim1], &sminpr, &s1, &c1); | |||
| claic1_(&c__1, rank, &work[ismax], &smax, &a[i__ * a_dim1 + 1], &a[ | |||
| i__ + i__ * a_dim1], &smaxpr, &s2, &c2); | |||
| if (smaxpr * *rcond <= sminpr) { | |||
| i__1 = *rank; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| i__2 = ismin + i__ - 1; | |||
| i__3 = ismin + i__ - 1; | |||
| q__1.r = s1.r * work[i__3].r - s1.i * work[i__3].i, q__1.i = | |||
| s1.r * work[i__3].i + s1.i * work[i__3].r; | |||
| work[i__2].r = q__1.r, work[i__2].i = q__1.i; | |||
| i__2 = ismax + i__ - 1; | |||
| i__3 = ismax + i__ - 1; | |||
| q__1.r = s2.r * work[i__3].r - s2.i * work[i__3].i, q__1.i = | |||
| s2.r * work[i__3].i + s2.i * work[i__3].r; | |||
| work[i__2].r = q__1.r, work[i__2].i = q__1.i; | |||
| /* L20: */ | |||
| } | |||
| i__1 = ismin + *rank; | |||
| work[i__1].r = c1.r, work[i__1].i = c1.i; | |||
| i__1 = ismax + *rank; | |||
| work[i__1].r = c2.r, work[i__1].i = c2.i; | |||
| smin = sminpr; | |||
| smax = smaxpr; | |||
| ++(*rank); | |||
| goto L10; | |||
| } | |||
| } | |||
| /* complex workspace: 3*MN. */ | |||
| /* Logically partition R = [ R11 R12 ] */ | |||
| /* [ 0 R22 ] */ | |||
| /* where R11 = R(1:RANK,1:RANK) */ | |||
| /* [R11,R12] = [ T11, 0 ] * Y */ | |||
| if (*rank < *n) { | |||
| i__1 = *lwork - (mn << 1); | |||
| ctzrzf_(rank, n, &a[a_offset], lda, &work[mn + 1], &work[(mn << 1) + | |||
| 1], &i__1, info); | |||
| } | |||
| /* complex workspace: 2*MN. */ | |||
| /* Details of Householder rotations stored in WORK(MN+1:2*MN) */ | |||
| /* B(1:M,1:NRHS) := Q**H * B(1:M,1:NRHS) */ | |||
| i__1 = *lwork - (mn << 1); | |||
| cunmqr_("Left", "Conjugate transpose", m, nrhs, &mn, &a[a_offset], lda, & | |||
| work[1], &b[b_offset], ldb, &work[(mn << 1) + 1], &i__1, info); | |||
| /* Computing MAX */ | |||
| i__1 = (mn << 1) + 1; | |||
| r__1 = wsize, r__2 = (mn << 1) + work[i__1].r; | |||
| wsize = f2cmax(r__1,r__2); | |||
| /* complex workspace: 2*MN+NB*NRHS. */ | |||
| /* B(1:RANK,1:NRHS) := inv(T11) * B(1:RANK,1:NRHS) */ | |||
| ctrsm_("Left", "Upper", "No transpose", "Non-unit", rank, nrhs, &c_b2, &a[ | |||
| a_offset], lda, &b[b_offset], ldb); | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = *rank + 1; i__ <= i__2; ++i__) { | |||
| i__3 = i__ + j * b_dim1; | |||
| b[i__3].r = 0.f, b[i__3].i = 0.f; | |||
| /* L30: */ | |||
| } | |||
| /* L40: */ | |||
| } | |||
| /* B(1:N,1:NRHS) := Y**H * B(1:N,1:NRHS) */ | |||
| if (*rank < *n) { | |||
| i__1 = *n - *rank; | |||
| i__2 = *lwork - (mn << 1); | |||
| cunmrz_("Left", "Conjugate transpose", n, nrhs, rank, &i__1, &a[ | |||
| a_offset], lda, &work[mn + 1], &b[b_offset], ldb, &work[(mn << | |||
| 1) + 1], &i__2, info); | |||
| } | |||
| /* complex workspace: 2*MN+NRHS. */ | |||
| /* B(1:N,1:NRHS) := P * B(1:N,1:NRHS) */ | |||
| i__1 = *nrhs; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| i__2 = *n; | |||
| for (i__ = 1; i__ <= i__2; ++i__) { | |||
| i__3 = jpvt[i__]; | |||
| i__4 = i__ + j * b_dim1; | |||
| work[i__3].r = b[i__4].r, work[i__3].i = b[i__4].i; | |||
| /* L50: */ | |||
| } | |||
| ccopy_(n, &work[1], &c__1, &b[j * b_dim1 + 1], &c__1); | |||
| /* L60: */ | |||
| } | |||
| /* complex workspace: N. */ | |||
| /* Undo scaling */ | |||
| if (iascl == 1) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &smlnum, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| clascl_("U", &c__0, &c__0, &smlnum, &anrm, rank, rank, &a[a_offset], | |||
| lda, info); | |||
| } else if (iascl == 2) { | |||
| clascl_("G", &c__0, &c__0, &anrm, &bignum, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| clascl_("U", &c__0, &c__0, &bignum, &anrm, rank, rank, &a[a_offset], | |||
| lda, info); | |||
| } | |||
| if (ibscl == 1) { | |||
| clascl_("G", &c__0, &c__0, &smlnum, &bnrm, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| } else if (ibscl == 2) { | |||
| clascl_("G", &c__0, &c__0, &bignum, &bnrm, n, nrhs, &b[b_offset], ldb, | |||
| info); | |||
| } | |||
| L70: | |||
| q__1.r = (real) lwkopt, q__1.i = 0.f; | |||
| work[1].r = q__1.r, work[1].i = q__1.i; | |||
| return 0; | |||
| /* End of CGELSY */ | |||
| } /* cgelsy_ */ | |||
| @@ -0,0 +1,707 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b CGEMLQ */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEMLQ( SIDE, TRANS, M, N, K, A, LDA, T, */ | |||
| /* $ TSIZE, C, LDC, WORK, LWORK, INFO ) */ | |||
| /* CHARACTER SIDE, TRANS */ | |||
| /* INTEGER INFO, LDA, M, N, K, LDT, TSIZE, LWORK, LDC */ | |||
| /* COMPLEX A( LDA, * ), T( * ), C(LDC, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEMLQ overwrites the general real M-by-N matrix C with */ | |||
| /* > */ | |||
| /* > SIDE = 'L' SIDE = 'R' */ | |||
| /* > TRANS = 'N': Q * C C * Q */ | |||
| /* > TRANS = 'C': Q**H * C C * Q**H */ | |||
| /* > where Q is a complex unitary matrix defined as the product */ | |||
| /* > of blocked elementary reflectors computed by short wide */ | |||
| /* > LQ factorization (CGELQ) */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': apply Q or Q**T from the Left; */ | |||
| /* > = 'R': apply Q or Q**T from the Right. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > = 'N': No transpose, apply Q; */ | |||
| /* > = 'T': Transpose, apply Q**T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >=0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of elementary reflectors whose product defines */ | |||
| /* > the matrix Q. */ | |||
| /* > If SIDE = 'L', M >= K >= 0; */ | |||
| /* > if SIDE = 'R', N >= K >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension */ | |||
| /* > (LDA,M) if SIDE = 'L', */ | |||
| /* > (LDA,N) if SIDE = 'R' */ | |||
| /* > Part of the data structure to represent Q as returned by CGELQ. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,K). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX array, dimension (MAX(5,TSIZE)). */ | |||
| /* > Part of the data structure to represent Q as returned by CGELQ. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TSIZE */ | |||
| /* > \verbatim */ | |||
| /* > TSIZE is INTEGER */ | |||
| /* > The dimension of the array T. TSIZE >= 5. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the array C. LDC >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > (workspace) COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > If LWORK = -1, then a workspace query is assumed. The routine */ | |||
| /* > only calculates the size of the WORK array, returns this */ | |||
| /* > value as WORK(1), and no error message related to WORK */ | |||
| /* > is issued by XERBLA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \par Further Details */ | |||
| /* ==================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > These details are particular for this LAPACK implementation. Users should not */ | |||
| /* > take them for granted. These details may change in the future, and are not likely */ | |||
| /* > true for another LAPACK implementation. These details are relevant if one wants */ | |||
| /* > to try to understand the code. They are not part of the interface. */ | |||
| /* > */ | |||
| /* > In this version, */ | |||
| /* > */ | |||
| /* > T(2): row block size (MB) */ | |||
| /* > T(3): column block size (NB) */ | |||
| /* > T(6:TSIZE): data structure needed for Q, computed by */ | |||
| /* > CLASWQR or CGELQT */ | |||
| /* > */ | |||
| /* > Depending on the matrix dimensions M and N, and row and column */ | |||
| /* > block sizes MB and NB returned by ILAENV, CGELQ will use either */ | |||
| /* > CLASWLQ (if the matrix is wide-and-short) or CGELQT to compute */ | |||
| /* > the LQ factorization. */ | |||
| /* > This version of CGEMLQ will use either CLAMSWLQ or CGEMLQT to */ | |||
| /* > multiply matrix Q by another matrix. */ | |||
| /* > Further Details in CLAMSWLQ or CGEMLQT. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgemlq_(char *side, char *trans, integer *m, integer *n, | |||
| integer *k, complex *a, integer *lda, complex *t, integer *tsize, | |||
| complex *c__, integer *ldc, complex *work, integer *lwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, c_dim1, c_offset, i__1; | |||
| real r__1; | |||
| /* Local variables */ | |||
| logical left, tran; | |||
| extern /* Subroutine */ int clamswlq_(char *, char *, integer *, integer * | |||
| , integer *, integer *, integer *, complex *, integer *, complex * | |||
| , integer *, complex *, integer *, complex *, integer *, integer * | |||
| ); | |||
| extern logical lsame_(char *, char *); | |||
| logical right; | |||
| integer mb, nb, mn, lw, nblcks; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| logical notran, lquery; | |||
| extern /* Subroutine */ int cgemlqt_(char *, char *, integer *, integer *, | |||
| integer *, integer *, complex *, integer *, complex *, integer *, | |||
| complex *, integer *, complex *, integer *); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --t; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| lquery = *lwork == -1; | |||
| notran = lsame_(trans, "N"); | |||
| tran = lsame_(trans, "C"); | |||
| left = lsame_(side, "L"); | |||
| right = lsame_(side, "R"); | |||
| mb = (integer) t[2].r; | |||
| nb = (integer) t[3].r; | |||
| if (left) { | |||
| lw = *n * mb; | |||
| mn = *m; | |||
| } else { | |||
| lw = *m * mb; | |||
| mn = *n; | |||
| } | |||
| if (nb > *k && mn > *k) { | |||
| if ((mn - *k) % (nb - *k) == 0) { | |||
| nblcks = (mn - *k) / (nb - *k); | |||
| } else { | |||
| nblcks = (mn - *k) / (nb - *k) + 1; | |||
| } | |||
| } else { | |||
| nblcks = 1; | |||
| } | |||
| *info = 0; | |||
| if (! left && ! right) { | |||
| *info = -1; | |||
| } else if (! tran && ! notran) { | |||
| *info = -2; | |||
| } else if (*m < 0) { | |||
| *info = -3; | |||
| } else if (*n < 0) { | |||
| *info = -4; | |||
| } else if (*k < 0 || *k > mn) { | |||
| *info = -5; | |||
| } else if (*lda < f2cmax(1,*k)) { | |||
| *info = -7; | |||
| } else if (*tsize < 5) { | |||
| *info = -9; | |||
| } else if (*ldc < f2cmax(1,*m)) { | |||
| *info = -11; | |||
| } else if (*lwork < f2cmax(1,lw) && ! lquery) { | |||
| *info = -13; | |||
| } | |||
| if (*info == 0) { | |||
| r__1 = (real) lw; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEMLQ", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*k) == 0) { | |||
| return 0; | |||
| } | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(*m,*n); | |||
| if (left && *m <= *k || right && *n <= *k || nb <= *k || nb >= f2cmax(i__1,* | |||
| k)) { | |||
| cgemlqt_(side, trans, m, n, k, &mb, &a[a_offset], lda, &t[6], &mb, & | |||
| c__[c_offset], ldc, &work[1], info); | |||
| } else { | |||
| clamswlq_(side, trans, m, n, k, &mb, &nb, &a[a_offset], lda, &t[6], & | |||
| mb, &c__[c_offset], ldc, &work[1], lwork, info); | |||
| } | |||
| r__1 = (real) lw; | |||
| work[1].r = r__1, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEMLQ */ | |||
| } /* cgemlq_ */ | |||
| @@ -0,0 +1,708 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b CGEMLQT */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEMLQT( SIDE, TRANS, M, N, K, MB, V, LDV, T, LDT, */ | |||
| /* C, LDC, WORK, INFO ) */ | |||
| /* CHARACTER SIDE, TRANS */ | |||
| /* INTEGER INFO, K, LDV, LDC, M, N, MB, LDT */ | |||
| /* COMPLEX V( LDV, * ), C( LDC, * ), T( LDT, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEMLQT overwrites the general real M-by-N matrix C with */ | |||
| /* > */ | |||
| /* > SIDE = 'L' SIDE = 'R' */ | |||
| /* > TRANS = 'N': Q C C Q */ | |||
| /* > TRANS = 'C': Q**H C C Q**H */ | |||
| /* > */ | |||
| /* > where Q is a complex orthogonal matrix defined as the product of K */ | |||
| /* > elementary reflectors: */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(K) = I - V T V**H */ | |||
| /* > */ | |||
| /* > generated using the compact WY representation as returned by CGELQT. */ | |||
| /* > */ | |||
| /* > Q is of order M if SIDE = 'L' and of order N if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': apply Q or Q**H from the Left; */ | |||
| /* > = 'R': apply Q or Q**H from the Right. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > = 'N': No transpose, apply Q; */ | |||
| /* > = 'C': Transpose, apply Q**H. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix C. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of elementary reflectors whose product defines */ | |||
| /* > the matrix Q. */ | |||
| /* > If SIDE = 'L', M >= K >= 0; */ | |||
| /* > if SIDE = 'R', N >= K >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] MB */ | |||
| /* > \verbatim */ | |||
| /* > MB is INTEGER */ | |||
| /* > The block size used for the storage of T. K >= MB >= 1. */ | |||
| /* > This must be the same value of MB used to generate T */ | |||
| /* > in DGELQT. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX array, dimension */ | |||
| /* > (LDV,M) if SIDE = 'L', */ | |||
| /* > (LDV,N) if SIDE = 'R' */ | |||
| /* > The i-th row must contain the vector which defines the */ | |||
| /* > elementary reflector H(i), for i = 1,2,...,k, as returned by */ | |||
| /* > DGELQT in the first K rows of its array argument A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. LDV >= f2cmax(1,K). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX array, dimension (LDT,K) */ | |||
| /* > The upper triangular factors of the block reflectors */ | |||
| /* > as returned by DGELQT, stored as a MB-by-K matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= MB. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by Q C, Q**H C, C Q**H or C Q. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the array C. LDC >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array. The dimension of */ | |||
| /* > WORK is N*MB if SIDE = 'L', or M*MB if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2017 */ | |||
| /* > \ingroup doubleGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgemlqt_(char *side, char *trans, integer *m, integer *n, | |||
| integer *k, integer *mb, complex *v, integer *ldv, complex *t, | |||
| integer *ldt, complex *c__, integer *ldc, complex *work, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer v_dim1, v_offset, c_dim1, c_offset, t_dim1, t_offset, i__1, i__2, | |||
| i__3, i__4; | |||
| /* Local variables */ | |||
| logical left, tran; | |||
| integer i__; | |||
| extern logical lsame_(char *, char *); | |||
| logical right; | |||
| integer ib, kf; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *), xerbla_(char *, integer *, ftnlen); | |||
| logical notran; | |||
| integer ldwork; | |||
| /* -- LAPACK computational routine (version 3.8.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* November 2017 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| v_dim1 = *ldv; | |||
| v_offset = 1 + v_dim1 * 1; | |||
| v -= v_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| left = lsame_(side, "L"); | |||
| right = lsame_(side, "R"); | |||
| tran = lsame_(trans, "C"); | |||
| notran = lsame_(trans, "N"); | |||
| if (left) { | |||
| ldwork = f2cmax(1,*n); | |||
| } else if (right) { | |||
| ldwork = f2cmax(1,*m); | |||
| } | |||
| if (! left && ! right) { | |||
| *info = -1; | |||
| } else if (! tran && ! notran) { | |||
| *info = -2; | |||
| } else if (*m < 0) { | |||
| *info = -3; | |||
| } else if (*n < 0) { | |||
| *info = -4; | |||
| } else if (*k < 0) { | |||
| *info = -5; | |||
| } else if (*mb < 1 || *mb > *k && *k > 0) { | |||
| *info = -6; | |||
| } else if (*ldv < f2cmax(1,*k)) { | |||
| *info = -8; | |||
| } else if (*ldt < *mb) { | |||
| *info = -10; | |||
| } else if (*ldc < f2cmax(1,*m)) { | |||
| *info = -12; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEMLQT", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| if (*m == 0 || *n == 0 || *k == 0) { | |||
| return 0; | |||
| } | |||
| if (left && notran) { | |||
| i__1 = *k; | |||
| i__2 = *mb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = *mb, i__4 = *k - i__ + 1; | |||
| ib = f2cmin(i__3,i__4); | |||
| i__3 = *m - i__ + 1; | |||
| clarfb_("L", "C", "F", "R", &i__3, n, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ + c_dim1], ldc, | |||
| &work[1], &ldwork); | |||
| } | |||
| } else if (right && tran) { | |||
| i__2 = *k; | |||
| i__1 = *mb; | |||
| for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) { | |||
| /* Computing MIN */ | |||
| i__3 = *mb, i__4 = *k - i__ + 1; | |||
| ib = f2cmin(i__3,i__4); | |||
| i__3 = *n - i__ + 1; | |||
| clarfb_("R", "N", "F", "R", m, &i__3, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ * c_dim1 + 1], | |||
| ldc, &work[1], &ldwork); | |||
| } | |||
| } else if (left && tran) { | |||
| kf = (*k - 1) / *mb * *mb + 1; | |||
| i__1 = -(*mb); | |||
| for (i__ = kf; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) { | |||
| /* Computing MIN */ | |||
| i__2 = *mb, i__3 = *k - i__ + 1; | |||
| ib = f2cmin(i__2,i__3); | |||
| i__2 = *m - i__ + 1; | |||
| clarfb_("L", "N", "F", "R", &i__2, n, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ + c_dim1], ldc, | |||
| &work[1], &ldwork); | |||
| } | |||
| } else if (right && notran) { | |||
| kf = (*k - 1) / *mb * *mb + 1; | |||
| i__1 = -(*mb); | |||
| for (i__ = kf; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) { | |||
| /* Computing MIN */ | |||
| i__2 = *mb, i__3 = *k - i__ + 1; | |||
| ib = f2cmin(i__2,i__3); | |||
| i__2 = *n - i__ + 1; | |||
| clarfb_("R", "C", "F", "R", m, &i__2, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ * c_dim1 + 1], | |||
| ldc, &work[1], &ldwork); | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGEMLQT */ | |||
| } /* cgemlqt_ */ | |||
| @@ -0,0 +1,706 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b CGEMQR */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEMQR( SIDE, TRANS, M, N, K, A, LDA, T, */ | |||
| /* $ TSIZE, C, LDC, WORK, LWORK, INFO ) */ | |||
| /* CHARACTER SIDE, TRANS */ | |||
| /* INTEGER INFO, LDA, M, N, K, LDT, TSIZE, LWORK, LDC */ | |||
| /* COMPLEX A( LDA, * ), T( * ), C( LDC, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEMQR overwrites the general real M-by-N matrix C with */ | |||
| /* > */ | |||
| /* > SIDE = 'L' SIDE = 'R' */ | |||
| /* > TRANS = 'N': Q * C C * Q */ | |||
| /* > TRANS = 'T': Q**H * C C * Q**H */ | |||
| /* > */ | |||
| /* > where Q is a complex unitary matrix defined as the product */ | |||
| /* > of blocked elementary reflectors computed by tall skinny */ | |||
| /* > QR factorization (CGEQR) */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': apply Q or Q**T from the Left; */ | |||
| /* > = 'R': apply Q or Q**T from the Right. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > = 'N': No transpose, apply Q; */ | |||
| /* > = 'T': Transpose, apply Q**T. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >=0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of elementary reflectors whose product defines */ | |||
| /* > the matrix Q. */ | |||
| /* > If SIDE = 'L', M >= K >= 0; */ | |||
| /* > if SIDE = 'R', N >= K >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,K) */ | |||
| /* > Part of the data structure to represent Q as returned by CGEQR. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. */ | |||
| /* > If SIDE = 'L', LDA >= f2cmax(1,M); */ | |||
| /* > if SIDE = 'R', LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX array, dimension (MAX(5,TSIZE)). */ | |||
| /* > Part of the data structure to represent Q as returned by CGEQR. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TSIZE */ | |||
| /* > \verbatim */ | |||
| /* > TSIZE is INTEGER */ | |||
| /* > The dimension of the array T. TSIZE >= 5. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the array C. LDC >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > (workspace) COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > If LWORK = -1, then a workspace query is assumed. The routine */ | |||
| /* > only calculates the size of the WORK array, returns this */ | |||
| /* > value as WORK(1), and no error message related to WORK */ | |||
| /* > is issued by XERBLA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \par Further Details */ | |||
| /* ==================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > These details are particular for this LAPACK implementation. Users should not */ | |||
| /* > take them for granted. These details may change in the future, and are not likely */ | |||
| /* > true for another LAPACK implementation. These details are relevant if one wants */ | |||
| /* > to try to understand the code. They are not part of the interface. */ | |||
| /* > */ | |||
| /* > In this version, */ | |||
| /* > */ | |||
| /* > T(2): row block size (MB) */ | |||
| /* > T(3): column block size (NB) */ | |||
| /* > T(6:TSIZE): data structure needed for Q, computed by */ | |||
| /* > CLATSQR or CGEQRT */ | |||
| /* > */ | |||
| /* > Depending on the matrix dimensions M and N, and row and column */ | |||
| /* > block sizes MB and NB returned by ILAENV, CGEQR will use either */ | |||
| /* > CLATSQR (if the matrix is tall-and-skinny) or CGEQRT to compute */ | |||
| /* > the QR factorization. */ | |||
| /* > This version of CGEMQR will use either CLAMTSQR or CGEMQRT to */ | |||
| /* > multiply matrix Q by another matrix. */ | |||
| /* > Further Details in CLAMTSQR or CGEMQRT. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgemqr_(char *side, char *trans, integer *m, integer *n, | |||
| integer *k, complex *a, integer *lda, complex *t, integer *tsize, | |||
| complex *c__, integer *ldc, complex *work, integer *lwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, c_dim1, c_offset, i__1; | |||
| /* Local variables */ | |||
| logical left, tran; | |||
| extern /* Subroutine */ int clamtsqr_(char *, char *, integer *, integer * | |||
| , integer *, integer *, integer *, complex *, integer *, complex * | |||
| , integer *, complex *, integer *, complex *, integer *, integer * | |||
| ); | |||
| extern logical lsame_(char *, char *); | |||
| logical right; | |||
| integer mb, nb, mn, lw, nblcks; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| logical notran, lquery; | |||
| extern /* Subroutine */ int cgemqrt_(char *, char *, integer *, integer *, | |||
| integer *, integer *, complex *, integer *, complex *, integer *, | |||
| complex *, integer *, complex *, integer *); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --t; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| lquery = *lwork == -1; | |||
| notran = lsame_(trans, "N"); | |||
| tran = lsame_(trans, "C"); | |||
| left = lsame_(side, "L"); | |||
| right = lsame_(side, "R"); | |||
| mb = (integer) t[2].r; | |||
| nb = (integer) t[3].r; | |||
| if (left) { | |||
| lw = *n * nb; | |||
| mn = *m; | |||
| } else { | |||
| lw = mb * nb; | |||
| mn = *n; | |||
| } | |||
| if (mb > *k && mn > *k) { | |||
| if ((mn - *k) % (mb - *k) == 0) { | |||
| nblcks = (mn - *k) / (mb - *k); | |||
| } else { | |||
| nblcks = (mn - *k) / (mb - *k) + 1; | |||
| } | |||
| } else { | |||
| nblcks = 1; | |||
| } | |||
| *info = 0; | |||
| if (! left && ! right) { | |||
| *info = -1; | |||
| } else if (! tran && ! notran) { | |||
| *info = -2; | |||
| } else if (*m < 0) { | |||
| *info = -3; | |||
| } else if (*n < 0) { | |||
| *info = -4; | |||
| } else if (*k < 0 || *k > mn) { | |||
| *info = -5; | |||
| } else if (*lda < f2cmax(1,mn)) { | |||
| *info = -7; | |||
| } else if (*tsize < 5) { | |||
| *info = -9; | |||
| } else if (*ldc < f2cmax(1,*m)) { | |||
| *info = -11; | |||
| } else if (*lwork < f2cmax(1,lw) && ! lquery) { | |||
| *info = -13; | |||
| } | |||
| if (*info == 0) { | |||
| work[1].r = (real) lw, work[1].i = 0.f; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEMQR", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| /* Computing MIN */ | |||
| i__1 = f2cmin(*m,*n); | |||
| if (f2cmin(i__1,*k) == 0) { | |||
| return 0; | |||
| } | |||
| /* Computing MAX */ | |||
| i__1 = f2cmax(*m,*n); | |||
| if (left && *m <= *k || right && *n <= *k || mb <= *k || mb >= f2cmax(i__1,* | |||
| k)) { | |||
| cgemqrt_(side, trans, m, n, k, &nb, &a[a_offset], lda, &t[6], &nb, & | |||
| c__[c_offset], ldc, &work[1], info); | |||
| } else { | |||
| clamtsqr_(side, trans, m, n, k, &mb, &nb, &a[a_offset], lda, &t[6], & | |||
| nb, &c__[c_offset], ldc, &work[1], lwork, info); | |||
| } | |||
| work[1].r = (real) lw, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEMQR */ | |||
| } /* cgemqr_ */ | |||
| @@ -0,0 +1,728 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* > \brief \b CGEMQRT */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEMQRT + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgemqrt | |||
| .f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgemqrt | |||
| .f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgemqrt | |||
| .f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEMQRT( SIDE, TRANS, M, N, K, NB, V, LDV, T, LDT, */ | |||
| /* C, LDC, WORK, INFO ) */ | |||
| /* CHARACTER SIDE, TRANS */ | |||
| /* INTEGER INFO, K, LDV, LDC, M, N, NB, LDT */ | |||
| /* COMPLEX V( LDV, * ), C( LDC, * ), T( LDT, * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEMQRT overwrites the general complex M-by-N matrix C with */ | |||
| /* > */ | |||
| /* > SIDE = 'L' SIDE = 'R' */ | |||
| /* > TRANS = 'N': Q C C Q */ | |||
| /* > TRANS = 'C': Q**H C C Q**H */ | |||
| /* > */ | |||
| /* > where Q is a complex orthogonal matrix defined as the product of K */ | |||
| /* > elementary reflectors: */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(K) = I - V T V**H */ | |||
| /* > */ | |||
| /* > generated using the compact WY representation as returned by CGEQRT. */ | |||
| /* > */ | |||
| /* > Q is of order M if SIDE = 'L' and of order N if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] SIDE */ | |||
| /* > \verbatim */ | |||
| /* > SIDE is CHARACTER*1 */ | |||
| /* > = 'L': apply Q or Q**H from the Left; */ | |||
| /* > = 'R': apply Q or Q**H from the Right. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TRANS */ | |||
| /* > \verbatim */ | |||
| /* > TRANS is CHARACTER*1 */ | |||
| /* > = 'N': No transpose, apply Q; */ | |||
| /* > = 'C': Transpose, apply Q**H. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix C. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix C. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] K */ | |||
| /* > \verbatim */ | |||
| /* > K is INTEGER */ | |||
| /* > The number of elementary reflectors whose product defines */ | |||
| /* > the matrix Q. */ | |||
| /* > If SIDE = 'L', M >= K >= 0; */ | |||
| /* > if SIDE = 'R', N >= K >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] NB */ | |||
| /* > \verbatim */ | |||
| /* > NB is INTEGER */ | |||
| /* > The block size used for the storage of T. K >= NB >= 1. */ | |||
| /* > This must be the same value of NB used to generate T */ | |||
| /* > in CGEQRT. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] V */ | |||
| /* > \verbatim */ | |||
| /* > V is COMPLEX array, dimension (LDV,K) */ | |||
| /* > The i-th column must contain the vector which defines the */ | |||
| /* > elementary reflector H(i), for i = 1,2,...,k, as returned by */ | |||
| /* > CGEQRT in the first K columns of its array argument A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDV */ | |||
| /* > \verbatim */ | |||
| /* > LDV is INTEGER */ | |||
| /* > The leading dimension of the array V. */ | |||
| /* > If SIDE = 'L', LDA >= f2cmax(1,M); */ | |||
| /* > if SIDE = 'R', LDA >= f2cmax(1,N). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX array, dimension (LDT,K) */ | |||
| /* > The upper triangular factors of the block reflectors */ | |||
| /* > as returned by CGEQRT, stored as a NB-by-N matrix. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDT */ | |||
| /* > \verbatim */ | |||
| /* > LDT is INTEGER */ | |||
| /* > The leading dimension of the array T. LDT >= NB. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] C */ | |||
| /* > \verbatim */ | |||
| /* > C is COMPLEX array, dimension (LDC,N) */ | |||
| /* > On entry, the M-by-N matrix C. */ | |||
| /* > On exit, C is overwritten by Q C, Q**H C, C Q**H or C Q. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDC */ | |||
| /* > \verbatim */ | |||
| /* > LDC is INTEGER */ | |||
| /* > The leading dimension of the array C. LDC >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array. The dimension of WORK is */ | |||
| /* > N*NB if SIDE = 'L', or M*NB if SIDE = 'R'. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgemqrt_(char *side, char *trans, integer *m, integer *n, | |||
| integer *k, integer *nb, complex *v, integer *ldv, complex *t, | |||
| integer *ldt, complex *c__, integer *ldc, complex *work, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer v_dim1, v_offset, c_dim1, c_offset, t_dim1, t_offset, i__1, i__2, | |||
| i__3, i__4; | |||
| /* Local variables */ | |||
| logical left, tran; | |||
| integer i__, q; | |||
| extern logical lsame_(char *, char *); | |||
| logical right; | |||
| integer ib, kf; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *), xerbla_(char *, integer *, ftnlen); | |||
| logical notran; | |||
| integer ldwork; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Parameter adjustments */ | |||
| v_dim1 = *ldv; | |||
| v_offset = 1 + v_dim1 * 1; | |||
| v -= v_offset; | |||
| t_dim1 = *ldt; | |||
| t_offset = 1 + t_dim1 * 1; | |||
| t -= t_offset; | |||
| c_dim1 = *ldc; | |||
| c_offset = 1 + c_dim1 * 1; | |||
| c__ -= c_offset; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| left = lsame_(side, "L"); | |||
| right = lsame_(side, "R"); | |||
| tran = lsame_(trans, "C"); | |||
| notran = lsame_(trans, "N"); | |||
| if (left) { | |||
| ldwork = f2cmax(1,*n); | |||
| q = *m; | |||
| } else if (right) { | |||
| ldwork = f2cmax(1,*m); | |||
| q = *n; | |||
| } | |||
| if (! left && ! right) { | |||
| *info = -1; | |||
| } else if (! tran && ! notran) { | |||
| *info = -2; | |||
| } else if (*m < 0) { | |||
| *info = -3; | |||
| } else if (*n < 0) { | |||
| *info = -4; | |||
| } else if (*k < 0 || *k > q) { | |||
| *info = -5; | |||
| } else if (*nb < 1 || *nb > *k && *k > 0) { | |||
| *info = -6; | |||
| } else if (*ldv < f2cmax(1,q)) { | |||
| *info = -8; | |||
| } else if (*ldt < *nb) { | |||
| *info = -10; | |||
| } else if (*ldc < f2cmax(1,*m)) { | |||
| *info = -12; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEMQRT", &i__1, (ftnlen)7); | |||
| return 0; | |||
| } | |||
| if (*m == 0 || *n == 0 || *k == 0) { | |||
| return 0; | |||
| } | |||
| if (left && tran) { | |||
| i__1 = *k; | |||
| i__2 = *nb; | |||
| for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = *nb, i__4 = *k - i__ + 1; | |||
| ib = f2cmin(i__3,i__4); | |||
| i__3 = *m - i__ + 1; | |||
| clarfb_("L", "C", "F", "C", &i__3, n, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ + c_dim1], ldc, | |||
| &work[1], &ldwork); | |||
| } | |||
| } else if (right && notran) { | |||
| i__2 = *k; | |||
| i__1 = *nb; | |||
| for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) { | |||
| /* Computing MIN */ | |||
| i__3 = *nb, i__4 = *k - i__ + 1; | |||
| ib = f2cmin(i__3,i__4); | |||
| i__3 = *n - i__ + 1; | |||
| clarfb_("R", "N", "F", "C", m, &i__3, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ * c_dim1 + 1], | |||
| ldc, &work[1], &ldwork); | |||
| } | |||
| } else if (left && notran) { | |||
| kf = (*k - 1) / *nb * *nb + 1; | |||
| i__1 = -(*nb); | |||
| for (i__ = kf; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) { | |||
| /* Computing MIN */ | |||
| i__2 = *nb, i__3 = *k - i__ + 1; | |||
| ib = f2cmin(i__2,i__3); | |||
| i__2 = *m - i__ + 1; | |||
| clarfb_("L", "N", "F", "C", &i__2, n, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ + c_dim1], ldc, | |||
| &work[1], &ldwork); | |||
| } | |||
| } else if (right && tran) { | |||
| kf = (*k - 1) / *nb * *nb + 1; | |||
| i__1 = -(*nb); | |||
| for (i__ = kf; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) { | |||
| /* Computing MIN */ | |||
| i__2 = *nb, i__3 = *k - i__ + 1; | |||
| ib = f2cmin(i__2,i__3); | |||
| i__2 = *n - i__ + 1; | |||
| clarfb_("R", "C", "F", "C", m, &i__2, &ib, &v[i__ + i__ * v_dim1], | |||
| ldv, &t[i__ * t_dim1 + 1], ldt, &c__[i__ * c_dim1 + 1], | |||
| ldc, &work[1], &ldwork); | |||
| } | |||
| } | |||
| return 0; | |||
| /* End of CGEMQRT */ | |||
| } /* cgemqrt_ */ | |||
| @@ -0,0 +1,617 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGEQL2 computes the QL factorization of a general rectangular matrix using an unblocked algorit | |||
| hm. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQL2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeql2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeql2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeql2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQL2( M, N, A, LDA, TAU, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQL2 computes a QL factorization of a complex m by n matrix A: */ | |||
| /* > A = Q * L. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the m by n matrix A. */ | |||
| /* > On exit, if m >= n, the lower triangle of the subarray */ | |||
| /* > A(m-n+1:m,1:n) contains the n by n lower triangular matrix L; */ | |||
| /* > if m <= n, the elements on and below the (n-m)-th */ | |||
| /* > superdiagonal contain the m by n lower trapezoidal matrix L; */ | |||
| /* > the remaining elements, with the array TAU, represent the */ | |||
| /* > unitary matrix Q as a product of elementary reflectors */ | |||
| /* > (see Further Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(k) . . . H(2) H(1), where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a complex vector with */ | |||
| /* > v(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in */ | |||
| /* > A(1:m-k+i-1,n-k+i), and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeql2_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| complex alpha; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| clarfg_(integer *, complex *, complex *, integer *, complex *), | |||
| xerbla_(char *, integer *, ftnlen); | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQL2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| k = f2cmin(*m,*n); | |||
| for (i__ = k; i__ >= 1; --i__) { | |||
| /* Generate elementary reflector H(i) to annihilate */ | |||
| /* A(1:m-k+i-1,n-k+i) */ | |||
| i__1 = *m - k + i__ + (*n - k + i__) * a_dim1; | |||
| alpha.r = a[i__1].r, alpha.i = a[i__1].i; | |||
| i__1 = *m - k + i__; | |||
| clarfg_(&i__1, &alpha, &a[(*n - k + i__) * a_dim1 + 1], &c__1, &tau[ | |||
| i__]); | |||
| /* Apply H(i)**H to A(1:m-k+i,1:n-k+i-1) from the left */ | |||
| i__1 = *m - k + i__ + (*n - k + i__) * a_dim1; | |||
| a[i__1].r = 1.f, a[i__1].i = 0.f; | |||
| i__1 = *m - k + i__; | |||
| i__2 = *n - k + i__ - 1; | |||
| r_cnjg(&q__1, &tau[i__]); | |||
| clarf_("Left", &i__1, &i__2, &a[(*n - k + i__) * a_dim1 + 1], &c__1, & | |||
| q__1, &a[a_offset], lda, &work[1]); | |||
| i__1 = *m - k + i__ + (*n - k + i__) * a_dim1; | |||
| a[i__1].r = alpha.r, a[i__1].i = alpha.i; | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of CGEQL2 */ | |||
| } /* cgeql2_ */ | |||
| @@ -0,0 +1,731 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGEQLF */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQLF + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqlf. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqlf. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqlf. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQLF( M, N, A, LDA, TAU, WORK, LWORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, LWORK, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQLF computes a QL factorization of a complex M-by-N matrix A: */ | |||
| /* > A = Q * L. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, */ | |||
| /* > if m >= n, the lower triangle of the subarray */ | |||
| /* > A(m-n+1:m,1:n) contains the N-by-N lower triangular matrix L; */ | |||
| /* > if m <= n, the elements on and below the (n-m)-th */ | |||
| /* > superdiagonal contain the M-by-N lower trapezoidal matrix L; */ | |||
| /* > the remaining elements, with the array TAU, represent the */ | |||
| /* > unitary matrix Q as a product of elementary reflectors */ | |||
| /* > (see Further Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= f2cmax(1,N). */ | |||
| /* > For optimum performance LWORK >= N*NB, where NB is */ | |||
| /* > the optimal blocksize. */ | |||
| /* > */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates the optimal size of the WORK array, returns */ | |||
| /* > this value as the first entry of the WORK array, and no error */ | |||
| /* > message related to LWORK is issued by XERBLA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(k) . . . H(2) H(1), where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a complex vector with */ | |||
| /* > v(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in */ | |||
| /* > A(1:m-k+i-1,n-k+i), and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqlf_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *lwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3, i__4; | |||
| /* Local variables */ | |||
| integer i__, k, nbmin, iinfo; | |||
| extern /* Subroutine */ int cgeql2_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *); | |||
| integer ib, nb, ki, kk; | |||
| extern /* Subroutine */ int clarfb_(char *, char *, char *, char *, | |||
| integer *, integer *, integer *, complex *, integer *, complex *, | |||
| integer *, complex *, integer *, complex *, integer *); | |||
| integer mu, nu, nx; | |||
| extern /* Subroutine */ int clarft_(char *, char *, integer *, integer *, | |||
| complex *, integer *, complex *, complex *, integer *), xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| integer ldwork, lwkopt; | |||
| logical lquery; | |||
| integer iws; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info == 0) { | |||
| k = f2cmin(*m,*n); | |||
| if (k == 0) { | |||
| lwkopt = 1; | |||
| } else { | |||
| nb = ilaenv_(&c__1, "CGEQLF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, | |||
| (ftnlen)1); | |||
| lwkopt = *n * nb; | |||
| } | |||
| work[1].r = (real) lwkopt, work[1].i = 0.f; | |||
| if (*lwork < f2cmax(1,*n) && ! lquery) { | |||
| *info = -7; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQLF", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (k == 0) { | |||
| return 0; | |||
| } | |||
| nbmin = 2; | |||
| nx = 1; | |||
| iws = *n; | |||
| if (nb > 1 && nb < k) { | |||
| /* Determine when to cross over from blocked to unblocked code. */ | |||
| /* Computing MAX */ | |||
| i__1 = 0, i__2 = ilaenv_(&c__3, "CGEQLF", " ", m, n, &c_n1, &c_n1, ( | |||
| ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| if (nx < k) { | |||
| /* Determine if workspace is large enough for blocked code. */ | |||
| ldwork = *n; | |||
| iws = ldwork * nb; | |||
| if (*lwork < iws) { | |||
| /* Not enough workspace to use optimal NB: reduce NB and */ | |||
| /* determine the minimum value of NB. */ | |||
| nb = *lwork / ldwork; | |||
| /* Computing MAX */ | |||
| i__1 = 2, i__2 = ilaenv_(&c__2, "CGEQLF", " ", m, n, &c_n1, & | |||
| c_n1, (ftnlen)6, (ftnlen)1); | |||
| nbmin = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| } | |||
| if (nb >= nbmin && nb < k && nx < k) { | |||
| /* Use blocked code initially. */ | |||
| /* The last kk columns are handled by the block method. */ | |||
| ki = (k - nx - 1) / nb * nb; | |||
| /* Computing MIN */ | |||
| i__1 = k, i__2 = ki + nb; | |||
| kk = f2cmin(i__1,i__2); | |||
| i__1 = k - kk + 1; | |||
| i__2 = -nb; | |||
| for (i__ = k - kk + ki + 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ | |||
| += i__2) { | |||
| /* Computing MIN */ | |||
| i__3 = k - i__ + 1; | |||
| ib = f2cmin(i__3,nb); | |||
| /* Compute the QL factorization of the current block */ | |||
| /* A(1:m-k+i+ib-1,n-k+i:n-k+i+ib-1) */ | |||
| i__3 = *m - k + i__ + ib - 1; | |||
| cgeql2_(&i__3, &ib, &a[(*n - k + i__) * a_dim1 + 1], lda, &tau[ | |||
| i__], &work[1], &iinfo); | |||
| if (*n - k + i__ > 1) { | |||
| /* Form the triangular factor of the block reflector */ | |||
| /* H = H(i+ib-1) . . . H(i+1) H(i) */ | |||
| i__3 = *m - k + i__ + ib - 1; | |||
| clarft_("Backward", "Columnwise", &i__3, &ib, &a[(*n - k + | |||
| i__) * a_dim1 + 1], lda, &tau[i__], &work[1], &ldwork); | |||
| /* Apply H**H to A(1:m-k+i+ib-1,1:n-k+i-1) from the left */ | |||
| i__3 = *m - k + i__ + ib - 1; | |||
| i__4 = *n - k + i__ - 1; | |||
| clarfb_("Left", "Conjugate transpose", "Backward", "Columnwi" | |||
| "se", &i__3, &i__4, &ib, &a[(*n - k + i__) * a_dim1 + | |||
| 1], lda, &work[1], &ldwork, &a[a_offset], lda, &work[ | |||
| ib + 1], &ldwork); | |||
| } | |||
| /* L10: */ | |||
| } | |||
| mu = *m - k + i__ + nb - 1; | |||
| nu = *n - k + i__ + nb - 1; | |||
| } else { | |||
| mu = *m; | |||
| nu = *n; | |||
| } | |||
| /* Use unblocked code to factor the last or only block */ | |||
| if (mu > 0 && nu > 0) { | |||
| cgeql2_(&mu, &nu, &a[a_offset], lda, &tau[1], &work[1], &iinfo); | |||
| } | |||
| work[1].r = (real) iws, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEQLF */ | |||
| } /* cgeqlf_ */ | |||
| @@ -0,0 +1,826 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__3 = 3; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGEQP3 */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQP3 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqp3. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqp3. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqp3. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQP3( M, N, A, LDA, JPVT, TAU, WORK, LWORK, RWORK, */ | |||
| /* INFO ) */ | |||
| /* INTEGER INFO, LDA, LWORK, M, N */ | |||
| /* INTEGER JPVT( * ) */ | |||
| /* REAL RWORK( * ) */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQP3 computes a QR factorization with column pivoting of a */ | |||
| /* > matrix A: A*P = Q*R using Level 3 BLAS. */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the upper triangle of the array contains the */ | |||
| /* > f2cmin(M,N)-by-N upper trapezoidal matrix R; the elements below */ | |||
| /* > the diagonal, together with the array TAU, represent the */ | |||
| /* > unitary matrix Q as a product of f2cmin(M,N) elementary */ | |||
| /* > reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] JPVT */ | |||
| /* > \verbatim */ | |||
| /* > JPVT is INTEGER array, dimension (N) */ | |||
| /* > On entry, if JPVT(J).ne.0, the J-th column of A is permuted */ | |||
| /* > to the front of A*P (a leading column); if JPVT(J)=0, */ | |||
| /* > the J-th column of A is a free column. */ | |||
| /* > On exit, if JPVT(J)=K, then the J-th column of A*P was the */ | |||
| /* > the K-th column of A. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO=0, WORK(1) returns the optimal LWORK. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. LWORK >= N+1. */ | |||
| /* > For optimal performance LWORK >= ( N+1 )*NB, where NB */ | |||
| /* > is the optimal blocksize. */ | |||
| /* > */ | |||
| /* > If LWORK = -1, then a workspace query is assumed; the routine */ | |||
| /* > only calculates the optimal size of the WORK array, returns */ | |||
| /* > this value as the first entry of the WORK array, and no error */ | |||
| /* > message related to LWORK is issued by XERBLA. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] RWORK */ | |||
| /* > \verbatim */ | |||
| /* > RWORK is REAL array, dimension (2*N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit. */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date December 2016 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(k), where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a real/complex vector */ | |||
| /* > with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in */ | |||
| /* > A(i+1:m,i), and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > \par Contributors: */ | |||
| /* ================== */ | |||
| /* > */ | |||
| /* > G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain */ | |||
| /* > X. Sun, Computer Science Dept., Duke University, USA */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqp3_(integer *m, integer *n, complex *a, integer *lda, | |||
| integer *jpvt, complex *tau, complex *work, integer *lwork, real * | |||
| rwork, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer nfxd, j, nbmin; | |||
| extern /* Subroutine */ int cswap_(integer *, complex *, integer *, | |||
| complex *, integer *); | |||
| integer minmn, minws; | |||
| extern /* Subroutine */ int claqp2_(integer *, integer *, integer *, | |||
| complex *, integer *, integer *, complex *, real *, real *, | |||
| complex *); | |||
| extern real scnrm2_(integer *, complex *, integer *); | |||
| integer jb, na, nb, sm, sn, nx; | |||
| extern /* Subroutine */ int cgeqrf_(integer *, integer *, complex *, | |||
| integer *, complex *, complex *, integer *, integer *), xerbla_( | |||
| char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| extern /* Subroutine */ int claqps_(integer *, integer *, integer *, | |||
| integer *, integer *, complex *, integer *, integer *, complex *, | |||
| real *, real *, complex *, complex *, integer *); | |||
| integer topbmn, sminmn; | |||
| extern /* Subroutine */ int cunmqr_(char *, char *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, complex *, integer *, | |||
| complex *, integer *, integer *); | |||
| integer lwkopt; | |||
| logical lquery; | |||
| integer fjb, iws; | |||
| /* -- LAPACK computational routine (version 3.7.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* December 2016 */ | |||
| /* ===================================================================== */ | |||
| /* Test input arguments */ | |||
| /* ==================== */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --jpvt; | |||
| --tau; | |||
| --work; | |||
| --rwork; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *lwork == -1; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info == 0) { | |||
| minmn = f2cmin(*m,*n); | |||
| if (minmn == 0) { | |||
| iws = 1; | |||
| lwkopt = 1; | |||
| } else { | |||
| iws = *n + 1; | |||
| nb = ilaenv_(&c__1, "CGEQRF", " ", m, n, &c_n1, &c_n1, (ftnlen)6, | |||
| (ftnlen)1); | |||
| lwkopt = (*n + 1) * nb; | |||
| } | |||
| q__1.r = (real) lwkopt, q__1.i = 0.f; | |||
| work[1].r = q__1.r, work[1].i = q__1.i; | |||
| if (*lwork < iws && ! lquery) { | |||
| *info = -8; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQP3", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Move initial columns up front. */ | |||
| nfxd = 1; | |||
| i__1 = *n; | |||
| for (j = 1; j <= i__1; ++j) { | |||
| if (jpvt[j] != 0) { | |||
| if (j != nfxd) { | |||
| cswap_(m, &a[j * a_dim1 + 1], &c__1, &a[nfxd * a_dim1 + 1], & | |||
| c__1); | |||
| jpvt[j] = jpvt[nfxd]; | |||
| jpvt[nfxd] = j; | |||
| } else { | |||
| jpvt[j] = j; | |||
| } | |||
| ++nfxd; | |||
| } else { | |||
| jpvt[j] = j; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| --nfxd; | |||
| /* Factorize fixed columns */ | |||
| /* ======================= */ | |||
| /* Compute the QR factorization of fixed columns and update */ | |||
| /* remaining columns. */ | |||
| if (nfxd > 0) { | |||
| na = f2cmin(*m,nfxd); | |||
| /* CC CALL CGEQR2( M, NA, A, LDA, TAU, WORK, INFO ) */ | |||
| cgeqrf_(m, &na, &a[a_offset], lda, &tau[1], &work[1], lwork, info); | |||
| /* Computing MAX */ | |||
| i__1 = iws, i__2 = (integer) work[1].r; | |||
| iws = f2cmax(i__1,i__2); | |||
| if (na < *n) { | |||
| /* CC CALL CUNM2R( 'Left', 'Conjugate Transpose', M, N-NA, */ | |||
| /* CC $ NA, A, LDA, TAU, A( 1, NA+1 ), LDA, WORK, */ | |||
| /* CC $ INFO ) */ | |||
| i__1 = *n - na; | |||
| cunmqr_("Left", "Conjugate Transpose", m, &i__1, &na, &a[a_offset] | |||
| , lda, &tau[1], &a[(na + 1) * a_dim1 + 1], lda, &work[1], | |||
| lwork, info); | |||
| /* Computing MAX */ | |||
| i__1 = iws, i__2 = (integer) work[1].r; | |||
| iws = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| /* Factorize free columns */ | |||
| /* ====================== */ | |||
| if (nfxd < minmn) { | |||
| sm = *m - nfxd; | |||
| sn = *n - nfxd; | |||
| sminmn = minmn - nfxd; | |||
| /* Determine the block size. */ | |||
| nb = ilaenv_(&c__1, "CGEQRF", " ", &sm, &sn, &c_n1, &c_n1, (ftnlen)6, | |||
| (ftnlen)1); | |||
| nbmin = 2; | |||
| nx = 0; | |||
| if (nb > 1 && nb < sminmn) { | |||
| /* Determine when to cross over from blocked to unblocked code. */ | |||
| /* Computing MAX */ | |||
| i__1 = 0, i__2 = ilaenv_(&c__3, "CGEQRF", " ", &sm, &sn, &c_n1, & | |||
| c_n1, (ftnlen)6, (ftnlen)1); | |||
| nx = f2cmax(i__1,i__2); | |||
| if (nx < sminmn) { | |||
| /* Determine if workspace is large enough for blocked code. */ | |||
| minws = (sn + 1) * nb; | |||
| iws = f2cmax(iws,minws); | |||
| if (*lwork < minws) { | |||
| /* Not enough workspace to use optimal NB: Reduce NB and */ | |||
| /* determine the minimum value of NB. */ | |||
| nb = *lwork / (sn + 1); | |||
| /* Computing MAX */ | |||
| i__1 = 2, i__2 = ilaenv_(&c__2, "CGEQRF", " ", &sm, &sn, & | |||
| c_n1, &c_n1, (ftnlen)6, (ftnlen)1); | |||
| nbmin = f2cmax(i__1,i__2); | |||
| } | |||
| } | |||
| } | |||
| /* Initialize partial column norms. The first N elements of work */ | |||
| /* store the exact column norms. */ | |||
| i__1 = *n; | |||
| for (j = nfxd + 1; j <= i__1; ++j) { | |||
| rwork[j] = scnrm2_(&sm, &a[nfxd + 1 + j * a_dim1], &c__1); | |||
| rwork[*n + j] = rwork[j]; | |||
| /* L20: */ | |||
| } | |||
| if (nb >= nbmin && nb < sminmn && nx < sminmn) { | |||
| /* Use blocked code initially. */ | |||
| j = nfxd + 1; | |||
| /* Compute factorization: while loop. */ | |||
| topbmn = minmn - nx; | |||
| L30: | |||
| if (j <= topbmn) { | |||
| /* Computing MIN */ | |||
| i__1 = nb, i__2 = topbmn - j + 1; | |||
| jb = f2cmin(i__1,i__2); | |||
| /* Factorize JB columns among columns J:N. */ | |||
| i__1 = *n - j + 1; | |||
| i__2 = j - 1; | |||
| i__3 = *n - j + 1; | |||
| claqps_(m, &i__1, &i__2, &jb, &fjb, &a[j * a_dim1 + 1], lda, & | |||
| jpvt[j], &tau[j], &rwork[j], &rwork[*n + j], &work[1], | |||
| &work[jb + 1], &i__3); | |||
| j += fjb; | |||
| goto L30; | |||
| } | |||
| } else { | |||
| j = nfxd + 1; | |||
| } | |||
| /* Use unblocked code to factor the last or only block. */ | |||
| if (j <= minmn) { | |||
| i__1 = *n - j + 1; | |||
| i__2 = j - 1; | |||
| claqp2_(m, &i__1, &i__2, &a[j * a_dim1 + 1], lda, &jpvt[j], &tau[ | |||
| j], &rwork[j], &rwork[*n + j], &work[1]); | |||
| } | |||
| } | |||
| q__1.r = (real) lwkopt, q__1.i = 0.f; | |||
| work[1].r = q__1.r, work[1].i = q__1.i; | |||
| return 0; | |||
| /* End of CGEQP3 */ | |||
| } /* cgeqp3_ */ | |||
| @@ -0,0 +1,759 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| static integer c_n1 = -1; | |||
| static integer c__2 = 2; | |||
| /* > \brief \b CGEQR */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQR( M, N, A, LDA, T, TSIZE, WORK, LWORK, */ | |||
| /* INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N, TSIZE, LWORK */ | |||
| /* COMPLEX A( LDA, * ), T( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQR computes a QR factorization of a complex M-by-N matrix A: */ | |||
| /* > */ | |||
| /* > A = Q * ( R ), */ | |||
| /* > ( 0 ) */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a M-by-M orthogonal matrix; */ | |||
| /* > R is an upper-triangular N-by-N matrix; */ | |||
| /* > 0 is a (M-N)-by-N zero matrix, if M > N. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the M-by-N matrix A. */ | |||
| /* > On exit, the elements on and above the diagonal of the array */ | |||
| /* > contain the f2cmin(M,N)-by-N upper trapezoidal matrix R */ | |||
| /* > (R is upper triangular if M >= N); */ | |||
| /* > the elements below the diagonal are used to store part of the */ | |||
| /* > data structure to represent Q. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] T */ | |||
| /* > \verbatim */ | |||
| /* > T is COMPLEX array, dimension (MAX(5,TSIZE)) */ | |||
| /* > On exit, if INFO = 0, T(1) returns optimal (or either minimal */ | |||
| /* > or optimal, if query is assumed) TSIZE. See TSIZE for details. */ | |||
| /* > Remaining T contains part of the data structure used to represent Q. */ | |||
| /* > If one wants to apply or construct Q, then one needs to keep T */ | |||
| /* > (in addition to A) and pass it to further subroutines. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] TSIZE */ | |||
| /* > \verbatim */ | |||
| /* > TSIZE is INTEGER */ | |||
| /* > If TSIZE >= 5, the dimension of the array T. */ | |||
| /* > If TSIZE = -1 or -2, then a workspace query is assumed. The routine */ | |||
| /* > only calculates the sizes of the T and WORK arrays, returns these */ | |||
| /* > values as the first entries of the T and WORK arrays, and no error */ | |||
| /* > message related to T or WORK is issued by XERBLA. */ | |||
| /* > If TSIZE = -1, the routine calculates optimal size of T for the */ | |||
| /* > optimum performance and returns this value in T(1). */ | |||
| /* > If TSIZE = -2, the routine calculates minimal size of T and */ | |||
| /* > returns this value in T(1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > (workspace) COMPLEX array, dimension (MAX(1,LWORK)) */ | |||
| /* > On exit, if INFO = 0, WORK(1) contains optimal (or either minimal */ | |||
| /* > or optimal, if query was assumed) LWORK. */ | |||
| /* > See LWORK for details. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LWORK */ | |||
| /* > \verbatim */ | |||
| /* > LWORK is INTEGER */ | |||
| /* > The dimension of the array WORK. */ | |||
| /* > If LWORK = -1 or -2, then a workspace query is assumed. The routine */ | |||
| /* > only calculates the sizes of the T and WORK arrays, returns these */ | |||
| /* > values as the first entries of the T and WORK arrays, and no error */ | |||
| /* > message related to T or WORK is issued by XERBLA. */ | |||
| /* > If LWORK = -1, the routine calculates optimal size of WORK for the */ | |||
| /* > optimal performance and returns this value in WORK(1). */ | |||
| /* > If LWORK = -2, the routine calculates minimal size of WORK and */ | |||
| /* > returns this value in WORK(1). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \par Further Details */ | |||
| /* ==================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The goal of the interface is to give maximum freedom to the developers for */ | |||
| /* > creating any QR factorization algorithm they wish. The triangular */ | |||
| /* > (trapezoidal) R has to be stored in the upper part of A. The lower part of A */ | |||
| /* > and the array T can be used to store any relevant information for applying or */ | |||
| /* > constructing the Q factor. The WORK array can safely be discarded after exit. */ | |||
| /* > */ | |||
| /* > Caution: One should not expect the sizes of T and WORK to be the same from one */ | |||
| /* > LAPACK implementation to the other, or even from one execution to the other. */ | |||
| /* > A workspace query (for T and WORK) is needed at each execution. However, */ | |||
| /* > for a given execution, the size of T and WORK are fixed and will not change */ | |||
| /* > from one query to the next. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \par Further Details particular to this LAPACK implementation: */ | |||
| /* ============================================================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > These details are particular for this LAPACK implementation. Users should not */ | |||
| /* > take them for granted. These details may change in the future, and are not likely */ | |||
| /* > true for another LAPACK implementation. These details are relevant if one wants */ | |||
| /* > to try to understand the code. They are not part of the interface. */ | |||
| /* > */ | |||
| /* > In this version, */ | |||
| /* > */ | |||
| /* > T(2): row block size (MB) */ | |||
| /* > T(3): column block size (NB) */ | |||
| /* > T(6:TSIZE): data structure needed for Q, computed by */ | |||
| /* > CLATSQR or CGEQRT */ | |||
| /* > */ | |||
| /* > Depending on the matrix dimensions M and N, and row and column */ | |||
| /* > block sizes MB and NB returned by ILAENV, CGEQR will use either */ | |||
| /* > CLATSQR (if the matrix is tall-and-skinny) or CGEQRT to compute */ | |||
| /* > the QR factorization. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqr_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *t, integer *tsize, complex *work, integer *lwork, integer * | |||
| info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| /* Local variables */ | |||
| logical mint, minw; | |||
| integer mb, nb, nblcks; | |||
| extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); | |||
| extern integer ilaenv_(integer *, char *, char *, integer *, integer *, | |||
| integer *, integer *, ftnlen, ftnlen); | |||
| extern /* Subroutine */ int cgeqrt_(integer *, integer *, integer *, | |||
| complex *, integer *, complex *, integer *, complex *, integer *); | |||
| logical lminws, lquery; | |||
| integer mintsz; | |||
| extern /* Subroutine */ int clatsqr_(integer *, integer *, integer *, | |||
| integer *, complex *, integer *, complex *, integer *, complex *, | |||
| integer *, integer *); | |||
| /* -- LAPACK computational routine (version 3.9.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd. -- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --t; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| lquery = *tsize == -1 || *tsize == -2 || *lwork == -1 || *lwork == -2; | |||
| mint = FALSE_; | |||
| minw = FALSE_; | |||
| if (*tsize == -2 || *lwork == -2) { | |||
| if (*tsize != -1) { | |||
| mint = TRUE_; | |||
| } | |||
| if (*lwork != -1) { | |||
| minw = TRUE_; | |||
| } | |||
| } | |||
| /* Determine the block size */ | |||
| if (f2cmin(*m,*n) > 0) { | |||
| mb = ilaenv_(&c__1, "CGEQR ", " ", m, n, &c__1, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| nb = ilaenv_(&c__1, "CGEQR ", " ", m, n, &c__2, &c_n1, (ftnlen)6, ( | |||
| ftnlen)1); | |||
| } else { | |||
| mb = *m; | |||
| nb = 1; | |||
| } | |||
| if (mb > *m || mb <= *n) { | |||
| mb = *m; | |||
| } | |||
| if (nb > f2cmin(*m,*n) || nb < 1) { | |||
| nb = 1; | |||
| } | |||
| mintsz = *n + 5; | |||
| if (mb > *n && *m > *n) { | |||
| if ((*m - *n) % (mb - *n) == 0) { | |||
| nblcks = (*m - *n) / (mb - *n); | |||
| } else { | |||
| nblcks = (*m - *n) / (mb - *n) + 1; | |||
| } | |||
| } else { | |||
| nblcks = 1; | |||
| } | |||
| /* Determine if the workspace size satisfies minimal size */ | |||
| lminws = FALSE_; | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = nb * *n * nblcks + 5; | |||
| if ((*tsize < f2cmax(i__1,i__2) || *lwork < nb * *n) && *lwork >= *n && * | |||
| tsize >= mintsz && ! lquery) { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = nb * *n * nblcks + 5; | |||
| if (*tsize < f2cmax(i__1,i__2)) { | |||
| lminws = TRUE_; | |||
| nb = 1; | |||
| mb = *m; | |||
| } | |||
| if (*lwork < nb * *n) { | |||
| lminws = TRUE_; | |||
| nb = 1; | |||
| } | |||
| } | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = nb * *n * nblcks + 5; | |||
| if (*tsize < f2cmax(i__1,i__2) && ! lquery && ! lminws) { | |||
| *info = -6; | |||
| } else /* if(complicated condition) */ { | |||
| /* Computing MAX */ | |||
| i__1 = 1, i__2 = *n * nb; | |||
| if (*lwork < f2cmax(i__1,i__2) && ! lquery && ! lminws) { | |||
| *info = -8; | |||
| } | |||
| } | |||
| } | |||
| if (*info == 0) { | |||
| if (mint) { | |||
| t[1].r = (real) mintsz, t[1].i = 0.f; | |||
| } else { | |||
| i__1 = nb * *n * nblcks + 5; | |||
| t[1].r = (real) i__1, t[1].i = 0.f; | |||
| } | |||
| t[2].r = (real) mb, t[2].i = 0.f; | |||
| t[3].r = (real) nb, t[3].i = 0.f; | |||
| if (minw) { | |||
| i__1 = f2cmax(1,*n); | |||
| work[1].r = (real) i__1, work[1].i = 0.f; | |||
| } else { | |||
| /* Computing MAX */ | |||
| i__2 = 1, i__3 = nb * *n; | |||
| i__1 = f2cmax(i__2,i__3); | |||
| work[1].r = (real) i__1, work[1].i = 0.f; | |||
| } | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQR", &i__1, (ftnlen)5); | |||
| return 0; | |||
| } else if (lquery) { | |||
| return 0; | |||
| } | |||
| /* Quick return if possible */ | |||
| if (f2cmin(*m,*n) == 0) { | |||
| return 0; | |||
| } | |||
| /* The QR Decomposition */ | |||
| if (*m <= *n || mb <= *n || mb >= *m) { | |||
| cgeqrt_(m, n, &nb, &a[a_offset], lda, &t[6], &nb, &work[1], info); | |||
| } else { | |||
| clatsqr_(m, n, &mb, &nb, &a[a_offset], lda, &t[6], &nb, &work[1], | |||
| lwork, info); | |||
| } | |||
| /* Computing MAX */ | |||
| i__2 = 1, i__3 = nb * *n; | |||
| i__1 = f2cmax(i__2,i__3); | |||
| work[1].r = (real) i__1, work[1].i = 0.f; | |||
| return 0; | |||
| /* End of CGEQR */ | |||
| } /* cgeqr_ */ | |||
| @@ -0,0 +1,628 @@ | |||
| /* f2c.h -- Standard Fortran to C header file */ | |||
| /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." | |||
| - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ | |||
| #ifndef F2C_INCLUDE | |||
| #define F2C_INCLUDE | |||
| #include <math.h> | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #include <stdio.h> | |||
| #include <complex.h> | |||
| #ifdef complex | |||
| #undef complex | |||
| #endif | |||
| #ifdef I | |||
| #undef I | |||
| #endif | |||
| #if defined(_WIN64) | |||
| typedef long long BLASLONG; | |||
| typedef unsigned long long BLASULONG; | |||
| #else | |||
| typedef long BLASLONG; | |||
| typedef unsigned long BLASULONG; | |||
| #endif | |||
| #ifdef LAPACK_ILP64 | |||
| typedef BLASLONG blasint; | |||
| #if defined(_WIN64) | |||
| #define blasabs(x) llabs(x) | |||
| #else | |||
| #define blasabs(x) labs(x) | |||
| #endif | |||
| #else | |||
| typedef int blasint; | |||
| #define blasabs(x) abs(x) | |||
| #endif | |||
| typedef blasint integer; | |||
| typedef unsigned int uinteger; | |||
| typedef char *address; | |||
| typedef short int shortint; | |||
| typedef float real; | |||
| typedef double doublereal; | |||
| typedef struct { real r, i; } complex; | |||
| typedef struct { doublereal r, i; } doublecomplex; | |||
| static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} | |||
| static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} | |||
| static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} | |||
| #define pCf(z) (*_pCf(z)) | |||
| #define pCd(z) (*_pCd(z)) | |||
| typedef int logical; | |||
| typedef short int shortlogical; | |||
| typedef char logical1; | |||
| typedef char integer1; | |||
| #define TRUE_ (1) | |||
| #define FALSE_ (0) | |||
| /* Extern is for use with -E */ | |||
| #ifndef Extern | |||
| #define Extern extern | |||
| #endif | |||
| /* I/O stuff */ | |||
| typedef int flag; | |||
| typedef int ftnlen; | |||
| typedef int ftnint; | |||
| /*external read, write*/ | |||
| typedef struct | |||
| { flag cierr; | |||
| ftnint ciunit; | |||
| flag ciend; | |||
| char *cifmt; | |||
| ftnint cirec; | |||
| } cilist; | |||
| /*internal read, write*/ | |||
| typedef struct | |||
| { flag icierr; | |||
| char *iciunit; | |||
| flag iciend; | |||
| char *icifmt; | |||
| ftnint icirlen; | |||
| ftnint icirnum; | |||
| } icilist; | |||
| /*open*/ | |||
| typedef struct | |||
| { flag oerr; | |||
| ftnint ounit; | |||
| char *ofnm; | |||
| ftnlen ofnmlen; | |||
| char *osta; | |||
| char *oacc; | |||
| char *ofm; | |||
| ftnint orl; | |||
| char *oblnk; | |||
| } olist; | |||
| /*close*/ | |||
| typedef struct | |||
| { flag cerr; | |||
| ftnint cunit; | |||
| char *csta; | |||
| } cllist; | |||
| /*rewind, backspace, endfile*/ | |||
| typedef struct | |||
| { flag aerr; | |||
| ftnint aunit; | |||
| } alist; | |||
| /* inquire */ | |||
| typedef struct | |||
| { flag inerr; | |||
| ftnint inunit; | |||
| char *infile; | |||
| ftnlen infilen; | |||
| ftnint *inex; /*parameters in standard's order*/ | |||
| ftnint *inopen; | |||
| ftnint *innum; | |||
| ftnint *innamed; | |||
| char *inname; | |||
| ftnlen innamlen; | |||
| char *inacc; | |||
| ftnlen inacclen; | |||
| char *inseq; | |||
| ftnlen inseqlen; | |||
| char *indir; | |||
| ftnlen indirlen; | |||
| char *infmt; | |||
| ftnlen infmtlen; | |||
| char *inform; | |||
| ftnint informlen; | |||
| char *inunf; | |||
| ftnlen inunflen; | |||
| ftnint *inrecl; | |||
| ftnint *innrec; | |||
| char *inblank; | |||
| ftnlen inblanklen; | |||
| } inlist; | |||
| #define VOID void | |||
| union Multitype { /* for multiple entry points */ | |||
| integer1 g; | |||
| shortint h; | |||
| integer i; | |||
| /* longint j; */ | |||
| real r; | |||
| doublereal d; | |||
| complex c; | |||
| doublecomplex z; | |||
| }; | |||
| typedef union Multitype Multitype; | |||
| struct Vardesc { /* for Namelist */ | |||
| char *name; | |||
| char *addr; | |||
| ftnlen *dims; | |||
| int type; | |||
| }; | |||
| typedef struct Vardesc Vardesc; | |||
| struct Namelist { | |||
| char *name; | |||
| Vardesc **vars; | |||
| int nvars; | |||
| }; | |||
| typedef struct Namelist Namelist; | |||
| #define abs(x) ((x) >= 0 ? (x) : -(x)) | |||
| #define dabs(x) (fabs(x)) | |||
| #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) | |||
| #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) | |||
| #define dmin(a,b) (f2cmin(a,b)) | |||
| #define dmax(a,b) (f2cmax(a,b)) | |||
| #define bit_test(a,b) ((a) >> (b) & 1) | |||
| #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) | |||
| #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) | |||
| #define abort_() { sig_die("Fortran abort routine called", 1); } | |||
| #define c_abs(z) (cabsf(Cf(z))) | |||
| #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } | |||
| #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} | |||
| #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} | |||
| #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} | |||
| #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} | |||
| #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} | |||
| //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} | |||
| #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} | |||
| #define d_abs(x) (fabs(*(x))) | |||
| #define d_acos(x) (acos(*(x))) | |||
| #define d_asin(x) (asin(*(x))) | |||
| #define d_atan(x) (atan(*(x))) | |||
| #define d_atn2(x, y) (atan2(*(x),*(y))) | |||
| #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } | |||
| #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } | |||
| #define d_cos(x) (cos(*(x))) | |||
| #define d_cosh(x) (cosh(*(x))) | |||
| #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) | |||
| #define d_exp(x) (exp(*(x))) | |||
| #define d_imag(z) (cimag(Cd(z))) | |||
| #define r_imag(z) (cimag(Cf(z))) | |||
| #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) | |||
| #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) | |||
| #define d_log(x) (log(*(x))) | |||
| #define d_mod(x, y) (fmod(*(x), *(y))) | |||
| #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) | |||
| #define d_nint(x) u_nint(*(x)) | |||
| #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) | |||
| #define d_sign(a,b) u_sign(*(a),*(b)) | |||
| #define r_sign(a,b) u_sign(*(a),*(b)) | |||
| #define d_sin(x) (sin(*(x))) | |||
| #define d_sinh(x) (sinh(*(x))) | |||
| #define d_sqrt(x) (sqrt(*(x))) | |||
| #define d_tan(x) (tan(*(x))) | |||
| #define d_tanh(x) (tanh(*(x))) | |||
| #define i_abs(x) abs(*(x)) | |||
| #define i_dnnt(x) ((integer)u_nint(*(x))) | |||
| #define i_len(s, n) (n) | |||
| #define i_nint(x) ((integer)u_nint(*(x))) | |||
| #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) | |||
| #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) | |||
| #define pow_si(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_ri(B,E) spow_ui(*(B),*(E)) | |||
| #define pow_di(B,E) dpow_ui(*(B),*(E)) | |||
| #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} | |||
| #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} | |||
| #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} | |||
| #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } | |||
| #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) | |||
| #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } | |||
| #define sig_die(s, kill) { exit(1); } | |||
| #define s_stop(s, n) {exit(0);} | |||
| static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; | |||
| #define z_abs(z) (cabs(Cd(z))) | |||
| #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} | |||
| #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} | |||
| #define myexit_() break; | |||
| #define mycycle() continue; | |||
| #define myceiling(w) {ceil(w)} | |||
| #define myhuge(w) {HUGE_VAL} | |||
| //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} | |||
| #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} | |||
| /* procedure parameter types for -A and -C++ */ | |||
| #define F2C_proc_par_types 1 | |||
| #ifdef __cplusplus | |||
| typedef logical (*L_fp)(...); | |||
| #else | |||
| typedef logical (*L_fp)(); | |||
| #endif | |||
| static float spow_ui(float x, integer n) { | |||
| float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static double dpow_ui(double x, integer n) { | |||
| double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex float cpow_ui(_Complex float x, integer n) { | |||
| _Complex float pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static _Complex double zpow_ui(_Complex double x, integer n) { | |||
| _Complex double pow=1.0; unsigned long int u; | |||
| if(n != 0) { | |||
| if(n < 0) n = -n, x = 1/x; | |||
| for(u = n; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer pow_ii(integer x, integer n) { | |||
| integer pow; unsigned long int u; | |||
| if (n <= 0) { | |||
| if (n == 0 || x == 1) pow = 1; | |||
| else if (x != -1) pow = x == 0 ? 1/x : 0; | |||
| else n = -n; | |||
| } | |||
| if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { | |||
| u = n; | |||
| for(pow = 1; ; ) { | |||
| if(u & 01) pow *= x; | |||
| if(u >>= 1) x *= x; | |||
| else break; | |||
| } | |||
| } | |||
| return pow; | |||
| } | |||
| static integer dmaxloc_(double *w, integer s, integer e, integer *n) | |||
| { | |||
| double m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static integer smaxloc_(float *w, integer s, integer e, integer *n) | |||
| { | |||
| float m; integer i, mi; | |||
| for(m=w[s-1], mi=s, i=s+1; i<=e; i++) | |||
| if (w[i-1]>m) mi=i ,m=w[i-1]; | |||
| return mi-s+1; | |||
| } | |||
| static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i])) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex float zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i]) * Cf(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); | |||
| } | |||
| } | |||
| pCf(z) = zdotc; | |||
| } | |||
| static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { | |||
| integer n = *n_, incx = *incx_, incy = *incy_, i; | |||
| _Complex double zdotc = 0.0; | |||
| if (incx == 1 && incy == 1) { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i]) * Cd(&y[i]); | |||
| } | |||
| } else { | |||
| for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ | |||
| zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); | |||
| } | |||
| } | |||
| pCd(z) = zdotc; | |||
| } | |||
| #endif | |||
| /* -- translated by f2c (version 20000121). | |||
| You must link the resulting object file with the libraries: | |||
| -lf2c -lm (in that order) | |||
| */ | |||
| /* Table of constant values */ | |||
| static integer c__1 = 1; | |||
| /* > \brief \b CGEQR2 computes the QR factorization of a general rectangular matrix using an unblocked algorit | |||
| hm. */ | |||
| /* =========== DOCUMENTATION =========== */ | |||
| /* Online html documentation available at */ | |||
| /* http://www.netlib.org/lapack/explore-html/ */ | |||
| /* > \htmlonly */ | |||
| /* > Download CGEQR2 + dependencies */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqr2. | |||
| f"> */ | |||
| /* > [TGZ]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqr2. | |||
| f"> */ | |||
| /* > [ZIP]</a> */ | |||
| /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqr2. | |||
| f"> */ | |||
| /* > [TXT]</a> */ | |||
| /* > \endhtmlonly */ | |||
| /* Definition: */ | |||
| /* =========== */ | |||
| /* SUBROUTINE CGEQR2( M, N, A, LDA, TAU, WORK, INFO ) */ | |||
| /* INTEGER INFO, LDA, M, N */ | |||
| /* COMPLEX A( LDA, * ), TAU( * ), WORK( * ) */ | |||
| /* > \par Purpose: */ | |||
| /* ============= */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > CGEQR2 computes a QR factorization of a complex m-by-n matrix A: */ | |||
| /* > */ | |||
| /* > A = Q * ( R ), */ | |||
| /* > ( 0 ) */ | |||
| /* > */ | |||
| /* > where: */ | |||
| /* > */ | |||
| /* > Q is a m-by-m orthogonal matrix; */ | |||
| /* > R is an upper-triangular n-by-n matrix; */ | |||
| /* > 0 is a (m-n)-by-n zero matrix, if m > n. */ | |||
| /* > */ | |||
| /* > \endverbatim */ | |||
| /* Arguments: */ | |||
| /* ========== */ | |||
| /* > \param[in] M */ | |||
| /* > \verbatim */ | |||
| /* > M is INTEGER */ | |||
| /* > The number of rows of the matrix A. M >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] N */ | |||
| /* > \verbatim */ | |||
| /* > N is INTEGER */ | |||
| /* > The number of columns of the matrix A. N >= 0. */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in,out] A */ | |||
| /* > \verbatim */ | |||
| /* > A is COMPLEX array, dimension (LDA,N) */ | |||
| /* > On entry, the m by n matrix A. */ | |||
| /* > On exit, the elements on and above the diagonal of the array */ | |||
| /* > contain the f2cmin(m,n) by n upper trapezoidal matrix R (R is */ | |||
| /* > upper triangular if m >= n); the elements below the diagonal, */ | |||
| /* > with the array TAU, represent the unitary matrix Q as a */ | |||
| /* > product of elementary reflectors (see Further Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[in] LDA */ | |||
| /* > \verbatim */ | |||
| /* > LDA is INTEGER */ | |||
| /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] TAU */ | |||
| /* > \verbatim */ | |||
| /* > TAU is COMPLEX array, dimension (f2cmin(M,N)) */ | |||
| /* > The scalar factors of the elementary reflectors (see Further */ | |||
| /* > Details). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] WORK */ | |||
| /* > \verbatim */ | |||
| /* > WORK is COMPLEX array, dimension (N) */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* > \param[out] INFO */ | |||
| /* > \verbatim */ | |||
| /* > INFO is INTEGER */ | |||
| /* > = 0: successful exit */ | |||
| /* > < 0: if INFO = -i, the i-th argument had an illegal value */ | |||
| /* > \endverbatim */ | |||
| /* Authors: */ | |||
| /* ======== */ | |||
| /* > \author Univ. of Tennessee */ | |||
| /* > \author Univ. of California Berkeley */ | |||
| /* > \author Univ. of Colorado Denver */ | |||
| /* > \author NAG Ltd. */ | |||
| /* > \date November 2019 */ | |||
| /* > \ingroup complexGEcomputational */ | |||
| /* > \par Further Details: */ | |||
| /* ===================== */ | |||
| /* > */ | |||
| /* > \verbatim */ | |||
| /* > */ | |||
| /* > The matrix Q is represented as a product of elementary reflectors */ | |||
| /* > */ | |||
| /* > Q = H(1) H(2) . . . H(k), where k = f2cmin(m,n). */ | |||
| /* > */ | |||
| /* > Each H(i) has the form */ | |||
| /* > */ | |||
| /* > H(i) = I - tau * v * v**H */ | |||
| /* > */ | |||
| /* > where tau is a complex scalar, and v is a complex vector with */ | |||
| /* > v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), */ | |||
| /* > and tau in TAU(i). */ | |||
| /* > \endverbatim */ | |||
| /* > */ | |||
| /* ===================================================================== */ | |||
| /* Subroutine */ int cgeqr2_(integer *m, integer *n, complex *a, integer *lda, | |||
| complex *tau, complex *work, integer *info) | |||
| { | |||
| /* System generated locals */ | |||
| integer a_dim1, a_offset, i__1, i__2, i__3; | |||
| complex q__1; | |||
| /* Local variables */ | |||
| integer i__, k; | |||
| complex alpha; | |||
| extern /* Subroutine */ int clarf_(char *, integer *, integer *, complex * | |||
| , integer *, complex *, complex *, integer *, complex *), | |||
| clarfg_(integer *, complex *, complex *, integer *, complex *), | |||
| xerbla_(char *, integer *, ftnlen); | |||
| /* -- LAPACK computational routine (version 3.9.0) -- */ | |||
| /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ | |||
| /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ | |||
| /* November 2019 */ | |||
| /* ===================================================================== */ | |||
| /* Test the input arguments */ | |||
| /* Parameter adjustments */ | |||
| a_dim1 = *lda; | |||
| a_offset = 1 + a_dim1 * 1; | |||
| a -= a_offset; | |||
| --tau; | |||
| --work; | |||
| /* Function Body */ | |||
| *info = 0; | |||
| if (*m < 0) { | |||
| *info = -1; | |||
| } else if (*n < 0) { | |||
| *info = -2; | |||
| } else if (*lda < f2cmax(1,*m)) { | |||
| *info = -4; | |||
| } | |||
| if (*info != 0) { | |||
| i__1 = -(*info); | |||
| xerbla_("CGEQR2", &i__1, (ftnlen)6); | |||
| return 0; | |||
| } | |||
| k = f2cmin(*m,*n); | |||
| i__1 = k; | |||
| for (i__ = 1; i__ <= i__1; ++i__) { | |||
| /* Generate elementary reflector H(i) to annihilate A(i+1:m,i) */ | |||
| i__2 = *m - i__ + 1; | |||
| /* Computing MIN */ | |||
| i__3 = i__ + 1; | |||
| clarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[f2cmin(i__3,*m) + i__ * a_dim1] | |||
| , &c__1, &tau[i__]); | |||
| if (i__ < *n) { | |||
| /* Apply H(i)**H to A(i:m,i+1:n) from the left */ | |||
| i__2 = i__ + i__ * a_dim1; | |||
| alpha.r = a[i__2].r, alpha.i = a[i__2].i; | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = 1.f, a[i__2].i = 0.f; | |||
| i__2 = *m - i__ + 1; | |||
| i__3 = *n - i__; | |||
| r_cnjg(&q__1, &tau[i__]); | |||
| clarf_("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, &q__1, | |||
| &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]); | |||
| i__2 = i__ + i__ * a_dim1; | |||
| a[i__2].r = alpha.r, a[i__2].i = alpha.i; | |||
| } | |||
| /* L10: */ | |||
| } | |||
| return 0; | |||
| /* End of CGEQR2 */ | |||
| } /* cgeqr2_ */ | |||