├── .gitignore ├── CHANGELOG ├── INSTALL.txt ├── Makefile ├── README.md ├── RunBundler.sh ├── bin ├── ToSift.sh ├── ToSiftList.sh ├── extract_focal.pl └── zlib1.dll ├── examples ├── ET │ ├── Makefile │ ├── bundler.config.example │ ├── et000.jpg │ ├── et001.jpg │ ├── et002.jpg │ ├── et003.jpg │ ├── et004.jpg │ ├── et005.jpg │ ├── et006.jpg │ ├── et007.jpg │ └── et008.jpg ├── Makefile └── kermit │ ├── Makefile │ ├── bundler.config.example │ ├── kermit000.jpg │ ├── kermit001.jpg │ ├── kermit002.jpg │ ├── kermit003.jpg │ ├── kermit004.jpg │ ├── kermit005.jpg │ ├── kermit006.jpg │ ├── kermit007.jpg │ ├── kermit008.jpg │ ├── kermit009.jpg │ ├── kermit010.jpg │ └── results.example │ ├── bundle.out │ └── matches.init.txt ├── include ├── cblas.h ├── lapack.h ├── minpack.h ├── snavely_reprojection_error.h └── types.h ├── lib ├── 5point │ ├── 5point.c │ ├── 5point.h │ ├── 5point.vcproj │ ├── Makefile │ ├── poly1.c │ ├── poly1.h │ ├── poly3.c │ └── poly3.h ├── ann_1.1_char │ ├── Copyright.txt │ ├── License.txt │ ├── MS_Win32 │ │ ├── Ann.sln │ │ ├── Makefile │ │ ├── ann2fig │ │ │ └── ann2fig.vcproj │ │ ├── dll │ │ │ └── dll.vcproj │ │ ├── sample │ │ │ └── sample.vcproj │ │ └── test │ │ │ └── test.vcproj │ ├── Make-config │ ├── Makefile │ ├── ann2fig │ │ ├── Makefile │ │ └── ann2fig.cpp │ ├── ann_1.1_char.vcproj │ ├── doc │ │ └── ANNmanual.pdf │ ├── include │ │ └── ANN │ │ │ ├── ANN.h │ │ │ ├── ANNperf.h │ │ │ └── ANNx.h │ ├── sample │ │ ├── Makefile │ │ ├── ann_sample.cpp │ │ ├── data.pts │ │ ├── query.pts │ │ └── sample.save │ ├── src │ │ ├── ANN.cpp │ │ ├── Makefile │ │ ├── bd_fix_rad_search.cpp │ │ ├── bd_pr_search.cpp │ │ ├── bd_search.cpp │ │ ├── bd_tree.cpp │ │ ├── bd_tree.h │ │ ├── brute.cpp │ │ ├── kd_dump.cpp │ │ ├── kd_fix_rad_search.cpp │ │ ├── kd_fix_rad_search.h │ │ ├── kd_pr_search.cpp │ │ ├── kd_pr_search.h │ │ ├── kd_search.cpp │ │ ├── kd_search.h │ │ ├── kd_split.cpp │ │ ├── kd_split.h │ │ ├── kd_tree.cpp │ │ ├── kd_tree.h │ │ ├── kd_util.cpp │ │ ├── kd_util.h │ │ ├── perf.cpp │ │ ├── pr_queue.h │ │ └── pr_queue_k.h │ └── test │ │ ├── Makefile │ │ ├── ann_test.cpp │ │ ├── rand.cpp │ │ ├── rand.h │ │ ├── test1-data.pts │ │ ├── test1-query.pts │ │ ├── test1.in │ │ ├── test1.save │ │ ├── test2-data.pts │ │ ├── test2-query.pts │ │ ├── test2.in │ │ └── test2.save ├── cblas │ ├── Makefile │ ├── cblas.h │ ├── cblas.vcproj │ ├── cblas_dgemm.c │ ├── cblas_f77.h │ ├── cblas_globals.c │ ├── cblas_xerbla.c │ └── xerbla.c ├── clapack │ ├── BLAS │ │ └── SRC │ │ │ ├── blaswrap.h │ │ │ ├── dasum.c │ │ │ ├── daxpy.c │ │ │ ├── dcabs1.c │ │ │ ├── dcopy.c │ │ │ ├── ddot.c │ │ │ ├── dgbmv.c │ │ │ ├── dgemm.c │ │ │ ├── dgemv.c │ │ │ ├── dger.c │ │ │ ├── dnrm2.c │ │ │ ├── drot.c │ │ │ ├── drotg.c │ │ │ ├── drotm.c │ │ │ ├── drotmg.c │ │ │ ├── dsbmv.c │ │ │ ├── dscal.c │ │ │ ├── dsdot.c │ │ │ ├── dspmv.c │ │ │ ├── dspr.c │ │ │ ├── dspr2.c │ │ │ ├── dswap.c │ │ │ ├── dsymm.c │ │ │ ├── dsymv.c │ │ │ ├── dsyr.c │ │ │ ├── dsyr2.c │ │ │ ├── dsyr2k.c │ │ │ ├── dsyrk.c │ │ │ ├── dtbmv.c │ │ │ ├── dtbsv.c │ │ │ ├── dtpmv.c │ │ │ ├── dtpsv.c │ │ │ ├── dtrmm.c │ │ │ ├── dtrmv.c │ │ │ ├── dtrsm.c │ │ │ ├── dtrsv.c │ │ │ ├── dzasum.c │ │ │ ├── dznrm2.c │ │ │ ├── icamax.c │ │ │ ├── idamax.c │ │ │ ├── isamax.c │ │ │ ├── izamax.c │ │ │ ├── lsame.c │ │ │ └── xerbla.c │ ├── INCLUDE │ │ ├── blaswrap.h │ │ ├── clapack.h │ │ └── f2c.h │ ├── INSTALL │ │ ├── LAPACK_version.c │ │ ├── blaswrap.h │ │ ├── dlamch.c │ │ ├── dlamchtst.c │ │ ├── dsecnd.c │ │ ├── dsecndtst.c │ │ ├── f2c.h │ │ ├── ilaver.c │ │ ├── lsame.c │ │ ├── lsametst.c │ │ ├── second.c │ │ ├── secondtst.c │ │ ├── slamch.c │ │ ├── slamchtst.c │ │ └── tstiee.c │ ├── SRC │ │ ├── blaswrap.h │ │ ├── dbdsdc.c │ │ ├── dbdsqr.c │ │ ├── ddisna.c │ │ ├── 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 │ │ ├── dgegs.c │ │ ├── dgegv.c │ │ ├── dgehd2.c │ │ ├── dgehrd.c │ │ ├── dgelq2.c │ │ ├── dgelqf.c │ │ ├── dgels.c │ │ ├── dgelsd.c │ │ ├── dgelss.c │ │ ├── dgelsx.c │ │ ├── dgelsy.c │ │ ├── dgeql2.c │ │ ├── dgeqlf.c │ │ ├── dgeqp3.c │ │ ├── dgeqpf.c │ │ ├── dgeqr2.c │ │ ├── dgeqrf.c │ │ ├── dgerfs.c │ │ ├── dgerq2.c │ │ ├── dgerqf.c │ │ ├── dgesc2.c │ │ ├── dgesdd.c │ │ ├── dgesv.c │ │ ├── dgesvd.c │ │ ├── dgesvx.c │ │ ├── dgetc2.c │ │ ├── dgetf2.c │ │ ├── dgetrf.c │ │ ├── dgetri.c │ │ ├── dgetrs.c │ │ ├── dggbak.c │ │ ├── dggbal.c │ │ ├── dgges.c │ │ ├── dggesx.c │ │ ├── dggev.c │ │ ├── dggevx.c │ │ ├── dggglm.c │ │ ├── dgghrd.c │ │ ├── dgglse.c │ │ ├── dggqrf.c │ │ ├── dggrqf.c │ │ ├── dggsvd.c │ │ ├── dggsvp.c │ │ ├── dgtcon.c │ │ ├── dgtrfs.c │ │ ├── dgtsv.c │ │ ├── dgtsvx.c │ │ ├── dgttrf.c │ │ ├── dgttrs.c │ │ ├── dgtts2.c │ │ ├── dhgeqz.c │ │ ├── dhsein.c │ │ ├── dhseqr.c │ │ ├── disnan.c │ │ ├── dlabad.c │ │ ├── dlabrd.c │ │ ├── dlacn2.c │ │ ├── dlacon.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 │ │ ├── dlaein.c │ │ ├── dlaev2.c │ │ ├── dlaexc.c │ │ ├── dlag2.c │ │ ├── dlag2s.c │ │ ├── dlags2.c │ │ ├── dlagtf.c │ │ ├── dlagtm.c │ │ ├── dlagts.c │ │ ├── dlagv2.c │ │ ├── dlahqr.c │ │ ├── dlahr2.c │ │ ├── dlahrd.c │ │ ├── dlaic1.c │ │ ├── dlaisnan.c │ │ ├── dlaln2.c │ │ ├── dlals0.c │ │ ├── dlalsa.c │ │ ├── dlalsd.c │ │ ├── dlamrg.c │ │ ├── dlaneg.c │ │ ├── dlangb.c │ │ ├── dlange.c │ │ ├── dlangt.c │ │ ├── dlanhs.c │ │ ├── dlansb.c │ │ ├── dlansp.c │ │ ├── dlanst.c │ │ ├── dlansy.c │ │ ├── dlantb.c │ │ ├── dlantp.c │ │ ├── dlantr.c │ │ ├── dlanv2.c │ │ ├── dlapll.c │ │ ├── dlapmt.c │ │ ├── dlapy2.c │ │ ├── dlapy3.c │ │ ├── dlaqgb.c │ │ ├── dlaqge.c │ │ ├── dlaqp2.c │ │ ├── dlaqps.c │ │ ├── dlaqr0.c │ │ ├── dlaqr1.c │ │ ├── dlaqr2.c │ │ ├── dlaqr3.c │ │ ├── dlaqr4.c │ │ ├── dlaqr5.c │ │ ├── dlaqsb.c │ │ ├── dlaqsp.c │ │ ├── dlaqsy.c │ │ ├── dlaqtr.c │ │ ├── dlar1v.c │ │ ├── dlar2v.c │ │ ├── dlarf.c │ │ ├── dlarfb.c │ │ ├── dlarfg.c │ │ ├── dlarft.c │ │ ├── dlarfx.c │ │ ├── dlargv.c │ │ ├── dlarnv.c │ │ ├── dlarra.c │ │ ├── dlarrb.c │ │ ├── dlarrc.c │ │ ├── dlarrd.c │ │ ├── dlarre.c │ │ ├── dlarrf.c │ │ ├── dlarrj.c │ │ ├── dlarrk.c │ │ ├── dlarrr.c │ │ ├── dlarrv.c │ │ ├── dlartg.c │ │ ├── dlartv.c │ │ ├── dlaruv.c │ │ ├── dlarz.c │ │ ├── dlarzb.c │ │ ├── dlarzt.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 │ │ ├── dlaset.c │ │ ├── dlasq1.c │ │ ├── dlasq2.c │ │ ├── dlasq3.c │ │ ├── dlasq4.c │ │ ├── dlasq5.c │ │ ├── dlasq6.c │ │ ├── dlasr.c │ │ ├── dlasrt.c │ │ ├── dlassq.c │ │ ├── dlasv2.c │ │ ├── dlaswp.c │ │ ├── dlasy2.c │ │ ├── dlasyf.c │ │ ├── dlatbs.c │ │ ├── dlatdf.c │ │ ├── dlatps.c │ │ ├── dlatrd.c │ │ ├── dlatrs.c │ │ ├── dlatrz.c │ │ ├── dlatzm.c │ │ ├── dlauu2.c │ │ ├── dlauum.c │ │ ├── dlazq3.c │ │ ├── dlazq4.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 │ │ ├── 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 │ │ ├── dpotf2.c │ │ ├── dpotrf.c │ │ ├── dpotri.c │ │ ├── dpotrs.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 │ │ ├── dpttrf.c │ │ ├── dpttrs.c │ │ ├── dptts2.c │ │ ├── drscl.c │ │ ├── dsbev.c │ │ ├── dsbevd.c │ │ ├── dsbevx.c │ │ ├── dsbgst.c │ │ ├── dsbgv.c │ │ ├── dsbgvd.c │ │ ├── dsbgvx.c │ │ ├── dsbtrd.c │ │ ├── dsgesv.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 │ │ ├── dstebz.c │ │ ├── dstedc.c │ │ ├── dstegr.c │ │ ├── dstein.c │ │ ├── dstemr.c │ │ ├── dsteqr.c │ │ ├── dsterf.c │ │ ├── dstev.c │ │ ├── dstevd.c │ │ ├── dstevr.c │ │ ├── dstevx.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 │ │ ├── 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 │ │ ├── dtrexc.c │ │ ├── dtrrfs.c │ │ ├── dtrsen.c │ │ ├── dtrsna.c │ │ ├── dtrsyl.c │ │ ├── dtrti2.c │ │ ├── dtrtri.c │ │ ├── dtrtrs.c │ │ ├── dtzrqf.c │ │ ├── dtzrzf.c │ │ ├── dzsum1.c │ │ ├── f2c.h │ │ ├── icmax1.c │ │ ├── ieeeck.c │ │ ├── ilaenv.c │ │ ├── ilaver.c │ │ ├── iparmq.c │ │ ├── izmax1.c │ │ ├── lsamen.c │ │ └── xerbla.c │ └── clapack.vcproj ├── cminpack │ ├── chkder.c │ ├── cminpack.vcproj │ ├── dogleg.c │ ├── dpmpar.c │ ├── enorm.c │ ├── fdjac1.c │ ├── fdjac2.c │ ├── hybrd.c │ ├── hybrd1.c │ ├── hybrj.c │ ├── hybrj1.c │ ├── lmder.c │ ├── lmder1.c │ ├── lmdif.c │ ├── lmdif1.c │ ├── lmpar.c │ ├── lmstr.c │ ├── lmstr1.c │ ├── minpack.h │ ├── qform.c │ ├── qrfac.c │ ├── qrsolv.c │ ├── r1mpyq.c │ ├── r1updt.c │ └── rwupdt.c ├── f2c │ ├── Makefile │ ├── abort_.c │ ├── arithchk.c │ ├── backspac.c │ ├── c_abs.c │ ├── c_cos.c │ ├── c_div.c │ ├── c_exp.c │ ├── c_log.c │ ├── c_sin.c │ ├── c_sqrt.c │ ├── cabs.c │ ├── close.c │ ├── ctype.c │ ├── ctype.h │ ├── d_abs.c │ ├── d_acos.c │ ├── d_asin.c │ ├── d_atan.c │ ├── d_atn2.c │ ├── d_cnjg.c │ ├── d_cos.c │ ├── d_cosh.c │ ├── d_dim.c │ ├── d_exp.c │ ├── d_imag.c │ ├── d_int.c │ ├── d_lg10.c │ ├── d_log.c │ ├── d_mod.c │ ├── d_nint.c │ ├── d_prod.c │ ├── d_sign.c │ ├── d_sin.c │ ├── d_sinh.c │ ├── d_sqrt.c │ ├── d_tan.c │ ├── d_tanh.c │ ├── derf_.c │ ├── derfc_.c │ ├── dfe.c │ ├── dolio.c │ ├── dtime_.c │ ├── due.c │ ├── ef1asc_.c │ ├── ef1cmc_.c │ ├── endfile.c │ ├── erf_.c │ ├── erfc_.c │ ├── err.c │ ├── etime_.c │ ├── exit_.c │ ├── f2c.h │ ├── f2c.h0 │ ├── f2c.vcproj │ ├── f77_aloc.c │ ├── f77vers.c │ ├── fio.h │ ├── fmt.c │ ├── fmt.h │ ├── fmtlib.c │ ├── fp.h │ ├── ftell64_.c │ ├── ftell_.c │ ├── getarg_.c │ ├── getenv_.c │ ├── h_abs.c │ ├── h_dim.c │ ├── h_dnnt.c │ ├── h_indx.c │ ├── h_len.c │ ├── h_mod.c │ ├── h_nint.c │ ├── h_sign.c │ ├── hl_ge.c │ ├── hl_gt.c │ ├── hl_le.c │ ├── hl_lt.c │ ├── i77vers.c │ ├── i_abs.c │ ├── i_dim.c │ ├── i_dnnt.c │ ├── i_indx.c │ ├── i_len.c │ ├── i_mod.c │ ├── i_nint.c │ ├── i_sign.c │ ├── iargc_.c │ ├── iio.c │ ├── ilnw.c │ ├── inquire.c │ ├── l_ge.c │ ├── l_gt.c │ ├── l_le.c │ ├── l_lt.c │ ├── lbitbits.c │ ├── lbitshft.c │ ├── lio.h │ ├── lread.c │ ├── lwrite.c │ ├── main.c │ ├── open.c │ ├── pow_ci.c │ ├── pow_dd.c │ ├── pow_di.c │ ├── pow_hh.c │ ├── pow_ii.c │ ├── pow_qq.c │ ├── pow_ri.c │ ├── pow_zi.c │ ├── pow_zz.c │ ├── qbitbits.c │ ├── qbitshft.c │ ├── r_abs.c │ ├── r_acos.c │ ├── r_asin.c │ ├── r_atan.c │ ├── r_atn2.c │ ├── r_cnjg.c │ ├── r_cos.c │ ├── r_cosh.c │ ├── r_dim.c │ ├── r_exp.c │ ├── r_imag.c │ ├── r_int.c │ ├── r_lg10.c │ ├── r_log.c │ ├── r_mod.c │ ├── r_nint.c │ ├── r_sign.c │ ├── r_sin.c │ ├── r_sinh.c │ ├── r_sqrt.c │ ├── r_tan.c │ ├── r_tanh.c │ ├── rawio.h │ ├── rdfmt.c │ ├── rewind.c │ ├── rsfe.c │ ├── rsli.c │ ├── rsne.c │ ├── s_cat.c │ ├── s_cmp.c │ ├── s_copy.c │ ├── s_paus.c │ ├── s_rnge.c │ ├── s_stop.c │ ├── sfe.c │ ├── sig_die.c │ ├── signal1.h0 │ ├── signal_.c │ ├── signbit.c │ ├── sue.c │ ├── sysdep1.h0 │ ├── system_.c │ ├── typesize.c │ ├── uio.c │ ├── uninit.c │ ├── util.c │ ├── wref.c │ ├── wrtfmt.c │ ├── wsfe.c │ ├── wsle.c │ ├── wsne.c │ ├── xwsne.c │ ├── z_abs.c │ ├── z_cos.c │ ├── z_div.c │ ├── z_exp.c │ ├── z_log.c │ ├── z_sin.c │ └── z_sqrt.c ├── getopt │ ├── getopt.c │ ├── getopt.h │ ├── getopt.vcproj │ └── queue.h ├── imagelib │ ├── Makefile │ ├── affine.c │ ├── affine.h │ ├── binimage.c │ ├── binimage.h │ ├── binvolume.c │ ├── binvolume.h │ ├── bmp.c │ ├── bmp.h │ ├── canny.c │ ├── canny.h │ ├── color.c │ ├── color.h │ ├── defines.h │ ├── dmap-io.h │ ├── fileio.c │ ├── fileio.h │ ├── filter.c │ ├── filter.h │ ├── fit.c │ ├── fit.h │ ├── fmatrix.c │ ├── fmatrix.h │ ├── homography.c │ ├── homography.h │ ├── horn.c │ ├── horn.h │ ├── image.c │ ├── image.h │ ├── imagelib.vcproj │ ├── lerp.c │ ├── lerp.h │ ├── morphology.c │ ├── morphology.h │ ├── pad.h │ ├── pgm.c │ ├── pgm.h │ ├── poly.c │ ├── poly.h │ ├── pyramid-io.c │ ├── pyramid-io.h │ ├── pyramid.c │ ├── pyramid.h │ ├── qsort.c │ ├── qsort.h │ ├── resample.c │ ├── resample.h │ ├── tps.c │ ├── tps.h │ ├── transform-opt.c │ ├── transform-opt.h │ ├── transform.c │ ├── transform.h │ ├── transform3D.c │ ├── transform3D.h │ ├── triangle.c │ ├── triangle.h │ ├── triangulate.c │ ├── triangulate.h │ ├── util.c │ ├── util.h │ ├── vanish.c │ └── vanish.h ├── jpeg │ ├── jpeg.vcproj │ └── src │ │ ├── jcapimin.c │ │ ├── jcapistd.c │ │ ├── jccoefct.c │ │ ├── jccolor.c │ │ ├── jcdctmgr.c │ │ ├── jchuff.c │ │ ├── jchuff.h │ │ ├── jcinit.c │ │ ├── jcmainct.c │ │ ├── jcmarker.c │ │ ├── jcmaster.c │ │ ├── jcomapi.c │ │ ├── jconfig.h │ │ ├── jcparam.c │ │ ├── jcphuff.c │ │ ├── jcprepct.c │ │ ├── jcsample.c │ │ ├── jctrans.c │ │ ├── jdapimin.c │ │ ├── jdapistd.c │ │ ├── jdatadst.c │ │ ├── jdatasrc.c │ │ ├── jdcoefct.c │ │ ├── jdcolor.c │ │ ├── jdct.h │ │ ├── jddctmgr.c │ │ ├── jdhuff.c │ │ ├── jdhuff.h │ │ ├── jdinput.c │ │ ├── jdmainct.c │ │ ├── jdmarker.c │ │ ├── jdmaster.c │ │ ├── jdmerge.c │ │ ├── jdphuff.c │ │ ├── jdpostct.c │ │ ├── jdsample.c │ │ ├── jdtrans.c │ │ ├── jerror.c │ │ ├── jerror.h │ │ ├── jfdctflt.c │ │ ├── jfdctfst.c │ │ ├── jfdctint.c │ │ ├── jidctflt.c │ │ ├── jidctfst.c │ │ ├── jidctint.c │ │ ├── jidctred.c │ │ ├── jinclude.h │ │ ├── jmemmgr.c │ │ ├── jmemnobs.c │ │ ├── jmemsys.h │ │ ├── jmorecfg.h │ │ ├── jpegint.h │ │ ├── jpeglib.h │ │ ├── jquant1.c │ │ ├── jquant2.c │ │ ├── jutils.c │ │ └── jversion.h ├── matrix │ ├── Makefile │ ├── matrix.c │ ├── matrix.h │ ├── matrix.vcproj │ ├── svd.c │ ├── svd.h │ ├── vector.c │ └── vector.h ├── minpack │ ├── Makefile │ ├── dpmpar.f │ ├── enorm.f │ ├── fdjac2.f │ ├── lmdif.f │ ├── lmdif1.f │ ├── lmpar.f │ ├── qrfac.f │ └── qrsolv.f ├── sba-1.5 │ ├── Makefile │ ├── compiler.h │ ├── sba-1.5.vcproj │ ├── sba.h │ ├── sba_chkjac.c │ ├── sba_chkjac.h │ ├── sba_crsm.c │ ├── sba_lapack.c │ ├── sba_levmar.c │ └── sba_levmar_wrap.c ├── sfm-driver │ ├── Makefile │ ├── sfm-driver.vcproj │ ├── sfm.c │ └── sfm.h └── zlib │ ├── include │ ├── zconf.h │ └── zlib.h │ ├── lib │ ├── zlib-bcc.lib │ ├── zlib.def │ └── zlib.lib │ └── manifest │ ├── zlib-1.2.3-lib.mft │ └── zlib-1.2.3-lib.ver ├── src ├── BaseApp.cpp ├── BaseApp.h ├── BaseGeometry.cpp ├── BoundingBox.cpp ├── BoundingBox.h ├── BruteForceSearch.cpp ├── BruteForceSearch.h ├── Bundle.cpp ├── Bundle.h ├── Bundle2PMVS.cpp ├── Bundle2Ply.cpp ├── Bundle2Vis.cpp ├── BundleAdd.cpp ├── BundleAdd.h ├── BundleCeres.cpp ├── BundleFast.cpp ├── BundleIO.cpp ├── BundleTwo.cpp ├── BundleUtil.cpp ├── BundleUtil.h ├── BundlerApp.cpp ├── BundlerApp.h ├── BundlerGeometry.cpp ├── Camera.cpp ├── Camera.h ├── ComputeTracks.cpp ├── CreateMatchScript.cpp ├── Decompose.cpp ├── Decompose.h ├── Distortion.cpp ├── Distortion.h ├── Epipolar.cpp ├── Epipolar.h ├── FisheyeUndistort.cpp ├── Geometry.cpp ├── Geometry.h ├── ImageData.cpp ├── ImageData.h ├── KeyMatch.cpp ├── KeyMatchFull.cpp ├── LinkDirection.h ├── LoadJPEG.cpp ├── LoadJPEG.h ├── Makefile ├── MatchTracks.cpp ├── ParameterBound.h ├── ProcessBundle.cpp ├── RadialUndistort.cpp ├── Register.cpp ├── Register.h ├── RelativePose.cpp ├── TwoFrameModel.cpp ├── TwoFrameModel.h ├── keys.cpp ├── keys.h ├── keys2a.cpp └── keys2a.h ├── utils └── bundler.py └── vc++ ├── Bundle2PMVS.vcproj ├── Bundler.sln ├── Bundler.vcproj ├── KeyMatchFull.vcproj └── RadialUndistort.vcproj /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source and libraries 2 | *.o 3 | *.a 4 | *.so 5 | *.dll 6 | *.exe 7 | 8 | # emacs temp files 9 | *~ 10 | 11 | # Compiled binaries and temporary library files 12 | bin/Bundle2PMVS 13 | bin/Bundle2Ply 14 | bin/Bundle2Vis 15 | bin/KeyMatchFull 16 | bin/RadialUndistort 17 | bin/FisheyeUndistort 18 | bin/bundler 19 | lib/ann_1.1_char/lib 20 | lib/f2c/arith.h 21 | lib/f2c/signal1.h 22 | lib/f2c/sysdep1.h 23 | src/Bundle2PMVS 24 | src/Bundle2Ply 25 | src/Bundle2Vis 26 | src/KeyMatchFull 27 | src/RadialUndistort 28 | src/FisheyeUndistort 29 | src/bundler 30 | 31 | # Binaries we depend on 32 | bin/sift 33 | 34 | # misc 35 | list_keys.txt 36 | list_tmp.txt 37 | options.txt 38 | sift.txt 39 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | 2013-12-29 Noah Snavely 2 | 3 | * Added support for Ceres solver 4 | * Cleaning up the code a bit 5 | 6 | 7 | 2010-04-03 Noah Snavely 8 | 9 | * Upgrade to v0.4 10 | * Removed reference implementations of LAPACK and BLAS due to 11 | bugs in 64-bit version 12 | * Updated Bundle2PMVS to work with new version of PMVS 13 | * Updated RadialUndistort (note that you now must specify an 14 | * output directory) 15 | * Added Bundle2Vis tool 16 | 17 | 18 | 2009-05-04 Noah Snavely 19 | 20 | * Upgrade to v0.3 21 | * Added Visual Studio project files 22 | * Added reference implementations of required libs: LAPACK, BLAS, 23 | MINPACK, CBLAS, f2c, etc. 24 | * Several bug fixes 25 | * Added Bundle2PMVS utility program 26 | * Cleaner Makefiles and scripts (thanks to Bart van Andel) 27 | 28 | 29 | 2008-10-08 Noah Snavely 30 | 31 | * Upgrade to v0.2 32 | * Mainly code refactoring 33 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #----------------------------------------------------------------------------- 2 | # Top level makefile for Bundler 3 | # 4 | # Bundler: Structure from Motion for Unordered Photo Collections 5 | # Version: 0.4 04/03/2010 6 | # http://phototour.cs.washington.edu/bundler/ 7 | #----------------------------------------------------------------------------- 8 | # Copyright (c) 2008-2010 University of Washington and Noah Snavely 9 | # All Rights Reserved. 10 | #----------------------------------------------------------------------------- 11 | 12 | ANN_TARGET = linux-g++-shared 13 | 14 | OS = $(shell uname -o) 15 | ifeq ($(OS), Cygwin) 16 | ANN_TARGET = win32-g++-shared 17 | endif 18 | 19 | default: 20 | # Make libraries 21 | cd lib/5point; $(MAKE) 22 | cd lib/ann_1.1_char; $(MAKE) $(ANN_TARGET) 23 | cd lib/imagelib; $(MAKE) 24 | cd lib/matrix; $(MAKE) 25 | cd lib/sba-1.5; $(MAKE) 26 | cd lib/sfm-driver; $(MAKE) 27 | # Auxiliary libraries 28 | cd lib/minpack; $(MAKE) 29 | cd lib/cblas; $(MAKE) 30 | cd lib/f2c; $(MAKE) 31 | # Main program 32 | cd src; $(MAKE) 33 | 34 | 35 | clean: 36 | cd lib/5point; $(MAKE) clean 37 | cd lib/ann_1.1_char; $(MAKE) clean 38 | cd lib/imagelib; $(MAKE) clean 39 | cd lib/matrix; $(MAKE) clean 40 | cd lib/sba-1.5; $(MAKE) clean 41 | cd lib/sfm-driver; $(MAKE) clean 42 | cd lib/minpack; $(MAKE) clean 43 | cd lib/cblas; $(MAKE) clean 44 | cd lib/f2c; $(MAKE) clean 45 | cd src; $(MAKE) clean 46 | rm -f bin/bundler bin/KeyMatchFull bin/Bundle2PMVS bin/Bundle2Vis bin/RadialUndistort 47 | rm -f lib/*.a 48 | -------------------------------------------------------------------------------- /bin/ToSift.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # ToSift.sh 4 | # Create a script for extracting sift features from a set of images 5 | 6 | # Set this variable to your base install path (e.g., /home/foo/bundler) 7 | BIN_PATH=$(dirname $(which $0)); 8 | 9 | IMAGE_DIR="." 10 | 11 | if [ $# -eq 1 ] 12 | then 13 | IMAGE_DIR=$1 14 | fi 15 | 16 | OS=`uname -o` 17 | 18 | if [ $OS == "Cygwin" ] 19 | then 20 | SIFT=$BIN_PATH/siftWin32.exe 21 | else 22 | SIFT=$BIN_PATH/sift 23 | fi 24 | 25 | if ! [ -e $SIFT ] ; then 26 | echo "[ToSift] Error: SIFT not found. Please install SIFT to $BIN_PATH" > /dev/stderr 27 | exit 1 28 | fi 29 | 30 | for d in `ls -1 $IMAGE_DIR | egrep "jpg$"` 31 | do 32 | pgm_file=$IMAGE_DIR/`echo $d | sed 's/jpg$/pgm/'` 33 | key_file=$IMAGE_DIR/`echo $d | sed 's/jpg$/key/'` 34 | echo "mogrify -format pgm $IMAGE_DIR/$d; $SIFT < $pgm_file > $key_file; rm $pgm_file; gzip -f $key_file" 35 | done 36 | -------------------------------------------------------------------------------- /bin/ToSiftList.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # ToSiftList.sh 4 | # Create a script for extracting sift features from a list of images 5 | 6 | # Set this variable to your base install path (e.g., /home/foo/bundler) 7 | BIN_PATH=$(dirname $(which $0)); 8 | 9 | if [ $# -ne 1 ] 10 | then 11 | echo "Usage: ToSiftList.sh " 12 | exit; 13 | fi 14 | 15 | OS=`uname -o` 16 | 17 | if [ $OS == "Cygwin" ] 18 | then 19 | SIFT=$BIN_PATH/siftWin32.exe 20 | else 21 | SIFT=$BIN_PATH/sift 22 | fi 23 | 24 | if ! [ -e $SIFT ] ; then 25 | echo "[ToSiftList] Error: SIFT not found. Please install SIFT to $BIN_PATH" > /dev/stderr 26 | exit 1 27 | fi 28 | 29 | IMAGE_LIST=$1 30 | 31 | awk "{pgm = \$1; key = \$1; sub(\"jpg\$\", \"pgm\", pgm); sub(\"jpg\$\", \"key\", key); print \"/usr/bin/mogrify -format pgm \" \$1 \"; $SIFT < \" pgm \" > \" key \"; gzip -f \" key \"; rm \" pgm}" $IMAGE_LIST 32 | -------------------------------------------------------------------------------- /bin/zlib1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/bin/zlib1.dll -------------------------------------------------------------------------------- /examples/ET/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | clean: 4 | rm -f *.key.gz 5 | rm -f *.txt 6 | rm -rf bundle 7 | rm *~ 8 | -------------------------------------------------------------------------------- /examples/ET/bundler.config.example: -------------------------------------------------------------------------------- 1 | # This file is a sample configuration file for the RunBundler.sh script 2 | # To use this configuration file, you would run 3 | # 4 | # ../../RunBundler.sh bundler.config.example 5 | # 6 | # See RunBundler.sh for a full list of configuration options 7 | 8 | # USE_CERES=true # if uncommented, would enable the use of Ceres solver 9 | # # (assuming you have installed it and compiled it into 10 | # # bundler -- see src/Makefile) 11 | -------------------------------------------------------------------------------- /examples/ET/et000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/ET/et000.jpg -------------------------------------------------------------------------------- /examples/ET/et001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/ET/et001.jpg -------------------------------------------------------------------------------- /examples/ET/et002.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/ET/et002.jpg -------------------------------------------------------------------------------- /examples/ET/et003.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/ET/et003.jpg -------------------------------------------------------------------------------- /examples/ET/et004.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/ET/et004.jpg -------------------------------------------------------------------------------- /examples/ET/et005.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/ET/et005.jpg -------------------------------------------------------------------------------- /examples/ET/et006.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/ET/et006.jpg -------------------------------------------------------------------------------- /examples/ET/et007.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/ET/et007.jpg -------------------------------------------------------------------------------- /examples/ET/et008.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/ET/et008.jpg -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | clean: 2 | rm *~ 3 | cd ET; $(MAKE) clean 4 | cd kermit; $(MAKE) clean 5 | -------------------------------------------------------------------------------- /examples/kermit/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | clean: 4 | rm -f *.key.gz 5 | rm -f *.txt 6 | rm -rf bundle 7 | rm *~ 8 | -------------------------------------------------------------------------------- /examples/kermit/bundler.config.example: -------------------------------------------------------------------------------- 1 | # This file is a sample configuration file for the RunBundler.sh script 2 | # To use this configuration file, you would run 3 | # 4 | # ../../RunBundler.sh bundler.config.example 5 | # 6 | # See RunBundler.sh for a full list of configuration options 7 | 8 | # USE_CERES=true # if uncommented, would enable the use of Ceres solver 9 | # # (assuming you have installed it and compiled it into 10 | # # bundler -- see src/Makefile) 11 | -------------------------------------------------------------------------------- /examples/kermit/kermit000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/kermit/kermit000.jpg -------------------------------------------------------------------------------- /examples/kermit/kermit001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/kermit/kermit001.jpg -------------------------------------------------------------------------------- /examples/kermit/kermit002.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/kermit/kermit002.jpg -------------------------------------------------------------------------------- /examples/kermit/kermit003.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/kermit/kermit003.jpg -------------------------------------------------------------------------------- /examples/kermit/kermit004.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/kermit/kermit004.jpg -------------------------------------------------------------------------------- /examples/kermit/kermit005.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/kermit/kermit005.jpg -------------------------------------------------------------------------------- /examples/kermit/kermit006.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/kermit/kermit006.jpg -------------------------------------------------------------------------------- /examples/kermit/kermit007.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/kermit/kermit007.jpg -------------------------------------------------------------------------------- /examples/kermit/kermit008.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/kermit/kermit008.jpg -------------------------------------------------------------------------------- /examples/kermit/kermit009.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/kermit/kermit009.jpg -------------------------------------------------------------------------------- /examples/kermit/kermit010.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/examples/kermit/kermit010.jpg -------------------------------------------------------------------------------- /include/cblas.h: -------------------------------------------------------------------------------- 1 | /* cblas.h */ 2 | /* cblas headers */ 3 | 4 | #ifndef __CBLAS_H__ 5 | #define __CBLAS_H__ 6 | 7 | #define CBLAS_INDEX size_t /* this may vary between platforms */ 8 | 9 | typedef enum { 10 | CblasRowMajor=101, CblasColMajor=102 11 | } CBLAS_ORDER; 12 | 13 | typedef enum { 14 | CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113 15 | } CBLAS_TRANSPOSE; 16 | 17 | typedef enum { 18 | CblasUpper=121, CblasLower=122 19 | } CBLAS_UPLO; 20 | 21 | typedef enum { 22 | CblasNonUnit=131, CblasUnit=132 23 | } CBLAS_DIAG; 24 | 25 | typedef enum { 26 | CblasLeft=141, CblasRight=142 27 | } CBLAS_SIDE; 28 | 29 | void cblas_dgemm(const CBLAS_ORDER Order, const CBLAS_TRANSPOSE TransA, 30 | const CBLAS_TRANSPOSE TransB, 31 | const int M, const int N, 32 | const int K, const double alpha, const double *A, 33 | const int lda, const double *B, const int ldb, 34 | const double beta, double *C, const int ldc); 35 | 36 | #endif /* __CBLAS_H__ */ 37 | -------------------------------------------------------------------------------- /include/lapack.h: -------------------------------------------------------------------------------- 1 | #ifndef __lapack_h__ 2 | #define __lapack_h__ 3 | 4 | /* Routines for inverting matrices */ 5 | void dgetrf_(int *m, int *n, double *A, int *lda, int *ipiv, int *info); 6 | void dgetri_(int *n, double *A, int *lda, int *ipiv, double *work, 7 | int *lwork, int *info); 8 | 9 | /* Routines for computing the least-squares solution to Ax = b */ 10 | void dgelss_(int *m, int *n, int *nrhs, double *A, int *lda, double *b, int *ldb, 11 | double *s, double *rcond, int *rank, double *work, int *lwork, int *info); 12 | void dgelsy_(int *m, int *n, int *nrhs, double *A, int *lda, double *b, int *ldb, 13 | int *jpvt, double *rcond, int *rank, double *work, int *lwork, int *info); 14 | 15 | void dgesv_(int *n, int *nrhs, double *A, int *lda, int *ipiv, double *b, 16 | int *ldb, int *info); 17 | 18 | void dgetrs_(char *trans, int *n, int *nrhs, double *A, int *lda, int *ipiv, 19 | double *b, int *ldb, int *info); 20 | 21 | /* Routine for computing the eigenvalues / eigenvectors of a matrix */ 22 | void dgeev_(char *jobvl, char *jobvr, int *n, double *A, int *lda, double *wr, double *wi, 23 | double *vl, int *ldvl, double *vr, int *ldvr, double *work, int *lwork, 24 | int *info); 25 | 26 | /* Routine for singular value decomposition */ 27 | void dgesvd_(char *jobu, char *jobvt, int *m, int *n, double *A, int *lda, 28 | double *S, double *U, int *ldu, double *VT, int *ldvt, 29 | double *work, int *lwork, int *info); 30 | 31 | /* Routine for Cholesky decomposition */ 32 | void dpotrf_(char *uplo, int *n, double *A, int *lda, int *info); 33 | 34 | /* Routine for QR factorization */ 35 | void dgeqrf_(int *m, int *n, double *A, int *lda, double *tau, double *work, 36 | int *lwork, int *info); 37 | 38 | /* Routine for RQ factorization */ 39 | void dgerqf_(int *m, int *n, double *A, int *lda, double *tau, double *work, 40 | int *lwork, int *info); 41 | 42 | #endif /* __lapack_h__ */ 43 | -------------------------------------------------------------------------------- /include/minpack.h: -------------------------------------------------------------------------------- 1 | /* minpack.h */ 2 | /* Prototypes for FORTRAN minpack routines */ 3 | 4 | #ifndef __minpack_h__ 5 | #define __minpack_h__ 6 | 7 | void lmdif1_(void *fcn, const int *m, const int *n, double *x, double *fvec, 8 | double *tol, int *info, int *iwa, double *wa, const int *lwa); 9 | 10 | void lmdif_(void *fcn, int *m, int *n, double *x, double *fvec, double *ftol, 11 | double *xtol, double *gtol, int *maxfev, double *epsfcn, double *diag, 12 | int *mode, double *factor, int *nprint, int *info, int *nfev, double *fjac, 13 | int *ldfjac, int *ipvt, double *qtf, double *wa1, double *wa2, double *wa3, 14 | double *wa4); 15 | 16 | #endif /* __minpack_h__ */ 17 | -------------------------------------------------------------------------------- /include/types.h: -------------------------------------------------------------------------------- 1 | #ifndef __my_types_h__ 2 | 3 | typedef unsigned char u_int8_t; 4 | typedef unsigned short u_int16_t; 5 | typedef unsigned long u_int32_t; 6 | typedef signed long int32_t; 7 | 8 | typedef signed short int16_t; 9 | 10 | #endif /* __my_types_h__ */ 11 | 12 | -------------------------------------------------------------------------------- /lib/5point/5point.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* 5point.h */ 18 | /* Solve the 5-point relative pose problem */ 19 | 20 | #ifndef __5POINT_H__ 21 | #define __5POINT_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "vector.h" 28 | 29 | int compute_pose_ransac(int n, v2_t *r_pts, v2_t *l_pts, 30 | double *K1, double *K2, 31 | double ransac_threshold, int ransac_rounds, 32 | double *R_out, double *t_out); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif /* __5POINT_H__ */ 39 | -------------------------------------------------------------------------------- /lib/5point/Makefile: -------------------------------------------------------------------------------- 1 | # 5point library makefile 2 | 3 | LIB = lib5point.a 4 | 5 | TARGET = $(LIB) 6 | OBJS = 5point.o poly1.o poly3.o 7 | 8 | CC=gcc 9 | OPTFLAGS=-O3 10 | OTHERFLAGS=-Wall 11 | 12 | MATRIX_PATH=../matrix 13 | IMAGELIB_PATH=../imagelib 14 | 15 | CPPFLAGS = $(OTHERFLAGS) $(OPTFLAGS) -I$(MATRIX_PATH) -I$(IMAGELIB_PATH) 16 | 17 | all: $(TARGET) 18 | 19 | $(TARGET): $(OBJS) 20 | ar r $@ $(OBJS) 21 | cp $@ .. 22 | 23 | clean: 24 | rm -f $(TARGET) *.o *~ 25 | -------------------------------------------------------------------------------- /lib/5point/poly1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* poly1.h */ 18 | /* 10-degree polynomial in one variable */ 19 | 20 | #ifndef __POLY1_H__ 21 | #define __POLY1_H__ 22 | 23 | #define MAX_DEGREE 10 24 | 25 | typedef struct { 26 | double v[MAX_DEGREE+1]; 27 | } poly1_t; 28 | 29 | poly1_t poly1_new3(double a, double b, double c, double d); 30 | poly1_t poly1_new4(double a, double b, double c, double d, double e); 31 | poly1_t poly1_add(poly1_t a, poly1_t b); 32 | poly1_t poly1_add3(poly1_t a, poly1_t b, poly1_t c); 33 | poly1_t poly1_sub(poly1_t a, poly1_t b); 34 | poly1_t poly1_mult(poly1_t a, poly1_t b); 35 | poly1_t poly1_scale(poly1_t a, double scale); 36 | poly1_t poly1_normalize(poly1_t a); 37 | 38 | double poly1_eval(poly1_t a, double x); 39 | 40 | #endif /* __POLY1_H__ */ 41 | -------------------------------------------------------------------------------- /lib/5point/poly3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* poly3.h */ 18 | /* 3-variable polynomial functions */ 19 | 20 | #ifndef __POLY3_H__ 21 | #define __POLY3_H__ 22 | 23 | typedef enum { 24 | POLY3_UNIT, 25 | POLY3_X, POLY3_Y, POLY3_Z, 26 | POLY3_XY, POLY3_XZ, POLY3_YZ, 27 | POLY3_X2, POLY3_Y2, POLY3_Z2, 28 | POLY3_X2Y, POLY3_X2Z, POLY3_XY2, POLY3_Y2Z, POLY3_XZ2, POLY3_YZ2, POLY3_XYZ, 29 | POLY3_X3, POLY3_Y3, POLY3_Z3, 30 | NUM_POLY3_COEFFS 31 | } poly3_coeff_t; 32 | 33 | typedef struct { 34 | double v[NUM_POLY3_COEFFS]; 35 | } poly3_t; 36 | 37 | poly3_t poly3_new(double x, double y, double z, double unit); 38 | poly3_t poly3_add(poly3_t a, poly3_t b); 39 | poly3_t poly3_add3(poly3_t a, poly3_t b, poly3_t c); 40 | poly3_t poly3_sub(poly3_t a, poly3_t b); 41 | poly3_t poly3_mult(poly3_t a, poly3_t b); 42 | poly3_t poly3_mult11(poly3_t a, poly3_t b); 43 | poly3_t poly3_mult21(poly3_t a, poly3_t b); 44 | poly3_t poly3_scale(poly3_t a, double scale); 45 | double poly3_eval(poly3_t a, double x, double y, double z); 46 | double poly3_get(poly3_t a, poly3_coeff_t idx); 47 | 48 | #endif /* __POLY3_H__ */ 49 | -------------------------------------------------------------------------------- /lib/ann_1.1_char/Copyright.txt: -------------------------------------------------------------------------------- 1 | ANN: Approximate Nearest Neighbors 2 | Version: 1.1 3 | Release Date: May 3, 2005 4 | ---------------------------------------------------------------------------- 5 | Copyright (c) 1997-2005 University of Maryland and Sunil Arya and David 6 | Mount All Rights Reserved. 7 | 8 | This program is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU Lesser Public License as published by the 10 | Free Software Foundation; either version 2.1 of the License, or (at your 11 | option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser Public License for more details. 17 | 18 | A copy of the terms and conditions of the license can be found in 19 | License.txt or online at 20 | 21 | http://www.gnu.org/copyleft/lesser.html 22 | 23 | To obtain a copy, write to the Free Software Foundation, Inc., 24 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 25 | 26 | Disclaimer 27 | ---------- 28 | The University of Maryland and the authors make no representations about 29 | the suitability or fitness of this software for any purpose. It is 30 | provided "as is" without express or implied warranty. 31 | --------------------------------------------------------------------- 32 | 33 | Authors 34 | ------- 35 | David Mount 36 | Dept of Computer Science 37 | University of Maryland, 38 | College Park, MD 20742 USA 39 | mount@cs.umd.edu 40 | http://www.cs.umd.edu/~mount/ 41 | 42 | Sunil Arya 43 | Dept of Computer Science 44 | Hong University of Science and Technology 45 | Clearwater Bay, HONG KONG 46 | arya@cs.ust.hk 47 | http://www.cs.ust.hk/faculty/arya/ 48 | -------------------------------------------------------------------------------- /lib/ann_1.1_char/doc/ANNmanual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/lib/ann_1.1_char/doc/ANNmanual.pdf -------------------------------------------------------------------------------- /lib/ann_1.1_char/sample/data.pts: -------------------------------------------------------------------------------- 1 | -0.297462 0.176102 2 | 0.565538 -0.361496 3 | 0.909313 -0.182785 4 | 0.920712 0.478408 5 | 0.167682 0.0499836 6 | 0.305223 -0.0805835 7 | 0.114973 0.882453 8 | 0.742916 0.16376 9 | 0.0724605 -0.826775 10 | 0.690960 -0.559284 11 | 0.188485 -0.643934 12 | 0.749427 -0.942415 13 | -0.970662 -0.223466 14 | 0.916110 0.879597 15 | 0.927417 -0.382593 16 | -0.711327 0.278713 17 | -0.519172 0.986146 18 | 0.135338 0.924588 19 | -0.0837537 0.61687 20 | 0.0520465 0.896306 21 | -------------------------------------------------------------------------------- /lib/ann_1.1_char/sample/query.pts: -------------------------------------------------------------------------------- 1 | 0.0902484 -0.207129 2 | -0.419567 0.485743 3 | 0.826225 -0.30962 4 | 0.694758 0.987088 5 | -0.410807 -0.465182 6 | -0.836501 0.490184 7 | 0.588289 0.656408 8 | 0.325807 0.38721 9 | -0.532226 -0.727036 10 | -0.52506 -0.853508 11 | -------------------------------------------------------------------------------- /lib/ann_1.1_char/sample/sample.save: -------------------------------------------------------------------------------- 1 | Data Points: 2 | (-0.297462, 0.176102) 3 | (0.565538, -0.361496) 4 | (0.909313, -0.182785) 5 | (0.920712, 0.478408) 6 | (0.167682, 0.0499836) 7 | (0.305223, -0.0805835) 8 | (0.114973, 0.882453) 9 | (0.742916, 0.16376) 10 | (0.0724605, -0.826775) 11 | (0.69096, -0.559284) 12 | (0.188485, -0.643934) 13 | (0.749427, -0.942415) 14 | (-0.970662, -0.223466) 15 | (0.91611, 0.879597) 16 | (0.927417, -0.382593) 17 | (-0.711327, 0.278713) 18 | (-0.519172, 0.986146) 19 | (0.135338, 0.924588) 20 | (-0.0837537, 0.61687) 21 | (0.0520465, 0.896306) 22 | Query point: (0.0902484, -0.207129) 23 | NN: Index Distance 24 | 0 5 0.249455 25 | Query point: (-0.419567, 0.485743) 26 | NN: Index Distance 27 | 0 0 0.332847 28 | Query point: (0.826225, -0.30962) 29 | NN: Index Distance 30 | 0 14 0.124759 31 | Query point: (0.694758, 0.987088) 32 | NN: Index Distance 33 | 0 13 0.246071 34 | Query point: (-0.410807, -0.465182) 35 | NN: Index Distance 36 | 0 8 0.60357 37 | Query point: (-0.836501, 0.490184) 38 | NN: Index Distance 39 | 0 15 0.245741 40 | Query point: (0.588289, 0.656408) 41 | NN: Index Distance 42 | 0 3 0.37708 43 | Query point: (0.325807, 0.38721) 44 | NN: Index Distance 45 | 0 4 0.372458 46 | Query point: (-0.532226, -0.727036) 47 | NN: Index Distance 48 | 0 8 0.612857 49 | Query point: (-0.52506, -0.853508) 50 | NN: Index Distance 51 | 0 8 0.598118 52 | -------------------------------------------------------------------------------- /lib/ann_1.1_char/src/kd_fix_rad_search.h: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------- 2 | // File: kd_fix_rad_search.h 3 | // Programmer: Sunil Arya and David Mount 4 | // Description: Standard kd-tree fixed-radius kNN search 5 | // Last modified: ??/??/?? (Version 1.1) 6 | //---------------------------------------------------------------------- 7 | // Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 8 | // David Mount. All Rights Reserved. 9 | // 10 | // This software and related documentation is part of the Approximate 11 | // Nearest Neighbor Library (ANN). This software is provided under 12 | // the provisions of the Lesser GNU Public License (LGPL). See the 13 | // file ../ReadMe.txt for further information. 14 | // 15 | // The University of Maryland (U.M.) and the authors make no 16 | // representations about the suitability or fitness of this software for 17 | // any purpose. It is provided "as is" without express or implied 18 | // warranty. 19 | //---------------------------------------------------------------------- 20 | // History: 21 | // Revision 1.1 ??/??/?? 22 | // Initial release 23 | //---------------------------------------------------------------------- 24 | 25 | #ifndef ANN_kd_fix_rad_search_H 26 | #define ANN_kd_fix_rad_search_H 27 | 28 | #include "kd_tree.h" // kd-tree declarations 29 | #include "kd_util.h" // kd-tree utilities 30 | #include "pr_queue_k.h" // k-element priority queue 31 | 32 | #include // performance evaluation 33 | 34 | namespace ann_1_1_char 35 | { 36 | 37 | //---------------------------------------------------------------------- 38 | // Global variables 39 | // These are active for the life of each call to 40 | // annRangeSearch(). They are set to save the number of 41 | // variables that need to be passed among the various search 42 | // procedures. 43 | //---------------------------------------------------------------------- 44 | 45 | extern ANNpoint ANNkdFRQ; // query point (static copy) 46 | 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /lib/ann_1.1_char/test/test1-data.pts: -------------------------------------------------------------------------------- 1 | -0.297462 0.176102 2 | 0.565538 -0.361496 3 | 0.909313 -0.182785 4 | 0.920712 0.478408 5 | 0.167682 0.0499836 6 | 0.305223 -0.0805835 7 | 0.114973 0.882453 8 | 0.742916 0.16376 9 | 0.0724605 -0.826775 10 | 0.690960 -0.559284 11 | 0.188485 -0.643934 12 | 0.749427 -0.942415 13 | -0.970662 -0.223466 14 | 0.916110 0.879597 15 | 0.927417 -0.382593 16 | -0.711327 0.278713 17 | -0.519172 0.986146 18 | 0.135338 0.924588 19 | -0.0837537 0.61687 20 | 0.0520465 0.896306 21 | -------------------------------------------------------------------------------- /lib/ann_1.1_char/test/test1-query.pts: -------------------------------------------------------------------------------- 1 | 0.0902484 -0.207129 2 | -0.419567 0.485743 3 | 0.826225 -0.30962 4 | 0.694758 0.987088 5 | -0.410807 -0.465182 6 | -0.836501 0.490184 7 | 0.588289 0.656408 8 | 0.325807 0.38721 9 | -0.532226 -0.727036 10 | -0.52506 -0.853508 11 | -------------------------------------------------------------------------------- /lib/ann_1.1_char/test/test1.in: -------------------------------------------------------------------------------- 1 | validate on 2 | stats query_stats 3 | dim 2 4 | data_size 20 5 | query_size 10 6 | read_data_pts test1-data.pts 7 | read_query_pts test1-query.pts 8 | bucket_size 1 9 | near_neigh 3 10 | split_rule suggest 11 | shrink_rule none 12 | build_ann 13 | epsilon 0.0 14 | run_queries standard 15 | run_queries priority 16 | -------------------------------------------------------------------------------- /lib/ann_1.1_char/test/test2.in: -------------------------------------------------------------------------------- 1 | validate on 2 | stats query_stats 3 | dim 8 4 | data_size 5000 5 | read_data_pts test2-data.pts 6 | query_size 100 7 | read_query_pts test2-query.pts 8 | bucket_size 1 9 | near_neigh 3 10 | split_rule suggest 11 | shrink_rule none 12 | build_ann 13 | epsilon 0.0 14 | run_queries standard 15 | run_queries priority 16 | epsilon 0.10 17 | run_queries standard 18 | run_queries priority 19 | epsilon 0.50 20 | run_queries standard 21 | run_queries priority 22 | -------------------------------------------------------------------------------- /lib/cblas/Makefile: -------------------------------------------------------------------------------- 1 | # This Makefile compiles the CBLAS routines 2 | # 3 | CC=gcc 4 | CFLAGS = -O3 -DADD_ 5 | FFLAGS = -O3 6 | 7 | all: libcblas.a 8 | 9 | errhand = cblas_globals.o cblas_xerbla.o xerbla.o 10 | 11 | # 12 | # All object files for double real precision 13 | # 14 | dlev3 = cblas_dgemm.o 15 | 16 | # 17 | # Make an archive file 18 | # 19 | 20 | .SUFFIXES: .o .c .f 21 | 22 | .c.o: 23 | $(CC) $(CFLAGS) $(INC) -c $*.c 24 | .f.o: 25 | $(FC) $(FFLAGS) -c $*.f 26 | 27 | libcblas.a: $(dlev3) $(errhand) 28 | $(AR) rs $@ $(dlev3) $(errhand) 29 | cp $@ ../ 30 | 31 | # 32 | # Erase all object and archive files 33 | # 34 | clean: 35 | rm -f *.o *~ 36 | 37 | -------------------------------------------------------------------------------- /lib/cblas/cblas_globals.c: -------------------------------------------------------------------------------- 1 | int CBLAS_CallFromC=0; 2 | int RowMajorStrg=0; 3 | -------------------------------------------------------------------------------- /lib/cblas/xerbla.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "cblas.h" 4 | #include "cblas_f77.h" 5 | 6 | #define XerblaStrLen 6 7 | #define XerblaStrLen1 7 8 | 9 | #ifdef F77_CHAR 10 | void F77_xerbla(F77_CHAR F77_srname, void *vinfo) 11 | #else 12 | void F77_xerbla(char *srname, void *vinfo) 13 | #endif 14 | 15 | { 16 | #ifdef F77_CHAR 17 | char *srname; 18 | #endif 19 | 20 | char rout[] = {'c','b','l','a','s','_','\0','\0','\0','\0','\0','\0','\0'}; 21 | 22 | #ifdef F77_INT 23 | F77_INT *info=vinfo; 24 | F77_INT i; 25 | #else 26 | int *info=vinfo; 27 | int i; 28 | #endif 29 | 30 | extern int CBLAS_CallFromC; 31 | 32 | #ifdef F77_CHAR 33 | srname = F2C_STR(F77_srname, XerblaStrLen); 34 | #endif 35 | 36 | if (CBLAS_CallFromC) 37 | { 38 | for(i=0; i != XerblaStrLen; i++) rout[i+6] = tolower(srname[i]); 39 | rout[XerblaStrLen+6] = '\0'; 40 | cblas_xerbla(*info+1,rout,""); 41 | } 42 | else 43 | { 44 | fprintf(stderr, "Parameter %d to routine %s was incorrect\n", 45 | *info, srname); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/clapack/BLAS/SRC/dcabs1.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | doublereal dcabs1_(doublecomplex *z__) 5 | { 6 | /* System generated locals */ 7 | doublereal ret_val, d__1, d__2; 8 | 9 | /* Builtin functions */ 10 | double d_imag(doublecomplex *); 11 | 12 | /* .. Scalar Arguments .. */ 13 | /* .. */ 14 | /* .. */ 15 | /* Purpose */ 16 | /* ======= */ 17 | 18 | /* DCABS1 computes absolute value of a double complex number */ 19 | 20 | /* .. Intrinsic Functions .. */ 21 | 22 | ret_val = (d__1 = z__->r, abs(d__1)) + (d__2 = d_imag(z__), abs(d__2)); 23 | return ret_val; 24 | } /* dcabs1_ */ 25 | -------------------------------------------------------------------------------- /lib/clapack/BLAS/SRC/drot.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | /* Subroutine */ int drot_(integer *n, doublereal *dx, integer *incx, 5 | doublereal *dy, integer *incy, doublereal *c__, doublereal *s) 6 | { 7 | /* System generated locals */ 8 | integer i__1; 9 | 10 | /* Local variables */ 11 | integer i__, ix, iy; 12 | doublereal dtemp; 13 | 14 | /* .. Scalar Arguments .. */ 15 | /* .. */ 16 | /* .. Array Arguments .. */ 17 | /* .. */ 18 | 19 | /* Purpose */ 20 | /* ======= */ 21 | 22 | /* applies a plane rotation. */ 23 | /* jack dongarra, linpack, 3/11/78. */ 24 | /* modified 12/3/93, array(1) declarations changed to array(*) */ 25 | 26 | 27 | /* .. Local Scalars .. */ 28 | /* .. */ 29 | /* Parameter adjustments */ 30 | --dy; 31 | --dx; 32 | 33 | /* Function Body */ 34 | if (*n <= 0) { 35 | return 0; 36 | } 37 | if (*incx == 1 && *incy == 1) { 38 | goto L20; 39 | } 40 | 41 | /* code for unequal increments or equal increments not equal */ 42 | /* to 1 */ 43 | 44 | ix = 1; 45 | iy = 1; 46 | if (*incx < 0) { 47 | ix = (-(*n) + 1) * *incx + 1; 48 | } 49 | if (*incy < 0) { 50 | iy = (-(*n) + 1) * *incy + 1; 51 | } 52 | i__1 = *n; 53 | for (i__ = 1; i__ <= i__1; ++i__) { 54 | dtemp = *c__ * dx[ix] + *s * dy[iy]; 55 | dy[iy] = *c__ * dy[iy] - *s * dx[ix]; 56 | dx[ix] = dtemp; 57 | ix += *incx; 58 | iy += *incy; 59 | /* L10: */ 60 | } 61 | return 0; 62 | 63 | /* code for both increments equal to 1 */ 64 | 65 | L20: 66 | i__1 = *n; 67 | for (i__ = 1; i__ <= i__1; ++i__) { 68 | dtemp = *c__ * dx[i__] + *s * dy[i__]; 69 | dy[i__] = *c__ * dy[i__] - *s * dx[i__]; 70 | dx[i__] = dtemp; 71 | /* L30: */ 72 | } 73 | return 0; 74 | } /* drot_ */ 75 | -------------------------------------------------------------------------------- /lib/clapack/BLAS/SRC/drotg.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | /* Table of constant values */ 5 | 6 | static doublereal c_b4 = 1.; 7 | 8 | /* Subroutine */ int drotg_(doublereal *da, doublereal *db, doublereal *c__, 9 | doublereal *s) 10 | { 11 | /* System generated locals */ 12 | doublereal d__1, d__2; 13 | 14 | /* Builtin functions */ 15 | double sqrt(doublereal), d_sign(doublereal *, doublereal *); 16 | 17 | /* Local variables */ 18 | doublereal r__, z__, roe, scale; 19 | 20 | /* .. Scalar Arguments .. */ 21 | /* .. */ 22 | 23 | /* Purpose */ 24 | /* ======= */ 25 | 26 | /* construct givens plane rotation. */ 27 | /* jack dongarra, linpack, 3/11/78. */ 28 | 29 | 30 | /* .. Local Scalars .. */ 31 | /* .. */ 32 | /* .. Intrinsic Functions .. */ 33 | /* .. */ 34 | roe = *db; 35 | if (abs(*da) > abs(*db)) { 36 | roe = *da; 37 | } 38 | scale = abs(*da) + abs(*db); 39 | if (scale != 0.) { 40 | goto L10; 41 | } 42 | *c__ = 1.; 43 | *s = 0.; 44 | r__ = 0.; 45 | z__ = 0.; 46 | goto L20; 47 | L10: 48 | /* Computing 2nd power */ 49 | d__1 = *da / scale; 50 | /* Computing 2nd power */ 51 | d__2 = *db / scale; 52 | r__ = scale * sqrt(d__1 * d__1 + d__2 * d__2); 53 | r__ = d_sign(&c_b4, &roe) * r__; 54 | *c__ = *da / r__; 55 | *s = *db / r__; 56 | z__ = 1.; 57 | if (abs(*da) > abs(*db)) { 58 | z__ = *s; 59 | } 60 | if (abs(*db) >= abs(*da) && *c__ != 0.) { 61 | z__ = 1. / *c__; 62 | } 63 | L20: 64 | *da = r__; 65 | *db = z__; 66 | return 0; 67 | } /* drotg_ */ 68 | -------------------------------------------------------------------------------- /lib/clapack/BLAS/SRC/dzasum.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | doublereal dzasum_(integer *n, doublecomplex *zx, integer *incx) 5 | { 6 | /* System generated locals */ 7 | integer i__1; 8 | doublereal ret_val; 9 | 10 | /* Local variables */ 11 | integer i__, ix; 12 | doublereal stemp; 13 | extern doublereal dcabs1_(doublecomplex *); 14 | 15 | /* .. Scalar Arguments .. */ 16 | /* .. */ 17 | /* .. Array Arguments .. */ 18 | /* .. */ 19 | 20 | /* Purpose */ 21 | /* ======= */ 22 | 23 | /* takes the sum of the absolute values. */ 24 | /* jack dongarra, 3/11/78. */ 25 | /* modified 3/93 to return if incx .le. 0. */ 26 | /* modified 12/3/93, array(1) declarations changed to array(*) */ 27 | 28 | 29 | /* .. Local Scalars .. */ 30 | /* .. */ 31 | /* .. External Functions .. */ 32 | /* .. */ 33 | /* Parameter adjustments */ 34 | --zx; 35 | 36 | /* Function Body */ 37 | ret_val = 0.; 38 | stemp = 0.; 39 | if (*n <= 0 || *incx <= 0) { 40 | return ret_val; 41 | } 42 | if (*incx == 1) { 43 | goto L20; 44 | } 45 | 46 | /* code for increment not equal to 1 */ 47 | 48 | ix = 1; 49 | i__1 = *n; 50 | for (i__ = 1; i__ <= i__1; ++i__) { 51 | stemp += dcabs1_(&zx[ix]); 52 | ix += *incx; 53 | /* L10: */ 54 | } 55 | ret_val = stemp; 56 | return ret_val; 57 | 58 | /* code for increment equal to 1 */ 59 | 60 | L20: 61 | i__1 = *n; 62 | for (i__ = 1; i__ <= i__1; ++i__) { 63 | stemp += dcabs1_(&zx[i__]); 64 | /* L30: */ 65 | } 66 | ret_val = stemp; 67 | return ret_val; 68 | } /* dzasum_ */ 69 | -------------------------------------------------------------------------------- /lib/clapack/BLAS/SRC/icamax.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | integer icamax_(integer *n, complex *cx, integer *incx) 5 | { 6 | /* System generated locals */ 7 | integer ret_val, i__1; 8 | 9 | /* Local variables */ 10 | integer i__, ix; 11 | real smax; 12 | extern doublereal scabs1_(complex *); 13 | 14 | /* .. Scalar Arguments .. */ 15 | /* .. */ 16 | /* .. Array Arguments .. */ 17 | /* .. */ 18 | 19 | /* Purpose */ 20 | /* ======= */ 21 | 22 | /* finds the index of element having max. absolute value. */ 23 | /* jack dongarra, linpack, 3/11/78. */ 24 | /* modified 3/93 to return if incx .le. 0. */ 25 | /* modified 12/3/93, array(1) declarations changed to array(*) */ 26 | 27 | 28 | /* .. Local Scalars .. */ 29 | /* .. */ 30 | /* .. External Functions .. */ 31 | /* .. */ 32 | /* Parameter adjustments */ 33 | --cx; 34 | 35 | /* Function Body */ 36 | ret_val = 0; 37 | if (*n < 1 || *incx <= 0) { 38 | return ret_val; 39 | } 40 | ret_val = 1; 41 | if (*n == 1) { 42 | return ret_val; 43 | } 44 | if (*incx == 1) { 45 | goto L20; 46 | } 47 | 48 | /* code for increment not equal to 1 */ 49 | 50 | ix = 1; 51 | smax = scabs1_(&cx[1]); 52 | ix += *incx; 53 | i__1 = *n; 54 | for (i__ = 2; i__ <= i__1; ++i__) { 55 | if (scabs1_(&cx[ix]) <= smax) { 56 | goto L5; 57 | } 58 | ret_val = i__; 59 | smax = scabs1_(&cx[ix]); 60 | L5: 61 | ix += *incx; 62 | /* L10: */ 63 | } 64 | return ret_val; 65 | 66 | /* code for increment equal to 1 */ 67 | 68 | L20: 69 | smax = scabs1_(&cx[1]); 70 | i__1 = *n; 71 | for (i__ = 2; i__ <= i__1; ++i__) { 72 | if (scabs1_(&cx[i__]) <= smax) { 73 | goto L30; 74 | } 75 | ret_val = i__; 76 | smax = scabs1_(&cx[i__]); 77 | L30: 78 | ; 79 | } 80 | return ret_val; 81 | } /* icamax_ */ 82 | -------------------------------------------------------------------------------- /lib/clapack/BLAS/SRC/idamax.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | integer idamax_(integer *n, doublereal *dx, integer *incx) 5 | { 6 | /* System generated locals */ 7 | integer ret_val, i__1; 8 | doublereal d__1; 9 | 10 | /* Local variables */ 11 | integer i__, ix; 12 | doublereal dmax__; 13 | 14 | /* .. Scalar Arguments .. */ 15 | /* .. */ 16 | /* .. Array Arguments .. */ 17 | /* .. */ 18 | 19 | /* Purpose */ 20 | /* ======= */ 21 | 22 | /* finds the index of element having max. absolute value. */ 23 | /* jack dongarra, linpack, 3/11/78. */ 24 | /* modified 3/93 to return if incx .le. 0. */ 25 | /* modified 12/3/93, array(1) declarations changed to array(*) */ 26 | 27 | 28 | /* .. Local Scalars .. */ 29 | /* .. */ 30 | /* .. Intrinsic Functions .. */ 31 | /* .. */ 32 | /* Parameter adjustments */ 33 | --dx; 34 | 35 | /* Function Body */ 36 | ret_val = 0; 37 | if (*n < 1 || *incx <= 0) { 38 | return ret_val; 39 | } 40 | ret_val = 1; 41 | if (*n == 1) { 42 | return ret_val; 43 | } 44 | if (*incx == 1) { 45 | goto L20; 46 | } 47 | 48 | /* code for increment not equal to 1 */ 49 | 50 | ix = 1; 51 | dmax__ = abs(dx[1]); 52 | ix += *incx; 53 | i__1 = *n; 54 | for (i__ = 2; i__ <= i__1; ++i__) { 55 | if ((d__1 = dx[ix], abs(d__1)) <= dmax__) { 56 | goto L5; 57 | } 58 | ret_val = i__; 59 | dmax__ = (d__1 = dx[ix], abs(d__1)); 60 | L5: 61 | ix += *incx; 62 | /* L10: */ 63 | } 64 | return ret_val; 65 | 66 | /* code for increment equal to 1 */ 67 | 68 | L20: 69 | dmax__ = abs(dx[1]); 70 | i__1 = *n; 71 | for (i__ = 2; i__ <= i__1; ++i__) { 72 | if ((d__1 = dx[i__], abs(d__1)) <= dmax__) { 73 | goto L30; 74 | } 75 | ret_val = i__; 76 | dmax__ = (d__1 = dx[i__], abs(d__1)); 77 | L30: 78 | ; 79 | } 80 | return ret_val; 81 | } /* idamax_ */ 82 | -------------------------------------------------------------------------------- /lib/clapack/BLAS/SRC/isamax.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | integer isamax_(integer *n, real *sx, integer *incx) 5 | { 6 | /* System generated locals */ 7 | integer ret_val, i__1; 8 | real r__1; 9 | 10 | /* Local variables */ 11 | integer i__, ix; 12 | real smax; 13 | 14 | /* .. Scalar Arguments .. */ 15 | /* .. */ 16 | /* .. Array Arguments .. */ 17 | /* .. */ 18 | 19 | /* Purpose */ 20 | /* ======= */ 21 | 22 | /* finds the index of element having max. absolute value. */ 23 | /* jack dongarra, linpack, 3/11/78. */ 24 | /* modified 3/93 to return if incx .le. 0. */ 25 | /* modified 12/3/93, array(1) declarations changed to array(*) */ 26 | 27 | 28 | /* .. Local Scalars .. */ 29 | /* .. */ 30 | /* .. Intrinsic Functions .. */ 31 | /* .. */ 32 | /* Parameter adjustments */ 33 | --sx; 34 | 35 | /* Function Body */ 36 | ret_val = 0; 37 | if (*n < 1 || *incx <= 0) { 38 | return ret_val; 39 | } 40 | ret_val = 1; 41 | if (*n == 1) { 42 | return ret_val; 43 | } 44 | if (*incx == 1) { 45 | goto L20; 46 | } 47 | 48 | /* code for increment not equal to 1 */ 49 | 50 | ix = 1; 51 | smax = dabs(sx[1]); 52 | ix += *incx; 53 | i__1 = *n; 54 | for (i__ = 2; i__ <= i__1; ++i__) { 55 | if ((r__1 = sx[ix], dabs(r__1)) <= smax) { 56 | goto L5; 57 | } 58 | ret_val = i__; 59 | smax = (r__1 = sx[ix], dabs(r__1)); 60 | L5: 61 | ix += *incx; 62 | /* L10: */ 63 | } 64 | return ret_val; 65 | 66 | /* code for increment equal to 1 */ 67 | 68 | L20: 69 | smax = dabs(sx[1]); 70 | i__1 = *n; 71 | for (i__ = 2; i__ <= i__1; ++i__) { 72 | if ((r__1 = sx[i__], dabs(r__1)) <= smax) { 73 | goto L30; 74 | } 75 | ret_val = i__; 76 | smax = (r__1 = sx[i__], dabs(r__1)); 77 | L30: 78 | ; 79 | } 80 | return ret_val; 81 | } /* isamax_ */ 82 | -------------------------------------------------------------------------------- /lib/clapack/BLAS/SRC/izamax.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | integer izamax_(integer *n, doublecomplex *zx, integer *incx) 5 | { 6 | /* System generated locals */ 7 | integer ret_val, i__1; 8 | 9 | /* Local variables */ 10 | integer i__, ix; 11 | doublereal smax; 12 | extern doublereal dcabs1_(doublecomplex *); 13 | 14 | /* .. Scalar Arguments .. */ 15 | /* .. */ 16 | /* .. Array Arguments .. */ 17 | /* .. */ 18 | 19 | /* Purpose */ 20 | /* ======= */ 21 | 22 | /* finds the index of element having max. absolute value. */ 23 | /* jack dongarra, 1/15/85. */ 24 | /* modified 3/93 to return if incx .le. 0. */ 25 | /* modified 12/3/93, array(1) declarations changed to array(*) */ 26 | 27 | 28 | /* .. Local Scalars .. */ 29 | /* .. */ 30 | /* .. External Functions .. */ 31 | /* .. */ 32 | /* Parameter adjustments */ 33 | --zx; 34 | 35 | /* Function Body */ 36 | ret_val = 0; 37 | if (*n < 1 || *incx <= 0) { 38 | return ret_val; 39 | } 40 | ret_val = 1; 41 | if (*n == 1) { 42 | return ret_val; 43 | } 44 | if (*incx == 1) { 45 | goto L20; 46 | } 47 | 48 | /* code for increment not equal to 1 */ 49 | 50 | ix = 1; 51 | smax = dcabs1_(&zx[1]); 52 | ix += *incx; 53 | i__1 = *n; 54 | for (i__ = 2; i__ <= i__1; ++i__) { 55 | if (dcabs1_(&zx[ix]) <= smax) { 56 | goto L5; 57 | } 58 | ret_val = i__; 59 | smax = dcabs1_(&zx[ix]); 60 | L5: 61 | ix += *incx; 62 | /* L10: */ 63 | } 64 | return ret_val; 65 | 66 | /* code for increment equal to 1 */ 67 | 68 | L20: 69 | smax = dcabs1_(&zx[1]); 70 | i__1 = *n; 71 | for (i__ = 2; i__ <= i__1; ++i__) { 72 | if (dcabs1_(&zx[i__]) <= smax) { 73 | goto L30; 74 | } 75 | ret_val = i__; 76 | smax = dcabs1_(&zx[i__]); 77 | L30: 78 | ; 79 | } 80 | return ret_val; 81 | } /* izamax_ */ 82 | -------------------------------------------------------------------------------- /lib/clapack/BLAS/SRC/xerbla.c: -------------------------------------------------------------------------------- 1 | #include "blaswrap.h" 2 | #include "stdio.h" 3 | #include "f2c.h" 4 | 5 | /* Subroutine */ int xerbla_(char *srname, integer *info) 6 | { 7 | /* -- LAPACK auxiliary routine (version 2.0) -- 8 | Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., 9 | Courant Institute, Argonne National Lab, and Rice University 10 | September 30, 1994 11 | 12 | 13 | Purpose 14 | ======= 15 | 16 | XERBLA is an error handler for the LAPACK routines. 17 | It is called by an LAPACK routine if an input parameter has an 18 | invalid value. A message is printed and execution stops. 19 | 20 | Installers may consider modifying the STOP statement in order to 21 | call system-specific exception-handling facilities. 22 | 23 | Arguments 24 | ========= 25 | 26 | SRNAME (input) CHARACTER*6 27 | The name of the routine which called XERBLA. 28 | 29 | INFO (input) INTEGER 30 | The position of the invalid parameter in the parameter list 31 | 32 | of the calling routine. 33 | 34 | ===================================================================== 35 | */ 36 | 37 | printf("** On entry to %6s, parameter number %2i had an illegal value\n", 38 | srname, *info); 39 | 40 | /* End of XERBLA */ 41 | 42 | return 0; 43 | } /* xerbla_ */ 44 | 45 | -------------------------------------------------------------------------------- /lib/clapack/INSTALL/LAPACK_version.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | /* Table of constant values */ 5 | 6 | static integer c__9 = 9; 7 | static integer c__1 = 1; 8 | static integer c__3 = 3; 9 | 10 | /* Main program */ int MAIN__(void) 11 | { 12 | /* Builtin functions */ 13 | integer s_wsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), 14 | e_wsle(void); 15 | 16 | /* Local variables */ 17 | integer patch, major, minor; 18 | extern /* Subroutine */ int ilaver_(integer *, integer *, integer *); 19 | 20 | /* Fortran I/O blocks */ 21 | static cilist io___4 = { 0, 6, 0, 0, 0 }; 22 | 23 | 24 | 25 | 26 | 27 | 28 | ilaver_(&major, &minor, &patch); 29 | s_wsle(&io___4); 30 | do_lio(&c__9, &c__1, "LAPACK ", (ftnlen)7); 31 | do_lio(&c__3, &c__1, (char *)&major, (ftnlen)sizeof(integer)); 32 | do_lio(&c__9, &c__1, ".", (ftnlen)1); 33 | do_lio(&c__3, &c__1, (char *)&minor, (ftnlen)sizeof(integer)); 34 | do_lio(&c__9, &c__1, ".", (ftnlen)1); 35 | do_lio(&c__3, &c__1, (char *)&patch, (ftnlen)sizeof(integer)); 36 | e_wsle(); 37 | 38 | return 0; 39 | } /* MAIN__ */ 40 | 41 | /* Main program alias */ int lapack_version__ () { MAIN__ (); return 0; } 42 | -------------------------------------------------------------------------------- /lib/clapack/INSTALL/dsecnd.c: -------------------------------------------------------------------------------- 1 | #include "blaswrap.h" 2 | #include "f2c.h" 3 | // #include 4 | // #include 5 | #include 6 | 7 | #ifndef CLK_TCK 8 | #define CLK_TCK 60 9 | #endif 10 | 11 | doublereal dsecnd_() 12 | { 13 | struct tms rusage; 14 | 15 | times(&rusage); 16 | return (doublereal)(rusage.tms_utime) / CLK_TCK; 17 | 18 | } /* dsecnd_ */ 19 | 20 | -------------------------------------------------------------------------------- /lib/clapack/INSTALL/ilaver.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | /* Subroutine */ int ilaver_(integer *vers_major__, integer *vers_minor__, 5 | integer *vers_patch__) 6 | { 7 | 8 | /* -- LAPACK routine (version 3.1.1) -- */ 9 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 10 | /* January 2007 */ 11 | 12 | /* .. Scalar Arguments .. */ 13 | /* .. */ 14 | 15 | /* Purpose */ 16 | /* ======= */ 17 | 18 | /* This subroutine return the Lapack version. */ 19 | 20 | /* Arguments */ 21 | /* ========= */ 22 | 23 | /* VERS_MAJOR (output) INTEGER */ 24 | /* return the lapack major version */ 25 | /* VERS_MINOR (output) INTEGER */ 26 | /* return the lapack minor version from the major version */ 27 | /* VERS_PATCH (output) INTEGER */ 28 | /* return the lapack patch version from the minor version */ 29 | 30 | /* .. Executable Statements .. */ 31 | 32 | *vers_major__ = 3; 33 | *vers_minor__ = 1; 34 | *vers_patch__ = 1; 35 | /* ===================================================================== */ 36 | 37 | return 0; 38 | } /* ilaver_ */ 39 | -------------------------------------------------------------------------------- /lib/clapack/INSTALL/second.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include 3 | #include 4 | #include 5 | 6 | #ifndef CLK_TCK 7 | #define CLK_TCK 60 8 | #endif 9 | 10 | doublereal second_() 11 | { 12 | struct tms rusage; 13 | 14 | times(&rusage); 15 | return (doublereal)(rusage.tms_utime) / CLK_TCK; 16 | 17 | } /* second_ */ 18 | 19 | -------------------------------------------------------------------------------- /lib/clapack/SRC/disnan.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | logical disnan_(doublereal *din) 5 | { 6 | /* System generated locals */ 7 | logical ret_val; 8 | 9 | /* Local variables */ 10 | extern logical dlaisnan_(doublereal *, doublereal *); 11 | 12 | 13 | /* -- LAPACK auxiliary routine (version 3.1) -- */ 14 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 15 | /* November 2006 */ 16 | 17 | /* .. Scalar Arguments .. */ 18 | /* .. */ 19 | 20 | /* Purpose */ 21 | /* ======= */ 22 | 23 | /* DISNAN returns .TRUE. if its argument is NaN, and .FALSE. */ 24 | /* otherwise. To be replaced by the Fortran 2003 intrinsic in the */ 25 | /* future. */ 26 | 27 | /* Arguments */ 28 | /* ========= */ 29 | 30 | /* DIN (input) DOUBLE PRECISION */ 31 | /* Input to test for NaN. */ 32 | 33 | /* ===================================================================== */ 34 | 35 | /* .. External Functions .. */ 36 | /* .. */ 37 | /* .. Executable Statements .. */ 38 | ret_val = dlaisnan_(din, din); 39 | return ret_val; 40 | } /* disnan_ */ 41 | -------------------------------------------------------------------------------- /lib/clapack/SRC/dladiv.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | /* Subroutine */ int dladiv_(doublereal *a, doublereal *b, doublereal *c__, 5 | doublereal *d__, doublereal *p, doublereal *q) 6 | { 7 | doublereal e, f; 8 | 9 | 10 | /* -- LAPACK auxiliary routine (version 3.1) -- */ 11 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 12 | /* November 2006 */ 13 | 14 | /* .. Scalar Arguments .. */ 15 | /* .. */ 16 | 17 | /* Purpose */ 18 | /* ======= */ 19 | 20 | /* DLADIV performs complex division in real arithmetic */ 21 | 22 | /* a + i*b */ 23 | /* p + i*q = --------- */ 24 | /* c + i*d */ 25 | 26 | /* The algorithm is due to Robert L. Smith and can be found */ 27 | /* in D. Knuth, The art of Computer Programming, Vol.2, p.195 */ 28 | 29 | /* Arguments */ 30 | /* ========= */ 31 | 32 | /* A (input) DOUBLE PRECISION */ 33 | /* B (input) DOUBLE PRECISION */ 34 | /* C (input) DOUBLE PRECISION */ 35 | /* D (input) DOUBLE PRECISION */ 36 | /* The scalars a, b, c, and d in the above expression. */ 37 | 38 | /* P (output) DOUBLE PRECISION */ 39 | /* Q (output) DOUBLE PRECISION */ 40 | /* The scalars p and q in the above expression. */ 41 | 42 | /* ===================================================================== */ 43 | 44 | /* .. Local Scalars .. */ 45 | /* .. */ 46 | /* .. Intrinsic Functions .. */ 47 | /* .. */ 48 | /* .. Executable Statements .. */ 49 | 50 | if (abs(*d__) < abs(*c__)) { 51 | e = *d__ / *c__; 52 | f = *c__ + *d__ * e; 53 | *p = (*a + *b * e) / f; 54 | *q = (*b - *a * e) / f; 55 | } else { 56 | e = *c__ / *d__; 57 | f = *d__ + *c__ * e; 58 | *p = (*b + *a * e) / f; 59 | *q = (-(*a) + *b * e) / f; 60 | } 61 | 62 | return 0; 63 | 64 | /* End of DLADIV */ 65 | 66 | } /* dladiv_ */ 67 | -------------------------------------------------------------------------------- /lib/clapack/SRC/dlaisnan.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | logical dlaisnan_(doublereal *din1, doublereal *din2) 5 | { 6 | /* System generated locals */ 7 | logical ret_val; 8 | 9 | 10 | /* -- LAPACK auxiliary routine (version 3.1) -- */ 11 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 12 | /* November 2006 */ 13 | 14 | /* .. Scalar Arguments .. */ 15 | /* .. */ 16 | 17 | /* Purpose */ 18 | /* ======= */ 19 | 20 | /* This routine is not for general use. It exists solely to avoid */ 21 | /* over-optimization in DISNAN. */ 22 | 23 | /* DLAISNAN checks for NaNs by comparing its two arguments for */ 24 | /* inequality. NaN is the only floating-point value where NaN != NaN */ 25 | /* returns .TRUE. To check for NaNs, pass the same variable as both */ 26 | /* arguments. */ 27 | 28 | /* Strictly speaking, Fortran does not allow aliasing of function */ 29 | /* arguments. So a compiler must assume that the two arguments are */ 30 | /* not the same variable, and the test will not be optimized away. */ 31 | /* Interprocedural or whole-program optimization may delete this */ 32 | /* test. The ISNAN functions will be replaced by the correct */ 33 | /* Fortran 03 intrinsic once the intrinsic is widely available. */ 34 | 35 | /* Arguments */ 36 | /* ========= */ 37 | 38 | /* DIN1 (input) DOUBLE PRECISION */ 39 | /* DIN2 (input) DOUBLE PRECISION */ 40 | /* Two numbers to compare for inequality. */ 41 | 42 | /* ===================================================================== */ 43 | 44 | /* .. Executable Statements .. */ 45 | ret_val = *din1 != *din2; 46 | return ret_val; 47 | } /* dlaisnan_ */ 48 | -------------------------------------------------------------------------------- /lib/clapack/SRC/dlapy2.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | doublereal dlapy2_(doublereal *x, doublereal *y) 5 | { 6 | /* System generated locals */ 7 | doublereal ret_val, d__1; 8 | 9 | /* Builtin functions */ 10 | double sqrt(doublereal); 11 | 12 | /* Local variables */ 13 | doublereal w, z__, xabs, yabs; 14 | 15 | 16 | /* -- LAPACK auxiliary routine (version 3.1) -- */ 17 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 18 | /* November 2006 */ 19 | 20 | /* .. Scalar Arguments .. */ 21 | /* .. */ 22 | 23 | /* Purpose */ 24 | /* ======= */ 25 | 26 | /* DLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary */ 27 | /* overflow. */ 28 | 29 | /* Arguments */ 30 | /* ========= */ 31 | 32 | /* X (input) DOUBLE PRECISION */ 33 | /* Y (input) DOUBLE PRECISION */ 34 | /* X and Y specify the values x and y. */ 35 | 36 | /* ===================================================================== */ 37 | 38 | /* .. Parameters .. */ 39 | /* .. */ 40 | /* .. Local Scalars .. */ 41 | /* .. */ 42 | /* .. Intrinsic Functions .. */ 43 | /* .. */ 44 | /* .. Executable Statements .. */ 45 | 46 | xabs = abs(*x); 47 | yabs = abs(*y); 48 | w = max(xabs,yabs); 49 | z__ = min(xabs,yabs); 50 | if (z__ == 0.) { 51 | ret_val = w; 52 | } else { 53 | /* Computing 2nd power */ 54 | d__1 = z__ / w; 55 | ret_val = w * sqrt(d__1 * d__1 + 1.); 56 | } 57 | return ret_val; 58 | 59 | /* End of DLAPY2 */ 60 | 61 | } /* dlapy2_ */ 62 | -------------------------------------------------------------------------------- /lib/clapack/SRC/ilaver.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "blaswrap.h" 3 | 4 | /* Subroutine */ int ilaver_(integer *vers_major__, integer *vers_minor__, 5 | integer *vers_patch__) 6 | { 7 | 8 | /* -- LAPACK routine (version 3.1.1) -- */ 9 | /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 10 | /* January 2007 */ 11 | /* .. */ 12 | 13 | /* Purpose */ 14 | /* ======= */ 15 | 16 | /* This subroutine return the Lapack version */ 17 | 18 | /* Arguments */ 19 | /* ========= */ 20 | /* VERS_MAJOR (output) INTEGER */ 21 | /* return the lapack major version */ 22 | /* VERS_MINOR (output) INTEGER */ 23 | /* return the lapack minor version from the major version */ 24 | /* VERS_PATCH (output) INTEGER */ 25 | /* return the lapack patch version from the minor version */ 26 | /* ===================================================================== */ 27 | 28 | /* ===================================================================== */ 29 | *vers_major__ = 3; 30 | *vers_minor__ = 1; 31 | *vers_patch__ = 1; 32 | /* ===================================================================== */ 33 | 34 | return 0; 35 | } /* ilaver_ */ 36 | -------------------------------------------------------------------------------- /lib/clapack/SRC/xerbla.c: -------------------------------------------------------------------------------- 1 | #include "blaswrap.h" 2 | #include "f2c.h" 3 | 4 | /* Subroutine */ int xerbla_(char *srname, integer *info) 5 | { 6 | /* -- LAPACK auxiliary routine (version 2.0) -- 7 | Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., 8 | Courant Institute, Argonne National Lab, and Rice University 9 | September 30, 1994 10 | 11 | 12 | Purpose 13 | ======= 14 | 15 | XERBLA is an error handler for the LAPACK routines. 16 | It is called by an LAPACK routine if an input parameter has an 17 | invalid value. A message is printed and execution stops. 18 | 19 | Installers may consider modifying the STOP statement in order to 20 | call system-specific exception-handling facilities. 21 | 22 | Arguments 23 | ========= 24 | 25 | SRNAME (input) CHARACTER*6 26 | The name of the routine which called XERBLA. 27 | 28 | INFO (input) INTEGER 29 | The position of the invalid parameter in the parameter list 30 | 31 | of the calling routine. 32 | 33 | ===================================================================== 34 | */ 35 | 36 | printf("** On entry to %6s, parameter number %2i had an illegal value\n", 37 | srname, *info); 38 | 39 | /* End of XERBLA */ 40 | 41 | return 0; 42 | } /* xerbla_ */ 43 | 44 | -------------------------------------------------------------------------------- /lib/f2c/abort_.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "f2c.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #ifdef KR_headers 8 | extern VOID sig_die(); 9 | 10 | int abort_() 11 | #else 12 | extern void sig_die(const char*,int); 13 | 14 | int abort_(void) 15 | #endif 16 | { 17 | sig_die("Fortran abort routine called", 1); 18 | return 0; /* not reached */ 19 | } 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /lib/f2c/backspac.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | #ifdef KR_headers 7 | integer f_back(a) alist *a; 8 | #else 9 | integer f_back(alist *a) 10 | #endif 11 | { unit *b; 12 | OFF_T v, w, x, y, z; 13 | uiolen n; 14 | FILE *f; 15 | 16 | f__curunit = b = &f__units[a->aunit]; /* curunit for error messages */ 17 | if(a->aunit >= MXUNIT || a->aunit < 0) 18 | err(a->aerr,101,"backspace") 19 | if(b->useek==0) err(a->aerr,106,"backspace") 20 | if(b->ufd == NULL) { 21 | fk_open(1, 1, a->aunit); 22 | return(0); 23 | } 24 | if(b->uend==1) 25 | { b->uend=0; 26 | return(0); 27 | } 28 | if(b->uwrt) { 29 | t_runc(a); 30 | if (f__nowreading(b)) 31 | err(a->aerr,errno,"backspace") 32 | } 33 | f = b->ufd; /* may have changed in t_runc() */ 34 | if(b->url>0) 35 | { 36 | x=FTELL(f); 37 | y = x % b->url; 38 | if(y == 0) x--; 39 | x /= b->url; 40 | x *= b->url; 41 | (void) FSEEK(f,x,SEEK_SET); 42 | return(0); 43 | } 44 | 45 | if(b->ufmt==0) 46 | { FSEEK(f,-(OFF_T)sizeof(uiolen),SEEK_CUR); 47 | fread((char *)&n,sizeof(uiolen),1,f); 48 | FSEEK(f,-(OFF_T)n-2*sizeof(uiolen),SEEK_CUR); 49 | return(0); 50 | } 51 | w = x = FTELL(f); 52 | z = 0; 53 | loop: 54 | while(x) { 55 | x -= x < 64 ? x : 64; 56 | FSEEK(f,x,SEEK_SET); 57 | for(y = x; y < w; y++) { 58 | if (getc(f) != '\n') 59 | continue; 60 | v = FTELL(f); 61 | if (v == w) { 62 | if (z) 63 | goto break2; 64 | goto loop; 65 | } 66 | z = v; 67 | } 68 | err(a->aerr,(EOF),"backspace") 69 | } 70 | break2: 71 | FSEEK(f, z, SEEK_SET); 72 | return 0; 73 | } 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | -------------------------------------------------------------------------------- /lib/f2c/c_abs.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern double f__cabs(); 8 | 9 | double c_abs(z) complex *z; 10 | #else 11 | extern double f__cabs(double, double); 12 | 13 | double c_abs(complex *z) 14 | #endif 15 | { 16 | return( f__cabs( z->r, z->i ) ); 17 | } 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /lib/f2c/c_cos.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | extern double sin(), cos(), sinh(), cosh(); 5 | 6 | VOID c_cos(r, z) complex *r, *z; 7 | #else 8 | #undef abs 9 | #include "math.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void c_cos(complex *r, complex *z) 15 | #endif 16 | { 17 | double zi = z->i, zr = z->r; 18 | r->r = cos(zr) * cosh(zi); 19 | r->i = - sin(zr) * sinh(zi); 20 | } 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /lib/f2c/c_div.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern VOID sig_die(); 8 | VOID c_div(c, a, b) 9 | complex *a, *b, *c; 10 | #else 11 | extern void sig_die(const char*,int); 12 | void c_div(complex *c, complex *a, complex *b) 13 | #endif 14 | { 15 | double ratio, den; 16 | double abr, abi, cr; 17 | 18 | if( (abr = b->r) < 0.) 19 | abr = - abr; 20 | if( (abi = b->i) < 0.) 21 | abi = - abi; 22 | if( abr <= abi ) 23 | { 24 | if(abi == 0) { 25 | #ifdef IEEE_COMPLEX_DIVIDE 26 | float af, bf; 27 | af = bf = abr; 28 | if (a->i != 0 || a->r != 0) 29 | af = 1.; 30 | c->i = c->r = af / bf; 31 | return; 32 | #else 33 | sig_die("complex division by zero", 1); 34 | #endif 35 | } 36 | ratio = (double)b->r / b->i ; 37 | den = b->i * (1 + ratio*ratio); 38 | cr = (a->r*ratio + a->i) / den; 39 | c->i = (a->i*ratio - a->r) / den; 40 | } 41 | 42 | else 43 | { 44 | ratio = (double)b->i / b->r ; 45 | den = b->r * (1 + ratio*ratio); 46 | cr = (a->r + a->i*ratio) / den; 47 | c->i = (a->i - a->r*ratio) / den; 48 | } 49 | c->r = cr; 50 | } 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /lib/f2c/c_exp.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | extern double exp(), cos(), sin(); 5 | 6 | VOID c_exp(r, z) complex *r, *z; 7 | #else 8 | #undef abs 9 | #include "math.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void c_exp(complex *r, complex *z) 15 | #endif 16 | { 17 | double expx, zi = z->i; 18 | 19 | expx = exp(z->r); 20 | r->r = expx * cos(zi); 21 | r->i = expx * sin(zi); 22 | } 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /lib/f2c/c_log.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | extern double log(), f__cabs(), atan2(); 5 | VOID c_log(r, z) complex *r, *z; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | extern double f__cabs(double, double); 13 | 14 | void c_log(complex *r, complex *z) 15 | #endif 16 | { 17 | double zi, zr; 18 | r->i = atan2(zi = z->i, zr = z->r); 19 | r->r = log( f__cabs(zr, zi) ); 20 | } 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /lib/f2c/c_sin.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | extern double sin(), cos(), sinh(), cosh(); 5 | 6 | VOID c_sin(r, z) complex *r, *z; 7 | #else 8 | #undef abs 9 | #include "math.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void c_sin(complex *r, complex *z) 15 | #endif 16 | { 17 | double zi = z->i, zr = z->r; 18 | r->r = sin(zr) * cosh(zi); 19 | r->i = cos(zr) * sinh(zi); 20 | } 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /lib/f2c/c_sqrt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | extern double sqrt(), f__cabs(); 5 | 6 | VOID c_sqrt(r, z) complex *r, *z; 7 | #else 8 | #undef abs 9 | #include "math.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | extern double f__cabs(double, double); 14 | 15 | void c_sqrt(complex *r, complex *z) 16 | #endif 17 | { 18 | double mag, t; 19 | double zi = z->i, zr = z->r; 20 | 21 | if( (mag = f__cabs(zr, zi)) == 0.) 22 | r->r = r->i = 0.; 23 | else if(zr > 0) 24 | { 25 | r->r = t = sqrt(0.5 * (mag + zr) ); 26 | t = zi / t; 27 | r->i = 0.5 * t; 28 | } 29 | else 30 | { 31 | t = sqrt(0.5 * (mag - zr) ); 32 | if(zi < 0) 33 | t = -t; 34 | r->i = t; 35 | t = zi / t; 36 | r->r = 0.5 * t; 37 | } 38 | } 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /lib/f2c/cabs.c: -------------------------------------------------------------------------------- 1 | #ifdef KR_headers 2 | extern double sqrt(); 3 | double f__cabs(real, imag) double real, imag; 4 | #else 5 | #undef abs 6 | #include "math.h" 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | double f__cabs(double real, double imag) 11 | #endif 12 | { 13 | double temp; 14 | 15 | if(real < 0) 16 | real = -real; 17 | if(imag < 0) 18 | imag = -imag; 19 | if(imag > real){ 20 | temp = real; 21 | real = imag; 22 | imag = temp; 23 | } 24 | if((real+imag) == real) 25 | return(real); 26 | 27 | temp = imag/real; 28 | temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/ 29 | return(temp); 30 | } 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /lib/f2c/close.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef KR_headers 4 | integer f_clos(a) cllist *a; 5 | #else 6 | #undef abs 7 | #undef min 8 | #undef max 9 | #include "stdlib.h" 10 | #ifdef NON_UNIX_STDIO 11 | #ifndef unlink 12 | #define unlink remove 13 | #endif 14 | #else 15 | #ifdef WIN32 16 | #include "io.h" 17 | #else 18 | #ifdef __cplusplus 19 | extern "C" int unlink(const char*); 20 | #else 21 | extern int unlink(const char*); 22 | #endif 23 | #endif 24 | #endif 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | integer f_clos(cllist *a) 31 | #endif 32 | { unit *b; 33 | 34 | if(a->cunit >= MXUNIT) return(0); 35 | b= &f__units[a->cunit]; 36 | if(b->ufd==NULL) 37 | goto done; 38 | if (b->uscrtch == 1) 39 | goto Delete; 40 | if (!a->csta) 41 | goto Keep; 42 | switch(*a->csta) { 43 | default: 44 | Keep: 45 | case 'k': 46 | case 'K': 47 | if(b->uwrt == 1) 48 | t_runc((alist *)a); 49 | if(b->ufnm) { 50 | fclose(b->ufd); 51 | free(b->ufnm); 52 | } 53 | break; 54 | case 'd': 55 | case 'D': 56 | Delete: 57 | fclose(b->ufd); 58 | if(b->ufnm) { 59 | unlink(b->ufnm); /*SYSDEP*/ 60 | free(b->ufnm); 61 | } 62 | } 63 | b->ufd=NULL; 64 | done: 65 | b->uend=0; 66 | b->ufnm=NULL; 67 | return(0); 68 | } 69 | void 70 | #ifdef KR_headers 71 | f_exit() 72 | #else 73 | f_exit(void) 74 | #endif 75 | { int i; 76 | static cllist xx; 77 | if (!xx.cerr) { 78 | xx.cerr=1; 79 | xx.csta=NULL; 80 | for(i=0;i 5 | #else /*{*/ 6 | #ifndef My_ctype_DEF 7 | extern char My_ctype[]; 8 | #else /*{*/ 9 | char My_ctype[264] = { 10 | 0, 0, 0, 0, 0, 0, 0, 0, 11 | 0, 0, 0, 0, 0, 0, 0, 0, 12 | 0, 2, 2, 2, 2, 2, 0, 0, 13 | 0, 0, 0, 0, 0, 0, 0, 0, 14 | 0, 0, 0, 0, 0, 0, 0, 0, 15 | 2, 0, 0, 0, 0, 0, 0, 0, 16 | 0, 0, 0, 0, 0, 0, 0, 0, 17 | 1, 1, 1, 1, 1, 1, 1, 1, 18 | 1, 1, 0, 0, 0, 0, 0, 0, 19 | 0, 0, 0, 0, 0, 0, 0, 0, 20 | 0, 0, 0, 0, 0, 0, 0, 0, 21 | 0, 0, 0, 0, 0, 0, 0, 0, 22 | 0, 0, 0, 0, 0, 0, 0, 0, 23 | 0, 0, 0, 0, 0, 0, 0, 0, 24 | 0, 0, 0, 0, 0, 0, 0, 0, 25 | 0, 0, 0, 0, 0, 0, 0, 0, 26 | 0, 0, 0, 0, 0, 0, 0, 0, 27 | 0, 0, 0, 0, 0, 0, 0, 0, 28 | 0, 0, 0, 0, 0, 0, 0, 0, 29 | 0, 0, 0, 0, 0, 0, 0, 0, 30 | 0, 0, 0, 0, 0, 0, 0, 0, 31 | 0, 0, 0, 0, 0, 0, 0, 0, 32 | 0, 0, 0, 0, 0, 0, 0, 0, 33 | 0, 0, 0, 0, 0, 0, 0, 0, 34 | 0, 0, 0, 0, 0, 0, 0, 0, 35 | 0, 0, 0, 0, 0, 0, 0, 0, 36 | 0, 0, 0, 0, 0, 0, 0, 0, 37 | 0, 0, 0, 0, 0, 0, 0, 0, 38 | 0, 0, 0, 0, 0, 0, 0, 0, 39 | 0, 0, 0, 0, 0, 0, 0, 0, 40 | 0, 0, 0, 0, 0, 0, 0, 0, 41 | 0, 0, 0, 0, 0, 0, 0, 0, 42 | 0, 0, 0, 0, 0, 0, 0, 0}; 43 | #endif /*}*/ 44 | 45 | #define isdigit(x) (My_ctype[(x)+8] & 1) 46 | #define isspace(x) (My_ctype[(x)+8] & 2) 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/f2c/d_abs.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double d_abs(x) doublereal *x; 8 | #else 9 | double d_abs(doublereal *x) 10 | #endif 11 | { 12 | if(*x >= 0) 13 | return(*x); 14 | return(- *x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/d_acos.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double acos(); 5 | double d_acos(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_acos(doublereal *x) 13 | #endif 14 | { 15 | return( acos(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_asin.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double asin(); 5 | double d_asin(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_asin(doublereal *x) 13 | #endif 14 | { 15 | return( asin(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_atan.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double atan(); 5 | double d_atan(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_atan(doublereal *x) 13 | #endif 14 | { 15 | return( atan(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_atn2.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double atan2(); 5 | double d_atn2(x,y) doublereal *x, *y; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_atn2(doublereal *x, doublereal *y) 13 | #endif 14 | { 15 | return( atan2(*x,*y) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_cnjg.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | VOID 7 | #ifdef KR_headers 8 | d_cnjg(r, z) doublecomplex *r, *z; 9 | #else 10 | d_cnjg(doublecomplex *r, doublecomplex *z) 11 | #endif 12 | { 13 | doublereal zi = z->i; 14 | r->r = z->r; 15 | r->i = -zi; 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_cos.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double cos(); 5 | double d_cos(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_cos(doublereal *x) 13 | #endif 14 | { 15 | return( cos(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_cosh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double cosh(); 5 | double d_cosh(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_cosh(doublereal *x) 13 | #endif 14 | { 15 | return( cosh(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_dim.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double d_dim(a,b) doublereal *a, *b; 8 | #else 9 | double d_dim(doublereal *a, doublereal *b) 10 | #endif 11 | { 12 | return( *a > *b ? *a - *b : 0); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/f2c/d_exp.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double exp(); 5 | double d_exp(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_exp(doublereal *x) 13 | #endif 14 | { 15 | return( exp(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_imag.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double d_imag(z) doublecomplex *z; 8 | #else 9 | double d_imag(doublecomplex *z) 10 | #endif 11 | { 12 | return(z->i); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/f2c/d_int.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | double d_int(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_int(doublereal *x) 13 | #endif 14 | { 15 | return( (*x>0) ? floor(*x) : -floor(- *x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_lg10.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #define log10e 0.43429448190325182765 4 | 5 | #ifdef KR_headers 6 | double log(); 7 | double d_lg10(x) doublereal *x; 8 | #else 9 | #undef abs 10 | #include "math.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | double d_lg10(doublereal *x) 15 | #endif 16 | { 17 | return( log10e * log(*x) ); 18 | } 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /lib/f2c/d_log.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double log(); 5 | double d_log(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_log(doublereal *x) 13 | #endif 14 | { 15 | return( log(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_mod.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | #ifdef IEEE_drem 5 | double drem(); 6 | #else 7 | double floor(); 8 | #endif 9 | double d_mod(x,y) doublereal *x, *y; 10 | #else 11 | #ifdef IEEE_drem 12 | double drem(double, double); 13 | #else 14 | #undef abs 15 | #include "math.h" 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | #endif 20 | double d_mod(doublereal *x, doublereal *y) 21 | #endif 22 | { 23 | #ifdef IEEE_drem 24 | double xa, ya, z; 25 | if ((ya = *y) < 0.) 26 | ya = -ya; 27 | z = drem(xa = *x, ya); 28 | if (xa > 0) { 29 | if (z < 0) 30 | z += ya; 31 | } 32 | else if (z > 0) 33 | z -= ya; 34 | return z; 35 | #else 36 | double quotient; 37 | if( (quotient = *x / *y) >= 0) 38 | quotient = floor(quotient); 39 | else 40 | quotient = -floor(-quotient); 41 | return(*x - (*y) * quotient ); 42 | #endif 43 | } 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /lib/f2c/d_nint.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | double d_nint(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_nint(doublereal *x) 13 | #endif 14 | { 15 | return( (*x)>=0 ? 16 | floor(*x + .5) : -floor(.5 - *x) ); 17 | } 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /lib/f2c/d_prod.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double d_prod(x,y) real *x, *y; 8 | #else 9 | double d_prod(real *x, real *y) 10 | #endif 11 | { 12 | return( (*x) * (*y) ); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/f2c/d_sign.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double d_sign(a,b) doublereal *a, *b; 8 | #else 9 | double d_sign(doublereal *a, doublereal *b) 10 | #endif 11 | { 12 | double x; 13 | x = (*a >= 0 ? *a : - *a); 14 | return( *b >= 0 ? x : -x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/d_sin.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sin(); 5 | double d_sin(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_sin(doublereal *x) 13 | #endif 14 | { 15 | return( sin(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_sinh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sinh(); 5 | double d_sinh(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_sinh(doublereal *x) 13 | #endif 14 | { 15 | return( sinh(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_sqrt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sqrt(); 5 | double d_sqrt(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_sqrt(doublereal *x) 13 | #endif 14 | { 15 | return( sqrt(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_tan.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double tan(); 5 | double d_tan(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_tan(doublereal *x) 13 | #endif 14 | { 15 | return( tan(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/d_tanh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double tanh(); 5 | double d_tanh(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_tanh(doublereal *x) 13 | #endif 14 | { 15 | return( tanh(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/derf_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double erf(); 8 | double derf_(x) doublereal *x; 9 | #else 10 | extern double erf(double); 11 | double derf_(doublereal *x) 12 | #endif 13 | { 14 | return( erf(*x) ); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/derfc_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern double erfc(); 8 | 9 | double derfc_(x) doublereal *x; 10 | #else 11 | extern double erfc(double); 12 | 13 | double derfc_(doublereal *x) 14 | #endif 15 | { 16 | return( erfc(*x) ); 17 | } 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /lib/f2c/dolio.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | #ifdef KR_headers 10 | extern int (*f__lioproc)(); 11 | 12 | integer do_lio(type,number,ptr,len) ftnint *number,*type; char *ptr; ftnlen len; 13 | #else 14 | extern int (*f__lioproc)(ftnint*, char*, ftnlen, ftnint); 15 | 16 | integer do_lio(ftnint *type, ftnint *number, char *ptr, ftnlen len) 17 | #endif 18 | { 19 | return((*f__lioproc)(number,ptr,len,*type)); 20 | } 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /lib/f2c/dtime_.c: -------------------------------------------------------------------------------- 1 | #include "time.h" 2 | 3 | #ifdef WIN32 4 | #undef USE_CLOCK 5 | #define USE_CLOCK 6 | #endif 7 | 8 | #ifndef REAL 9 | #define REAL double 10 | #endif 11 | 12 | #ifndef USE_CLOCK 13 | #define _INCLUDE_POSIX_SOURCE /* for HP-UX */ 14 | #define _INCLUDE_XOPEN_SOURCE /* for HP-UX */ 15 | #include "sys/types.h" 16 | #include "sys/times.h" 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | #endif 21 | 22 | #undef Hz 23 | #ifdef CLK_TCK 24 | #define Hz CLK_TCK 25 | #else 26 | #ifdef HZ 27 | #define Hz HZ 28 | #else 29 | #define Hz 60 30 | #endif 31 | #endif 32 | 33 | REAL 34 | #ifdef KR_headers 35 | dtime_(tarray) float *tarray; 36 | #else 37 | dtime_(float *tarray) 38 | #endif 39 | { 40 | #ifdef USE_CLOCK 41 | #ifndef CLOCKS_PER_SECOND 42 | #define CLOCKS_PER_SECOND Hz 43 | #endif 44 | static double t0; 45 | double t = clock(); 46 | tarray[1] = 0; 47 | tarray[0] = (t - t0) / CLOCKS_PER_SECOND; 48 | t0 = t; 49 | return tarray[0]; 50 | #else 51 | struct tms t; 52 | static struct tms t0; 53 | 54 | times(&t); 55 | tarray[0] = (double)(t.tms_utime - t0.tms_utime) / Hz; 56 | tarray[1] = (double)(t.tms_stime - t0.tms_stime) / Hz; 57 | t0 = t; 58 | return tarray[0] + tarray[1]; 59 | #endif 60 | } 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | -------------------------------------------------------------------------------- /lib/f2c/due.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | int 8 | #ifdef KR_headers 9 | c_due(a) cilist *a; 10 | #else 11 | c_due(cilist *a) 12 | #endif 13 | { 14 | if(!f__init) f_init(); 15 | f__sequential=f__formatted=f__recpos=0; 16 | f__external=1; 17 | f__curunit = &f__units[a->ciunit]; 18 | if(a->ciunit>=MXUNIT || a->ciunit<0) 19 | err(a->cierr,101,"startio"); 20 | f__elist=a; 21 | if(f__curunit->ufd==NULL && fk_open(DIR,UNF,a->ciunit) ) err(a->cierr,104,"due"); 22 | f__cf=f__curunit->ufd; 23 | if(f__curunit->ufmt) err(a->cierr,102,"cdue") 24 | if(!f__curunit->useek) err(a->cierr,104,"cdue") 25 | if(f__curunit->ufd==NULL) err(a->cierr,114,"cdue") 26 | if(a->cirec <= 0) 27 | err(a->cierr,130,"due") 28 | FSEEK(f__cf,(OFF_T)(a->cirec-1)*f__curunit->url,SEEK_SET); 29 | f__curunit->uend = 0; 30 | return(0); 31 | } 32 | #ifdef KR_headers 33 | integer s_rdue(a) cilist *a; 34 | #else 35 | integer s_rdue(cilist *a) 36 | #endif 37 | { 38 | int n; 39 | f__reading=1; 40 | if(n=c_due(a)) return(n); 41 | if(f__curunit->uwrt && f__nowreading(f__curunit)) 42 | err(a->cierr,errno,"read start"); 43 | return(0); 44 | } 45 | #ifdef KR_headers 46 | integer s_wdue(a) cilist *a; 47 | #else 48 | integer s_wdue(cilist *a) 49 | #endif 50 | { 51 | int n; 52 | f__reading=0; 53 | if(n=c_due(a)) return(n); 54 | if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) 55 | err(a->cierr,errno,"write start"); 56 | return(0); 57 | } 58 | integer e_rdue(Void) 59 | { 60 | if(f__curunit->url==1 || f__recpos==f__curunit->url) 61 | return(0); 62 | FSEEK(f__cf,(OFF_T)(f__curunit->url-f__recpos),SEEK_CUR); 63 | if(FTELL(f__cf)%f__curunit->url) 64 | err(f__elist->cierr,200,"syserr"); 65 | return(0); 66 | } 67 | integer e_wdue(Void) 68 | { 69 | #ifdef ALWAYS_FLUSH 70 | if (fflush(f__cf)) 71 | err(f__elist->cierr,errno,"write end"); 72 | #endif 73 | return(e_rdue()); 74 | } 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | -------------------------------------------------------------------------------- /lib/f2c/ef1asc_.c: -------------------------------------------------------------------------------- 1 | /* EFL support routine to copy string b to string a */ 2 | 3 | #include "f2c.h" 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | 9 | #define M ( (long) (sizeof(long) - 1) ) 10 | #define EVEN(x) ( ( (x)+ M) & (~M) ) 11 | 12 | #ifdef KR_headers 13 | extern VOID s_copy(); 14 | ef1asc_(a, la, b, lb) ftnint *a, *b; ftnlen *la, *lb; 15 | #else 16 | extern void s_copy(char*,char*,ftnlen,ftnlen); 17 | int ef1asc_(ftnint *a, ftnlen *la, ftnint *b, ftnlen *lb) 18 | #endif 19 | { 20 | s_copy( (char *)a, (char *)b, EVEN(*la), *lb ); 21 | return 0; /* ignored return value */ 22 | } 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /lib/f2c/ef1cmc_.c: -------------------------------------------------------------------------------- 1 | /* EFL support routine to compare two character strings */ 2 | 3 | #include "f2c.h" 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #ifdef KR_headers 9 | extern integer s_cmp(); 10 | integer ef1cmc_(a, la, b, lb) ftnint *a, *b; ftnlen *la, *lb; 11 | #else 12 | extern integer s_cmp(char*,char*,ftnlen,ftnlen); 13 | integer ef1cmc_(ftnint *a, ftnlen *la, ftnint *b, ftnlen *lb) 14 | #endif 15 | { 16 | return( s_cmp( (char *)a, (char *)b, *la, *lb) ); 17 | } 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /lib/f2c/erf_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifndef REAL 7 | #define REAL double 8 | #endif 9 | 10 | #ifdef KR_headers 11 | double erf(); 12 | REAL erf_(x) real *x; 13 | #else 14 | extern double erf(double); 15 | REAL erf_(real *x) 16 | #endif 17 | { 18 | return( erf((double)*x) ); 19 | } 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /lib/f2c/erfc_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifndef REAL 7 | #define REAL double 8 | #endif 9 | 10 | #ifdef KR_headers 11 | double erfc(); 12 | REAL erfc_(x) real *x; 13 | #else 14 | extern double erfc(double); 15 | REAL erfc_(real *x) 16 | #endif 17 | { 18 | return( erfc((double)*x) ); 19 | } 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /lib/f2c/etime_.c: -------------------------------------------------------------------------------- 1 | #include "time.h" 2 | 3 | #ifdef WIN32 4 | #undef USE_CLOCK 5 | #define USE_CLOCK 6 | #endif 7 | 8 | #ifndef REAL 9 | #define REAL double 10 | #endif 11 | 12 | #ifndef USE_CLOCK 13 | #define _INCLUDE_POSIX_SOURCE /* for HP-UX */ 14 | #define _INCLUDE_XOPEN_SOURCE /* for HP-UX */ 15 | #include "sys/types.h" 16 | #include "sys/times.h" 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | #endif 21 | 22 | #undef Hz 23 | #ifdef CLK_TCK 24 | #define Hz CLK_TCK 25 | #else 26 | #ifdef HZ 27 | #define Hz HZ 28 | #else 29 | #define Hz 60 30 | #endif 31 | #endif 32 | 33 | REAL 34 | #ifdef KR_headers 35 | etime_(tarray) float *tarray; 36 | #else 37 | etime_(float *tarray) 38 | #endif 39 | { 40 | #ifdef USE_CLOCK 41 | #ifndef CLOCKS_PER_SECOND 42 | #define CLOCKS_PER_SECOND Hz 43 | #endif 44 | double t = clock(); 45 | tarray[1] = 0; 46 | return tarray[0] = t / CLOCKS_PER_SECOND; 47 | #else 48 | struct tms t; 49 | 50 | times(&t); 51 | return (tarray[0] = (double)t.tms_utime/Hz) 52 | + (tarray[1] = (double)t.tms_stime/Hz); 53 | #endif 54 | } 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /lib/f2c/exit_.c: -------------------------------------------------------------------------------- 1 | /* This gives the effect of 2 | 3 | subroutine exit(rc) 4 | integer*4 rc 5 | stop 6 | end 7 | 8 | * with the added side effect of supplying rc as the program's exit code. 9 | */ 10 | 11 | #include "f2c.h" 12 | #undef abs 13 | #undef min 14 | #undef max 15 | #ifndef KR_headers 16 | #include "stdlib.h" 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | extern void f_exit(void); 24 | #endif 25 | 26 | void 27 | #ifdef KR_headers 28 | exit_(rc) integer *rc; 29 | #else 30 | exit_(integer *rc) 31 | #endif 32 | { 33 | #ifdef NO_ONEXIT 34 | f_exit(); 35 | #endif 36 | exit(*rc); 37 | } 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/f2c/f77_aloc.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #undef abs 3 | #undef min 4 | #undef max 5 | #include "stdio.h" 6 | 7 | static integer memfailure = 3; 8 | 9 | #ifdef KR_headers 10 | extern char *malloc(); 11 | extern void exit_(); 12 | 13 | char * 14 | F77_aloc(Len, whence) integer Len; char *whence; 15 | #else 16 | #include "stdlib.h" 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | extern void exit_(integer*); 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | char * 29 | F77_aloc(integer Len, const char *whence) 30 | #endif 31 | { 32 | char *rv; 33 | unsigned int uLen = (unsigned int) Len; /* for K&R C */ 34 | 35 | if (!(rv = (char*)malloc(uLen))) { 36 | fprintf(stderr, "malloc(%u) failure in %s\n", 37 | uLen, whence); 38 | exit_(&memfailure); 39 | } 40 | return rv; 41 | } 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /lib/f2c/fmtlib.c: -------------------------------------------------------------------------------- 1 | /* @(#)fmtlib.c 1.2 */ 2 | #define MAXINTLENGTH 23 3 | 4 | #include "f2c.h" 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | #ifndef Allow_TYQUAD 9 | #undef longint 10 | #define longint long 11 | #undef ulongint 12 | #define ulongint unsigned long 13 | #endif 14 | 15 | #ifdef KR_headers 16 | char *f__icvt(value,ndigit,sign, base) longint value; int *ndigit,*sign; 17 | register int base; 18 | #else 19 | char *f__icvt(longint value, int *ndigit, int *sign, int base) 20 | #endif 21 | { 22 | static char buf[MAXINTLENGTH+1]; 23 | register int i; 24 | ulongint uvalue; 25 | 26 | if(value > 0) { 27 | uvalue = value; 28 | *sign = 0; 29 | } 30 | else if (value < 0) { 31 | uvalue = -value; 32 | *sign = 1; 33 | } 34 | else { 35 | *sign = 0; 36 | *ndigit = 1; 37 | buf[MAXINTLENGTH-1] = '0'; 38 | return &buf[MAXINTLENGTH-1]; 39 | } 40 | i = MAXINTLENGTH; 41 | do { 42 | buf[--i] = (uvalue%base) + '0'; 43 | uvalue /= base; 44 | } 45 | while(uvalue > 0); 46 | *ndigit = MAXINTLENGTH - i; 47 | return &buf[i]; 48 | } 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /lib/f2c/fp.h: -------------------------------------------------------------------------------- 1 | #define FMAX 40 2 | #define EXPMAXDIGS 8 3 | #define EXPMAX 99999999 4 | /* FMAX = max number of nonzero digits passed to atof() */ 5 | /* EXPMAX = 10^EXPMAXDIGS - 1 = largest allowed exponent absolute value */ 6 | 7 | #ifdef V10 /* Research Tenth-Edition Unix */ 8 | #include "local.h" 9 | #endif 10 | 11 | /* MAXFRACDIGS and MAXINTDIGS are for wrt_F -- bounds (not necessarily 12 | tight) on the maximum number of digits to the right and left of 13 | * the decimal point. 14 | */ 15 | 16 | #ifdef VAX 17 | #define MAXFRACDIGS 56 18 | #define MAXINTDIGS 38 19 | #else 20 | #ifdef CRAY 21 | #define MAXFRACDIGS 9880 22 | #define MAXINTDIGS 9864 23 | #else 24 | /* values that suffice for IEEE double */ 25 | #define MAXFRACDIGS 344 26 | #define MAXINTDIGS 308 27 | #endif 28 | #endif 29 | -------------------------------------------------------------------------------- /lib/f2c/ftell64_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | static FILE * 8 | #ifdef KR_headers 9 | unit_chk(Unit, who) integer Unit; char *who; 10 | #else 11 | unit_chk(integer Unit, char *who) 12 | #endif 13 | { 14 | if (Unit >= MXUNIT || Unit < 0) 15 | f__fatal(101, who); 16 | return f__units[Unit].ufd; 17 | } 18 | 19 | longint 20 | #ifdef KR_headers 21 | ftell64_(Unit) integer *Unit; 22 | #else 23 | ftell64_(integer *Unit) 24 | #endif 25 | { 26 | FILE *f; 27 | return (f = unit_chk(*Unit, "ftell")) ? FTELL(f) : -1L; 28 | } 29 | 30 | int 31 | #ifdef KR_headers 32 | fseek64_(Unit, offset, whence) integer *Unit, *whence; longint *offset; 33 | #else 34 | fseek64_(integer *Unit, longint *offset, integer *whence) 35 | #endif 36 | { 37 | FILE *f; 38 | int w = (int)*whence; 39 | #ifdef SEEK_SET 40 | static int wohin[3] = { SEEK_SET, SEEK_CUR, SEEK_END }; 41 | #endif 42 | if (w < 0 || w > 2) 43 | w = 0; 44 | #ifdef SEEK_SET 45 | w = wohin[w]; 46 | #endif 47 | return !(f = unit_chk(*Unit, "fseek")) 48 | || FSEEK(f, (OFF_T)*offset, w) ? 1 : 0; 49 | } 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /lib/f2c/ftell_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | static FILE * 8 | #ifdef KR_headers 9 | unit_chk(Unit, who) integer Unit; char *who; 10 | #else 11 | unit_chk(integer Unit, const char *who) 12 | #endif 13 | { 14 | if (Unit >= MXUNIT || Unit < 0) 15 | f__fatal(101, who); 16 | return f__units[Unit].ufd; 17 | } 18 | 19 | integer 20 | #ifdef KR_headers 21 | ftell_(Unit) integer *Unit; 22 | #else 23 | ftell_(integer *Unit) 24 | #endif 25 | { 26 | FILE *f; 27 | return (f = unit_chk(*Unit, "ftell")) ? ftell(f) : -1L; 28 | } 29 | 30 | int 31 | #ifdef KR_headers 32 | fseek_(Unit, offset, whence) integer *Unit, *offset, *whence; 33 | #else 34 | fseek_(integer *Unit, integer *offset, integer *whence) 35 | #endif 36 | { 37 | FILE *f; 38 | int w = (int)*whence; 39 | #ifdef SEEK_SET 40 | static int wohin[3] = { SEEK_SET, SEEK_CUR, SEEK_END }; 41 | #endif 42 | if (w < 0 || w > 2) 43 | w = 0; 44 | #ifdef SEEK_SET 45 | w = wohin[w]; 46 | #endif 47 | return !(f = unit_chk(*Unit, "fseek")) 48 | || fseek(f, *offset, w) ? 1 : 0; 49 | } 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /lib/f2c/getarg_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | /* 7 | * subroutine getarg(k, c) 8 | * returns the kth unix command argument in fortran character 9 | * variable argument c 10 | */ 11 | 12 | #ifdef KR_headers 13 | VOID getarg_(n, s, ls) ftnint *n; char *s; ftnlen ls; 14 | #define Const /*nothing*/ 15 | #else 16 | #define Const const 17 | void getarg_(ftnint *n, char *s, ftnlen ls) 18 | #endif 19 | { 20 | extern int xargc; 21 | extern char **xargv; 22 | Const char *t; 23 | int i; 24 | 25 | if(*n>=0 && *n 7 | #include 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | extern char *F77_aloc(ftnlen, const char*); 12 | #endif 13 | 14 | /* 15 | * getenv - f77 subroutine to return environment variables 16 | * 17 | * called by: 18 | * call getenv (ENV_NAME, char_var) 19 | * where: 20 | * ENV_NAME is the name of an environment variable 21 | * char_var is a character variable which will receive 22 | * the current value of ENV_NAME, or all blanks 23 | * if ENV_NAME is not defined 24 | */ 25 | 26 | #ifdef KR_headers 27 | VOID 28 | getenv_(fname, value, flen, vlen) char *value, *fname; ftnlen vlen, flen; 29 | #else 30 | void 31 | getenv_(char *fname, char *value, ftnlen flen, ftnlen vlen) 32 | #endif 33 | { 34 | char buf[256], *ep, *fp; 35 | integer i; 36 | 37 | if (flen <= 0) 38 | goto add_blanks; 39 | for(i = 0; i < sizeof(buf); i++) { 40 | if (i == flen || (buf[i] = fname[i]) == ' ') { 41 | buf[i] = 0; 42 | ep = getenv(buf); 43 | goto have_ep; 44 | } 45 | } 46 | while(i < flen && fname[i] != ' ') 47 | i++; 48 | strncpy(fp = F77_aloc(i+1, "getenv_"), fname, (int)i); 49 | fp[i] = 0; 50 | ep = getenv(fp); 51 | free(fp); 52 | have_ep: 53 | if (ep) 54 | while(*ep && vlen-- > 0) 55 | *value++ = *ep++; 56 | add_blanks: 57 | while(vlen-- > 0) 58 | *value++ = ' '; 59 | } 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | -------------------------------------------------------------------------------- /lib/f2c/h_abs.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint h_abs(x) shortint *x; 8 | #else 9 | shortint h_abs(shortint *x) 10 | #endif 11 | { 12 | if(*x >= 0) 13 | return(*x); 14 | return(- *x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/h_dim.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint h_dim(a,b) shortint *a, *b; 8 | #else 9 | shortint h_dim(shortint *a, shortint *b) 10 | #endif 11 | { 12 | return( *a > *b ? *a - *b : 0); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/f2c/h_dnnt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | shortint h_dnnt(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | shortint h_dnnt(doublereal *x) 13 | #endif 14 | { 15 | return (shortint)(*x >= 0. ? floor(*x + .5) : -floor(.5 - *x)); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/h_indx.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint h_indx(a, b, la, lb) char *a, *b; ftnlen la, lb; 8 | #else 9 | shortint h_indx(char *a, char *b, ftnlen la, ftnlen lb) 10 | #endif 11 | { 12 | ftnlen i, n; 13 | char *s, *t, *bend; 14 | 15 | n = la - lb + 1; 16 | bend = b + lb; 17 | 18 | for(i = 0 ; i < n ; ++i) 19 | { 20 | s = a + i; 21 | t = b; 22 | while(t < bend) 23 | if(*s++ != *t++) 24 | goto no; 25 | return((shortint)i+1); 26 | no: ; 27 | } 28 | return(0); 29 | } 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /lib/f2c/h_len.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint h_len(s, n) char *s; ftnlen n; 8 | #else 9 | shortint h_len(char *s, ftnlen n) 10 | #endif 11 | { 12 | return(n); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/f2c/h_mod.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint h_mod(a,b) short *a, *b; 8 | #else 9 | shortint h_mod(short *a, short *b) 10 | #endif 11 | { 12 | return( *a % *b); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/f2c/h_nint.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | shortint h_nint(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | shortint h_nint(real *x) 13 | #endif 14 | { 15 | return (shortint)(*x >= 0 ? floor(*x + .5) : -floor(.5 - *x)); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/h_sign.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint h_sign(a,b) shortint *a, *b; 8 | #else 9 | shortint h_sign(shortint *a, shortint *b) 10 | #endif 11 | { 12 | shortint x; 13 | x = (*a >= 0 ? *a : - *a); 14 | return( *b >= 0 ? x : -x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/hl_ge.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | shortlogical hl_ge(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | shortlogical hl_ge(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) >= 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/hl_gt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | shortlogical hl_gt(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | shortlogical hl_gt(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) > 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/hl_le.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | shortlogical hl_le(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | shortlogical hl_le(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) <= 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/hl_lt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | shortlogical hl_lt(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | shortlogical hl_lt(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) < 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/i_abs.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer i_abs(x) integer *x; 8 | #else 9 | integer i_abs(integer *x) 10 | #endif 11 | { 12 | if(*x >= 0) 13 | return(*x); 14 | return(- *x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/i_dim.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer i_dim(a,b) integer *a, *b; 8 | #else 9 | integer i_dim(integer *a, integer *b) 10 | #endif 11 | { 12 | return( *a > *b ? *a - *b : 0); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/f2c/i_dnnt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | integer i_dnnt(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | integer i_dnnt(doublereal *x) 13 | #endif 14 | { 15 | return (integer)(*x >= 0. ? floor(*x + .5) : -floor(.5 - *x)); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/i_indx.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer i_indx(a, b, la, lb) char *a, *b; ftnlen la, lb; 8 | #else 9 | integer i_indx(char *a, char *b, ftnlen la, ftnlen lb) 10 | #endif 11 | { 12 | ftnlen i, n; 13 | char *s, *t, *bend; 14 | 15 | n = la - lb + 1; 16 | bend = b + lb; 17 | 18 | for(i = 0 ; i < n ; ++i) 19 | { 20 | s = a + i; 21 | t = b; 22 | while(t < bend) 23 | if(*s++ != *t++) 24 | goto no; 25 | return(i+1); 26 | no: ; 27 | } 28 | return(0); 29 | } 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /lib/f2c/i_len.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer i_len(s, n) char *s; ftnlen n; 8 | #else 9 | integer i_len(char *s, ftnlen n) 10 | #endif 11 | { 12 | return(n); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/f2c/i_mod.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer i_mod(a,b) integer *a, *b; 8 | #else 9 | integer i_mod(integer *a, integer *b) 10 | #endif 11 | { 12 | return( *a % *b); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/f2c/i_nint.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | integer i_nint(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | integer i_nint(real *x) 13 | #endif 14 | { 15 | return (integer)(*x >= 0 ? floor(*x + .5) : -floor(.5 - *x)); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/i_sign.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer i_sign(a,b) integer *a, *b; 8 | #else 9 | integer i_sign(integer *a, integer *b) 10 | #endif 11 | { 12 | integer x; 13 | x = (*a >= 0 ? *a : - *a); 14 | return( *b >= 0 ? x : -x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/iargc_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | ftnint iargc_() 8 | #else 9 | ftnint iargc_(void) 10 | #endif 11 | { 12 | extern int xargc; 13 | return ( xargc - 1 ); 14 | } 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /lib/f2c/ilnw.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #include "lio.h" 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | extern char *f__icptr; 8 | extern char *f__icend; 9 | extern icilist *f__svic; 10 | extern int f__icnum; 11 | #ifdef KR_headers 12 | extern void z_putc(); 13 | #else 14 | extern void z_putc(int); 15 | #endif 16 | 17 | static int 18 | z_wSL(Void) 19 | { 20 | while(f__recpos < f__svic->icirlen) 21 | z_putc(' '); 22 | return z_rnew(); 23 | } 24 | 25 | static void 26 | #ifdef KR_headers 27 | c_liw(a) icilist *a; 28 | #else 29 | c_liw(icilist *a) 30 | #endif 31 | { 32 | f__reading = 0; 33 | f__external = 0; 34 | f__formatted = 1; 35 | f__putn = z_putc; 36 | L_len = a->icirlen; 37 | f__donewrec = z_wSL; 38 | f__svic = a; 39 | f__icnum = f__recpos = 0; 40 | f__cursor = 0; 41 | f__cf = 0; 42 | f__curunit = 0; 43 | f__icptr = a->iciunit; 44 | f__icend = f__icptr + a->icirlen*a->icirnum; 45 | f__elist = (cilist *)a; 46 | } 47 | 48 | integer 49 | #ifdef KR_headers 50 | s_wsni(a) icilist *a; 51 | #else 52 | s_wsni(icilist *a) 53 | #endif 54 | { 55 | cilist ca; 56 | 57 | c_liw(a); 58 | ca.cifmt = a->icifmt; 59 | x_wsne(&ca); 60 | z_wSL(); 61 | return 0; 62 | } 63 | 64 | integer 65 | #ifdef KR_headers 66 | s_wsli(a) icilist *a; 67 | #else 68 | s_wsli(icilist *a) 69 | #endif 70 | { 71 | f__lioproc = l_write; 72 | c_liw(a); 73 | return(0); 74 | } 75 | 76 | integer e_wsli(Void) 77 | { 78 | z_wSL(); 79 | return(0); 80 | } 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | -------------------------------------------------------------------------------- /lib/f2c/l_ge.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | logical l_ge(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | logical l_ge(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) >= 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/l_gt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | logical l_gt(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | logical l_gt(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) > 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/l_le.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | logical l_le(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | logical l_le(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) <= 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/l_lt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | logical l_lt(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | logical l_lt(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) < 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/lbitbits.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifndef LONGBITS 7 | #define LONGBITS 32 8 | #endif 9 | 10 | integer 11 | #ifdef KR_headers 12 | lbit_bits(a, b, len) integer a, b, len; 13 | #else 14 | lbit_bits(integer a, integer b, integer len) 15 | #endif 16 | { 17 | /* Assume 2's complement arithmetic */ 18 | 19 | unsigned long x, y; 20 | 21 | x = (unsigned long) a; 22 | y = (unsigned long)-1L; 23 | x >>= b; 24 | y <<= len; 25 | return (integer)(x & ~y); 26 | } 27 | 28 | integer 29 | #ifdef KR_headers 30 | lbit_cshift(a, b, len) integer a, b, len; 31 | #else 32 | lbit_cshift(integer a, integer b, integer len) 33 | #endif 34 | { 35 | unsigned long x, y, z; 36 | 37 | x = (unsigned long)a; 38 | if (len <= 0) { 39 | if (len == 0) 40 | return 0; 41 | goto full_len; 42 | } 43 | if (len >= LONGBITS) { 44 | full_len: 45 | if (b >= 0) { 46 | b %= LONGBITS; 47 | return (integer)(x << b | x >> LONGBITS -b ); 48 | } 49 | b = -b; 50 | b %= LONGBITS; 51 | return (integer)(x << LONGBITS - b | x >> b); 52 | } 53 | y = z = (unsigned long)-1; 54 | y <<= len; 55 | z &= ~y; 56 | y &= x; 57 | x &= z; 58 | if (b >= 0) { 59 | b %= len; 60 | return (integer)(y | z & (x << b | x >> len - b)); 61 | } 62 | b = -b; 63 | b %= len; 64 | return (integer)(y | z & (x >> b | x << len - b)); 65 | } 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | -------------------------------------------------------------------------------- /lib/f2c/lbitshft.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | integer 7 | #ifdef KR_headers 8 | lbit_shift(a, b) integer a; integer b; 9 | #else 10 | lbit_shift(integer a, integer b) 11 | #endif 12 | { 13 | return b >= 0 ? a << b : (integer)((uinteger)a >> -b); 14 | } 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /lib/f2c/lio.h: -------------------------------------------------------------------------------- 1 | /* copy of ftypes from the compiler */ 2 | /* variable types 3 | * numeric assumptions: 4 | * int < reals < complexes 5 | * TYDREAL-TYREAL = TYDCOMPLEX-TYCOMPLEX 6 | */ 7 | 8 | /* 0-10 retain their old (pre LOGICAL*1, etc.) */ 9 | /* values to allow mixing old and new objects. */ 10 | 11 | #define TYUNKNOWN 0 12 | #define TYADDR 1 13 | #define TYSHORT 2 14 | #define TYLONG 3 15 | #define TYREAL 4 16 | #define TYDREAL 5 17 | #define TYCOMPLEX 6 18 | #define TYDCOMPLEX 7 19 | #define TYLOGICAL 8 20 | #define TYCHAR 9 21 | #define TYSUBR 10 22 | #define TYINT1 11 23 | #define TYLOGICAL1 12 24 | #define TYLOGICAL2 13 25 | #ifdef Allow_TYQUAD 26 | #undef TYQUAD 27 | #define TYQUAD 14 28 | #endif 29 | 30 | #define LINTW 24 31 | #define LINE 80 32 | #define LLOGW 2 33 | #ifdef Old_list_output 34 | #define LLOW 1.0 35 | #define LHIGH 1.e9 36 | #define LEFMT " %# .8E" 37 | #define LFFMT " %# .9g" 38 | #else 39 | #define LGFMT "%.9G" 40 | #endif 41 | /* LEFBL 20 should suffice; 24 overcomes a NeXT bug. */ 42 | #define LEFBL 24 43 | 44 | typedef union 45 | { 46 | char flchar; 47 | short flshort; 48 | ftnint flint; 49 | #ifdef Allow_TYQUAD 50 | longint fllongint; 51 | #endif 52 | real flreal; 53 | doublereal fldouble; 54 | } flex; 55 | #ifdef KR_headers 56 | extern int (*f__lioproc)(), (*l_getc)(), (*l_ungetc)(); 57 | extern int l_read(), l_write(); 58 | #else 59 | #ifdef __cplusplus 60 | extern "C" { 61 | #endif 62 | extern int (*f__lioproc)(ftnint*, char*, ftnlen, ftnint); 63 | extern int l_write(ftnint*, char*, ftnlen, ftnint); 64 | extern void x_wsne(cilist*); 65 | extern int c_le(cilist*), (*l_getc)(void), (*l_ungetc)(int,FILE*); 66 | extern int l_read(ftnint*,char*,ftnlen,ftnint); 67 | extern integer e_rsle(void), e_wsle(void), s_wsne(cilist*); 68 | extern int z_rnew(void); 69 | #endif 70 | extern ftnint L_len; 71 | extern int f__scale; 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | -------------------------------------------------------------------------------- /lib/f2c/pow_ci.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | VOID pow_ci(p, a, b) /* p = a**b */ 8 | complex *p, *a; integer *b; 9 | #else 10 | extern void pow_zi(doublecomplex*, doublecomplex*, integer*); 11 | void pow_ci(complex *p, complex *a, integer *b) /* p = a**b */ 12 | #endif 13 | { 14 | doublecomplex p1, a1; 15 | 16 | a1.r = a->r; 17 | a1.i = a->i; 18 | 19 | pow_zi(&p1, &a1, b); 20 | 21 | p->r = p1.r; 22 | p->i = p1.i; 23 | } 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /lib/f2c/pow_dd.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double pow(); 5 | double pow_dd(ap, bp) doublereal *ap, *bp; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double pow_dd(doublereal *ap, doublereal *bp) 13 | #endif 14 | { 15 | return(pow(*ap, *bp) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/pow_di.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double pow_di(ap, bp) doublereal *ap; integer *bp; 8 | #else 9 | double pow_di(doublereal *ap, integer *bp) 10 | #endif 11 | { 12 | double pow, x; 13 | integer n; 14 | unsigned long u; 15 | 16 | pow = 1; 17 | x = *ap; 18 | n = *bp; 19 | 20 | if(n != 0) 21 | { 22 | if(n < 0) 23 | { 24 | n = -n; 25 | x = 1/x; 26 | } 27 | for(u = n; ; ) 28 | { 29 | if(u & 01) 30 | pow *= x; 31 | if(u >>= 1) 32 | x *= x; 33 | else 34 | break; 35 | } 36 | } 37 | return(pow); 38 | } 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /lib/f2c/pow_hh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint pow_hh(ap, bp) shortint *ap, *bp; 8 | #else 9 | shortint pow_hh(shortint *ap, shortint *bp) 10 | #endif 11 | { 12 | shortint pow, x, n; 13 | unsigned u; 14 | 15 | x = *ap; 16 | n = *bp; 17 | 18 | if (n <= 0) { 19 | if (n == 0 || x == 1) 20 | return 1; 21 | if (x != -1) 22 | return x == 0 ? 1/x : 0; 23 | n = -n; 24 | } 25 | u = n; 26 | for(pow = 1; ; ) 27 | { 28 | if(u & 01) 29 | pow *= x; 30 | if(u >>= 1) 31 | x *= x; 32 | else 33 | break; 34 | } 35 | return(pow); 36 | } 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /lib/f2c/pow_ii.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer pow_ii(ap, bp) integer *ap, *bp; 8 | #else 9 | integer pow_ii(integer *ap, integer *bp) 10 | #endif 11 | { 12 | integer pow, x, n; 13 | unsigned long u; 14 | 15 | x = *ap; 16 | n = *bp; 17 | 18 | if (n <= 0) { 19 | if (n == 0 || x == 1) 20 | return 1; 21 | if (x != -1) 22 | return x == 0 ? 1/x : 0; 23 | n = -n; 24 | } 25 | u = n; 26 | for(pow = 1; ; ) 27 | { 28 | if(u & 01) 29 | pow *= x; 30 | if(u >>= 1) 31 | x *= x; 32 | else 33 | break; 34 | } 35 | return(pow); 36 | } 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /lib/f2c/pow_qq.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | longint pow_qq(ap, bp) longint *ap, *bp; 8 | #else 9 | longint pow_qq(longint *ap, longint *bp) 10 | #endif 11 | { 12 | longint pow, x, n; 13 | unsigned long long u; /* system-dependent */ 14 | 15 | x = *ap; 16 | n = *bp; 17 | 18 | if (n <= 0) { 19 | if (n == 0 || x == 1) 20 | return 1; 21 | if (x != -1) 22 | return x == 0 ? 1/x : 0; 23 | n = -n; 24 | } 25 | u = n; 26 | for(pow = 1; ; ) 27 | { 28 | if(u & 01) 29 | pow *= x; 30 | if(u >>= 1) 31 | x *= x; 32 | else 33 | break; 34 | } 35 | return(pow); 36 | } 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /lib/f2c/pow_ri.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double pow_ri(ap, bp) real *ap; integer *bp; 8 | #else 9 | double pow_ri(real *ap, integer *bp) 10 | #endif 11 | { 12 | double pow, x; 13 | integer n; 14 | unsigned long u; 15 | 16 | pow = 1; 17 | x = *ap; 18 | n = *bp; 19 | 20 | if(n != 0) 21 | { 22 | if(n < 0) 23 | { 24 | n = -n; 25 | x = 1/x; 26 | } 27 | for(u = n; ; ) 28 | { 29 | if(u & 01) 30 | pow *= x; 31 | if(u >>= 1) 32 | x *= x; 33 | else 34 | break; 35 | } 36 | } 37 | return(pow); 38 | } 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /lib/f2c/pow_zi.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | VOID pow_zi(p, a, b) /* p = a**b */ 8 | doublecomplex *p, *a; integer *b; 9 | #else 10 | extern void z_div(doublecomplex*, doublecomplex*, doublecomplex*); 11 | void pow_zi(doublecomplex *p, doublecomplex *a, integer *b) /* p = a**b */ 12 | #endif 13 | { 14 | integer n; 15 | unsigned long u; 16 | double t; 17 | doublecomplex q, x; 18 | static doublecomplex one = {1.0, 0.0}; 19 | 20 | n = *b; 21 | q.r = 1; 22 | q.i = 0; 23 | 24 | if(n == 0) 25 | goto done; 26 | if(n < 0) 27 | { 28 | n = -n; 29 | z_div(&x, &one, a); 30 | } 31 | else 32 | { 33 | x.r = a->r; 34 | x.i = a->i; 35 | } 36 | 37 | for(u = n; ; ) 38 | { 39 | if(u & 01) 40 | { 41 | t = q.r * x.r - q.i * x.i; 42 | q.i = q.r * x.i + q.i * x.r; 43 | q.r = t; 44 | } 45 | if(u >>= 1) 46 | { 47 | t = x.r * x.r - x.i * x.i; 48 | x.i = 2 * x.r * x.i; 49 | x.r = t; 50 | } 51 | else 52 | break; 53 | } 54 | done: 55 | p->i = q.i; 56 | p->r = q.r; 57 | } 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /lib/f2c/pow_zz.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double log(), exp(), cos(), sin(), atan2(), f__cabs(); 5 | VOID pow_zz(r,a,b) doublecomplex *r, *a, *b; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | extern double f__cabs(double,double); 13 | void pow_zz(doublecomplex *r, doublecomplex *a, doublecomplex *b) 14 | #endif 15 | { 16 | double logr, logi, x, y; 17 | 18 | logr = log( f__cabs(a->r, a->i) ); 19 | logi = atan2(a->i, a->r); 20 | 21 | x = exp( logr * b->r - logi * b->i ); 22 | y = logr * b->i + logi * b->r; 23 | 24 | r->r = x * cos(y); 25 | r->i = x * sin(y); 26 | } 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /lib/f2c/qbitbits.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifndef LONGBITS 7 | #define LONGBITS 32 8 | #endif 9 | 10 | #ifndef LONG8BITS 11 | #define LONG8BITS (2*LONGBITS) 12 | #endif 13 | 14 | longint 15 | #ifdef KR_headers 16 | qbit_bits(a, b, len) longint a; integer b, len; 17 | #else 18 | qbit_bits(longint a, integer b, integer len) 19 | #endif 20 | { 21 | /* Assume 2's complement arithmetic */ 22 | 23 | ulongint x, y; 24 | 25 | x = (ulongint) a; 26 | y = (ulongint)-1L; 27 | x >>= b; 28 | y <<= len; 29 | return (longint)(x & ~y); 30 | } 31 | 32 | longint 33 | #ifdef KR_headers 34 | qbit_cshift(a, b, len) longint a; integer b, len; 35 | #else 36 | qbit_cshift(longint a, integer b, integer len) 37 | #endif 38 | { 39 | ulongint x, y, z; 40 | 41 | x = (ulongint)a; 42 | if (len <= 0) { 43 | if (len == 0) 44 | return 0; 45 | goto full_len; 46 | } 47 | if (len >= LONG8BITS) { 48 | full_len: 49 | if (b >= 0) { 50 | b %= LONG8BITS; 51 | return (longint)(x << b | x >> LONG8BITS - b ); 52 | } 53 | b = -b; 54 | b %= LONG8BITS; 55 | return (longint)(x << LONG8BITS - b | x >> b); 56 | } 57 | y = z = (unsigned long)-1; 58 | y <<= len; 59 | z &= ~y; 60 | y &= x; 61 | x &= z; 62 | if (b >= 0) { 63 | b %= len; 64 | return (longint)(y | z & (x << b | x >> len - b)); 65 | } 66 | b = -b; 67 | b %= len; 68 | return (longint)(y | z & (x >> b | x << len - b)); 69 | } 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | -------------------------------------------------------------------------------- /lib/f2c/qbitshft.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | longint 7 | #ifdef KR_headers 8 | qbit_shift(a, b) longint a; integer b; 9 | #else 10 | qbit_shift(longint a, integer b) 11 | #endif 12 | { 13 | return b >= 0 ? a << b : (longint)((ulongint)a >> -b); 14 | } 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /lib/f2c/r_abs.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double r_abs(x) real *x; 8 | #else 9 | double r_abs(real *x) 10 | #endif 11 | { 12 | if(*x >= 0) 13 | return(*x); 14 | return(- *x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/r_acos.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double acos(); 5 | double r_acos(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_acos(real *x) 13 | #endif 14 | { 15 | return( acos(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_asin.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double asin(); 5 | double r_asin(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_asin(real *x) 13 | #endif 14 | { 15 | return( asin(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_atan.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double atan(); 5 | double r_atan(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_atan(real *x) 13 | #endif 14 | { 15 | return( atan(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_atn2.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double atan2(); 5 | double r_atn2(x,y) real *x, *y; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_atn2(real *x, real *y) 13 | #endif 14 | { 15 | return( atan2(*x,*y) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_cnjg.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | VOID r_cnjg(r, z) complex *r, *z; 8 | #else 9 | VOID r_cnjg(complex *r, complex *z) 10 | #endif 11 | { 12 | real zi = z->i; 13 | r->r = z->r; 14 | r->i = -zi; 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/r_cos.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double cos(); 5 | double r_cos(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_cos(real *x) 13 | #endif 14 | { 15 | return( cos(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_cosh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double cosh(); 5 | double r_cosh(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_cosh(real *x) 13 | #endif 14 | { 15 | return( cosh(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_dim.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double r_dim(a,b) real *a, *b; 8 | #else 9 | double r_dim(real *a, real *b) 10 | #endif 11 | { 12 | return( *a > *b ? *a - *b : 0); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/f2c/r_exp.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double exp(); 5 | double r_exp(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_exp(real *x) 13 | #endif 14 | { 15 | return( exp(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_imag.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double r_imag(z) complex *z; 8 | #else 9 | double r_imag(complex *z) 10 | #endif 11 | { 12 | return(z->i); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /lib/f2c/r_int.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | double r_int(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_int(real *x) 13 | #endif 14 | { 15 | return( (*x>0) ? floor(*x) : -floor(- *x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_lg10.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #define log10e 0.43429448190325182765 4 | 5 | #ifdef KR_headers 6 | double log(); 7 | double r_lg10(x) real *x; 8 | #else 9 | #undef abs 10 | #include "math.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | double r_lg10(real *x) 15 | #endif 16 | { 17 | return( log10e * log(*x) ); 18 | } 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /lib/f2c/r_log.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double log(); 5 | double r_log(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_log(real *x) 13 | #endif 14 | { 15 | return( log(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_mod.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | #ifdef IEEE_drem 5 | double drem(); 6 | #else 7 | double floor(); 8 | #endif 9 | double r_mod(x,y) real *x, *y; 10 | #else 11 | #ifdef IEEE_drem 12 | double drem(double, double); 13 | #else 14 | #undef abs 15 | #include "math.h" 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | #endif 20 | double r_mod(real *x, real *y) 21 | #endif 22 | { 23 | #ifdef IEEE_drem 24 | double xa, ya, z; 25 | if ((ya = *y) < 0.) 26 | ya = -ya; 27 | z = drem(xa = *x, ya); 28 | if (xa > 0) { 29 | if (z < 0) 30 | z += ya; 31 | } 32 | else if (z > 0) 33 | z -= ya; 34 | return z; 35 | #else 36 | double quotient; 37 | if( (quotient = (double)*x / *y) >= 0) 38 | quotient = floor(quotient); 39 | else 40 | quotient = -floor(-quotient); 41 | return(*x - (*y) * quotient ); 42 | #endif 43 | } 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /lib/f2c/r_nint.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | double r_nint(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_nint(real *x) 13 | #endif 14 | { 15 | return( (*x)>=0 ? 16 | floor(*x + .5) : -floor(.5 - *x) ); 17 | } 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /lib/f2c/r_sign.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double r_sign(a,b) real *a, *b; 8 | #else 9 | double r_sign(real *a, real *b) 10 | #endif 11 | { 12 | double x; 13 | x = (*a >= 0 ? *a : - *a); 14 | return( *b >= 0 ? x : -x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/r_sin.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sin(); 5 | double r_sin(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_sin(real *x) 13 | #endif 14 | { 15 | return( sin(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_sinh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sinh(); 5 | double r_sinh(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_sinh(real *x) 13 | #endif 14 | { 15 | return( sinh(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_sqrt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sqrt(); 5 | double r_sqrt(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_sqrt(real *x) 13 | #endif 14 | { 15 | return( sqrt(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_tan.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double tan(); 5 | double r_tan(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_tan(real *x) 13 | #endif 14 | { 15 | return( tan(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/r_tanh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double tanh(); 5 | double r_tanh(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_tanh(real *x) 13 | #endif 14 | { 15 | return( tanh(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/f2c/rawio.h: -------------------------------------------------------------------------------- 1 | #ifndef KR_headers 2 | #ifdef MSDOS 3 | #include "io.h" 4 | #ifndef WATCOM 5 | #define close _close 6 | #define creat _creat 7 | #define open _open 8 | #define read _read 9 | #define write _write 10 | #endif /*WATCOM*/ 11 | #endif /*MSDOS*/ 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | #ifndef MSDOS 16 | #ifdef OPEN_DECL 17 | extern int creat(const char*,int), open(const char*,int); 18 | #endif 19 | extern int close(int); 20 | extern int read(int,void*,size_t), write(int,void*,size_t); 21 | extern int unlink(const char*); 22 | #ifndef _POSIX_SOURCE 23 | #ifndef NON_UNIX_STDIO 24 | extern FILE *fdopen(int, const char*); 25 | #endif 26 | #endif 27 | #endif /*KR_HEADERS*/ 28 | 29 | extern char *mktemp(char*); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | #endif 35 | 36 | #include "fcntl.h" 37 | 38 | #ifndef O_WRONLY 39 | #define O_RDONLY 0 40 | #define O_WRONLY 1 41 | #endif 42 | -------------------------------------------------------------------------------- /lib/f2c/rewind.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | #ifdef KR_headers 7 | integer f_rew(a) alist *a; 8 | #else 9 | integer f_rew(alist *a) 10 | #endif 11 | { 12 | unit *b; 13 | if(a->aunit>=MXUNIT || a->aunit<0) 14 | err(a->aerr,101,"rewind"); 15 | b = &f__units[a->aunit]; 16 | if(b->ufd == NULL || b->uwrt == 3) 17 | return(0); 18 | if(!b->useek) 19 | err(a->aerr,106,"rewind") 20 | if(b->uwrt) { 21 | (void) t_runc(a); 22 | b->uwrt = 3; 23 | } 24 | rewind(b->ufd); 25 | b->uend=0; 26 | return(0); 27 | } 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/f2c/rsfe.c: -------------------------------------------------------------------------------- 1 | /* read sequential formatted external */ 2 | #include "f2c.h" 3 | #include "fio.h" 4 | #include "fmt.h" 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | int 10 | xrd_SL(Void) 11 | { int ch; 12 | if(!f__curunit->uend) 13 | while((ch=getc(f__cf))!='\n') 14 | if (ch == EOF) { 15 | f__curunit->uend = 1; 16 | break; 17 | } 18 | f__cursor=f__recpos=0; 19 | return(1); 20 | } 21 | 22 | int 23 | x_getc(Void) 24 | { int ch; 25 | if(f__curunit->uend) return(EOF); 26 | ch = getc(f__cf); 27 | if(ch!=EOF && ch!='\n') 28 | { f__recpos++; 29 | return(ch); 30 | } 31 | if(ch=='\n') 32 | { (void) ungetc(ch,f__cf); 33 | return(ch); 34 | } 35 | if(f__curunit->uend || feof(f__cf)) 36 | { errno=0; 37 | f__curunit->uend=1; 38 | return(-1); 39 | } 40 | return(-1); 41 | } 42 | 43 | int 44 | x_endp(Void) 45 | { 46 | xrd_SL(); 47 | return f__curunit->uend == 1 ? EOF : 0; 48 | } 49 | 50 | int 51 | x_rev(Void) 52 | { 53 | (void) xrd_SL(); 54 | return(0); 55 | } 56 | #ifdef KR_headers 57 | integer s_rsfe(a) cilist *a; /* start */ 58 | #else 59 | integer s_rsfe(cilist *a) /* start */ 60 | #endif 61 | { int n; 62 | if(!f__init) f_init(); 63 | f__reading=1; 64 | f__sequential=1; 65 | f__formatted=1; 66 | f__external=1; 67 | if(n=c_sfe(a)) return(n); 68 | f__elist=a; 69 | f__cursor=f__recpos=0; 70 | f__scale=0; 71 | f__fmtbuf=a->cifmt; 72 | f__cf=f__curunit->ufd; 73 | if(pars_f(f__fmtbuf)<0) err(a->cierr,100,"startio"); 74 | f__getn= x_getc; 75 | f__doed= rd_ed; 76 | f__doned= rd_ned; 77 | fmt_bg(); 78 | f__doend=x_endp; 79 | f__donewrec=xrd_SL; 80 | f__dorevert=x_rev; 81 | f__cblank=f__curunit->ublnk; 82 | f__cplus=0; 83 | if(f__curunit->uwrt && f__nowreading(f__curunit)) 84 | err(a->cierr,errno,"read start"); 85 | if(f__curunit->uend) 86 | err(f__elist->ciend,(EOF),"read start"); 87 | return(0); 88 | } 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | -------------------------------------------------------------------------------- /lib/f2c/s_cat.c: -------------------------------------------------------------------------------- 1 | /* Unless compiled with -DNO_OVERWRITE, this variant of s_cat allows the 2 | * target of a concatenation to appear on its right-hand side (contrary 3 | * to the Fortran 77 Standard, but in accordance with Fortran 90). 4 | */ 5 | 6 | #include "f2c.h" 7 | #ifndef NO_OVERWRITE 8 | #include "stdio.h" 9 | #undef abs 10 | #ifdef KR_headers 11 | extern char *F77_aloc(); 12 | extern void free(); 13 | extern void exit_(); 14 | #else 15 | #undef min 16 | #undef max 17 | #include "stdlib.h" 18 | extern 19 | #ifdef __cplusplus 20 | "C" 21 | #endif 22 | char *F77_aloc(ftnlen, const char*); 23 | #endif 24 | #include "string.h" 25 | #endif /* NO_OVERWRITE */ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | VOID 32 | #ifdef KR_headers 33 | s_cat(lp, rpp, rnp, np, ll) char *lp, *rpp[]; ftnint rnp[], *np; ftnlen ll; 34 | #else 35 | s_cat(char *lp, char *rpp[], ftnint rnp[], ftnint *np, ftnlen ll) 36 | #endif 37 | { 38 | ftnlen i, nc; 39 | char *rp; 40 | ftnlen n = *np; 41 | #ifndef NO_OVERWRITE 42 | ftnlen L, m; 43 | char *lp0, *lp1; 44 | 45 | lp0 = 0; 46 | lp1 = lp; 47 | L = ll; 48 | i = 0; 49 | while(i < n) { 50 | rp = rpp[i]; 51 | m = rnp[i++]; 52 | if (rp >= lp1 || rp + m <= lp) { 53 | if ((L -= m) <= 0) { 54 | n = i; 55 | break; 56 | } 57 | lp1 += m; 58 | continue; 59 | } 60 | lp0 = lp; 61 | lp = lp1 = F77_aloc(L = ll, "s_cat"); 62 | break; 63 | } 64 | lp1 = lp; 65 | #endif /* NO_OVERWRITE */ 66 | for(i = 0 ; i < n ; ++i) { 67 | nc = ll; 68 | if(rnp[i] < nc) 69 | nc = rnp[i]; 70 | ll -= nc; 71 | rp = rpp[i]; 72 | while(--nc >= 0) 73 | *lp++ = *rp++; 74 | } 75 | while(--ll >= 0) 76 | *lp++ = ' '; 77 | #ifndef NO_OVERWRITE 78 | if (lp0) { 79 | memcpy(lp0, lp1, L); 80 | free(lp1); 81 | } 82 | #endif 83 | } 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | -------------------------------------------------------------------------------- /lib/f2c/s_cmp.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | /* compare two strings */ 7 | 8 | #ifdef KR_headers 9 | integer s_cmp(a0, b0, la, lb) char *a0, *b0; ftnlen la, lb; 10 | #else 11 | integer s_cmp(char *a0, char *b0, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | register unsigned char *a, *aend, *b, *bend; 15 | a = (unsigned char *)a0; 16 | b = (unsigned char *)b0; 17 | aend = a + la; 18 | bend = b + lb; 19 | 20 | if(la <= lb) 21 | { 22 | while(a < aend) 23 | if(*a != *b) 24 | return( *a - *b ); 25 | else 26 | { ++a; ++b; } 27 | 28 | while(b < bend) 29 | if(*b != ' ') 30 | return( ' ' - *b ); 31 | else ++b; 32 | } 33 | 34 | else 35 | { 36 | while(b < bend) 37 | if(*a == *b) 38 | { ++a; ++b; } 39 | else 40 | return( *a - *b ); 41 | while(a < aend) 42 | if(*a != ' ') 43 | return(*a - ' '); 44 | else ++a; 45 | } 46 | return(0); 47 | } 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /lib/f2c/s_copy.c: -------------------------------------------------------------------------------- 1 | /* Unless compiled with -DNO_OVERWRITE, this variant of s_copy allows the 2 | * target of an assignment to appear on its right-hand side (contrary 3 | * to the Fortran 77 Standard, but in accordance with Fortran 90), 4 | * as in a(2:5) = a(4:7) . 5 | */ 6 | 7 | #include "f2c.h" 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | /* assign strings: a = b */ 13 | 14 | #ifdef KR_headers 15 | VOID s_copy(a, b, la, lb) register char *a, *b; ftnlen la, lb; 16 | #else 17 | void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb) 18 | #endif 19 | { 20 | register char *aend, *bend; 21 | 22 | aend = a + la; 23 | 24 | if(la <= lb) 25 | #ifndef NO_OVERWRITE 26 | if (a <= b || a >= b + la) 27 | #endif 28 | while(a < aend) 29 | *a++ = *b++; 30 | #ifndef NO_OVERWRITE 31 | else 32 | for(b += la; a < aend; ) 33 | *--aend = *--b; 34 | #endif 35 | 36 | else { 37 | bend = b + lb; 38 | #ifndef NO_OVERWRITE 39 | if (a <= b || a >= bend) 40 | #endif 41 | while(b < bend) 42 | *a++ = *b++; 43 | #ifndef NO_OVERWRITE 44 | else { 45 | a += lb; 46 | while(b < bend) 47 | *--a = *--bend; 48 | a += lb; 49 | } 50 | #endif 51 | while(a < aend) 52 | *a++ = ' '; 53 | } 54 | } 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /lib/f2c/s_rnge.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "f2c.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | /* called when a subscript is out of range */ 8 | 9 | #ifdef KR_headers 10 | extern VOID sig_die(); 11 | integer s_rnge(varn, offset, procn, line) char *varn, *procn; ftnint offset, line; 12 | #else 13 | extern VOID sig_die(const char*,int); 14 | integer s_rnge(char *varn, ftnint offset, char *procn, ftnint line) 15 | #endif 16 | { 17 | register int i; 18 | 19 | fprintf(stderr, "Subscript out of range on file line %ld, procedure ", 20 | (long)line); 21 | while((i = *procn) && i != '_' && i != ' ') 22 | putc(*procn++, stderr); 23 | fprintf(stderr, ".\nAttempt to access the %ld-th element of variable ", 24 | (long)offset+1); 25 | while((i = *varn) && i != ' ') 26 | putc(*varn++, stderr); 27 | sig_die(".", 1); 28 | return 0; /* not reached */ 29 | } 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /lib/f2c/s_stop.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "f2c.h" 3 | 4 | #ifdef KR_headers 5 | extern void f_exit(); 6 | int s_stop(s, n) char *s; ftnlen n; 7 | #else 8 | #undef abs 9 | #undef min 10 | #undef max 11 | #include "stdlib.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | void f_exit(void); 19 | 20 | int s_stop(char *s, ftnlen n) 21 | #endif 22 | { 23 | int i; 24 | 25 | if(n > 0) 26 | { 27 | fprintf(stderr, "STOP "); 28 | for(i = 0; iciunit]; 29 | if(a->ciunit >= MXUNIT || a->ciunit<0) 30 | err(a->cierr,101,"startio"); 31 | if(p->ufd==NULL && fk_open(SEQ,FMT,a->ciunit)) err(a->cierr,114,"sfe") 32 | if(!p->ufmt) err(a->cierr,102,"sfe") 33 | return(0); 34 | } 35 | integer e_wsfe(Void) 36 | { 37 | int n = en_fio(); 38 | f__fmtbuf = NULL; 39 | #ifdef ALWAYS_FLUSH 40 | if (!n && fflush(f__cf)) 41 | err(f__elist->cierr, errno, "write end"); 42 | #endif 43 | return n; 44 | } 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/f2c/sig_die.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "signal.h" 3 | 4 | #ifndef SIGIOT 5 | #ifdef SIGABRT 6 | #define SIGIOT SIGABRT 7 | #endif 8 | #endif 9 | 10 | #ifdef KR_headers 11 | void sig_die(s, kill) char *s; int kill; 12 | #else 13 | #include "stdlib.h" 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | extern void f_exit(void); 21 | 22 | void sig_die(const char *s, int kill) 23 | #endif 24 | { 25 | /* print error message, then clear buffers */ 26 | fprintf(stderr, "%s\n", s); 27 | 28 | if(kill) 29 | { 30 | fflush(stderr); 31 | f_exit(); 32 | fflush(stderr); 33 | /* now get a core */ 34 | #ifdef SIGIOT 35 | signal(SIGIOT, SIG_DFL); 36 | #endif 37 | abort(); 38 | } 39 | else { 40 | #ifdef NO_ONEXIT 41 | f_exit(); 42 | #endif 43 | exit(1); 44 | } 45 | } 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /lib/f2c/signal1.h0: -------------------------------------------------------------------------------- 1 | /* You may need to adjust the definition of signal1 to supply a */ 2 | /* cast to the correct argument type. This detail is system- and */ 3 | /* compiler-dependent. The #define below assumes signal.h declares */ 4 | /* type SIG_PF for the signal function's second argument. */ 5 | 6 | /* For some C++ compilers, "#define Sigarg_t ..." may be appropriate. */ 7 | 8 | #include 9 | 10 | #ifndef Sigret_t 11 | #define Sigret_t void 12 | #endif 13 | #ifndef Sigarg_t 14 | #ifdef KR_headers 15 | #define Sigarg_t 16 | #else 17 | #define Sigarg_t int 18 | #endif 19 | #endif /*Sigarg_t*/ 20 | 21 | #ifdef USE_SIG_PF /* compile with -DUSE_SIG_PF under IRIX */ 22 | #define sig_pf SIG_PF 23 | #else 24 | typedef Sigret_t (*sig_pf)(Sigarg_t); 25 | #endif 26 | 27 | #define signal1(a,b) signal(a,(sig_pf)b) 28 | 29 | #ifdef __cplusplus 30 | #define Sigarg ... 31 | #define Use_Sigarg 32 | #else 33 | #define Sigarg Int n 34 | #define Use_Sigarg n = n /* shut up compiler warning */ 35 | #endif 36 | -------------------------------------------------------------------------------- /lib/f2c/signal_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "signal1.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | ftnint 8 | #ifdef KR_headers 9 | signal_(sigp, proc) integer *sigp; sig_pf proc; 10 | #else 11 | signal_(integer *sigp, sig_pf proc) 12 | #endif 13 | { 14 | int sig; 15 | sig = (int)*sigp; 16 | 17 | return (ftnint)signal(sig, proc); 18 | } 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /lib/f2c/signbit.c: -------------------------------------------------------------------------------- 1 | #include "arith.h" 2 | 3 | #ifndef Long 4 | #define Long long 5 | #endif 6 | 7 | int 8 | #ifdef KR_headers 9 | signbit_f2c(x) double *x; 10 | #else 11 | signbit_f2c(double *x) 12 | #endif 13 | { 14 | #ifdef IEEE_MC68k 15 | if (*(Long*)x & 0x80000000) 16 | return 1; 17 | #else 18 | #ifdef IEEE_8087 19 | if (((Long*)x)[1] & 0x80000000) 20 | return 1; 21 | #endif /*IEEE_8087*/ 22 | #endif /*IEEE_MC68k*/ 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /lib/f2c/sysdep1.h0: -------------------------------------------------------------------------------- 1 | #ifndef SYSDEP_H_INCLUDED 2 | #define SYSDEP_H_INCLUDED 3 | #undef USE_LARGEFILE 4 | #ifndef NO_LONG_LONG 5 | 6 | #ifdef __sun__ 7 | #define USE_LARGEFILE 8 | #define OFF_T off64_t 9 | #endif 10 | 11 | #ifdef __linux__ 12 | #define USE_LARGEFILE 13 | #define OFF_T __off64_t 14 | #endif 15 | 16 | #ifdef _AIX43 17 | #define _LARGE_FILES 18 | #define _LARGE_FILE_API 19 | #define USE_LARGEFILE 20 | #endif /*_AIX43*/ 21 | 22 | #ifdef __hpux 23 | #define _FILE64 24 | #define _LARGEFILE64_SOURCE 25 | #define USE_LARGEFILE 26 | #endif /*__hpux*/ 27 | 28 | #ifdef __sgi 29 | #define USE_LARGEFILE 30 | #endif /*__sgi*/ 31 | 32 | #ifdef __FreeBSD__ 33 | #define OFF_T off_t 34 | #define FSEEK fseeko 35 | #define FTELL ftello 36 | #endif 37 | 38 | #ifdef USE_LARGEFILE 39 | #ifndef OFF_T 40 | #define OFF_T off64_t 41 | #endif 42 | #define _LARGEFILE_SOURCE 43 | #define _LARGEFILE64_SOURCE 44 | #include 45 | #include 46 | #define FOPEN fopen64 47 | #define FREOPEN freopen64 48 | #define FSEEK fseeko64 49 | #define FSTAT fstat64 50 | #define FTELL ftello64 51 | #define FTRUNCATE ftruncate64 52 | #define STAT stat64 53 | #define STAT_ST stat64 54 | #endif /*USE_LARGEFILE*/ 55 | #endif /*NO_LONG_LONG*/ 56 | 57 | #ifndef NON_UNIX_STDIO 58 | #ifndef USE_LARGEFILE 59 | #define _INCLUDE_POSIX_SOURCE /* for HP-UX */ 60 | #define _INCLUDE_XOPEN_SOURCE /* for HP-UX */ 61 | #include "sys/types.h" 62 | #include "sys/stat.h" 63 | #endif 64 | #endif 65 | 66 | #endif /*SYSDEP_H_INCLUDED*/ 67 | -------------------------------------------------------------------------------- /lib/f2c/system_.c: -------------------------------------------------------------------------------- 1 | /* f77 interface to system routine */ 2 | 3 | #include "f2c.h" 4 | 5 | #ifdef KR_headers 6 | extern char *F77_aloc(); 7 | 8 | integer 9 | system_(s, n) register char *s; ftnlen n; 10 | #else 11 | #undef abs 12 | #undef min 13 | #undef max 14 | #include "stdlib.h" 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | extern char *F77_aloc(ftnlen, const char*); 19 | 20 | integer 21 | system_(register char *s, ftnlen n) 22 | #endif 23 | { 24 | char buff0[256], *buff; 25 | register char *bp, *blast; 26 | integer rv; 27 | 28 | buff = bp = n < sizeof(buff0) 29 | ? buff0 : F77_aloc(n+1, "system_"); 30 | blast = bp + n; 31 | 32 | while(bp < blast && *s) 33 | *bp++ = *s++; 34 | *bp = 0; 35 | rv = system(buff); 36 | if (buff != buff0) 37 | free(buff); 38 | return rv; 39 | } 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /lib/f2c/typesize.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | ftnlen f__typesize[] = { 0, 0, sizeof(shortint), sizeof(integer), 7 | sizeof(real), sizeof(doublereal), 8 | sizeof(complex), sizeof(doublecomplex), 9 | sizeof(logical), sizeof(char), 10 | 0, sizeof(integer1), 11 | sizeof(logical1), sizeof(shortlogical), 12 | #ifdef Allow_TYQUAD 13 | sizeof(longint), 14 | #endif 15 | 0}; 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/uio.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | uiolen f__reclen; 7 | 8 | int 9 | #ifdef KR_headers 10 | do_us(number,ptr,len) ftnint *number; char *ptr; ftnlen len; 11 | #else 12 | do_us(ftnint *number, char *ptr, ftnlen len) 13 | #endif 14 | { 15 | if(f__reading) 16 | { 17 | f__recpos += (int)(*number * len); 18 | if(f__recpos>f__reclen) 19 | err(f__elist->cierr, 110, "do_us"); 20 | if (fread(ptr,(int)len,(int)(*number),f__cf) != *number) 21 | err(f__elist->ciend, EOF, "do_us"); 22 | return(0); 23 | } 24 | else 25 | { 26 | f__reclen += *number * len; 27 | (void) fwrite(ptr,(int)len,(int)(*number),f__cf); 28 | return(0); 29 | } 30 | } 31 | #ifdef KR_headers 32 | integer do_ud(number,ptr,len) ftnint *number; char *ptr; ftnlen len; 33 | #else 34 | integer do_ud(ftnint *number, char *ptr, ftnlen len) 35 | #endif 36 | { 37 | f__recpos += (int)(*number * len); 38 | if(f__recpos > f__curunit->url && f__curunit->url!=1) 39 | err(f__elist->cierr,110,"do_ud"); 40 | if(f__reading) 41 | { 42 | #ifdef Pad_UDread 43 | #ifdef KR_headers 44 | int i; 45 | #else 46 | size_t i; 47 | #endif 48 | if (!(i = fread(ptr,(int)len,(int)(*number),f__cf)) 49 | && !(f__recpos - *number*len)) 50 | err(f__elist->cierr,EOF,"do_ud") 51 | if (i < *number) 52 | memset(ptr + i*len, 0, (*number - i)*len); 53 | return 0; 54 | #else 55 | if(fread(ptr,(int)len,(int)(*number),f__cf) != *number) 56 | err(f__elist->cierr,EOF,"do_ud") 57 | else return(0); 58 | #endif 59 | } 60 | (void) fwrite(ptr,(int)len,(int)(*number),f__cf); 61 | return(0); 62 | } 63 | #ifdef KR_headers 64 | integer do_uio(number,ptr,len) ftnint *number; char *ptr; ftnlen len; 65 | #else 66 | integer do_uio(ftnint *number, char *ptr, ftnlen len) 67 | #endif 68 | { 69 | if(f__sequential) 70 | return(do_us(number,ptr,len)); 71 | else return(do_ud(number,ptr,len)); 72 | } 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | -------------------------------------------------------------------------------- /lib/f2c/util.c: -------------------------------------------------------------------------------- 1 | #include "sysdep1.h" /* here to get stat64 on some badly designed Linux systems */ 2 | #include "f2c.h" 3 | #include "fio.h" 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | VOID 9 | #ifdef KR_headers 10 | #define Const /*nothing*/ 11 | g_char(a,alen,b) char *a,*b; ftnlen alen; 12 | #else 13 | #define Const const 14 | g_char(const char *a, ftnlen alen, char *b) 15 | #endif 16 | { 17 | Const char *x = a + alen; 18 | char *y = b + alen; 19 | 20 | for(;; y--) { 21 | if (x <= a) { 22 | *b = 0; 23 | return; 24 | } 25 | if (*--x != ' ') 26 | break; 27 | } 28 | *y-- = 0; 29 | do *y-- = *x; 30 | while(x-- > a); 31 | } 32 | 33 | VOID 34 | #ifdef KR_headers 35 | b_char(a,b,blen) char *a,*b; ftnlen blen; 36 | #else 37 | b_char(const char *a, char *b, ftnlen blen) 38 | #endif 39 | { int i; 40 | for(i=0;icifmt; 61 | f__cf=f__curunit->ufd; 62 | if(pars_f(f__fmtbuf)<0) err(a->cierr,100,"startio"); 63 | f__putn= x_putc; 64 | f__doed= w_ed; 65 | f__doned= w_ned; 66 | f__doend=xw_end; 67 | f__dorevert=xw_rev; 68 | f__donewrec=x_wSL; 69 | fmt_bg(); 70 | f__cplus=0; 71 | f__cblank=f__curunit->ublnk; 72 | if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) 73 | err(a->cierr,errno,"write start"); 74 | return(0); 75 | } 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | -------------------------------------------------------------------------------- /lib/f2c/wsle.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #include "fmt.h" 4 | #include "lio.h" 5 | #include "string.h" 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #ifdef KR_headers 11 | integer s_wsle(a) cilist *a; 12 | #else 13 | integer s_wsle(cilist *a) 14 | #endif 15 | { 16 | int n; 17 | if(n=c_le(a)) return(n); 18 | f__reading=0; 19 | f__external=1; 20 | f__formatted=1; 21 | f__putn = x_putc; 22 | f__lioproc = l_write; 23 | L_len = LINE; 24 | f__donewrec = x_wSL; 25 | if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) 26 | err(a->cierr, errno, "list output start"); 27 | return(0); 28 | } 29 | 30 | integer e_wsle(Void) 31 | { 32 | int n = f__putbuf('\n'); 33 | f__recpos=0; 34 | #ifdef ALWAYS_FLUSH 35 | if (!n && fflush(f__cf)) 36 | err(f__elist->cierr, errno, "write end"); 37 | #endif 38 | return(n); 39 | } 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /lib/f2c/wsne.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #include "lio.h" 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | integer 9 | #ifdef KR_headers 10 | s_wsne(a) cilist *a; 11 | #else 12 | s_wsne(cilist *a) 13 | #endif 14 | { 15 | int n; 16 | 17 | if(n=c_le(a)) 18 | return(n); 19 | f__reading=0; 20 | f__external=1; 21 | f__formatted=1; 22 | f__putn = x_putc; 23 | L_len = LINE; 24 | f__donewrec = x_wSL; 25 | if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) 26 | err(a->cierr, errno, "namelist output start"); 27 | x_wsne(a); 28 | return e_wsle(); 29 | } 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /lib/f2c/xwsne.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #include "lio.h" 4 | #include "fmt.h" 5 | 6 | extern int f__Aquote; 7 | 8 | static VOID 9 | nl_donewrec(Void) 10 | { 11 | (*f__donewrec)(); 12 | PUT(' '); 13 | } 14 | 15 | #ifdef KR_headers 16 | x_wsne(a) cilist *a; 17 | #else 18 | #include "string.h" 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | VOID 24 | x_wsne(cilist *a) 25 | #endif 26 | { 27 | Namelist *nl; 28 | char *s; 29 | Vardesc *v, **vd, **vde; 30 | ftnint number, type; 31 | ftnlen *dims; 32 | ftnlen size; 33 | extern ftnlen f__typesize[]; 34 | 35 | nl = (Namelist *)a->cifmt; 36 | PUT('&'); 37 | for(s = nl->name; *s; s++) 38 | PUT(*s); 39 | PUT(' '); 40 | f__Aquote = 1; 41 | vd = nl->vars; 42 | vde = vd + nl->nvars; 43 | while(vd < vde) { 44 | v = *vd++; 45 | s = v->name; 46 | #ifdef No_Extra_Namelist_Newlines 47 | if (f__recpos+strlen(s)+2 >= L_len) 48 | #endif 49 | nl_donewrec(); 50 | while(*s) 51 | PUT(*s++); 52 | PUT(' '); 53 | PUT('='); 54 | number = (dims = v->dims) ? dims[1] : 1; 55 | type = v->type; 56 | if (type < 0) { 57 | size = -type; 58 | type = TYCHAR; 59 | } 60 | else 61 | size = f__typesize[type]; 62 | l_write(&number, v->addr, size, type); 63 | if (vd < vde) { 64 | if (f__recpos+2 >= L_len) 65 | nl_donewrec(); 66 | PUT(','); 67 | PUT(' '); 68 | } 69 | else if (f__recpos+1 >= L_len) 70 | nl_donewrec(); 71 | } 72 | f__Aquote = 0; 73 | PUT('/'); 74 | } 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | -------------------------------------------------------------------------------- /lib/f2c/z_abs.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double f__cabs(); 8 | double z_abs(z) doublecomplex *z; 9 | #else 10 | double f__cabs(double, double); 11 | double z_abs(doublecomplex *z) 12 | #endif 13 | { 14 | return( f__cabs( z->r, z->i ) ); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /lib/f2c/z_cos.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sin(), cos(), sinh(), cosh(); 5 | VOID z_cos(r, z) doublecomplex *r, *z; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | void z_cos(doublecomplex *r, doublecomplex *z) 13 | #endif 14 | { 15 | double zi = z->i, zr = z->r; 16 | r->r = cos(zr) * cosh(zi); 17 | r->i = - sin(zr) * sinh(zi); 18 | } 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /lib/f2c/z_div.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern VOID sig_die(); 8 | VOID z_div(c, a, b) doublecomplex *a, *b, *c; 9 | #else 10 | extern void sig_die(const char*, int); 11 | void z_div(doublecomplex *c, doublecomplex *a, doublecomplex *b) 12 | #endif 13 | { 14 | double ratio, den; 15 | double abr, abi, cr; 16 | 17 | if( (abr = b->r) < 0.) 18 | abr = - abr; 19 | if( (abi = b->i) < 0.) 20 | abi = - abi; 21 | if( abr <= abi ) 22 | { 23 | if(abi == 0) { 24 | #ifdef IEEE_COMPLEX_DIVIDE 25 | if (a->i != 0 || a->r != 0) 26 | abi = 1.; 27 | c->i = c->r = abi / abr; 28 | return; 29 | #else 30 | sig_die("complex division by zero", 1); 31 | #endif 32 | } 33 | ratio = b->r / b->i ; 34 | den = b->i * (1 + ratio*ratio); 35 | cr = (a->r*ratio + a->i) / den; 36 | c->i = (a->i*ratio - a->r) / den; 37 | } 38 | 39 | else 40 | { 41 | ratio = b->i / b->r ; 42 | den = b->r * (1 + ratio*ratio); 43 | cr = (a->r + a->i*ratio) / den; 44 | c->i = (a->i - a->r*ratio) / den; 45 | } 46 | c->r = cr; 47 | } 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /lib/f2c/z_exp.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double exp(), cos(), sin(); 5 | VOID z_exp(r, z) doublecomplex *r, *z; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | void z_exp(doublecomplex *r, doublecomplex *z) 13 | #endif 14 | { 15 | double expx, zi = z->i; 16 | 17 | expx = exp(z->r); 18 | r->r = expx * cos(zi); 19 | r->i = expx * sin(zi); 20 | } 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /lib/f2c/z_sin.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sin(), cos(), sinh(), cosh(); 5 | VOID z_sin(r, z) doublecomplex *r, *z; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | void z_sin(doublecomplex *r, doublecomplex *z) 13 | #endif 14 | { 15 | double zi = z->i, zr = z->r; 16 | r->r = sin(zr) * cosh(zi); 17 | r->i = cos(zr) * sinh(zi); 18 | } 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /lib/f2c/z_sqrt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sqrt(), f__cabs(); 5 | VOID z_sqrt(r, z) doublecomplex *r, *z; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | extern double f__cabs(double, double); 13 | void z_sqrt(doublecomplex *r, doublecomplex *z) 14 | #endif 15 | { 16 | double mag, zi = z->i, zr = z->r; 17 | 18 | if( (mag = f__cabs(zr, zi)) == 0.) 19 | r->r = r->i = 0.; 20 | else if(zr > 0) 21 | { 22 | r->r = sqrt(0.5 * (mag + zr) ); 23 | r->i = zi / r->r / 2; 24 | } 25 | else 26 | { 27 | r->i = sqrt(0.5 * (mag - zr) ); 28 | if(zi < 0) 29 | r->i = - r->i; 30 | r->r = zi / r->i / 2; 31 | } 32 | } 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /lib/getopt/queue.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/lib/getopt/queue.h -------------------------------------------------------------------------------- /lib/imagelib/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for imagelib 2 | 3 | GCC = g++ 4 | 5 | CC=gcc 6 | OPTFLAGS=-O3 7 | OTHERFLAGS=-Wall 8 | 9 | IMAGELIB_OBJS= affine.o bmp.o canny.o color.o fileio.o filter.o fit.o \ 10 | fmatrix.o homography.o horn.o image.o lerp.o morphology.o \ 11 | pgm.o poly.o qsort.o resample.o tps.o transform.o \ 12 | triangulate.o util.o 13 | 14 | INCLUDE_PATH=-I../matrix 15 | 16 | CFLAGS=$(OTHERFLAGS) $(OPTFLAGS) $(INCLUDE_PATH) 17 | 18 | IMAGELIB=libimage.a 19 | 20 | all: $(IMAGELIB) 21 | 22 | $(IMAGELIB): $(IMAGELIB_OBJS) 23 | ar r $(IMAGELIB) $(IMAGELIB_OBJS) 24 | cp $(IMAGELIB) .. 25 | 26 | clean: 27 | rm -f *.o *~ $(IMAGELIB) 28 | -------------------------------------------------------------------------------- /lib/imagelib/affine.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* affine.h */ 18 | /* Computes an affine transformation */ 19 | 20 | #ifndef __affine_h__ 21 | #define __affine_h__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "vector.h" 28 | 29 | /* Computes the affine transformation that, when applied to the points 30 | * in l_pts, minimizes the least-squares error between the result and 31 | * the corresponding points in r_pts. 32 | * 33 | * n -- number of points 34 | * r_pts -- matches 35 | * l_pts -- initial points 36 | * Tout -- on return, contains the 3x3 transformation matrix */ 37 | void align_affine(int num_pts, v3_t *r_pts, v3_t *l_pts, double *Tout); 38 | 39 | void align_affine_3D(int num_pts, v3_t *r_pts, v3_t *l_pts, double *Tout); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* __affine_h__ */ 46 | -------------------------------------------------------------------------------- /lib/imagelib/defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* defines.h */ 18 | /* Contains standard definitions */ 19 | 20 | #ifndef __defines_h__ 21 | #define __defines_h__ 22 | 23 | #define CLAMP(x,mn,mx) (((x) < mn) ? mn : (((x) > mx) ? mx : (x))) 24 | 25 | #define MAX(x,y) (((x) < (y)) ? (y) : (x)) 26 | #define MIN(x,y) (((x) < (y)) ? (x) : (y)) 27 | 28 | #define MAX4(a,b,c,d) (MAX(MAX(a,b), MAX(c,d))) 29 | #define MIN4(a,b,c,d) (MIN(MIN(a,b), MIN(c,d))) 30 | 31 | #define DEG2RAD(d) ((d) * (M_PI / 180.0)) 32 | #define RAD2DEG(r) ((r) * (180.0 / M_PI)) 33 | 34 | #define SQ(x) ((x) * (x)) 35 | #define CB(x) ((x) * (x) * (x)) 36 | 37 | /* Return the index of entry (x, y) in a 2D array */ 38 | #define INDEX(x, y, w) ((y) * (w) + (x)) 39 | 40 | #define SGN(x) ((x) < 0 ? (-1) : (1)) 41 | 42 | #ifdef WIN32 43 | #ifndef M_PI 44 | #define M_PI 3.14159265358979323846f 45 | #endif 46 | #endif 47 | 48 | #endif /* __defines_h__ */ 49 | -------------------------------------------------------------------------------- /lib/imagelib/dmap-io.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* dmap-io.h */ 18 | /* Routines for reading / writing / rendering distance maps */ 19 | 20 | #ifndef __dmap_io_h__ 21 | #define __dmap_io_h__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "dmap.h" 28 | #include "image.h" 29 | #include "vector.h" 30 | 31 | /* Create a clean dmap */ 32 | img_dmap_t *img_dmap_new(int w, int h); 33 | 34 | /* Produces an image of a distance map */ 35 | img_t *img_dmap_render(img_dmap_t *dmap); 36 | 37 | /* Produces an image of the disparity between two images */ 38 | img_t *img_dmap_render_disparity(img_dmap_t *dmap); 39 | 40 | /* Produces an image of the flow map */ 41 | img_t *img_dmap_render_flow(img_dmap_t *dmap); 42 | 43 | /* Write a distance map to a file */ 44 | void img_dmap_write(FILE *f, img_dmap_t *dmap); 45 | 46 | /* Read a distance map from a file */ 47 | img_dmap_t *img_dmap_read(FILE *f); 48 | img_dmap_t *img_dmap_read_file(char *fname); 49 | 50 | /* Free a distance map */ 51 | void img_dmap_free(img_dmap_t *dmap); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif /* __dmap_io_h__ */ 58 | -------------------------------------------------------------------------------- /lib/imagelib/fileio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* fileio.c */ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #ifdef WIN32 24 | #include "types.h" 25 | #endif 26 | 27 | FILE *open_file(char *fname, char *flags) { 28 | FILE *f = fopen(fname, flags); 29 | if (f == NULL) { 30 | printf("Error opening file %s\n", fname); 31 | exit(1); 32 | } 33 | 34 | return f; 35 | } 36 | 37 | void read_word(u_int32_t *w, FILE *f) { 38 | fread(w, 4, 1, f); 39 | } 40 | 41 | void read_short(u_int16_t *s, FILE *f) { 42 | fread(s, 2, 1, f); 43 | } 44 | 45 | void read_byte(u_int8_t *b, FILE *f) { 46 | fread(b, 1, 1, f); 47 | } 48 | 49 | void read_float(float *fl, FILE *f) { 50 | fread(fl, sizeof(float), 1, f); 51 | } 52 | 53 | void read_double(u_int8_t *d, FILE *f) { 54 | fread(d, sizeof(double), 1, f); 55 | } 56 | 57 | void write_word(u_int32_t *w, FILE *f) { 58 | fwrite(w, 4, 1, f); 59 | } 60 | 61 | void write_short(u_int16_t *s, FILE *f) { 62 | fwrite(s, 2, 1, f); 63 | } 64 | 65 | void write_byte(u_int8_t *b, FILE *f) { 66 | fwrite(b, 1, 1, f); 67 | } 68 | 69 | void write_float(float *fl, FILE *f) { 70 | fwrite(fl, sizeof(float), 1, f); 71 | } 72 | 73 | 74 | void write_double(u_int8_t *d, FILE *f) { 75 | fwrite(d, sizeof(double), 1, f); 76 | } 77 | -------------------------------------------------------------------------------- /lib/imagelib/fileio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | #ifndef __fileio_h__ 18 | #define __fileio_h__ 19 | 20 | #include 21 | 22 | /* Open a file, exiting on error */ 23 | FILE *open_file(char *fname, char *flags); 24 | 25 | /* Read/write various sized items */ 26 | void read_word(u_int32_t *w, FILE *f); 27 | void read_short(u_int16_t *s, FILE *f); 28 | void read_byte(u_int8_t *b, FILE *f); 29 | void read_float(float *fl, FILE *f); 30 | void read_double(double *d, FILE *f); 31 | void write_word(u_int32_t *w, FILE *f); 32 | void write_short(u_int16_t *s, FILE *f); 33 | void write_byte(u_int8_t *b, FILE *f); 34 | void write_float(float *fl, FILE *f); 35 | void write_double(double *d, FILE *f); 36 | 37 | #endif /* __fileio_h__ */ 38 | -------------------------------------------------------------------------------- /lib/imagelib/homography.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* homography.h */ 18 | /* Computes a homography */ 19 | 20 | #ifndef __homography_h__ 21 | #define __homography_h__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "vector.h" 28 | 29 | /* Computes the homography that, when applied to the points in l_pts, 30 | * minimizes the least-squares error between the result and the 31 | * corresponding points in r_pts. 32 | * 33 | * n -- number of points 34 | * r_pts -- matches 35 | * l_pts -- initial points 36 | * Tout -- on return, contains the 3x3 transformation matrix */ 37 | void align_homography(int num_pts, v3_t *r_pts, v3_t *l_pts, double *Tout, int refine); 38 | 39 | /* Use non-linear least squares to refine a homography */ 40 | void align_homography_non_linear(int num_pts, v3_t *r_pts, v3_t *l_pts, 41 | double *Tin, double *Tout); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* __homography_h__ */ 48 | -------------------------------------------------------------------------------- /lib/imagelib/morphology.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* morphology.h */ 18 | /* Morphological operators */ 19 | 20 | #ifndef __morphology_h__ 21 | #define __morphology_h__ 22 | 23 | #include "image.h" 24 | 25 | /* Subtract one image from another */ 26 | img_t *img_subtract(img_t *img1, img_t *img2); 27 | 28 | /* Apply the hit-or-miss operator with the given structural element 29 | * and 90 degree rotation */ 30 | img_t *img_hit_or_miss(img_t *img, int esize, int *elem, int rot90); 31 | 32 | /* Dilate an image a given number of times */ 33 | img_t *img_dilate(img_t *img, int num_times); 34 | 35 | /* Apply thinning to an image */ 36 | img_t *img_thin(img_t *img); 37 | 38 | #endif /* __morphology_h__ */ 39 | -------------------------------------------------------------------------------- /lib/imagelib/pad.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* pad.h */ 18 | /* Contains definitions for padding integers in various ways */ 19 | 20 | #ifndef __pad_h__ 21 | #define __pad_h__ 22 | 23 | #define BIT_PAD_BYTE(x) ((((x) % 8) == 0) ? (x) : (x) + 8 - ((x) % 8)) 24 | #define BIT_PAD_WORD(x) ((((x) % 32) == 0) ? (x) : (x) + 32 - ((x) % 32)) 25 | #define BYTE_PAD_WORD(x) ((((x) % 4) == 0) ? (x) : (x) + 4 - ((x) % 4)) 26 | 27 | #endif /* __pad_h__ */ 28 | -------------------------------------------------------------------------------- /lib/imagelib/pgm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* pgm.h */ 18 | /* Read PGM files */ 19 | 20 | #ifndef __pgm_h__ 21 | #define __pgm_h__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Read a PGM file */ 28 | img_t *img_read_pgm_file(const char *filename); 29 | 30 | /* Read the dimensions of an image */ 31 | int img_read_pgm_dimensions(char *filename, int *w, int *h); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* __pgm_h__ */ 38 | -------------------------------------------------------------------------------- /lib/imagelib/pyramid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* pyramid.h */ 18 | /* Routines for creating a gaussian pyramid from an image */ 19 | 20 | #ifndef __pyramid_h__ 21 | #define __pyramid_h__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include 28 | 29 | #include "image.h" 30 | #include "vector.h" 31 | 32 | typedef struct { 33 | u_int16_t num_levels; /* Number of levels of the pyramid */ 34 | u_int16_t w, h; /* Width and height of the bottom of the pyramid */ 35 | img_t **imgs; /* Images in the pyramid */ 36 | } img_pyr_t; 37 | 38 | img_pyr_t *img_pyramid_new(int w, int h); 39 | 40 | /* Create a gaussian pyramid from an image, with a number of extra levels */ 41 | img_pyr_t *img_create_gaussian_pyramid(img_t *img, int extra); 42 | 43 | /* Use linear interpolation to compute the color of the point (x,y) 44 | * in the given image pyramid */ 45 | fcolor_t img_pyramid_pixel_lerp(img_pyr_t *pyr, double x, double y, 46 | double scale); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __pyramid_h__ */ 53 | -------------------------------------------------------------------------------- /lib/imagelib/qsort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | #ifndef __qsort_h__ 18 | #define __qsort_h__ 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /* Set whether we should sort in ascending or descending order */ 25 | void qsort_ascending(); 26 | void qsort_descending(); 27 | 28 | /* Sorts the array of doubles `arr' (of length n) and puts the 29 | * corresponding permutation in `perm' */ 30 | void qsort_perm(int n, double *arr, int *perm); 31 | 32 | /* Permute the array `arr' given permutation `perm' */ 33 | void permute_dbl(int n, double *arr, int *perm); 34 | void permute(int n, int size, void *arr, int *perm); 35 | 36 | /* Find the median in a set of doubles */ 37 | double median(int n, double *arr); 38 | double median_copy(int n, double *arr); 39 | 40 | /* Find the kth element in an unordered list of doubles (changes the 41 | * array) */ 42 | double kth_element(int n, int k, double *arr); 43 | /* Same as above, doesn't change the array */ 44 | double kth_element_copy(int n, int k, double *arr); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* __qsort_h__ */ 51 | -------------------------------------------------------------------------------- /lib/imagelib/tps.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* tps.h */ 18 | /* Routines for computing thin plate splines */ 19 | 20 | #ifndef __tps_h__ 21 | #define __tps_h__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "vector.h" 28 | 29 | /* Computes the TPS transformation that, when applied to the points 30 | * in l_pts, minimizes the least-squares error between the result and 31 | * the corresponding points in r_pts. 32 | * 33 | * n -- number of points 34 | * r_pts -- matches 35 | * l_pts -- initial points 36 | * Tout -- on return, contains the 3x3 transformation matrix */ 37 | void align_tps(int num_pts, v3_t *r_pts, v3_t *l_pts,double lambda, 38 | double *x_affine, double *x_weights, 39 | double *y_affine, double *y_weights); 40 | 41 | void get_tps_basis(int num_pts, v3_t *l_pts, double lambda, 42 | double *LU, int *ipiv); 43 | 44 | void align_tps_factored(int num_pts, v3_t *r_pts, 45 | double *LU, int *ipiv, 46 | double *x_affine, double *x_weights, 47 | double *y_affine, double *y_weights); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* __tps_h__ */ 54 | -------------------------------------------------------------------------------- /lib/imagelib/transform-opt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* transform-opt.h */ 18 | /* Methods for finding optimal transforms */ 19 | 20 | #ifndef __transform_opt_h__ 21 | #define __transform_opt_h__ 22 | 23 | /* List of known transformation classes */ 24 | typedef enum { 25 | TRANSFORM_TRANSLATE, 26 | TRANSFORM_TRANSLATE_ROTATE, 27 | TRANSFORM_AFFINE, 28 | TRANSFORM_HOMOGRAPHY 29 | } transform_class_t; 30 | 31 | /* Find the optimal transform of a given class, given point 32 | * correspondences */ 33 | void find_optimal_transform(transform_class_t tclass, int n, 34 | v3_t *r_pts, v3_t *l_pts, double *Tout); 35 | 36 | #endif /* __transform_opt_h__ */ 37 | -------------------------------------------------------------------------------- /lib/imagelib/triangle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | #ifndef __triangle_h__ 18 | #define __triangle_h__ 19 | 20 | #include "vector.h" 21 | 22 | /* Compute the nearest point on the segment (s1, s2) to point p */ 23 | v3_t segment_pt_nearest_pt(v3_t s1, v3_t s2, v3_t p); 24 | 25 | /* Compute the nearest point on the triangle (t1, t2, t3) to point p */ 26 | v3_t triangle_pt_nearest_pt(v3_t t1, v3_t t2, v3_t t3, v3_t p); 27 | 28 | #endif /* __triangle_h__ */ 29 | -------------------------------------------------------------------------------- /lib/imagelib/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* util.h */ 18 | /* Various utility functions */ 19 | 20 | #ifndef __util_h__ 21 | #define __util_h__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Returns the floor of the log (base 2) of the given number */ 28 | int ilog2(int n); 29 | 30 | /* Returns a random double between 0.0 and 1.0 */ 31 | double rand_unit(); 32 | 33 | /* Returns a random double between min and max */ 34 | double rand_double(double min, double max); 35 | 36 | /* Clamps the value x to lie within min and max */ 37 | double clamp(double x, double min, double max); 38 | 39 | /* Returns true if n is a power of two */ 40 | int is_power_of_two(int n); 41 | 42 | /* Returns the smallest power of two no smaller than the input */ 43 | int least_larger_power_of_two(int n); 44 | 45 | /* Return the closest integer to x, rounding up */ 46 | int iround(double x); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __util_h__ */ 53 | -------------------------------------------------------------------------------- /lib/imagelib/vanish.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* vanish.c */ 18 | /* Compute vanishing points from an image */ 19 | 20 | #ifndef __vanish_h__ 21 | #define __vanish_h__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "image.h" 28 | 29 | /* Find vanishing points using a Hough transform */ 30 | void compute_vps_hough(img_t *img); 31 | 32 | /* Find vanishing points using a Hough transform */ 33 | void compute_vps_hough_edges(img_t *img, int num_edges, edge_link_t *edges); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* __vanish_h__ */ 40 | -------------------------------------------------------------------------------- /lib/jpeg/src/jchuff.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jchuff.h 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains declarations for Huffman entropy encoding routines 9 | * that are shared between the sequential encoder (jchuff.c) and the 10 | * progressive encoder (jcphuff.c). No other modules need to see these. 11 | */ 12 | 13 | /* The legal range of a DCT coefficient is 14 | * -1024 .. +1023 for 8-bit data; 15 | * -16384 .. +16383 for 12-bit data. 16 | * Hence the magnitude should always fit in 10 or 14 bits respectively. 17 | */ 18 | 19 | #if BITS_IN_JSAMPLE == 8 20 | #define MAX_COEF_BITS 10 21 | #else 22 | #define MAX_COEF_BITS 14 23 | #endif 24 | 25 | /* Derived data constructed for each Huffman table */ 26 | 27 | typedef struct { 28 | unsigned int ehufco[256]; /* code for each symbol */ 29 | char ehufsi[256]; /* length of code for each symbol */ 30 | /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ 31 | } c_derived_tbl; 32 | 33 | /* Short forms of external names for systems with brain-damaged linkers. */ 34 | 35 | #ifdef NEED_SHORT_EXTERNAL_NAMES 36 | #define jpeg_make_c_derived_tbl jMkCDerived 37 | #define jpeg_gen_optimal_table jGenOptTbl 38 | #endif /* NEED_SHORT_EXTERNAL_NAMES */ 39 | 40 | /* Expand a Huffman table definition into the derived format */ 41 | EXTERN(void) jpeg_make_c_derived_tbl 42 | JPP((j_compress_ptr cinfo, boolean isDC, int tblno, 43 | c_derived_tbl ** pdtbl)); 44 | 45 | /* Generate an optimal table definition given the specified counts */ 46 | EXTERN(void) jpeg_gen_optimal_table 47 | JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); 48 | -------------------------------------------------------------------------------- /lib/jpeg/src/jconfig.h: -------------------------------------------------------------------------------- 1 | /* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ 2 | /* see jconfig.doc for explanations */ 3 | 4 | #define HAVE_PROTOTYPES 5 | #define HAVE_UNSIGNED_CHAR 6 | #define HAVE_UNSIGNED_SHORT 7 | /* #define void char */ 8 | /* #define const */ 9 | #undef CHAR_IS_UNSIGNED 10 | #define HAVE_STDDEF_H 11 | #define HAVE_STDLIB_H 12 | #undef NEED_BSD_STRINGS 13 | #undef NEED_SYS_TYPES_H 14 | #undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ 15 | #undef NEED_SHORT_EXTERNAL_NAMES 16 | #undef INCOMPLETE_TYPES_BROKEN 17 | 18 | /* Define "boolean" as unsigned char, not int, per Windows custom */ 19 | #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ 20 | typedef unsigned char boolean; 21 | #endif 22 | #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ 23 | 24 | 25 | #ifdef JPEG_INTERNALS 26 | 27 | #undef RIGHT_SHIFT_IS_UNSIGNED 28 | 29 | #endif /* JPEG_INTERNALS */ 30 | 31 | #ifdef JPEG_CJPEG_DJPEG 32 | 33 | #define BMP_SUPPORTED /* BMP image file format */ 34 | #define GIF_SUPPORTED /* GIF image file format */ 35 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ 36 | #undef RLE_SUPPORTED /* Utah RLE image file format */ 37 | #define TARGA_SUPPORTED /* Targa image file format */ 38 | 39 | #define TWO_FILE_COMMANDLINE /* optional */ 40 | #define USE_SETMODE /* Microsoft has setmode() */ 41 | #undef NEED_SIGNAL_CATCHER 42 | #undef DONT_USE_B_MODE 43 | #undef PROGRESS_REPORT /* optional */ 44 | 45 | #endif /* JPEG_CJPEG_DJPEG */ 46 | -------------------------------------------------------------------------------- /lib/jpeg/src/jversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jversion.h 3 | * 4 | * Copyright (C) 1991-1998, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains software version identification. 9 | */ 10 | 11 | 12 | #define JVERSION "6b 27-Mar-1998" 13 | 14 | #define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" 15 | -------------------------------------------------------------------------------- /lib/matrix/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for matrix library 2 | 3 | CC=gcc 4 | OPTFLAGS=-O3 5 | OTHERFLAGS=-Wall -D__NO_MKL__ 6 | 7 | INCLUDE_PATH = -I../imagelib -I../../include 8 | CFLAGS = $(OPTFLAGS) $(OTHERFLAGS) $(INCLUDE_PATH) 9 | 10 | TARGET = libmatrix.a 11 | OBJS = matrix.o vector.o svd.o 12 | 13 | all: $(TARGET) 14 | 15 | $(TARGET): $(OBJS) 16 | ar r $@ $(OBJS) 17 | cp $@ .. 18 | 19 | clean: 20 | rm -f *.o $(TARGET) *~ 21 | -------------------------------------------------------------------------------- /lib/matrix/svd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Noah Snavely (snavely (at) cs.washington.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | #ifndef __svd_h__ 18 | #define __svd_h__ 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | int svd(int m,int n,int withu,int withv,double eps,double tol, 25 | double *a, double *q, double *u, double *v, double *vt); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* __matrix_h__ */ 32 | -------------------------------------------------------------------------------- /lib/minpack/Makefile: -------------------------------------------------------------------------------- 1 | OBJS=dpmpar.o \ 2 | enorm.o \ 3 | fdjac2.o \ 4 | lmdif1.o \ 5 | lmdif.o \ 6 | lmpar.o \ 7 | qrfac.o \ 8 | qrsolv.o 9 | 10 | AR=ar 11 | FC=gcc 12 | FFLAGS=-O2 -ffast-math 13 | 14 | all: libminpack.a 15 | 16 | libminpack.a: $(OBJS) 17 | $(AR) rs $@ $(OBJS) 18 | cp $@ ../ 19 | 20 | clean: 21 | rm -f *.o *~ libminpack.a 22 | -------------------------------------------------------------------------------- /lib/sba-1.5/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Sparse Bundle Adjustment library & demo program 3 | # 4 | 5 | COMPILER=gcc 6 | CC=$(COMPILER) 7 | 8 | INCLUDE_FLAGS=-I../matrix 9 | 10 | OPTFLAGS=-O3 11 | 12 | OBJS=sba_levmar.o sba_levmar_wrap.o sba_lapack.o sba_crsm.o sba_chkjac.o 13 | SRCS=sba_levmar.c sba_levmar_wrap.c sba_lapack.c sba_crsm.c sba_chkjac.c 14 | AR=ar 15 | RANLIB=ranlib 16 | MAKE=make 17 | 18 | LIB=libsba.v1.5.a 19 | 20 | CFLAGS=-Wall $(OPTFLAGS) $(INCLUDE_FLAGS) 21 | 22 | all: $(LIB) 23 | 24 | $(LIB): $(OBJS) 25 | $(AR) crv $(LIB) $(OBJS) 26 | $(RANLIB) $(LIB) 27 | cp $(LIB) .. 28 | 29 | sba_levmar.o: sba.h sba_chkjac.h compiler.h 30 | sba_levmar_wrap.o: sba.h 31 | sba_lapack.o: sba.h compiler.h 32 | sba_crsm.o: sba.h 33 | sba_chkjac.o: sba.h sba_chkjac.h compiler.h 34 | 35 | clean: 36 | @rm -f *.o 37 | 38 | realclean cleanall: clean 39 | @rm -f libsba.a 40 | 41 | depend: 42 | makedepend -f Makefile $(SRCS) 43 | 44 | # DO NOT DELETE THIS LINE -- make depend depends on it. 45 | -------------------------------------------------------------------------------- /lib/sba-1.5/compiler.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////// 2 | //// 3 | //// Compiler-specific definitions for sparse bundle adjustment based on the 4 | //// Levenberg - Marquardt minimization algorithm 5 | //// Copyright (C) 2004-2008 Manolis Lourakis (lourakis at ics forth gr) 6 | //// Institute of Computer Science, Foundation for Research & Technology - Hellas 7 | //// Heraklion, Crete, Greece. 8 | //// 9 | //// This program is free software; you can redistribute it and/or modify 10 | //// it under the terms of the GNU General Public License as published by 11 | //// the Free Software Foundation; either version 2 of the License, or 12 | //// (at your option) any later version. 13 | //// 14 | //// This program is distributed in the hope that it will be useful, 15 | //// but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | //// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | //// GNU General Public License for more details. 18 | //// 19 | /////////////////////////////////////////////////////////////////////////////////// 20 | 21 | #ifndef _COMPILER_H_ 22 | #define _COMPILER_H_ 23 | 24 | /* note: intel's icc defines both __ICC & __INTEL_COMPILER. 25 | * Also, some compilers other than gcc define __GNUC__, 26 | * therefore gcc should be checked last 27 | */ 28 | #ifdef _MSC_VER 29 | #define inline __inline // MSVC 30 | #elif !defined(__ICC) && !defined(__INTEL_COMPILER) && !defined(__GNUC__) 31 | #define inline // other than MSVC, ICC, GCC: define empty 32 | #endif 33 | 34 | #ifdef _MSC_VER 35 | #define SBA_FINITE _finite // MSVC 36 | #elif defined(__ICC) || defined(__INTEL_COMPILER) || defined(__GNUC__) 37 | #define SBA_FINITE finite // ICC, GCC 38 | #else 39 | #define SBA_FINITE finite // other than MSVC, ICC, GCC, let's hope this will work 40 | #endif 41 | 42 | #endif /* _COMPILER_H_ */ 43 | -------------------------------------------------------------------------------- /lib/sfm-driver/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for sfm driver 2 | 3 | CC=gcc 4 | OPTFLAGS=-O3 5 | OTHERFLAGS=-Wall 6 | INCLUDE_PATH=-I../matrix -I../imagelib -I../sba-1.5 7 | 8 | CFLAGS=$(OTHERFLAGS) $(OPTFLAGS) $(INCLUDE_PATH) 9 | 10 | LIBSFM=libsfmdrv.a 11 | 12 | all: $(LIBSFM) 13 | 14 | $(LIBSFM): sfm.o 15 | ar r $@ sfm.o 16 | cp $@ .. 17 | 18 | clean: 19 | rm -f $(LIBSFM) *.o *~ 20 | -------------------------------------------------------------------------------- /lib/zlib/lib/zlib-bcc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/lib/zlib/lib/zlib-bcc.lib -------------------------------------------------------------------------------- /lib/zlib/lib/zlib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snavely/bundler_sfm/a35a8f589b7b8419f43f9e41553a84522faa6f9e/lib/zlib/lib/zlib.lib -------------------------------------------------------------------------------- /lib/zlib/manifest/zlib-1.2.3-lib.mft: -------------------------------------------------------------------------------- 1 | include/zconf.h 2 | include/zlib.h 3 | lib/libz.a 4 | lib/libz.dll.a 5 | lib/zlib-bcc.lib 6 | lib/zlib.def 7 | lib/zlib.lib 8 | manifest/zlib-1.2.3-lib.mft 9 | manifest/zlib-1.2.3-lib.ver 10 | -------------------------------------------------------------------------------- /lib/zlib/manifest/zlib-1.2.3-lib.ver: -------------------------------------------------------------------------------- 1 | Zlib-1.2.3: Developer files 2 | Zlib: general purpose data compression / decompression library -------------------------------------------------------------------------------- /src/BoundingBox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* BoundingBox.h */ 18 | /* Routines for bounding boxes */ 19 | 20 | #ifndef __bounding_box_h__ 21 | #define __bounding_box_h__ 22 | 23 | #include 24 | #include "vector.h" 25 | 26 | class BoundingBox { 27 | public: 28 | BoundingBox() { } 29 | BoundingBox(double xmin, double ymin, double xmax, double ymax) : 30 | m_xmin(xmin), m_xmax(xmax), m_ymin(ymin), m_ymax(ymax) { } 31 | BoundingBox(double x, double y) : 32 | m_xmin(x), m_xmax(x), m_ymin(y), m_ymax(y) { } 33 | 34 | /* Returns the area of the bounding box */ 35 | double Area(); 36 | 37 | BoundingBox Intersect(const BoundingBox &bbox) const; 38 | 39 | /* Returns true iff the box contains the given point */ 40 | bool Contains(double x, double y); 41 | bool Contains(const BoundingBox &bbox); 42 | 43 | void Scale(double scale); 44 | void Print(); 45 | 46 | double Width() { return m_xmax - m_xmin; } 47 | double Height() { return m_ymax - m_ymin; } 48 | 49 | double m_xmin, m_xmax; 50 | double m_ymin, m_ymax; 51 | }; 52 | 53 | /* Create a bounding box for a set of points */ 54 | BoundingBox CreateBoundingBox(const std::vector &points); 55 | 56 | /* Return the union of two bounding boxes */ 57 | BoundingBox BoundingBoxUnion(const BoundingBox &bb1, const BoundingBox &bb2); 58 | 59 | #endif /* __bounding_box_h__ */ 60 | -------------------------------------------------------------------------------- /src/BruteForceSearch.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu) 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | */ 15 | 16 | /* BruteForceSearch.cpp */ 17 | /* Brute force nearest-neighbor search data structure */ 18 | 19 | #include "BruteForceSearch.h" 20 | 21 | #include "qsort.h" 22 | #include "vector.h" 23 | 24 | BruteForceSearch::BruteForceSearch(int n, v3_t *pts) 25 | { 26 | m_num_points = n; 27 | m_points = new v3_t[n]; 28 | 29 | for (int i = 0; i < n; i++) 30 | m_points[i] = pts[i]; 31 | } 32 | 33 | void BruteForceSearch::GetClosestPoints(v3_t query, int num_points, 34 | int *idxs, double *dists) 35 | { 36 | double *dists_all = new double[m_num_points]; 37 | 38 | for (int i = 0; i < m_num_points; i++) { 39 | dists_all[i] = v3_magsq(v3_sub(query, m_points[i])); 40 | } 41 | 42 | int *perm = new int[m_num_points]; 43 | qsort_ascending(); 44 | qsort_perm(m_num_points, dists_all, perm); 45 | 46 | for (int i = 0; i < num_points; i++) { 47 | idxs[i] = perm[i]; 48 | dists[i] = dists_all[i]; 49 | } 50 | 51 | delete [] dists_all; 52 | delete [] perm; 53 | } 54 | -------------------------------------------------------------------------------- /src/BruteForceSearch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* BruteForceSearch.h */ 18 | /* Brute force nearest-neighbor search data structure */ 19 | 20 | #ifndef __brute_force_search_h__ 21 | #define __brute_force_search_h__ 22 | 23 | #include 24 | #include "vector.h" 25 | 26 | class BruteForceSearch 27 | { 28 | public: 29 | BruteForceSearch() : m_num_points(0), m_points(NULL) { } 30 | BruteForceSearch(int n, v3_t *pts); 31 | ~BruteForceSearch() { if (m_points != NULL) delete [] m_points; } 32 | 33 | void GetClosestPoints(v3_t query, int num_points, 34 | int *idxs, double *dists); 35 | 36 | int m_num_points; 37 | v3_t *m_points; 38 | }; 39 | 40 | #endif /* __brute_force_search_h__ */ 41 | -------------------------------------------------------------------------------- /src/Bundle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* Bundle.h */ 18 | /* Utility functions for bundle adjustment */ 19 | 20 | #ifndef __bundle_h__ 21 | #define __bundle_h__ 22 | 23 | #include "ImageData.h" 24 | #include "Geometry.h" 25 | 26 | #include "sfm.h" 27 | 28 | /* Compute the angle between two rays */ 29 | double ComputeRayAngle(v2_t p, v2_t q, 30 | const camera_params_t &cam1, 31 | const camera_params_t &cam2); 32 | 33 | /* Check cheirality for a camera and a point */ 34 | bool CheckCheirality(v3_t p, const camera_params_t &camera); 35 | 36 | void GetIntrinsics(const camera_params_t &camera, double *K); 37 | 38 | double GetCameraDistance(camera_params_t *c1, camera_params_t *c2); 39 | 40 | /* Use a 180 rotation to fix up the intrinsic matrix */ 41 | void FixIntrinsics(double *P, double *K, double *R, double *t); 42 | 43 | void InitializeCameraParams(const ImageData &data, camera_params_t &camera); 44 | 45 | #endif /* __bundle_h__ */ 46 | -------------------------------------------------------------------------------- /src/BundleAdd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* BundleAdd.h */ 18 | 19 | #ifndef __bundle_add_h__ 20 | #define __bundle_add_h__ 21 | 22 | #include "vector.h" 23 | #include "sfm.h" 24 | 25 | /* Triangulate two points */ 26 | v3_t Triangulate(v2_t p, v2_t q, 27 | camera_params_t c1, camera_params_t c2, 28 | double &proj_error, bool &in_front, double &angle, 29 | bool explicit_camera_centers); 30 | 31 | #endif /* __bundle_add_h__ */ 32 | -------------------------------------------------------------------------------- /src/Decompose.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* Decompose.h */ 18 | /* Decompose a homography into R and T */ 19 | 20 | #ifndef __decompose_h__ 21 | #define __decompose_h__ 22 | 23 | #include "vector.h" 24 | 25 | /* H is a map from image 2 to image 1 */ 26 | bool DecomposeHomography(double *H, double f1, double f2, 27 | double *Ra, double *ta, 28 | double *Rb, double *tb, v2_t p, v2_t q); 29 | 30 | bool ComputeFundamentalMatrix(double f1, double f2, 31 | double *R2, double *t2, double *F); 32 | 33 | #endif /* __decompose_h__ */ 34 | -------------------------------------------------------------------------------- /src/Distortion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* Distortion.h */ 18 | 19 | #ifndef __distortion_h__ 20 | #define __distortion_h__ 21 | 22 | #include "sfm.h" 23 | #include "vector.h" 24 | 25 | void InvertDistortion(int n_in, int n_out, double r0, double r1, 26 | double *k_in, double *k_out); 27 | 28 | v2_t UndistortNormalizedPoint(v2_t p, camera_params_t c); 29 | 30 | #endif /* __distortion_h__ */ 31 | -------------------------------------------------------------------------------- /src/LinkDirection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* LinkDirection.h */ 18 | 19 | #ifndef __link_direction_h__ 20 | #define __link_direction_h__ 21 | 22 | typedef enum { 23 | DIRECTION_LEFT = 0, 24 | DIRECTION_RIGHT = 1, 25 | DIRECTION_FORWARD = 2, 26 | DIRECTION_BACKWARD = 3, 27 | DIRECTION_UP = 4, 28 | DIRECTION_DOWN = 5, 29 | DIRECTION_ZOOM_OUT = 6, 30 | DIRECTION_ZOOM_IN = 7, 31 | NUM_LINK_DIRECTIONS = 8 32 | } LinkDirection; 33 | 34 | #endif /* __link_direction_h__ */ 35 | -------------------------------------------------------------------------------- /src/LoadJPEG.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* LoadJPEG.h */ 18 | /* Code for reading and write jpeg files */ 19 | 20 | #ifndef __load_jpeg_h__ 21 | #define __load_jpeg_h__ 22 | 23 | img_t *LoadJPEG(const char *filename); 24 | void GetJPEGDimensions(const char *filename, int &w, int &h); 25 | void WriteJPEG(const img_t *img, const char *filename); 26 | 27 | #endif /* __load_jpeg_h__ */ 28 | -------------------------------------------------------------------------------- /src/ParameterBound.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* ParameterBound.h */ 18 | 19 | #ifndef __parameter_bound_h__ 20 | #define __parameter_bound_h__ 21 | 22 | class ParameterBound 23 | { 24 | public: 25 | ParameterBound() { } 26 | ParameterBound(float min_x, float min_y, float max_x, float max_y) : 27 | m_min_x(min_x), m_min_y(min_y), m_max_x(max_x), m_max_y(max_y) 28 | { } 29 | 30 | float m_min_x, m_min_y; 31 | float m_max_x, m_max_y; 32 | }; 33 | 34 | #endif /* __parameter_bound_h__ */ 35 | -------------------------------------------------------------------------------- /src/Register.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu) 3 | * and the University of Washington 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | /* Register.h */ 18 | /* Compute relationships between images */ 19 | 20 | #ifndef __register_h__ 21 | #define __register_h__ 22 | 23 | #include 24 | 25 | 26 | 27 | #include "keys.h" 28 | 29 | enum MotionModel { 30 | MotionRigid, 31 | MotionHomography, 32 | }; 33 | 34 | /* Estimate a transform between two sets of keypoints */ 35 | std::vector EstimateTransform(const std::vector &k1, 36 | const std::vector &k2, 37 | const std::vector &matches, 38 | MotionModel mm, 39 | int nRANSAC, double RANSACthresh, 40 | double *Mout); 41 | 42 | 43 | 44 | #endif /* __register_h__ */ 45 | --------------------------------------------------------------------------------