comparison liboctave/array/Array.h @ 15271:648dabbb4c6b

build: Refactor liboctave into multiple subdirectories. Move libcruft into liboctave. * array/Array-C.cc, array/Array-b.cc, array/Array-ch.cc, array/Array-d.cc, array/Array-f.cc, array/Array-fC.cc, array/Array-i.cc, array/Array-idx-vec.cc, array/Array-s.cc, array/Array-str.cc, array/Array-util.cc, array/Array-util.h, array/Array-voidp.cc, array/Array.cc, array/Array.h, array/Array2.h, array/Array3.h, array/ArrayN.h, array/CColVector.cc, array/CColVector.h, array/CDiagMatrix.cc, array/CDiagMatrix.h, array/CMatrix.cc, array/CMatrix.h, array/CNDArray.cc, array/CNDArray.h, array/CRowVector.cc, array/CRowVector.h, array/CSparse.cc, array/CSparse.h, array/DiagArray2.cc, array/DiagArray2.h, array/MArray-C.cc, array/MArray-d.cc, array/MArray-decl.h, array/MArray-defs.h, array/MArray-f.cc, array/MArray-fC.cc, array/MArray-i.cc, array/MArray-s.cc, array/MArray.cc, array/MArray.h, array/MArray2.h, array/MArrayN.h, array/MDiagArray2.cc, array/MDiagArray2.h, array/MSparse-C.cc, array/MSparse-d.cc, array/MSparse-defs.h, array/MSparse.cc, array/MSparse.h, array/Matrix.h, array/MatrixType.cc, array/MatrixType.h, array/PermMatrix.cc, array/PermMatrix.h, array/Range.cc, array/Range.h, array/Sparse-C.cc, array/Sparse-b.cc, array/Sparse-d.cc, array/Sparse.cc, array/Sparse.h, array/boolMatrix.cc, array/boolMatrix.h, array/boolNDArray.cc, array/boolNDArray.h, array/boolSparse.cc, array/boolSparse.h, array/chMatrix.cc, array/chMatrix.h, array/chNDArray.cc, array/chNDArray.h, array/dColVector.cc, array/dColVector.h, array/dDiagMatrix.cc, array/dDiagMatrix.h, array/dMatrix.cc, array/dMatrix.h, array/dNDArray.cc, array/dNDArray.h, array/dRowVector.cc, array/dRowVector.h, array/dSparse.cc, array/dSparse.h, array/dim-vector.cc, array/dim-vector.h, array/fCColVector.cc, array/fCColVector.h, array/fCDiagMatrix.cc, array/fCDiagMatrix.h, array/fCMatrix.cc, array/fCMatrix.h, array/fCNDArray.cc, array/fCNDArray.h, array/fCRowVector.cc, array/fCRowVector.h, array/fColVector.cc, array/fColVector.h, array/fDiagMatrix.cc, array/fDiagMatrix.h, array/fMatrix.cc, array/fMatrix.h, array/fNDArray.cc, array/fNDArray.h, array/fRowVector.cc, array/fRowVector.h, array/idx-vector.cc, array/idx-vector.h, array/int16NDArray.cc, array/int16NDArray.h, array/int32NDArray.cc, array/int32NDArray.h, array/int64NDArray.cc, array/int64NDArray.h, array/int8NDArray.cc, array/int8NDArray.h, array/intNDArray.cc, array/intNDArray.h, array/module.mk, array/uint16NDArray.cc, array/uint16NDArray.h, array/uint32NDArray.cc, array/uint32NDArray.h, array/uint64NDArray.cc, array/uint64NDArray.h, array/uint8NDArray.cc, array/uint8NDArray.h: Moved from liboctave dir to array subdirectory. * cruft/Makefile.am, cruft/amos/README, cruft/amos/cacai.f, cruft/amos/cacon.f, cruft/amos/cairy.f, cruft/amos/casyi.f, cruft/amos/cbesh.f, cruft/amos/cbesi.f, cruft/amos/cbesj.f, cruft/amos/cbesk.f, cruft/amos/cbesy.f, cruft/amos/cbinu.f, cruft/amos/cbiry.f, cruft/amos/cbknu.f, cruft/amos/cbuni.f, cruft/amos/cbunk.f, cruft/amos/ckscl.f, cruft/amos/cmlri.f, cruft/amos/crati.f, cruft/amos/cs1s2.f, cruft/amos/cseri.f, cruft/amos/cshch.f, cruft/amos/cuchk.f, cruft/amos/cunhj.f, cruft/amos/cuni1.f, cruft/amos/cuni2.f, cruft/amos/cunik.f, cruft/amos/cunk1.f, cruft/amos/cunk2.f, cruft/amos/cuoik.f, cruft/amos/cwrsk.f, cruft/amos/dgamln.f, cruft/amos/gamln.f, cruft/amos/module.mk, cruft/amos/xzabs.f, cruft/amos/xzexp.f, cruft/amos/xzlog.f, cruft/amos/xzsqrt.f, cruft/amos/zacai.f, cruft/amos/zacon.f, cruft/amos/zairy.f, cruft/amos/zasyi.f, cruft/amos/zbesh.f, cruft/amos/zbesi.f, cruft/amos/zbesj.f, cruft/amos/zbesk.f, cruft/amos/zbesy.f, cruft/amos/zbinu.f, cruft/amos/zbiry.f, cruft/amos/zbknu.f, cruft/amos/zbuni.f, cruft/amos/zbunk.f, cruft/amos/zdiv.f, cruft/amos/zkscl.f, cruft/amos/zmlri.f, cruft/amos/zmlt.f, cruft/amos/zrati.f, cruft/amos/zs1s2.f, cruft/amos/zseri.f, cruft/amos/zshch.f, cruft/amos/zuchk.f, cruft/amos/zunhj.f, cruft/amos/zuni1.f, cruft/amos/zuni2.f, cruft/amos/zunik.f, cruft/amos/zunk1.f, cruft/amos/zunk2.f, cruft/amos/zuoik.f, cruft/amos/zwrsk.f, cruft/blas-xtra/cconv2.f, cruft/blas-xtra/cdotc3.f, cruft/blas-xtra/cmatm3.f, cruft/blas-xtra/csconv2.f, cruft/blas-xtra/dconv2.f, cruft/blas-xtra/ddot3.f, cruft/blas-xtra/dmatm3.f, cruft/blas-xtra/module.mk, cruft/blas-xtra/sconv2.f, cruft/blas-xtra/sdot3.f, cruft/blas-xtra/smatm3.f, cruft/blas-xtra/xcdotc.f, cruft/blas-xtra/xcdotu.f, cruft/blas-xtra/xddot.f, cruft/blas-xtra/xdnrm2.f, cruft/blas-xtra/xdznrm2.f, cruft/blas-xtra/xerbla.f, cruft/blas-xtra/xscnrm2.f, cruft/blas-xtra/xsdot.f, cruft/blas-xtra/xsnrm2.f, cruft/blas-xtra/xzdotc.f, cruft/blas-xtra/xzdotu.f, cruft/blas-xtra/zconv2.f, cruft/blas-xtra/zdconv2.f, cruft/blas-xtra/zdotc3.f, cruft/blas-xtra/zmatm3.f, cruft/daspk/datv.f, cruft/daspk/dcnst0.f, cruft/daspk/dcnstr.f, cruft/daspk/ddasic.f, cruft/daspk/ddasid.f, cruft/daspk/ddasik.f, cruft/daspk/ddaspk.f, cruft/daspk/ddstp.f, cruft/daspk/ddwnrm.f, cruft/daspk/dfnrmd.f, cruft/daspk/dfnrmk.f, cruft/daspk/dhels.f, cruft/daspk/dheqr.f, cruft/daspk/dinvwt.f, cruft/daspk/dlinsd.f, cruft/daspk/dlinsk.f, cruft/daspk/dmatd.f, cruft/daspk/dnedd.f, cruft/daspk/dnedk.f, cruft/daspk/dnsd.f, cruft/daspk/dnsid.f, cruft/daspk/dnsik.f, cruft/daspk/dnsk.f, cruft/daspk/dorth.f, cruft/daspk/dslvd.f, cruft/daspk/dslvk.f, cruft/daspk/dspigm.f, cruft/daspk/dyypnw.f, cruft/daspk/module.mk, cruft/dasrt/ddasrt.f, cruft/dasrt/drchek.f, cruft/dasrt/droots.f, cruft/dasrt/module.mk, cruft/dassl/ddaini.f, cruft/dassl/ddajac.f, cruft/dassl/ddanrm.f, cruft/dassl/ddaslv.f, cruft/dassl/ddassl.f, cruft/dassl/ddastp.f, cruft/dassl/ddatrp.f, cruft/dassl/ddawts.f, cruft/dassl/module.mk, cruft/fftpack/cfftb.f, cruft/fftpack/cfftb1.f, cruft/fftpack/cfftf.f, cruft/fftpack/cfftf1.f, cruft/fftpack/cffti.f, cruft/fftpack/cffti1.f, cruft/fftpack/fftpack.doc, cruft/fftpack/module.mk, cruft/fftpack/passb.f, cruft/fftpack/passb2.f, cruft/fftpack/passb3.f, cruft/fftpack/passb4.f, cruft/fftpack/passb5.f, cruft/fftpack/passf.f, cruft/fftpack/passf2.f, cruft/fftpack/passf3.f, cruft/fftpack/passf4.f, cruft/fftpack/passf5.f, cruft/fftpack/zfftb.f, cruft/fftpack/zfftb1.f, cruft/fftpack/zfftf.f, cruft/fftpack/zfftf1.f, cruft/fftpack/zffti.f, cruft/fftpack/zffti1.f, cruft/fftpack/zpassb.f, cruft/fftpack/zpassb2.f, cruft/fftpack/zpassb3.f, cruft/fftpack/zpassb4.f, cruft/fftpack/zpassb5.f, cruft/fftpack/zpassf.f, cruft/fftpack/zpassf2.f, cruft/fftpack/zpassf3.f, cruft/fftpack/zpassf4.f, cruft/fftpack/zpassf5.f, cruft/lapack-xtra/crsf2csf.f, cruft/lapack-xtra/module.mk, cruft/lapack-xtra/xclange.f, cruft/lapack-xtra/xdlamch.f, cruft/lapack-xtra/xdlange.f, cruft/lapack-xtra/xilaenv.f, cruft/lapack-xtra/xslamch.f, cruft/lapack-xtra/xslange.f, cruft/lapack-xtra/xzlange.f, cruft/lapack-xtra/zrsf2csf.f, cruft/link-deps.mk, cruft/misc/blaswrap.c, cruft/misc/cquit.c, cruft/misc/d1mach-tst.for, cruft/misc/d1mach.f, cruft/misc/f77-extern.cc, cruft/misc/f77-fcn.c, cruft/misc/f77-fcn.h, cruft/misc/i1mach.f, cruft/misc/lo-error.c, cruft/misc/lo-error.h, cruft/misc/module.mk, cruft/misc/quit.cc, cruft/misc/quit.h, cruft/misc/r1mach.f, cruft/mkf77def.in, cruft/odepack/cfode.f, cruft/odepack/dlsode.f, cruft/odepack/ewset.f, cruft/odepack/intdy.f, cruft/odepack/module.mk, cruft/odepack/prepj.f, cruft/odepack/scfode.f, cruft/odepack/sewset.f, cruft/odepack/sintdy.f, cruft/odepack/slsode.f, cruft/odepack/solsy.f, cruft/odepack/sprepj.f, cruft/odepack/ssolsy.f, cruft/odepack/sstode.f, cruft/odepack/stode.f, cruft/odepack/svnorm.f, cruft/odepack/vnorm.f, cruft/ordered-qz/README, cruft/ordered-qz/dsubsp.f, cruft/ordered-qz/exchqz.f, cruft/ordered-qz/module.mk, cruft/ordered-qz/sexchqz.f, cruft/ordered-qz/ssubsp.f, cruft/quadpack/dqagi.f, cruft/quadpack/dqagie.f, cruft/quadpack/dqagp.f, cruft/quadpack/dqagpe.f, cruft/quadpack/dqelg.f, cruft/quadpack/dqk15i.f, cruft/quadpack/dqk21.f, cruft/quadpack/dqpsrt.f, cruft/quadpack/module.mk, cruft/quadpack/qagi.f, cruft/quadpack/qagie.f, cruft/quadpack/qagp.f, cruft/quadpack/qagpe.f, cruft/quadpack/qelg.f, cruft/quadpack/qk15i.f, cruft/quadpack/qk21.f, cruft/quadpack/qpsrt.f, cruft/quadpack/xerror.f, cruft/ranlib/Basegen.doc, cruft/ranlib/HOWTOGET, cruft/ranlib/README, cruft/ranlib/advnst.f, cruft/ranlib/genbet.f, cruft/ranlib/genchi.f, cruft/ranlib/genexp.f, cruft/ranlib/genf.f, cruft/ranlib/gengam.f, cruft/ranlib/genmn.f, cruft/ranlib/genmul.f, cruft/ranlib/gennch.f, cruft/ranlib/gennf.f, cruft/ranlib/gennor.f, cruft/ranlib/genprm.f, cruft/ranlib/genunf.f, cruft/ranlib/getcgn.f, cruft/ranlib/getsd.f, cruft/ranlib/ignbin.f, cruft/ranlib/ignlgi.f, cruft/ranlib/ignnbn.f, cruft/ranlib/ignpoi.f, cruft/ranlib/ignuin.f, cruft/ranlib/initgn.f, cruft/ranlib/inrgcm.f, cruft/ranlib/lennob.f, cruft/ranlib/mltmod.f, cruft/ranlib/module.mk, cruft/ranlib/phrtsd.f, cruft/ranlib/qrgnin.f, cruft/ranlib/randlib.chs, cruft/ranlib/randlib.fdoc, cruft/ranlib/ranf.f, cruft/ranlib/setall.f, cruft/ranlib/setant.f, cruft/ranlib/setgmn.f, cruft/ranlib/setsd.f, cruft/ranlib/sexpo.f, cruft/ranlib/sgamma.f, cruft/ranlib/snorm.f, cruft/ranlib/tstbot.for, cruft/ranlib/tstgmn.for, cruft/ranlib/tstmid.for, cruft/ranlib/wrap.f, cruft/slatec-err/fdump.f, cruft/slatec-err/ixsav.f, cruft/slatec-err/j4save.f, cruft/slatec-err/module.mk, cruft/slatec-err/xerclr.f, cruft/slatec-err/xercnt.f, cruft/slatec-err/xerhlt.f, cruft/slatec-err/xermsg.f, cruft/slatec-err/xerprn.f, cruft/slatec-err/xerrwd.f, cruft/slatec-err/xersve.f, cruft/slatec-err/xgetf.f, cruft/slatec-err/xgetua.f, cruft/slatec-err/xsetf.f, cruft/slatec-err/xsetua.f, cruft/slatec-fn/acosh.f, cruft/slatec-fn/albeta.f, cruft/slatec-fn/algams.f, cruft/slatec-fn/alngam.f, cruft/slatec-fn/alnrel.f, cruft/slatec-fn/asinh.f, cruft/slatec-fn/atanh.f, cruft/slatec-fn/betai.f, cruft/slatec-fn/csevl.f, cruft/slatec-fn/d9gmit.f, cruft/slatec-fn/d9lgic.f, cruft/slatec-fn/d9lgit.f, cruft/slatec-fn/d9lgmc.f, cruft/slatec-fn/dacosh.f, cruft/slatec-fn/dasinh.f, cruft/slatec-fn/datanh.f, cruft/slatec-fn/dbetai.f, cruft/slatec-fn/dcsevl.f, cruft/slatec-fn/derf.f, cruft/slatec-fn/derfc.in.f, cruft/slatec-fn/dgami.f, cruft/slatec-fn/dgamit.f, cruft/slatec-fn/dgamlm.f, cruft/slatec-fn/dgamma.f, cruft/slatec-fn/dgamr.f, cruft/slatec-fn/dlbeta.f, cruft/slatec-fn/dlgams.f, cruft/slatec-fn/dlngam.f, cruft/slatec-fn/dlnrel.f, cruft/slatec-fn/dpchim.f, cruft/slatec-fn/dpchst.f, cruft/slatec-fn/erf.f, cruft/slatec-fn/erfc.in.f, cruft/slatec-fn/gami.f, cruft/slatec-fn/gamit.f, cruft/slatec-fn/gamlim.f, cruft/slatec-fn/gamma.f, cruft/slatec-fn/gamr.f, cruft/slatec-fn/initds.f, cruft/slatec-fn/inits.f, cruft/slatec-fn/module.mk, cruft/slatec-fn/pchim.f, cruft/slatec-fn/pchst.f, cruft/slatec-fn/r9gmit.f, cruft/slatec-fn/r9lgic.f, cruft/slatec-fn/r9lgit.f, cruft/slatec-fn/r9lgmc.f, cruft/slatec-fn/xacosh.f, cruft/slatec-fn/xasinh.f, cruft/slatec-fn/xatanh.f, cruft/slatec-fn/xbetai.f, cruft/slatec-fn/xdacosh.f, cruft/slatec-fn/xdasinh.f, cruft/slatec-fn/xdatanh.f, cruft/slatec-fn/xdbetai.f, cruft/slatec-fn/xderf.f, cruft/slatec-fn/xderfc.f, cruft/slatec-fn/xdgami.f, cruft/slatec-fn/xdgamit.f, cruft/slatec-fn/xdgamma.f, cruft/slatec-fn/xerf.f, cruft/slatec-fn/xerfc.f, cruft/slatec-fn/xgamma.f, cruft/slatec-fn/xgmainc.f, cruft/slatec-fn/xsgmainc.f: Moved from top-level libcruft to cruft directory below liboctave. * numeric/CmplxAEPBAL.cc, numeric/CmplxAEPBAL.h, numeric/CmplxCHOL.cc, numeric/CmplxCHOL.h, numeric/CmplxGEPBAL.cc, numeric/CmplxGEPBAL.h, numeric/CmplxHESS.cc, numeric/CmplxHESS.h, numeric/CmplxLU.cc, numeric/CmplxLU.h, numeric/CmplxQR.cc, numeric/CmplxQR.h, numeric/CmplxQRP.cc, numeric/CmplxQRP.h, numeric/CmplxSCHUR.cc, numeric/CmplxSCHUR.h, numeric/CmplxSVD.cc, numeric/CmplxSVD.h, numeric/CollocWt.cc, numeric/CollocWt.h, numeric/DAE.h, numeric/DAEFunc.h, numeric/DAERT.h, numeric/DAERTFunc.h, numeric/DASPK-opts.in, numeric/DASPK.cc, numeric/DASPK.h, numeric/DASRT-opts.in, numeric/DASRT.cc, numeric/DASRT.h, numeric/DASSL-opts.in, numeric/DASSL.cc, numeric/DASSL.h, numeric/DET.h, numeric/EIG.cc, numeric/EIG.h, numeric/LSODE-opts.in, numeric/LSODE.cc, numeric/LSODE.h, numeric/ODE.h, numeric/ODEFunc.h, numeric/ODES.cc, numeric/ODES.h, numeric/ODESFunc.h, numeric/Quad-opts.in, numeric/Quad.cc, numeric/Quad.h, numeric/SparseCmplxCHOL.cc, numeric/SparseCmplxCHOL.h, numeric/SparseCmplxLU.cc, numeric/SparseCmplxLU.h, numeric/SparseCmplxQR.cc, numeric/SparseCmplxQR.h, numeric/SparseQR.cc, numeric/SparseQR.h, numeric/SparsedbleCHOL.cc, numeric/SparsedbleCHOL.h, numeric/SparsedbleLU.cc, numeric/SparsedbleLU.h, numeric/base-aepbal.h, numeric/base-dae.h, numeric/base-de.h, numeric/base-lu.cc, numeric/base-lu.h, numeric/base-min.h, numeric/base-qr.cc, numeric/base-qr.h, numeric/bsxfun-decl.h, numeric/bsxfun-defs.cc, numeric/bsxfun.h, numeric/dbleAEPBAL.cc, numeric/dbleAEPBAL.h, numeric/dbleCHOL.cc, numeric/dbleCHOL.h, numeric/dbleGEPBAL.cc, numeric/dbleGEPBAL.h, numeric/dbleHESS.cc, numeric/dbleHESS.h, numeric/dbleLU.cc, numeric/dbleLU.h, numeric/dbleQR.cc, numeric/dbleQR.h, numeric/dbleQRP.cc, numeric/dbleQRP.h, numeric/dbleSCHUR.cc, numeric/dbleSCHUR.h, numeric/dbleSVD.cc, numeric/dbleSVD.h, numeric/eigs-base.cc, numeric/fCmplxAEPBAL.cc, numeric/fCmplxAEPBAL.h, numeric/fCmplxCHOL.cc, numeric/fCmplxCHOL.h, numeric/fCmplxGEPBAL.cc, numeric/fCmplxGEPBAL.h, numeric/fCmplxHESS.cc, numeric/fCmplxHESS.h, numeric/fCmplxLU.cc, numeric/fCmplxLU.h, numeric/fCmplxQR.cc, numeric/fCmplxQR.h, numeric/fCmplxQRP.cc, numeric/fCmplxQRP.h, numeric/fCmplxSCHUR.cc, numeric/fCmplxSCHUR.h, numeric/fCmplxSVD.cc, numeric/fCmplxSVD.h, numeric/fEIG.cc, numeric/fEIG.h, numeric/floatAEPBAL.cc, numeric/floatAEPBAL.h, numeric/floatCHOL.cc, numeric/floatCHOL.h, numeric/floatGEPBAL.cc, numeric/floatGEPBAL.h, numeric/floatHESS.cc, numeric/floatHESS.h, numeric/floatLU.cc, numeric/floatLU.h, numeric/floatQR.cc, numeric/floatQR.h, numeric/floatQRP.cc, numeric/floatQRP.h, numeric/floatSCHUR.cc, numeric/floatSCHUR.h, numeric/floatSVD.cc, numeric/floatSVD.h, numeric/lo-mappers.cc, numeric/lo-mappers.h, numeric/lo-specfun.cc, numeric/lo-specfun.h, numeric/module.mk, numeric/oct-convn.cc, numeric/oct-convn.h, numeric/oct-fftw.cc, numeric/oct-fftw.h, numeric/oct-norm.cc, numeric/oct-norm.h, numeric/oct-rand.cc, numeric/oct-rand.h, numeric/oct-spparms.cc, numeric/oct-spparms.h, numeric/randgamma.c, numeric/randgamma.h, numeric/randmtzig.c, numeric/randmtzig.h, numeric/randpoisson.c, numeric/randpoisson.h, numeric/sparse-base-chol.cc, numeric/sparse-base-chol.h, numeric/sparse-base-lu.cc, numeric/sparse-base-lu.h, numeric/sparse-dmsolve.cc: Moved from liboctave dir to numeric subdirectory. * operators/Sparse-diag-op-defs.h, operators/Sparse-op-defs.h, operators/Sparse-perm-op-defs.h, operators/config-ops.sh, operators/mk-ops.awk, operators/module.mk, operators/mx-base.h, operators/mx-defs.h, operators/mx-ext.h, operators/mx-inlines.cc, operators/mx-op-decl.h, operators/mx-op-defs.h, operators/mx-ops, operators/sparse-mk-ops.awk, operators/sparse-mx-ops, operators/vx-ops: Moved from liboctave dir to operators subdirectory. * system/dir-ops.cc, system/dir-ops.h, system/file-ops.cc, system/file-ops.h, system/file-stat.cc, system/file-stat.h, system/lo-sysdep.cc, system/lo-sysdep.h, system/mach-info.cc, system/mach-info.h, system/module.mk, system/oct-env.cc, system/oct-env.h, system/oct-group.cc, system/oct-group.h, system/oct-openmp.h, system/oct-passwd.cc, system/oct-passwd.h, system/oct-syscalls.cc, system/oct-syscalls.h, system/oct-time.cc, system/oct-time.h, system/oct-uname.cc, system/oct-uname.h, system/pathlen.h, system/sysdir.h, system/syswait.h, system/tempnam.c, system/tempname.c: Moved from liboctave dir to system subdirectory. * util/base-list.h, util/byte-swap.h, util/caseless-str.h, util/cmd-edit.cc, util/cmd-edit.h, util/cmd-hist.cc, util/cmd-hist.h, util/data-conv.cc, util/data-conv.h, util/f2c-main.c, util/functor.h, util/glob-match.cc, util/glob-match.h, util/kpse.cc, util/lo-array-gripes.cc, util/lo-array-gripes.h, util/lo-cieee.c, util/lo-cutils.c, util/lo-cutils.h, util/lo-ieee.cc, util/lo-ieee.h, util/lo-macros.h, util/lo-math.h, util/lo-traits.h, util/lo-utils.cc, util/lo-utils.h, util/module.mk, util/oct-alloc.cc, util/oct-alloc.h, util/oct-base64.cc, util/oct-base64.h, util/oct-binmap.h, util/oct-cmplx.h, util/oct-glob.cc, util/oct-glob.h, util/oct-inttypes.cc, util/oct-inttypes.h, util/oct-locbuf.cc, util/oct-locbuf.h, util/oct-md5.cc, util/oct-md5.h, util/oct-mem.h, util/oct-mutex.cc, util/oct-mutex.h, util/oct-refcount.h, util/oct-rl-edit.c, util/oct-rl-edit.h, util/oct-rl-hist.c, util/oct-rl-hist.h, util/oct-shlib.cc, util/oct-shlib.h, util/oct-sort.cc, util/oct-sort.h, util/oct-sparse.h, util/pathsearch.cc, util/pathsearch.h, util/regexp.cc, util/regexp.h, util/singleton-cleanup.cc, util/singleton-cleanup.h, util/sparse-sort.cc, util/sparse-sort.h, util/sparse-util.cc, util/sparse-util.h, util/statdefs.h, util/str-vec.cc, util/str-vec.h, util/sun-utils.h: Moved from liboctave dir to util subdirectory. * Makefile.am: Eliminate reference to top-level liboctave directory. * autogen.sh: cd to new liboctave/operators directory to run config-ops.sh. * build-aux/common.mk: Eliminate LIBCRUFT references. * configure.ac: Eliminate libcruft top-level references. Switch test programs to find files in liboctave/cruft subdirectory. * OctaveFAQ.texi, install.txi, mkoctfile.1: Eliminate references to libcruft in docs. * libgui/src/Makefile.am, libinterp/Makefile.am, src/Makefile.am: Update include file locations. Stop linking against libcruft. * libinterp/corefcn/module.mk: Update location of OPT_INC files which are now in numeric/ subdirectory. * libinterp/dldfcn/config-module.awk: Stop linking against libcruft. * libinterp/interpfcn/toplev.cc: Remove reference to LIBCRUFT. * libinterp/link-deps.mk, liboctave/link-deps.mk: Add GNULIB_LINK_DEPS to link dependencies. * libinterp/oct-conf.in.h: Remove reference to OCTAVE_CONF_LIBCRUFT. * liboctave/Makefile.am: Overhaul to use convenience libraries in subdirectories. * scripts/miscellaneous/mkoctfile.m: Eliminate reference to LIBCRUFT. * src/mkoctfile.in.cc, src/mkoctfile.in.sh: Stop linking againt libcruft. Eliminate references to LIBCRUFT.
author Rik <rik@octave.org>
date Fri, 31 Aug 2012 20:00:20 -0700
parents liboctave/Array.h@dd7c37ceb800
children d63878346099
comparison
equal deleted inserted replaced
15270:6615a46d90ec 15271:648dabbb4c6b
1 // Template array classes
2 /*
3
4 Copyright (C) 1993-2012 John W. Eaton
5 Copyright (C) 2008-2009 Jaroslav Hajek
6 Copyright (C) 2010 VZLU Prague
7
8 This file is part of Octave.
9
10 Octave is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by the
12 Free Software Foundation; either version 3 of the License, or (at your
13 option) any later version.
14
15 Octave is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with Octave; see the file COPYING. If not, see
22 <http://www.gnu.org/licenses/>.
23
24 */
25
26 #if !defined (octave_Array_h)
27 #define octave_Array_h 1
28
29 #include <cassert>
30 #include <cstddef>
31
32 #include <algorithm>
33 #include <iosfwd>
34
35 #include "dim-vector.h"
36 #include "idx-vector.h"
37 #include "lo-traits.h"
38 #include "lo-utils.h"
39 #include "oct-sort.h"
40 #include "quit.h"
41 #include "oct-mem.h"
42 #include "oct-refcount.h"
43
44 // One dimensional array class. Handles the reference counting for
45 // all the derived classes.
46
47 template <class T>
48 class
49 Array
50 {
51 protected:
52
53 //--------------------------------------------------------------------
54 // The real representation of all arrays.
55 //--------------------------------------------------------------------
56
57 class ArrayRep
58 {
59 public:
60
61 T *data;
62 octave_idx_type len;
63 octave_refcount<int> count;
64
65 ArrayRep (T *d, octave_idx_type l)
66 : data (no_ctor_new<T> (l)), len (l), count (1)
67 {
68 copy_or_memcpy (l, d, data);
69 }
70
71 template <class U>
72 ArrayRep (U *d, octave_idx_type l)
73 : data (no_ctor_new<T> (l)), len (l), count (1)
74 {
75 std::copy (d, d+l, data);
76 }
77
78 ArrayRep (void) : data (0), len (0), count (1) { }
79
80 explicit ArrayRep (octave_idx_type n) : data (no_ctor_new<T> (n)), len (n), count (1) { }
81
82 explicit ArrayRep (octave_idx_type n, const T& val)
83 : data (no_ctor_new<T> (n)), len (n), count (1)
84 {
85 fill_or_memset (n, val, data);
86 }
87
88 ArrayRep (const ArrayRep& a)
89 : data (no_ctor_new<T> (a.len)), len (a.len), count (1)
90 {
91 copy_or_memcpy (a.len, a.data, data);
92 }
93
94 ~ArrayRep (void) { no_ctor_delete<T> (data); }
95
96 octave_idx_type length (void) const { return len; }
97
98 private:
99
100 // No assignment!
101
102 ArrayRep& operator = (const ArrayRep& a);
103 };
104
105 //--------------------------------------------------------------------
106
107 public:
108
109 void make_unique (void)
110 {
111 if (rep->count > 1)
112 {
113 ArrayRep *r = new ArrayRep (slice_data, slice_len);
114
115 if (--rep->count == 0)
116 delete rep;
117
118 rep = r;
119 slice_data = rep->data;
120 }
121 }
122
123 typedef T element_type;
124
125 typedef typename ref_param<T>::type crefT;
126
127 typedef bool (*compare_fcn_type) (typename ref_param<T>::type,
128 typename ref_param<T>::type);
129
130 protected:
131
132 dim_vector dimensions;
133
134 typename Array<T>::ArrayRep *rep;
135
136 // Rationale:
137 // slice_data is a pointer to rep->data, denoting together with slice_len the
138 // actual portion of the data referenced by this Array<T> object. This allows
139 // to make shallow copies not only of a whole array, but also of contiguous
140 // subranges. Every time rep is directly manipulated, slice_data and slice_len
141 // need to be properly updated.
142
143 T* slice_data;
144 octave_idx_type slice_len;
145
146 // slice constructor
147 Array (const Array<T>& a, const dim_vector& dv,
148 octave_idx_type l, octave_idx_type u)
149 : dimensions (dv), rep(a.rep), slice_data (a.slice_data+l), slice_len (u-l)
150 {
151 rep->count++;
152 dimensions.chop_trailing_singletons ();
153 }
154
155 private:
156
157 typename Array<T>::ArrayRep *nil_rep (void) const
158 {
159 // NR was originally allocated with new, but that does not seem
160 // to be necessary since it will never be deleted. So just use
161 // a static object instead.
162
163 static typename Array<T>::ArrayRep nr;
164 return &nr;
165 }
166
167 protected:
168
169 // For jit support
170 Array (T *sdata, octave_idx_type slen, octave_idx_type *adims, void *arep)
171 : dimensions (adims),
172 rep (reinterpret_cast<typename Array<T>::ArrayRep *> (arep)),
173 slice_data (sdata), slice_len (slen) {}
174
175 public:
176
177 // Empty ctor (0x0).
178
179 Array (void)
180 : dimensions (), rep (nil_rep ()), slice_data (rep->data),
181 slice_len (rep->len)
182 {
183 rep->count++;
184 }
185
186 // Obsolete 1D ctor (there are no 1D arrays).
187 explicit Array (octave_idx_type n) GCC_ATTR_DEPRECATED
188 : dimensions (n, 1), rep (new typename Array<T>::ArrayRep (n)),
189 slice_data (rep->data), slice_len (rep->len)
190 { }
191
192 // Obsolete initialized 1D ctor (there are no 1D arrays).
193 explicit Array (octave_idx_type n, const T& val) GCC_ATTR_DEPRECATED
194 : dimensions (n, 1), rep (new typename Array<T>::ArrayRep (n)),
195 slice_data (rep->data), slice_len (rep->len)
196 {
197 fill (val);
198 }
199
200 // nD uninitialized ctor.
201 explicit Array (const dim_vector& dv)
202 : dimensions (dv),
203 rep (new typename Array<T>::ArrayRep (dv.safe_numel ())),
204 slice_data (rep->data), slice_len (rep->len)
205 {
206 dimensions.chop_trailing_singletons ();
207 }
208
209 // nD initialized ctor.
210 explicit Array (const dim_vector& dv, const T& val)
211 : dimensions (dv),
212 rep (new typename Array<T>::ArrayRep (dv.safe_numel ())),
213 slice_data (rep->data), slice_len (rep->len)
214 {
215 fill (val);
216 dimensions.chop_trailing_singletons ();
217 }
218
219 // Reshape constructor.
220 Array (const Array<T>& a, const dim_vector& dv);
221
222 // Type conversion case.
223 template <class U>
224 Array (const Array<U>& a)
225 : dimensions (a.dims ()),
226 rep (new typename Array<T>::ArrayRep (a.data (), a.length ())),
227 slice_data (rep->data), slice_len (rep->len)
228 { }
229
230 // No type conversion case.
231 Array (const Array<T>& a)
232 : dimensions (a.dimensions), rep (a.rep), slice_data (a.slice_data),
233 slice_len (a.slice_len)
234 {
235 rep->count++;
236 }
237
238 public:
239
240 virtual ~Array (void)
241 {
242 if (--rep->count == 0)
243 delete rep;
244 }
245
246 Array<T>& operator = (const Array<T>& a)
247 {
248 if (this != &a)
249 {
250 if (--rep->count == 0)
251 delete rep;
252
253 rep = a.rep;
254 rep->count++;
255
256 dimensions = a.dimensions;
257 slice_data = a.slice_data;
258 slice_len = a.slice_len;
259 }
260
261 return *this;
262 }
263
264 void fill (const T& val);
265
266 void clear (void);
267 void clear (const dim_vector& dv);
268
269 void clear (octave_idx_type r, octave_idx_type c)
270 { clear (dim_vector (r, c)); }
271
272 octave_idx_type capacity (void) const { return slice_len; }
273 octave_idx_type length (void) const { return capacity (); }
274 octave_idx_type nelem (void) const { return capacity (); }
275 octave_idx_type numel (void) const { return nelem (); }
276
277 octave_idx_type dim1 (void) const { return dimensions(0); }
278 octave_idx_type dim2 (void) const { return dimensions(1); }
279 octave_idx_type dim3 (void) const { return dimensions(2); }
280
281 // Return the array as a column vector.
282 Array<T> as_column (void) const
283 {
284 Array<T> retval (*this);
285 if (dimensions.length () != 2 || dimensions(1) != 1)
286 retval.dimensions = dim_vector (numel (), 1);
287
288 return retval;
289 }
290
291 // Return the array as a row vector.
292 Array<T> as_row (void) const
293 {
294 Array<T> retval (*this);
295 if (dimensions.length () != 2 || dimensions(0) != 1)
296 retval.dimensions = dim_vector (1, numel ());
297
298 return retval;
299 }
300
301 // Return the array as a matrix.
302 Array<T> as_matrix (void) const
303 {
304 Array<T> retval (*this);
305 if (dimensions.length () != 2)
306 retval.dimensions = dimensions.redim (2);
307
308 return retval;
309 }
310
311 octave_idx_type rows (void) const { return dim1 (); }
312 octave_idx_type cols (void) const { return dim2 (); }
313 octave_idx_type columns (void) const { return dim2 (); }
314 octave_idx_type pages (void) const { return dim3 (); }
315
316 size_t byte_size (void) const { return static_cast<size_t> (numel ()) * sizeof (T); }
317
318 // Return a const-reference so that dims ()(i) works efficiently.
319 const dim_vector& dims (void) const { return dimensions; }
320
321 Array<T> squeeze (void) const;
322
323 void chop_trailing_singletons (void) GCC_ATTR_DEPRECATED
324 { dimensions.chop_trailing_singletons (); }
325
326 octave_idx_type compute_index (octave_idx_type i, octave_idx_type j) const;
327 octave_idx_type compute_index (octave_idx_type i, octave_idx_type j, octave_idx_type k) const;
328 octave_idx_type compute_index (const Array<octave_idx_type>& ra_idx) const;
329
330 octave_idx_type compute_index_unchecked (const Array<octave_idx_type>& ra_idx) const
331 { return dimensions.compute_index (ra_idx.data (), ra_idx.length ()); }
332
333 // No checking, even for multiple references, ever.
334
335 T& xelem (octave_idx_type n) { return slice_data[n]; }
336 crefT xelem (octave_idx_type n) const { return slice_data[n]; }
337
338 T& xelem (octave_idx_type i, octave_idx_type j) { return xelem (dim1 ()*j+i); }
339 crefT xelem (octave_idx_type i, octave_idx_type j) const { return xelem (dim1 ()*j+i); }
340
341 T& xelem (octave_idx_type i, octave_idx_type j, octave_idx_type k)
342 { return xelem (i, dim2 ()*k+j); }
343 crefT xelem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const
344 { return xelem (i, dim2 ()*k+j); }
345
346 T& xelem (const Array<octave_idx_type>& ra_idx)
347 { return xelem (compute_index_unchecked (ra_idx)); }
348
349 crefT xelem (const Array<octave_idx_type>& ra_idx) const
350 { return xelem (compute_index_unchecked (ra_idx)); }
351
352 // FIXME -- would be nice to fix this so that we don't
353 // unnecessarily force a copy, but that is not so easy, and I see no
354 // clean way to do it.
355
356 T& checkelem (octave_idx_type n);
357 T& checkelem (octave_idx_type i, octave_idx_type j);
358 T& checkelem (octave_idx_type i, octave_idx_type j, octave_idx_type k);
359 T& checkelem (const Array<octave_idx_type>& ra_idx);
360
361 T& elem (octave_idx_type n)
362 {
363 make_unique ();
364 return xelem (n);
365 }
366
367 T& elem (octave_idx_type i, octave_idx_type j) { return elem (dim1 ()*j+i); }
368
369 T& elem (octave_idx_type i, octave_idx_type j, octave_idx_type k) { return elem (i, dim2 ()*k+j); }
370
371 T& elem (const Array<octave_idx_type>& ra_idx)
372 { return Array<T>::elem (compute_index_unchecked (ra_idx)); }
373
374 #if defined (BOUNDS_CHECKING)
375 T& operator () (octave_idx_type n) { return checkelem (n); }
376 T& operator () (octave_idx_type i, octave_idx_type j) { return checkelem (i, j); }
377 T& operator () (octave_idx_type i, octave_idx_type j, octave_idx_type k) { return checkelem (i, j, k); }
378 T& operator () (const Array<octave_idx_type>& ra_idx) { return checkelem (ra_idx); }
379 #else
380 T& operator () (octave_idx_type n) { return elem (n); }
381 T& operator () (octave_idx_type i, octave_idx_type j) { return elem (i, j); }
382 T& operator () (octave_idx_type i, octave_idx_type j, octave_idx_type k) { return elem (i, j, k); }
383 T& operator () (const Array<octave_idx_type>& ra_idx) { return elem (ra_idx); }
384 #endif
385
386 crefT checkelem (octave_idx_type n) const;
387 crefT checkelem (octave_idx_type i, octave_idx_type j) const;
388 crefT checkelem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const;
389 crefT checkelem (const Array<octave_idx_type>& ra_idx) const;
390
391 crefT elem (octave_idx_type n) const { return xelem (n); }
392
393 crefT elem (octave_idx_type i, octave_idx_type j) const { return xelem (i, j); }
394
395 crefT elem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const { return xelem (i, j, k); }
396
397 crefT elem (const Array<octave_idx_type>& ra_idx) const
398 { return Array<T>::xelem (compute_index_unchecked (ra_idx)); }
399
400 #if defined (BOUNDS_CHECKING)
401 crefT operator () (octave_idx_type n) const { return checkelem (n); }
402 crefT operator () (octave_idx_type i, octave_idx_type j) const { return checkelem (i, j); }
403 crefT operator () (octave_idx_type i, octave_idx_type j, octave_idx_type k) const { return checkelem (i, j, k); }
404 crefT operator () (const Array<octave_idx_type>& ra_idx) const { return checkelem (ra_idx); }
405 #else
406 crefT operator () (octave_idx_type n) const { return elem (n); }
407 crefT operator () (octave_idx_type i, octave_idx_type j) const { return elem (i, j); }
408 crefT operator () (octave_idx_type i, octave_idx_type j, octave_idx_type k) const { return elem (i, j, k); }
409 crefT operator () (const Array<octave_idx_type>& ra_idx) const { return elem (ra_idx); }
410 #endif
411
412 // Fast extractors. All of these produce shallow copies.
413 // Warning: none of these do check bounds, unless BOUNDS_CHECKING is on!
414
415 // Extract column: A(:,k+1).
416 Array<T> column (octave_idx_type k) const;
417 // Extract page: A(:,:,k+1).
418 Array<T> page (octave_idx_type k) const;
419
420 // Extract a slice from this array as a column vector: A(:)(lo+1:up).
421 // Must be 0 <= lo && up <= numel. May be up < lo.
422 Array<T> linear_slice (octave_idx_type lo, octave_idx_type up) const;
423
424 Array<T> reshape (octave_idx_type nr, octave_idx_type nc) const
425 { return Array<T> (*this, dim_vector (nr, nc)); }
426
427 Array<T> reshape (const dim_vector& new_dims) const
428 { return Array<T> (*this, new_dims); }
429
430 Array<T> permute (const Array<octave_idx_type>& vec, bool inv = false) const;
431 Array<T> ipermute (const Array<octave_idx_type>& vec) const
432 { return permute (vec, true); }
433
434 bool is_square (void) const { return (dim1 () == dim2 ()); }
435
436 bool is_empty (void) const { return numel () == 0; }
437
438 bool is_vector (void) const { return dimensions.is_vector (); }
439
440 Array<T> transpose (void) const;
441 Array<T> hermitian (T (*fcn) (const T&) = 0) const;
442
443 const T *data (void) const { return slice_data; }
444
445 const T *fortran_vec (void) const { return data (); }
446
447 T *fortran_vec (void);
448
449 bool is_shared (void) { return rep->count > 1; }
450
451 int ndims (void) const { return dimensions.length (); }
452
453 // Indexing without resizing.
454
455 Array<T> index (const idx_vector& i) const;
456
457 Array<T> index (const idx_vector& i, const idx_vector& j) const;
458
459 Array<T> index (const Array<idx_vector>& ia) const;
460
461 virtual T resize_fill_value (void) const;
462
463 // Resizing (with fill).
464
465 void resize1 (octave_idx_type n, const T& rfv);
466 void resize1 (octave_idx_type n) { resize1 (n, resize_fill_value ()); }
467
468 void resize (octave_idx_type n) GCC_ATTR_DEPRECATED { resize1 (n); }
469
470 void resize (octave_idx_type nr, octave_idx_type nc, const T& rfv) GCC_ATTR_DEPRECATED
471 {
472 resize2 (nr, nc, rfv);
473 }
474
475 void resize (octave_idx_type nr, octave_idx_type nc) GCC_ATTR_DEPRECATED
476 {
477 resize2 (nr, nc, resize_fill_value ());
478 }
479
480 void resize (const dim_vector& dv, const T& rfv);
481 void resize (const dim_vector& dv) { resize (dv, resize_fill_value ()); }
482
483 // Indexing with possible resizing and fill
484 // FIXME -- this is really a corner case, that should better be
485 // handled directly in liboctinterp.
486
487 Array<T> index (const idx_vector& i, bool resize_ok, const T& rfv) const;
488 Array<T> index (const idx_vector& i, bool resize_ok) const
489 {
490 return index (i, resize_ok, resize_fill_value ());
491 }
492
493 Array<T> index (const idx_vector& i, const idx_vector& j, bool resize_ok, const T& rfv) const;
494 Array<T> index (const idx_vector& i, const idx_vector& j, bool resize_ok) const
495 {
496 return index (i, j, resize_ok, resize_fill_value ());
497 }
498
499 Array<T> index (const Array<idx_vector>& ia, bool resize_ok, const T& rfv) const;
500 Array<T> index (const Array<idx_vector>& ia, bool resize_ok) const
501 {
502 return index (ia, resize_ok, resize_fill_value ());
503 }
504
505 // Indexed assignment (always with resize & fill).
506
507 void assign (const idx_vector& i, const Array<T>& rhs, const T& rfv);
508 void assign (const idx_vector& i, const Array<T>& rhs)
509 {
510 assign (i, rhs, resize_fill_value ());
511 }
512
513 void assign (const idx_vector& i, const idx_vector& j, const Array<T>& rhs, const T& rfv);
514 void assign (const idx_vector& i, const idx_vector& j, const Array<T>& rhs)
515 {
516 assign (i, j, rhs, resize_fill_value ());
517 }
518
519 void assign (const Array<idx_vector>& ia, const Array<T>& rhs, const T& rfv);
520 void assign (const Array<idx_vector>& ia, const Array<T>& rhs)
521 {
522 assign (ia, rhs, resize_fill_value ());
523 }
524
525 // Deleting elements.
526
527 // A(I) = [] (with a single subscript)
528 void delete_elements (const idx_vector& i);
529
530 // A(:,...,I,...,:) = [] (>= 2 subscripts, one of them is non-colon)
531 void delete_elements (int dim, const idx_vector& i);
532
533 // Dispatcher to the above two.
534 void delete_elements (const Array<idx_vector>& ia);
535
536 // Insert an array into another at a specified position.
537 // If size (a) is [d1 d2 ... dN] and idx is [i1 i2 ... iN],
538 // this method is equivalent to
539 // x(i1:i1+d1-1, i2:i2+d2-1, ... , iN:iN+dN-1) = a.
540 Array<T>& insert (const Array<T>& a, const Array<octave_idx_type>& idx);
541
542 // This is just a special case for idx = [r c 0 ...]
543 Array<T>& insert (const Array<T>& a, octave_idx_type r, octave_idx_type c);
544
545 void maybe_economize (void)
546 {
547 if (rep->count == 1 && slice_len != rep->len)
548 {
549 ArrayRep *new_rep = new ArrayRep (slice_data, slice_len);
550 delete rep;
551 rep = new_rep;
552 slice_data = rep->data;
553 }
554 }
555
556 void print_info (std::ostream& os, const std::string& prefix) const;
557
558 // Unsafe. This function exists to support the MEX interface.
559 // You should not use it anywhere else.
560 void *mex_get_data (void) const { return const_cast<T *> (data ()); }
561
562 Array<T> sort (int dim = 0, sortmode mode = ASCENDING) const;
563 Array<T> sort (Array<octave_idx_type> &sidx, int dim = 0,
564 sortmode mode = ASCENDING) const;
565
566 // Ordering is auto-detected or can be specified.
567 sortmode is_sorted (sortmode mode = UNSORTED) const;
568
569 // Sort by rows returns only indices.
570 Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const;
571
572 // Ordering is auto-detected or can be specified.
573 sortmode is_sorted_rows (sortmode mode = UNSORTED) const;
574
575 // Do a binary lookup in a sorted array. Must not contain NaNs.
576 // Mode can be specified or is auto-detected by comparing 1st and last element.
577 octave_idx_type lookup (const T& value, sortmode mode = UNSORTED) const;
578
579 // Ditto, but for an array of values, specializing on the case when values
580 // are sorted. NaNs get the value N.
581 Array<octave_idx_type> lookup (const Array<T>& values, sortmode mode = UNSORTED) const;
582
583 // Count nonzero elements.
584 octave_idx_type nnz (void) const;
585
586 // Find indices of (at most n) nonzero elements. If n is specified, backward
587 // specifies search from backward.
588 Array<octave_idx_type> find (octave_idx_type n = -1, bool backward = false) const;
589
590 // Returns the n-th element in increasing order, using the same ordering as
591 // used for sort. n can either be a scalar index or a contiguous range.
592 Array<T> nth_element (const idx_vector& n, int dim = 0) const;
593
594 Array<T> diag (octave_idx_type k = 0) const;
595
596 Array<T> diag (octave_idx_type m, octave_idx_type n) const;
597
598 // Concatenation along a specified (0-based) dimension, equivalent to cat().
599 // dim = -1 corresponds to dim = 0 and dim = -2 corresponds to dim = 1,
600 // but apply the looser matching rules of vertcat/horzcat.
601 static Array<T>
602 cat (int dim, octave_idx_type n, const Array<T> *array_list);
603
604 template <class U, class F>
605 Array<U>
606 map (F fcn) const
607 {
608 octave_idx_type len = length ();
609
610 const T *m = data ();
611
612 Array<U> result (dims ());
613 U *p = result.fortran_vec ();
614
615 octave_idx_type i;
616 for (i = 0; i < len - 3; i += 4)
617 {
618 octave_quit ();
619
620 p[i] = fcn (m[i]);
621 p[i+1] = fcn (m[i+1]);
622 p[i+2] = fcn (m[i+2]);
623 p[i+3] = fcn (m[i+3]);
624 }
625
626 octave_quit ();
627
628 for (; i < len; i++)
629 p[i] = fcn (m[i]);
630
631 return result;
632 }
633
634 // Overloads for function references.
635 template <class U>
636 Array<U>
637 map (U (&fcn) (T)) const
638 { return map<U, U (&) (T)> (fcn); }
639
640 template <class U>
641 Array<U>
642 map (U (&fcn) (const T&)) const
643 { return map<U, U (&) (const T&)> (fcn); }
644
645 // Generic any/all test functionality with arbitrary predicate.
646 template <class F, bool zero>
647 bool test (F fcn) const
648 {
649 return any_all_test<F, T, zero> (fcn, data (), length ());
650 }
651
652 // Simpler calls.
653 template <class F>
654 bool test_any (F fcn) const
655 { return test<F, false> (fcn); }
656
657 template <class F>
658 bool test_all (F fcn) const
659 { return test<F, true> (fcn); }
660
661 // Overloads for function references.
662 bool test_any (bool (&fcn) (T)) const
663 { return test<bool (&) (T), false> (fcn); }
664
665 bool test_any (bool (&fcn) (const T&)) const
666 { return test<bool (&) (const T&), false> (fcn); }
667
668 bool test_all (bool (&fcn) (T)) const
669 { return test<bool (&) (T), true> (fcn); }
670
671 bool test_all (bool (&fcn) (const T&)) const
672 { return test<bool (&) (const T&), true> (fcn); }
673
674 template <class U> friend class Array;
675
676 // Returns true if this->dims () == dv, and if so, replaces this->dimensions
677 // by a shallow copy of dv. This is useful for maintaining several arrays with
678 // supposedly equal dimensions (e.g. structs in the interpreter).
679 bool optimize_dimensions (const dim_vector& dv);
680
681 // WARNING: Only call these functions from jit
682
683 int *jit_ref_count (void) { return rep->count.get (); }
684
685 T *jit_slice_data (void) const { return slice_data; }
686
687 octave_idx_type *jit_dimensions (void) const { return dimensions.to_jit (); }
688
689 void *jit_array_rep (void) const { return rep; }
690
691 private:
692
693 void resize2 (octave_idx_type nr, octave_idx_type nc, const T& rfv);
694 void resize2 (octave_idx_type nr, octave_idx_type nc)
695 {
696 resize2 (nr, nc, resize_fill_value ());
697 }
698
699 static void instantiation_guard ();
700 };
701
702 // This is a simple wrapper template that will subclass an Array<T> type or any
703 // later type derived from it and override the default non-const operator() to
704 // not check for the array's uniqueness. It is, however, the user's
705 // responsibility to ensure the array is actually unaliased whenever elements
706 // are accessed.
707
708 template<class ArrayClass>
709 class NoAlias : public ArrayClass
710 {
711 typedef typename ArrayClass::element_type T;
712 public:
713 NoAlias () : ArrayClass () { }
714
715 // FIXME: this would be simpler once C++0x is available
716 template <class X>
717 explicit NoAlias (X x) : ArrayClass (x) { }
718
719 template <class X, class Y>
720 explicit NoAlias (X x, Y y) : ArrayClass (x, y) { }
721
722 template <class X, class Y, class Z>
723 explicit NoAlias (X x, Y y, Z z) : ArrayClass (x, y, z) { }
724
725 T& operator () (octave_idx_type n)
726 { return ArrayClass::xelem (n); }
727 T& operator () (octave_idx_type i, octave_idx_type j)
728 { return ArrayClass::xelem (i, j); }
729 T& operator () (octave_idx_type i, octave_idx_type j, octave_idx_type k)
730 { return ArrayClass::xelem (i, j, k); }
731 T& operator () (const Array<octave_idx_type>& ra_idx)
732 { return ArrayClass::xelem (ra_idx); }
733 };
734
735 template <class T>
736 std::ostream&
737 operator << (std::ostream& os, const Array<T>& a);
738
739 #endif