diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2002-12-17 04:36:31 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2002-12-17 04:36:31 +0000 |
commit | a5b45e8e2e99686ea73fa2793d7fec84f0d1a3ed (patch) | |
tree | 4b31406382bacd13aa784ea22d584ac634f8d8ad /externals/grill/vasp/source | |
parent | a0cb0bd2e02740e50ec16dde2fb4e07f1702d1d0 (diff) |
""
svn path=/trunk/; revision=303
Diffstat (limited to 'externals/grill/vasp/source')
41 files changed, 406 insertions, 294 deletions
diff --git a/externals/grill/vasp/source/buflib.cpp b/externals/grill/vasp/source/buflib.cpp index 03c2944e..78866a8e 100644 --- a/externals/grill/vasp/source/buflib.cpp +++ b/externals/grill/vasp/source/buflib.cpp @@ -52,7 +52,6 @@ public: static BufEntry *libhead = NULL,*libtail = NULL; static FreeEntry *freehead = NULL,*freetail = NULL; static I libcnt = 0,libtick = 0; -static t_clock *libclk = NULL; #ifdef FLEXT_THREADS static flext::ThrMutex libmtx; @@ -114,6 +113,73 @@ V BufLib::DecRef(t_symbol *s) } } +static V Collect() +{ +#ifdef FLEXT_THREADS + libmtx.Lock(); +#endif + + // collect garbage + BufEntry *e,*p; + for(p = NULL,e = libhead; e; ) { + if(e->refcnt <= 0 && e->tick+LIBTOL < libtick) { + ASSERT(e->refcnt == 0); + + BufEntry *n = e->nxt; + + if(p) p->nxt = n; + else libhead = n; + + if(!n) libtail = p; + else e->nxt = NULL; + + delete e; + + e = n; + } + else + p = e,e = e->nxt; + } + +#ifdef FLEXT_THREADS + libmtx.Unlock(); +#endif +} + + +#ifdef FLEXT_THREADS +static bool libthractive = false; +static pthread_t libthrid; +static bool libthrexit = false; // currently not used +static flext::ThrCond *libthrcond = NULL; + +static V *LibThr(V *) +{ + flext::RelPriority(-2); + + while(libthrexit) { + libthrcond->TimedWait(0.5f); + // TODO - should process return value of TimedWait + Collect(); + } + return NULL; +} +#endif + +static t_clock *libclk = NULL; +static V LibTick(V *) +{ +#ifdef FLEXT_THREADS + libthrcond->Signal(); +#else + Collect(); +#endif + + ++libtick; + clock_delay(libclk,LIBTICK); + +} + static t_symbol *GetLibSym() { if(freehead) { @@ -135,7 +201,7 @@ static t_symbol *GetLibSym() libcnt++; return gensym(tmp); } - + clock_delay(libclk,LIBTICK); } @@ -147,44 +213,20 @@ static V FreeLibSym(t_symbol *sym) freetail = f; } -static V LibTick(V *) + +BufEntry *BufLib::NewImm(I fr,BL zero) { #ifdef FLEXT_THREADS - libmtx.Lock(); -#endif - - // collect garbage - BufEntry *e,*p; - for(p = NULL,e = libhead; e; ) { - if(e->refcnt <= 0 && e->tick+LIBTOL < libtick) { - ASSERT(e->refcnt == 0); - - BufEntry *n = e->nxt; - - if(p) p->nxt = n; - else libhead = n; - - if(!n) libtail = p; - else e->nxt = NULL; - - delete e; - - e = n; + if(!libthractive) { + int ret = pthread_create(&libthrid,NULL,LibThr,NULL); + if(ret) + error("vasp - Could not launch helper thread"); + else { + libthrcond = new flext::ThrCond; + libthractive = true; } - else - p = e,e = e->nxt; } - - ++libtick; - clock_delay(libclk,LIBTICK); - -#ifdef FLEXT_THREADS - libmtx.Unlock(); #endif -} - -BufEntry *BufLib::NewImm(I fr,BL zero) -{ if(!libclk) { libclk = (t_clock *)clock_new(NULL,(t_method)LibTick); clock_delay(libclk,LIBTICK); diff --git a/externals/grill/vasp/source/classes.cpp b/externals/grill/vasp/source/classes.cpp index 582f5959..fa9ff7d4 100644 --- a/externals/grill/vasp/source/classes.cpp +++ b/externals/grill/vasp/source/classes.cpp @@ -94,7 +94,6 @@ vasp_op::vasp_op(BL op) FLEXT_ADDBANG(0,m_dobang); FLEXT_ADDMETHOD_(0,"vasp",m_vasp); FLEXT_ADDMETHOD_(0,"set",m_set); -// if(op) FLEXT_ADDMETHOD_(0,"to",m_to); FLEXT_ADDATTR_VAR("ref",m_getref,m_setref); if(op) FLEXT_ADDATTR_VAR("to",m_getto,m_setto); @@ -170,23 +169,6 @@ V vasp_op::m_update(I argc,const t_atom *argv) } } - -/* -V vasp_op::m_detach(BL thr) -{ -#ifdef FLEXT_THREADS - detach = thr; -#endif -} - -V vasp_op::m_prior(I p) -{ -#ifdef FLEXT_THREADS - prior = p; -#endif -} -*/ - V vasp_op::m_stop() {} /////////////////////////////////////////////////////////////////////////// @@ -201,10 +183,10 @@ V vasp_tx::m_bang() Lock(); #ifdef FLEXT_THREADS -// ChangePriority(prior); +// RelPriority(prior); #endif - if(ref.Ok()) + if(ref.Check()) { Vasp *ret = x_work(); if(ret) { diff --git a/externals/grill/vasp/source/classes.h b/externals/grill/vasp/source/classes.h index d6a31413..64719cd3 100644 --- a/externals/grill/vasp/source/classes.h +++ b/externals/grill/vasp/source/classes.h @@ -256,7 +256,8 @@ protected: \ virtual Vasp *tx_work() \ { \ OpParam p(thisName(),0); \ - return VaspOp::m_##op(p,ref,&dst); \ + CVasp cdst(dst); \ + return VaspOp::m_##op(p,CVasp(ref),&cdst); \ } \ virtual V m_help() { post("%s - " help,thisName()); } \ }; \ @@ -269,12 +270,13 @@ class vasp_ ## op: \ { \ FLEXT_HEADER(vasp_##op,vasp_binop) \ public: \ - vasp_##op(I argc,const t_atom *argv): vasp_binop(argc,argv,def,to) {} \ + vasp_##op(I argc,const t_atom *argv): vasp_binop(argc,argv,def,to) {} \ protected: \ virtual Vasp *tx_work(const Argument &arg) \ { \ OpParam p(thisName(),1); \ - return VaspOp::m_##op(p,ref,arg,&dst); \ + CVasp cdst(dst); \ + return VaspOp::m_##op(p,CVasp(ref),arg,&cdst); \ } \ virtual V m_help() { post("%s - " help,thisName()); } \ }; \ @@ -287,12 +289,13 @@ class vasp_ ## op: \ { \ FLEXT_HEADER(vasp_##op,vasp_anyop) \ public: \ - vasp_##op(I argc,const t_atom *argv): vasp_anyop(argc,argv,def,to) {} \ + vasp_##op(I argc,const t_atom *argv): vasp_anyop(argc,argv,def,to) {} \ protected: \ virtual Vasp *tx_work(const Argument &arg) \ { \ OpParam p(thisName(),args); \ - return VaspOp::m_##op(p,ref,arg,&dst); \ + CVasp cdst(dst); \ + return VaspOp::m_##op(p,CVasp(ref),arg,&cdst); \ } \ virtual V m_help() { post("%s - " help,thisName()); } \ }; \ diff --git a/externals/grill/vasp/source/main.cpp b/externals/grill/vasp/source/main.cpp index 1603d107..b50cded2 100644 --- a/externals/grill/vasp/source/main.cpp +++ b/externals/grill/vasp/source/main.cpp @@ -36,6 +36,7 @@ V lib_setup() VASP_SETUP(check); // vasp.check VASP_SETUP(update); // vasp.update +// VASP_SETUP(post); // vasp.post VASP_SETUP(sync); // vasp.sync diff --git a/externals/grill/vasp/source/obj_size.cpp b/externals/grill/vasp/source/obj_size.cpp index 6c38184c..1d28b1cb 100644 --- a/externals/grill/vasp/source/obj_size.cpp +++ b/externals/grill/vasp/source/obj_size.cpp @@ -34,7 +34,7 @@ class vasp_size: public: vasp_size(I argc,t_atom *argv,BL abs = true): - size(0),sets(false) + size(0),sets(false),keep(true) { if(argc >= 1 && CanbeFloat(argv[0])) m_arg(GetAFloat(argv[0])); @@ -47,6 +47,7 @@ public: FLEXT_ADDMETHOD(1,m_arg); if(abs) FLEXT_ADDATTR_VAR("frames",size,m_arg); + FLEXT_ADDATTR_VAR1("keep",keep); } virtual V m_arg(F s) @@ -58,19 +59,20 @@ public: virtual Vasp *x_work() { Vasp *ret = new Vasp(ref); - if(sets) ret->Size(size); + if(sets) ret->Size(size,keep); return ret; } virtual V m_help() { post("%s - Set the size of the vector buffers",thisName()); } protected: I size; - BL sets; + BL sets,keep; private: FLEXT_CALLBACK_F(m_arg); FLEXT_CALLSET_I(m_arg); FLEXT_ATTRGET_I(size); + FLEXT_ATTRVAR_B(keep); }; FLEXT_LIB_V("vasp, vasp.size vasp.s",vasp_size) @@ -227,7 +229,7 @@ public: virtual V m_bang() { - if(!ref.Ok()) + if(!ref.Check()) post("%s - Invalid vasp!",thisName()); else if(ref.Vectors() > 1) post("%s - More than one vector in vasp!",thisName()); diff --git a/externals/grill/vasp/source/obj_split.cpp b/externals/grill/vasp/source/obj_split.cpp index 04eb3eea..e308e19c 100644 --- a/externals/grill/vasp/source/obj_split.cpp +++ b/externals/grill/vasp/source/obj_split.cpp @@ -62,7 +62,7 @@ public: } if(rem > 0) { Vasp v(ref.Frames(),ref.Vector(outs)); - for(I i = 1; i < rem; ++i) v += ref.Vector(outs+i); + for(I i = 1; i < rem; ++i) v.AddVector(ref.Vector(outs+i)); ToOutVasp(outs,v); } else @@ -122,7 +122,7 @@ public: ~vasp_join() { if(vi) delete[] vi; } virtual Vasp *x_work() { - Vasp *ret = new Vasp(ref); + CVasp *ret = new CVasp(ref); for(I i = 0; i < cnt-1; ++i) if(vi[i]) *ret += *vi[i]; return ret; } @@ -255,25 +255,26 @@ public: virtual Vasp *x_work() { - Vasp *ret = new Vasp(ref); - *ret += dst; + CVasp *ret = new CVasp(ref); + *ret += cdst; m_reset(); return ret; } - V m_reset() { ref.Clear(); dst.Clear(); rem = cnt; } + V m_reset() { ref.Clear(); cdst.Clear(); rem = cnt; } virtual I m_set(I argc,t_atom *argv) { rem = cnt; return vasp_tx::m_set(argc,argv); } V m_add(I argc,t_atom *argv) { - dst += Vasp(argc,argv); + cdst += Vasp(argc,argv); if(cnt && !--rem) m_bang(); } virtual V m_help() { post("%s - Gather several vasps into one",thisName()); } private: I cnt,rem; + CVasp cdst; FLEXT_CALLBACK(m_reset) FLEXT_CALLBACK_V(m_add) diff --git a/externals/grill/vasp/source/obj_vasp.cpp b/externals/grill/vasp/source/obj_vasp.cpp index ba91a7c5..680bede7 100644 --- a/externals/grill/vasp/source/obj_vasp.cpp +++ b/externals/grill/vasp/source/obj_vasp.cpp @@ -189,8 +189,10 @@ public: virtual V m_bang() { - Vasp r(ref); - for(I i = CntOut()-1; i >= 0; --i) ToOutVasp(i,r); + if(ref.Check()) + for(I i = CntOut()-1; i >= 0; --i) ToOutVasp(i,ref); + else + post("%s - Invalid vasp",thisName()); } virtual V m_help() { post("%s - Output a vasp multiple times",thisName()); } diff --git a/externals/grill/vasp/source/opbase.cpp b/externals/grill/vasp/source/opbase.cpp index df4150f1..989a4952 100644 --- a/externals/grill/vasp/source/opbase.cpp +++ b/externals/grill/vasp/source/opbase.cpp @@ -12,7 +12,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "opbase.h" #include "opdefs.h" -Vasp *VaspOp::m_run(OpParam &p,Vasp &src,Vasp *dst,VecOp::opfun *fun) +Vasp *VaspOp::m_run(OpParam &p,CVasp &src,CVasp *dst,VecOp::opfun *fun) { Vasp *ret = NULL; RVecBlock *vecs = GetRVecs(p.opname,src,dst); @@ -24,7 +24,7 @@ Vasp *VaspOp::m_run(OpParam &p,Vasp &src,Vasp *dst,VecOp::opfun *fun) return ret; } -Vasp *VaspOp::m_cun(OpParam &p,Vasp &src,Vasp *dst,VecOp::opfun *fun) +Vasp *VaspOp::m_cun(OpParam &p,CVasp &src,CVasp *dst,VecOp::opfun *fun) { Vasp *ret = NULL; CVecBlock *vecs = GetCVecs(p.opname,src,dst); @@ -36,7 +36,7 @@ Vasp *VaspOp::m_cun(OpParam &p,Vasp &src,Vasp *dst,VecOp::opfun *fun) return ret; } -Vasp *VaspOp::m_rbin(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,VecOp::opfun *fun) +Vasp *VaspOp::m_rbin(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,VecOp::opfun *fun) { Vasp *ret = NULL; BL argvasp = arg.IsVasp(); @@ -58,7 +58,7 @@ Vasp *VaspOp::m_rbin(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,VecOp::o return ret; } -Vasp *VaspOp::m_cbin(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,VecOp::opfun *fun) +Vasp *VaspOp::m_cbin(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,VecOp::opfun *fun) { Vasp *ret = NULL; BL argvasp = arg.IsVasp(); diff --git a/externals/grill/vasp/source/opbase.h b/externals/grill/vasp/source/opbase.h index a4d1347b..a429b7a6 100644 --- a/externals/grill/vasp/source/opbase.h +++ b/externals/grill/vasp/source/opbase.h @@ -29,10 +29,10 @@ namespace VecOp { namespace VaspOp { - RVecBlock *GetRVecs(const C *op,Vasp &src,Vasp *dst = NULL); - CVecBlock *GetCVecs(const C *op,Vasp &src,Vasp *dst = NULL,BL full = false); - RVecBlock *GetRVecs(const C *op,Vasp &src,const Vasp &arg,Vasp *dst = NULL,I multi = -1,BL ssize = true); - CVecBlock *GetCVecs(const C *op,Vasp &src,const Vasp &arg,Vasp *dst = NULL,I multi = -1,BL ssize = true,BL full = false); + RVecBlock *GetRVecs(const C *op,CVasp &src,CVasp *dst = NULL); + CVecBlock *GetCVecs(const C *op,CVasp &src,CVasp *dst = NULL,BL full = false); + RVecBlock *GetRVecs(const C *op,CVasp &src,const CVasp &arg,CVasp *dst = NULL,I multi = -1,BL ssize = true); + CVecBlock *GetCVecs(const C *op,CVasp &src,const CVasp &arg,CVasp *dst = NULL,I multi = -1,BL ssize = true,BL full = false); Vasp *DoOp(RVecBlock *vecs,VecOp::opfun *fun,OpParam &p,BL symm = false); Vasp *DoOp(CVecBlock *vecs,VecOp::opfun *fun,OpParam &p,BL symm = false); @@ -40,11 +40,11 @@ namespace VaspOp { // -------- transformations ----------------------------------- // unary functions - Vasp *m_run(OpParam &p,Vasp &src,Vasp *dst,VecOp::opfun *fun); // real unary (one vec or real) - Vasp *m_cun(OpParam &p,Vasp &src,Vasp *dst,VecOp::opfun *fun); // complex unary (one vec or complex) + Vasp *m_run(OpParam &p,CVasp &src,CVasp *dst,VecOp::opfun *fun); // real unary (one vec or real) + Vasp *m_cun(OpParam &p,CVasp &src,CVasp *dst,VecOp::opfun *fun); // complex unary (one vec or complex) // binary functions - Vasp *m_rbin(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,VecOp::opfun *fun); // real binary (one vec or real) - Vasp *m_cbin(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,VecOp::opfun *fun); // complex binary (one vec or complex) + Vasp *m_rbin(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,VecOp::opfun *fun); // real binary (one vec or real) + Vasp *m_cbin(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,VecOp::opfun *fun); // complex binary (one vec or complex) } #endif diff --git a/externals/grill/vasp/source/ops_arith.h b/externals/grill/vasp/source/ops_arith.h index 6e2bb879..d4fcd470 100644 --- a/externals/grill/vasp/source/ops_arith.h +++ b/externals/grill/vasp/source/ops_arith.h @@ -42,31 +42,31 @@ namespace VecOp { } namespace VaspOp { - inline Vasp *m_add(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_add); } // add to (one vec or real) - inline Vasp *m_sub(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_sub); } // sub from (one vec or real) - inline Vasp *m_subr(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_subr); } // reverse sub from (one vec or real) - inline Vasp *m_mul(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_mul); } // mul with (one vec or real) - inline Vasp *m_div(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_div); } // div by (one vec or real) - inline Vasp *m_divr(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_divr); } // reverse div by (one vec or real) - inline Vasp *m_mod(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_mod); } // modulo by (one vec or real) + inline Vasp *m_add(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_add); } // add to (one vec or real) + inline Vasp *m_sub(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_sub); } // sub from (one vec or real) + inline Vasp *m_subr(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_subr); } // reverse sub from (one vec or real) + inline Vasp *m_mul(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_mul); } // mul with (one vec or real) + inline Vasp *m_div(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_div); } // div by (one vec or real) + inline Vasp *m_divr(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_divr); } // reverse div by (one vec or real) + inline Vasp *m_mod(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_mod); } // modulo by (one vec or real) - inline Vasp *m_cadd(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cadd); } // complex add (pairs of vecs or complex) - inline Vasp *m_csub(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_csub); } // complex sub (pairs of vecs or complex) - inline Vasp *m_csubr(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_csubr); } // reverse complex sub (pairs of vecs or complex) - inline Vasp *m_cmul(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cmul); } // complex mul (pairs of vecs or complex) - inline Vasp *m_cdiv(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cdiv); } // complex div (pairs of vecs or complex) - inline Vasp *m_cdivr(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cdivr); } // complex reverse div (pairs of vecs or complex) + inline Vasp *m_cadd(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cadd); } // complex add (pairs of vecs or complex) + inline Vasp *m_csub(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_csub); } // complex sub (pairs of vecs or complex) + inline Vasp *m_csubr(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_csubr); } // reverse complex sub (pairs of vecs or complex) + inline Vasp *m_cmul(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cmul); } // complex mul (pairs of vecs or complex) + inline Vasp *m_cdiv(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cdiv); } // complex div (pairs of vecs or complex) + inline Vasp *m_cdivr(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cdivr); } // complex reverse div (pairs of vecs or complex) - inline Vasp *m_sqr(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_sqr); } // unsigned square - inline Vasp *m_ssqr(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_ssqr); } // signed square - inline Vasp *m_csqr(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_csqr); } // complex square (with each two channels) -// inline Vasp *m_csqrt(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_csqrt); } // complex square root (how about branches?) + inline Vasp *m_sqr(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_sqr); } // unsigned square + inline Vasp *m_ssqr(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_ssqr); } // signed square + inline Vasp *m_csqr(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_csqr); } // complex square (with each two channels) +// inline Vasp *m_csqrt(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_csqrt); } // complex square root (how about branches?) - Vasp *m_cpowi(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL); // complex integer power (with each two channels) + Vasp *m_cpowi(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL); // complex integer power (with each two channels) - inline Vasp *m_sign(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_sign); } // sign function - inline Vasp *m_abs(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_abs); } // absolute values - inline Vasp *m_cabs(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_cabs); } // absolute values + inline Vasp *m_sign(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_sign); } // sign function + inline Vasp *m_abs(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_abs); } // absolute values + inline Vasp *m_cabs(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_cabs); } // absolute values } #endif diff --git a/externals/grill/vasp/source/ops_assign.cpp b/externals/grill/vasp/source/ops_assign.cpp index a8033bb9..2495d68a 100644 --- a/externals/grill/vasp/source/ops_assign.cpp +++ b/externals/grill/vasp/source/ops_assign.cpp @@ -32,7 +32,7 @@ VASP_BINARY("vasp.cset vasp.c=",cset,false,VASP_ARG_R(0),"Assigns a complex valu -Vasp *VaspOp::m_copy(OpParam &p,Vasp &src,Vasp &arg) +Vasp *VaspOp::m_copy(OpParam &p,CVasp &src,CVasp &arg) { Vasp *s = NULL,*d = NULL; RVecBlock *vecs = GetRVecs(p.opname,src,&arg); @@ -45,7 +45,7 @@ Vasp *VaspOp::m_copy(OpParam &p,Vasp &src,Vasp &arg) return s; } -Vasp *VaspOp::m_ccopy(OpParam &p,Vasp &src,Vasp &arg) +Vasp *VaspOp::m_ccopy(OpParam &p,CVasp &src,CVasp &arg) { Vasp *s = NULL,*d = NULL; CVecBlock *vecs = GetCVecs(p.opname,src,&arg); @@ -69,14 +69,14 @@ public: virtual V m_to(I,const t_atom *) { post("s - destination vasp is ignored!",thisName()); } - virtual Vasp *do_copy(OpParam &p,Vasp &dst) { return VaspOp::m_copy(p,ref,dst); } + virtual Vasp *do_copy(OpParam &p,CVasp &dst) { return VaspOp::m_copy(p,CVasp(ref),dst); } virtual Vasp *tx_work(const Argument &arg) { OpParam p(thisName(),0); if(arg.CanbeVasp()) { - Vasp dst = arg.GetAVasp(); + CVasp dst(arg.GetAVasp()); Vasp *ret = do_copy(p,dst); ToOutVasp(1,dst); return ret; @@ -100,7 +100,7 @@ public: vasp_ccopy(I argc,const t_atom *argv): vasp_copy(argc,argv) {} - virtual Vasp *do_copy(OpParam &p,Vasp &dst) { return VaspOp::m_ccopy(p,ref,dst); } + virtual Vasp *do_copy(OpParam &p,CVasp &dst) { return VaspOp::m_ccopy(p,CVasp(ref),dst); } virtual V m_help() { post("%s - Copies complex pairs of the triggering vasp to the argument vasp",thisName()); } }; diff --git a/externals/grill/vasp/source/ops_assign.h b/externals/grill/vasp/source/ops_assign.h index e80501f0..e27b3798 100644 --- a/externals/grill/vasp/source/ops_assign.h +++ b/externals/grill/vasp/source/ops_assign.h @@ -24,11 +24,11 @@ namespace VecOp { } namespace VaspOp { - inline Vasp *m_set(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_set); } // copy to (one vec or real) - inline Vasp *m_cset(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cset); } // complex copy (pairs of vecs or complex) + inline Vasp *m_set(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_set); } // copy to (one vec or real) + inline Vasp *m_cset(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cset); } // complex copy (pairs of vecs or complex) - Vasp *m_copy(OpParam &p,Vasp &src,Vasp &dst); - Vasp *m_ccopy(OpParam &p,Vasp &src,Vasp &dst); + Vasp *m_copy(OpParam &p,CVasp &src,CVasp &dst); + Vasp *m_ccopy(OpParam &p,CVasp &src,CVasp &dst); } #endif diff --git a/externals/grill/vasp/source/ops_carith.cpp b/externals/grill/vasp/source/ops_carith.cpp index cf00b439..cece7031 100644 --- a/externals/grill/vasp/source/ops_carith.cpp +++ b/externals/grill/vasp/source/ops_carith.cpp @@ -71,7 +71,7 @@ template<class T> V f_cpowi(T &rv,T &iv,T ra,T ia,OpParam &p) BL VecOp::d_cpowi(OpParam &p) { d__cop(f_cpowi<S>,p); } -Vasp *VaspOp::m_cpowi(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) +Vasp *VaspOp::m_cpowi(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { Vasp *ret = NULL; CVecBlock *vecs = GetCVecs(p.opname,src,dst); diff --git a/externals/grill/vasp/source/ops_carith.h b/externals/grill/vasp/source/ops_carith.h index 7f841750..3910c0ad 100644 --- a/externals/grill/vasp/source/ops_carith.h +++ b/externals/grill/vasp/source/ops_carith.h @@ -30,19 +30,19 @@ namespace VecOp { } namespace VaspOp { - inline Vasp *m_cadd(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cadd); } // complex add (pairs of vecs or complex) - inline Vasp *m_csub(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_csub); } // complex sub (pairs of vecs or complex) - inline Vasp *m_csubr(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_csubr); } // reverse complex sub (pairs of vecs or complex) - inline Vasp *m_cmul(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cmul); } // complex mul (pairs of vecs or complex) - inline Vasp *m_cdiv(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cdiv); } // complex div (pairs of vecs or complex) - inline Vasp *m_cdivr(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cdivr); } // complex reverse div (pairs of vecs or complex) + inline Vasp *m_cadd(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cadd); } // complex add (pairs of vecs or complex) + inline Vasp *m_csub(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_csub); } // complex sub (pairs of vecs or complex) + inline Vasp *m_csubr(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_csubr); } // reverse complex sub (pairs of vecs or complex) + inline Vasp *m_cmul(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cmul); } // complex mul (pairs of vecs or complex) + inline Vasp *m_cdiv(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cdiv); } // complex div (pairs of vecs or complex) + inline Vasp *m_cdivr(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_cdivr); } // complex reverse div (pairs of vecs or complex) - inline Vasp *m_csqr(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_csqr); } // complex square (with each two channels) -// inline Vasp *m_csqrt(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_csqrt); } // complex square root (how about branches?) + inline Vasp *m_csqr(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_csqr); } // complex square (with each two channels) +// inline Vasp *m_csqrt(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_csqrt); } // complex square root (how about branches?) - Vasp *m_cpowi(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL); // complex integer power (with each two channels) + Vasp *m_cpowi(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL); // complex integer power (with each two channels) - inline Vasp *m_cabs(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_cabs); } // absolute values + inline Vasp *m_cabs(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_cabs); } // absolute values } #endif diff --git a/externals/grill/vasp/source/ops_cmp.h b/externals/grill/vasp/source/ops_cmp.h index 87af3a19..8fab0e27 100644 --- a/externals/grill/vasp/source/ops_cmp.h +++ b/externals/grill/vasp/source/ops_cmp.h @@ -50,37 +50,37 @@ namespace VecOp { } namespace VaspOp { - inline Vasp *m_lwr(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_lwr); } // lower than - inline Vasp *m_gtr(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_gtr); } // greater than - inline Vasp *m_alwr(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_alwr); } // abs lower than - inline Vasp *m_agtr(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_agtr); } // abs greater than - inline Vasp *m_leq(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_leq); } // abs lower than - inline Vasp *m_geq(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_geq); } // abs greater than - inline Vasp *m_aleq(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_aleq); } // lower than - inline Vasp *m_ageq(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_ageq); } // greater than - inline Vasp *m_equ(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_equ); } // lower than - inline Vasp *m_neq(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_neq); } // greater than - - inline Vasp *m_min(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_min); } // min (one vec or real) - inline Vasp *m_max(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_max); } // max (one vec or real) - - inline Vasp *m_rmin(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_rmin); } // complex (radius) min (pairs of vecs or complex) - inline Vasp *m_rmax(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_rmax); } // complex (radius) max (pairs of vecs or complex) - - inline Vasp *m_minmax(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_minmax); } // min/max - - inline Vasp *m_qmin(OpParam &p,Vasp &src) { return m_run(p,src,NULL,VecOp::d_minq); } // get minimum sample value - inline Vasp *m_qmax(OpParam &p,Vasp &src) { return m_run(p,src,NULL,VecOp::d_maxq); } // get maximum sample value - inline Vasp *m_qamin(OpParam &p,Vasp &src) { return m_run(p,src,NULL,VecOp::d_aminq); } // get minimum sample value - inline Vasp *m_qamax(OpParam &p,Vasp &src) { return m_run(p,src,NULL,VecOp::d_amaxq); } // get maximum sample value - - inline Vasp *m_qrmin(OpParam &p,Vasp &src) { return m_cun(p,src,NULL,VecOp::d_rminq); } // get minimum sample value - inline Vasp *m_qrmax(OpParam &p,Vasp &src) { return m_cun(p,src,NULL,VecOp::d_rmaxq); } // get maximum sample value - - Vasp *m_gate(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL); // gate - Vasp *m_igate(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL); // inverse gate - Vasp *m_rgate(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL); // radius gate - Vasp *m_rigate(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL); // inverse radius gate + inline Vasp *m_lwr(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_lwr); } // lower than + inline Vasp *m_gtr(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_gtr); } // greater than + inline Vasp *m_alwr(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_alwr); } // abs lower than + inline Vasp *m_agtr(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_agtr); } // abs greater than + inline Vasp *m_leq(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_leq); } // abs lower than + inline Vasp *m_geq(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_geq); } // abs greater than + inline Vasp *m_aleq(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_aleq); } // lower than + inline Vasp *m_ageq(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_ageq); } // greater than + inline Vasp *m_equ(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_equ); } // lower than + inline Vasp *m_neq(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_neq); } // greater than + + inline Vasp *m_min(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_min); } // min (one vec or real) + inline Vasp *m_max(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_max); } // max (one vec or real) + + inline Vasp *m_rmin(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_rmin); } // complex (radius) min (pairs of vecs or complex) + inline Vasp *m_rmax(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_cbin(p,src,arg,dst,VecOp::d_rmax); } // complex (radius) max (pairs of vecs or complex) + + inline Vasp *m_minmax(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_minmax); } // min/max + + inline Vasp *m_qmin(OpParam &p,CVasp &src) { return m_run(p,src,NULL,VecOp::d_minq); } // get minimum sample value + inline Vasp *m_qmax(OpParam &p,CVasp &src) { return m_run(p,src,NULL,VecOp::d_maxq); } // get maximum sample value + inline Vasp *m_qamin(OpParam &p,CVasp &src) { return m_run(p,src,NULL,VecOp::d_aminq); } // get minimum sample value + inline Vasp *m_qamax(OpParam &p,CVasp &src) { return m_run(p,src,NULL,VecOp::d_amaxq); } // get maximum sample value + + inline Vasp *m_qrmin(OpParam &p,CVasp &src) { return m_cun(p,src,NULL,VecOp::d_rminq); } // get minimum sample value + inline Vasp *m_qrmax(OpParam &p,CVasp &src) { return m_cun(p,src,NULL,VecOp::d_rmaxq); } // get maximum sample value + + Vasp *m_gate(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL); // gate + Vasp *m_igate(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL); // inverse gate + Vasp *m_rgate(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL); // radius gate + Vasp *m_rigate(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL); // inverse radius gate } #endif diff --git a/externals/grill/vasp/source/ops_cplx.cpp b/externals/grill/vasp/source/ops_cplx.cpp index 5311b2db..b2f01788 100644 --- a/externals/grill/vasp/source/ops_cplx.cpp +++ b/externals/grill/vasp/source/ops_cplx.cpp @@ -40,7 +40,7 @@ template<class T> V f_radd(T &rv,T &iv,T ra,T ia,T rb,T) BL VecOp::d_radd(OpParam &p) { d__cbin(f_radd<S>,p); } -Vasp *VaspOp::m_radd(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) +Vasp *VaspOp::m_radd(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { Vasp *ret = NULL; CVecBlock *vecs = GetCVecs(p.opname,src,dst); diff --git a/externals/grill/vasp/source/ops_cplx.h b/externals/grill/vasp/source/ops_cplx.h index de1426f2..b3aaa4c6 100644 --- a/externals/grill/vasp/source/ops_cplx.h +++ b/externals/grill/vasp/source/ops_cplx.h @@ -28,15 +28,15 @@ namespace VecOp { } namespace VaspOp { - inline Vasp *m_polar(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_polar); } // cartesian -> polar (each two) - inline Vasp *m_rect(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_rect); } // polar -> cartesian (each two) + inline Vasp *m_polar(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_polar); } // cartesian -> polar (each two) + inline Vasp *m_rect(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_rect); } // polar -> cartesian (each two) - Vasp *m_radd(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL); // radius offset + Vasp *m_radd(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL); // radius offset - inline Vasp *m_cnorm(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_cnorm); } // complex normalize + inline Vasp *m_cnorm(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_cnorm); } // complex normalize -// inline Vasp *m_cswap(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_cswap); } // swap real and imaginary parts - inline Vasp *m_cconj(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_cconj); } // complex conjugate +// inline Vasp *m_cswap(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_cswap); } // swap real and imaginary parts + inline Vasp *m_cconj(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_cconj); } // complex conjugate } #endif diff --git a/externals/grill/vasp/source/ops_dft.cpp b/externals/grill/vasp/source/ops_dft.cpp index dec49a26..827c2a03 100644 --- a/externals/grill/vasp/source/ops_dft.cpp +++ b/externals/grill/vasp/source/ops_dft.cpp @@ -584,7 +584,7 @@ static I radix2(I size) return j == size?i:-1; } -Vasp *VaspOp::m_rfft(OpParam &p,Vasp &src,Vasp *dst,BL inv) +Vasp *VaspOp::m_rfft(OpParam &p,CVasp &src,CVasp *dst,BL inv) { RVecBlock *vecs = GetRVecs(p.opname,src,dst); if(vecs) { @@ -614,7 +614,7 @@ Vasp *VaspOp::m_rfft(OpParam &p,Vasp &src,Vasp *dst,BL inv) return NULL; } -Vasp *VaspOp::m_cfft(OpParam &p,Vasp &src,Vasp *dst,BL inv) +Vasp *VaspOp::m_cfft(OpParam &p,CVasp &src,CVasp *dst,BL inv) { CVecBlock *vecs = GetCVecs(p.opname,src,dst,true); if(vecs) { diff --git a/externals/grill/vasp/source/ops_dft.h b/externals/grill/vasp/source/ops_dft.h index f2f3fe40..24b9a23d 100644 --- a/externals/grill/vasp/source/ops_dft.h +++ b/externals/grill/vasp/source/ops_dft.h @@ -16,10 +16,10 @@ WARRANTIES, see the file, "license.txt," in this distribution. // Fourier transforms namespace VaspOp { - Vasp *m_rfft(OpParam &p,Vasp &src,Vasp *dst = NULL,BL inv = false); // real forward - inline Vasp *m_rifft(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_rfft(p,src,dst,true); } // real inverse - Vasp *m_cfft(OpParam &p,Vasp &src,Vasp *dst = NULL,BL inv = false); // complex forward - inline Vasp *m_cifft(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cfft(p,src,dst,true); } // complex inverse + Vasp *m_rfft(OpParam &p,CVasp &src,CVasp *dst = NULL,BL inv = false); // real forward + inline Vasp *m_rifft(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_rfft(p,src,dst,true); } // real inverse + Vasp *m_cfft(OpParam &p,CVasp &src,CVasp *dst = NULL,BL inv = false); // complex forward + inline Vasp *m_cifft(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cfft(p,src,dst,true); } // complex inverse } #endif diff --git a/externals/grill/vasp/source/ops_feature.cpp b/externals/grill/vasp/source/ops_feature.cpp index ede711e2..3e33f313 100644 --- a/externals/grill/vasp/source/ops_feature.cpp +++ b/externals/grill/vasp/source/ops_feature.cpp @@ -101,7 +101,7 @@ inline BL d_rvalleys(OpParam &p) { return d_vlpk(p,lower); } \param inv true for valley operation \return normalized destination vasp */ -Vasp *VaspOp::m_peaks(OpParam &p,Vasp &src,Vasp *dst,BL inv) +Vasp *VaspOp::m_peaks(OpParam &p,CVasp &src,CVasp *dst,BL inv) { Vasp *ret = NULL; RVecBlock *vecs = GetRVecs(p.opname,src,dst); @@ -123,7 +123,7 @@ Vasp *VaspOp::m_peaks(OpParam &p,Vasp &src,Vasp *dst,BL inv) \param inv true for valley operation \return normalized destination vasp */ -Vasp *VaspOp::m_rpeaks(OpParam &p,Vasp &src,Vasp *dst,BL inv) +Vasp *VaspOp::m_rpeaks(OpParam &p,CVasp &src,CVasp *dst,BL inv) { Vasp *ret = NULL; CVecBlock *vecs = GetCVecs(p.opname,src,dst); @@ -146,7 +146,11 @@ public: vasp_anyop(argc,argv,VASP_ARG(),true,XletCode(xlet::tp_float,0)) {} - virtual Vasp *do_peaks(OpParam &p) { return VaspOp::m_peaks(p,ref,&dst); } + virtual Vasp *do_peaks(OpParam &p) + { + CVasp cdst(dst); + return VaspOp::m_peaks(p,CVasp(ref),&cdst); + } virtual Vasp *tx_work(const Argument &arg) { @@ -174,7 +178,11 @@ class vasp_valleys: FLEXT_HEADER(vasp_valleys,vasp_peaks) public: vasp_valleys(I argc,const t_atom *argv): vasp_peaks(argc,argv) {} - virtual Vasp *do_peaks(OpParam &p) { return VaspOp::m_valleys(p,ref,&dst); } + virtual Vasp *do_peaks(OpParam &p) + { + CVasp cdst(dst); + return VaspOp::m_valleys(p,CVasp(ref),&cdst); + } }; FLEXT_LIB_V("vasp, vasp.valleys",vasp_valleys) @@ -185,7 +193,11 @@ class vasp_rpeaks: FLEXT_HEADER(vasp_rpeaks,vasp_peaks) public: vasp_rpeaks(I argc,const t_atom *argv): vasp_peaks(argc,argv) {} - virtual Vasp *do_peaks(OpParam &p) { return VaspOp::m_rpeaks(p,ref,&dst); } + virtual Vasp *do_peaks(OpParam &p) + { + CVasp cdst(dst); + return VaspOp::m_rpeaks(p,CVasp(ref),&cdst); + } }; FLEXT_LIB_V("vasp, vasp.rpeaks",vasp_rpeaks) @@ -196,7 +208,11 @@ class vasp_rvalleys: FLEXT_HEADER(vasp_rvalleys,vasp_peaks) public: vasp_rvalleys(I argc,const t_atom *argv): vasp_peaks(argc,argv) {} - virtual Vasp *do_peaks(OpParam &p) { return VaspOp::m_rvalleys(p,ref,&dst); } + virtual Vasp *do_peaks(OpParam &p) + { + CVasp cdst(dst); + return VaspOp::m_rvalleys(p,CVasp(ref),&cdst); + } }; FLEXT_LIB_V("vasp, vasp.rvalleys",vasp_rvalleys) diff --git a/externals/grill/vasp/source/ops_feature.h b/externals/grill/vasp/source/ops_feature.h index 05efc8b5..95293bad 100644 --- a/externals/grill/vasp/source/ops_feature.h +++ b/externals/grill/vasp/source/ops_feature.h @@ -20,10 +20,10 @@ namespace VecOp { namespace VaspOp { // extrema functions - Vasp *m_peaks(OpParam &p,Vasp &src,Vasp *dst = NULL,BL inv = false); //! find peaks - inline Vasp *m_valleys(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_peaks(p,src,dst,true); } //! find valleys - Vasp *m_rpeaks(OpParam &p,Vasp &src,Vasp *dst = NULL,BL inv = false); //! find radius peaks - inline Vasp *m_rvalleys(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_rpeaks(p,src,dst,true); } //! find radius valleys + Vasp *m_peaks(OpParam &p,CVasp &src,CVasp *dst = NULL,BL inv = false); //! find peaks + inline Vasp *m_valleys(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_peaks(p,src,dst,true); } //! find valleys + Vasp *m_rpeaks(OpParam &p,CVasp &src,CVasp *dst = NULL,BL inv = false); //! find radius peaks + inline Vasp *m_rvalleys(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_rpeaks(p,src,dst,true); } //! find radius valleys } #endif diff --git a/externals/grill/vasp/source/ops_flt.cpp b/externals/grill/vasp/source/ops_flt.cpp index 7784b081..fae66f56 100644 --- a/externals/grill/vasp/source/ops_flt.cpp +++ b/externals/grill/vasp/source/ops_flt.cpp @@ -105,7 +105,7 @@ BL VecOp::d_flp(OpParam &p) -Vasp *VaspOp::m_fhp(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL hp) +Vasp *VaspOp::m_fhp(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL hp) { Vasp *ret = NULL; if(arg.IsList() && arg.GetList().Count() >= 1) { @@ -186,7 +186,7 @@ BL VecOp::d_dif(OpParam &p) \param inv true for differentiation \return normalized destination vasp */ -Vasp *VaspOp::m_int(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL inv) +Vasp *VaspOp::m_int(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL inv) { Vasp *ret = NULL; RVecBlock *vecs = GetRVecs(p.opname,src,dst); diff --git a/externals/grill/vasp/source/ops_flt.h b/externals/grill/vasp/source/ops_flt.h index 0ab37111..21761d90 100644 --- a/externals/grill/vasp/source/ops_flt.h +++ b/externals/grill/vasp/source/ops_flt.h @@ -27,15 +27,15 @@ namespace VecOp { namespace VaspOp { // passive filters - Vasp *m_fhp(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL,BL hp = true); //! hi pass - inline Vasp *m_flp(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_fhp(p,src,arg,dst,false); } //! lo pass + Vasp *m_fhp(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL,BL hp = true); //! hi pass + inline Vasp *m_flp(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_fhp(p,src,arg,dst,false); } //! lo pass // int/dif functions - Vasp *m_int(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL,BL inv = false); //! integrate - inline Vasp *m_dif(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_int(p,src,arg,dst,true); } //! differentiate + Vasp *m_int(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL,BL inv = false); //! integrate + inline Vasp *m_dif(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_int(p,src,arg,dst,true); } //! differentiate // fix denormals/NANs - inline Vasp *m_fix(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_fix); } // ! NAN/denormal filter + inline Vasp *m_fix(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_fix); } // ! NAN/denormal filter } #endif diff --git a/externals/grill/vasp/source/ops_gate.cpp b/externals/grill/vasp/source/ops_gate.cpp index 97faf682..3dd15fbb 100644 --- a/externals/grill/vasp/source/ops_gate.cpp +++ b/externals/grill/vasp/source/ops_gate.cpp @@ -43,7 +43,7 @@ BL VecOp::d_rigate(OpParam &p) { d__cbin(f_rigate<S>,p); } -Vasp *VaspOp::m_gate(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) +Vasp *VaspOp::m_gate(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { Vasp *ret = NULL; RVecBlock *vecs = GetRVecs(p.opname,src,dst); @@ -62,7 +62,7 @@ Vasp *VaspOp::m_gate(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) } -Vasp *VaspOp::m_rgate(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) +Vasp *VaspOp::m_rgate(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { Vasp *ret = NULL; CVecBlock *vecs = GetCVecs(p.opname,src,dst); diff --git a/externals/grill/vasp/source/ops_gen.cpp b/externals/grill/vasp/source/ops_gen.cpp index f45be684..fb354468 100644 --- a/externals/grill/vasp/source/ops_gen.cpp +++ b/externals/grill/vasp/source/ops_gen.cpp @@ -48,7 +48,7 @@ BL VecOp::d_mosc(OpParam &p) \todo Replace period length by frequency specification */ -Vasp *VaspOp::m_osc(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL mul) +Vasp *VaspOp::m_osc(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL mul) { Vasp *ret = NULL; if(arg.IsList() && arg.GetList().Count() >= 1) { @@ -109,7 +109,7 @@ BL VecOp::d_mcosc(OpParam &p) \todo Replace period length by frequency specification */ -Vasp *VaspOp::m_cosc(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL mul) +Vasp *VaspOp::m_cosc(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL mul) { Vasp *ret = NULL; if(arg.IsList() && arg.GetList().Count() >= 1) { @@ -172,7 +172,7 @@ BL VecOp::d_mphasor(OpParam &p) \todo Replace period length by frequency specification */ -Vasp *VaspOp::m_phasor(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL mul) +Vasp *VaspOp::m_phasor(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL mul) { Vasp *ret = NULL; if(arg.IsList() && arg.GetList().Count() >= 1) { @@ -220,7 +220,7 @@ BL VecOp::d_noise(OpParam &p) \return normalized destination vasp */ -Vasp *VaspOp::m_noise(OpParam &p,Vasp &src,Vasp *dst) +Vasp *VaspOp::m_noise(OpParam &p,CVasp &src,CVasp *dst) { Vasp *ret = NULL; RVecBlock *vecs = GetRVecs(p.opname,src,dst); @@ -250,7 +250,7 @@ BL VecOp::d_cnoise(OpParam &p) \todo Replace period length by frequency specification */ -Vasp *VaspOp::m_cnoise(OpParam &p,Vasp &src,Vasp *dst) +Vasp *VaspOp::m_cnoise(OpParam &p,CVasp &src,CVasp *dst) { Vasp *ret = NULL; CVecBlock *vecs = GetCVecs(p.opname,src,dst); diff --git a/externals/grill/vasp/source/ops_gen.h b/externals/grill/vasp/source/ops_gen.h index 9d1902d5..eff28710 100644 --- a/externals/grill/vasp/source/ops_gen.h +++ b/externals/grill/vasp/source/ops_gen.h @@ -27,14 +27,14 @@ namespace VecOp { } namespace VaspOp { - Vasp *m_osc(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL mul = false); // real osc - inline Vasp *m_mosc(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) { return m_osc(p,src,arg,dst,true); } // * real osc - Vasp *m_cosc(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL mul = false); // complex osc (phase rotates) - inline Vasp *m_mcosc(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) { return m_cosc(p,src,arg,dst,true); } // * complex osc (phase rotates) - Vasp *m_phasor(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL mul = false); // phasor - inline Vasp *m_mphasor(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) { return m_phasor(p,src,arg,dst,true); } // * phasor - Vasp *m_noise(OpParam &p,Vasp &src,Vasp *dst); // real noise - Vasp *m_cnoise(OpParam &p,Vasp &src,Vasp *dst); // complex noise (arg and abs random) + Vasp *m_osc(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL mul = false); // real osc + inline Vasp *m_mosc(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { return m_osc(p,src,arg,dst,true); } // * real osc + Vasp *m_cosc(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL mul = false); // complex osc (phase rotates) + inline Vasp *m_mcosc(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { return m_cosc(p,src,arg,dst,true); } // * complex osc (phase rotates) + Vasp *m_phasor(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL mul = false); // phasor + inline Vasp *m_mphasor(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { return m_phasor(p,src,arg,dst,true); } // * phasor + Vasp *m_noise(OpParam &p,CVasp &src,CVasp *dst); // real noise + Vasp *m_cnoise(OpParam &p,CVasp &src,CVasp *dst); // complex noise (arg and abs random) } #endif diff --git a/externals/grill/vasp/source/ops_qminmax.cpp b/externals/grill/vasp/source/ops_qminmax.cpp index adcb15d2..debbfbd2 100644 --- a/externals/grill/vasp/source/ops_qminmax.cpp +++ b/externals/grill/vasp/source/ops_qminmax.cpp @@ -84,7 +84,7 @@ public: virtual Vasp *do_opt(OpParam &p) { p.norm.minmax = BIG; - Vasp *ret = VaspOp::m_qmin(p,ref); + Vasp *ret = VaspOp::m_qmin(p,CVasp(ref)); if(p.norm.minmax == BIG) p.norm.minmax = 0; return ret; } @@ -124,7 +124,7 @@ public: virtual Vasp *do_opt(OpParam &p) { p.norm.minmax = BIG; - Vasp *ret = VaspOp::m_qamin(p,ref); + Vasp *ret = VaspOp::m_qamin(p,CVasp(ref)); if(p.norm.minmax == BIG) p.norm.minmax = 0; return ret; } @@ -157,7 +157,7 @@ public: virtual Vasp *do_opt(OpParam &p) { p.norm.minmax = -BIG; - Vasp *ret = VaspOp::m_qmax(p,ref); + Vasp *ret = VaspOp::m_qmax(p,CVasp(ref)); if(p.norm.minmax == -BIG) p.norm.minmax = 0; return ret; } @@ -190,7 +190,7 @@ public: virtual Vasp *do_opt(OpParam &p) { p.norm.minmax = 0; - return VaspOp::m_qamax(p,ref); + return VaspOp::m_qamax(p,CVasp(ref)); } virtual V m_help() { post("%s - Get a vasp's maximum absolute sample value",thisName()); } @@ -225,7 +225,7 @@ public: virtual Vasp *do_opt(OpParam &p) { p.norm.minmax = BIG; - Vasp *ret = VaspOp::m_qrmin(p,ref); + Vasp *ret = VaspOp::m_qrmin(p,CVasp(ref)); if(p.norm.minmax == BIG) p.norm.minmax = 0; return ret; } @@ -266,7 +266,7 @@ public: virtual Vasp *do_opt(OpParam &p) { p.norm.minmax = 0; - return VaspOp::m_qrmax(p,ref); + return VaspOp::m_qrmax(p,CVasp(ref)); } virtual V m_help() { post("%s - Get a vasp's maximum complex radius",thisName()); } diff --git a/externals/grill/vasp/source/ops_rearr.cpp b/externals/grill/vasp/source/ops_rearr.cpp index bee58c56..80093c17 100644 --- a/externals/grill/vasp/source/ops_rearr.cpp +++ b/externals/grill/vasp/source/ops_rearr.cpp @@ -16,7 +16,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. /*! \brief vasp shift or rotation \todo units for shift */ -Vasp *VaspOp::m_shift(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL shift,BL symm) +Vasp *VaspOp::m_shift(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL shift,BL symm) { Vasp *ret = NULL; RVecBlock *vecs = GetRVecs(p.opname,src,dst); @@ -114,7 +114,11 @@ public: xsf_none = 0,xsf_zero,xsf_edge }; - virtual Vasp *do_shift(OpParam &p) { return VaspOp::m_shift(p,ref,arg,&dst); } + virtual Vasp *do_shift(OpParam &p) + { + CVasp cdst(dst); + return VaspOp::m_shift(p,CVasp(ref),arg,&cdst); + } virtual Vasp *tx_work(const Argument &arg) { @@ -144,7 +148,11 @@ public: vasp_xshift(I argc,const t_atom *argv): vasp_shift(argc,argv) {} - virtual Vasp *do_shift(OpParam &p) { return VaspOp::m_xshift(p,ref,arg,&dst); } + virtual Vasp *do_shift(OpParam &p) + { + CVasp cdst(dst); + return VaspOp::m_xshift(p,CVasp(ref),arg,&cdst); + } virtual V m_help() { post("%s - Shifts buffer data symmetrically (in two halves)",thisName()); } }; @@ -225,7 +233,7 @@ BL VecOp::d_mirr(OpParam &p) /*! \brief vasp mirror */ -Vasp *VaspOp::m_mirr(OpParam &p,Vasp &src,Vasp *dst,BL symm) +Vasp *VaspOp::m_mirr(OpParam &p,CVasp &src,CVasp *dst,BL symm) { Vasp *ret = NULL; RVecBlock *vecs = GetRVecs(p.opname,src,dst); diff --git a/externals/grill/vasp/source/ops_rearr.h b/externals/grill/vasp/source/ops_rearr.h index d1c6ce73..aa412937 100644 --- a/externals/grill/vasp/source/ops_rearr.h +++ b/externals/grill/vasp/source/ops_rearr.h @@ -22,12 +22,12 @@ namespace VecOp { } namespace VaspOp { - Vasp *m_shift(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL,BL sh = true,BL symm = false); // shift buffer - inline Vasp *m_xshift(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_shift(p,src,arg,dst,true,true); } // shift buffer (symmetrically) - inline Vasp *m_rot(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_shift(p,src,arg,dst,false,false); } // rotate buffer - inline Vasp *m_xrot(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_shift(p,src,arg,dst,false,true); } // rotate buffer (symmetrically) - Vasp *m_mirr(OpParam &p,Vasp &src,Vasp *dst = NULL,BL symm = false); //! mirror buffer - inline Vasp *m_xmirr(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_mirr(p,src,dst,true); } //! mirror buffer (symmetrically) + Vasp *m_shift(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL,BL sh = true,BL symm = false); // shift buffer + inline Vasp *m_xshift(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_shift(p,src,arg,dst,true,true); } // shift buffer (symmetrically) + inline Vasp *m_rot(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_shift(p,src,arg,dst,false,false); } // rotate buffer + inline Vasp *m_xrot(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_shift(p,src,arg,dst,false,true); } // rotate buffer (symmetrically) + Vasp *m_mirr(OpParam &p,CVasp &src,CVasp *dst = NULL,BL symm = false); //! mirror buffer + inline Vasp *m_xmirr(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_mirr(p,src,dst,true); } //! mirror buffer (symmetrically) } diff --git a/externals/grill/vasp/source/ops_resmp.cpp b/externals/grill/vasp/source/ops_resmp.cpp index cb51dbac..16780df8 100644 --- a/externals/grill/vasp/source/ops_resmp.cpp +++ b/externals/grill/vasp/source/ops_resmp.cpp @@ -176,7 +176,7 @@ BL VecOp::d_tilt(OpParam &p) \param mode interpolation mode \return normalized destination vasp */ -Vasp *VaspOp::m_tilt(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL symm) +Vasp *VaspOp::m_tilt(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL symm) { Vasp *ret = NULL; if(arg.IsList() && arg.GetList().Count() >= 1) { @@ -222,7 +222,11 @@ public: xti_inpl = 0,xti_none,xti_lin,xti_4p }; - virtual Vasp *do_shift(OpParam &p) { return VaspOp::m_tilt(p,ref,arg,&dst); } + virtual Vasp *do_shift(OpParam &p) + { + CVasp cdst(dst); + return VaspOp::m_tilt(p,CVasp(ref),arg,&cdst); + } virtual Vasp *tx_work(const Argument &arg) { @@ -255,7 +259,11 @@ public: vasp_xtilt(I argc,t_atom *argv): vasp_tilt(argc,argv) {} - virtual Vasp *do_shift(OpParam &p) { return VaspOp::m_xtilt(p,ref,arg,&dst); } + virtual Vasp *do_shift(OpParam &p) + { + CVasp cdst(dst); + return VaspOp::m_xtilt(p,CVasp(ref),arg,&cdst); + } virtual V m_help() { post("%s - Resamples buffer data symmetrically (in two halves)",thisName()); } }; diff --git a/externals/grill/vasp/source/ops_resmp.h b/externals/grill/vasp/source/ops_resmp.h index 9c4a8bde..e164ee0b 100644 --- a/externals/grill/vasp/source/ops_resmp.h +++ b/externals/grill/vasp/source/ops_resmp.h @@ -20,9 +20,9 @@ namespace VecOp { } namespace VaspOp { - Vasp *m_tilt(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL,BL symm = false); + Vasp *m_tilt(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL,BL symm = false); // Symmetric resampling (around center sample) - inline Vasp *m_xtilt(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_tilt(p,src,arg,dst,true); } + inline Vasp *m_xtilt(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_tilt(p,src,arg,dst,true); } } #endif diff --git a/externals/grill/vasp/source/ops_search.cpp b/externals/grill/vasp/source/ops_search.cpp index 4202a77c..f514d6f3 100644 --- a/externals/grill/vasp/source/ops_search.cpp +++ b/externals/grill/vasp/source/ops_search.cpp @@ -70,17 +70,17 @@ BL VecOp::d_search(OpParam &p) return true; } -Vasp *VaspOp::m_search(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL st) +Vasp *VaspOp::m_search(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL st) { Vasp *ret = NULL; if(src.Vectors() > 1) post("%s - More than one vector in vasp!",p.opName()); else if(arg.CanbeFloat() || (arg.IsList() && arg.GetList().Count() >= 1)) { - I fr = src.ChkFrames(); + I fr = src.Frames(); I o = src.Vector(0).Offset(); I sz = src.Buffer(0)->Frames(); - Vasp all(src); + CVasp all(src); if(st) { // search start point p.srch.offs = o; @@ -112,7 +112,7 @@ Vasp *VaspOp::m_search(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL st) if(ret) { ret->Offset(o); ret->Frames(fr); - ret->Frames(ret->ChkFrames()); + ret->Frames(ret->ChkFrames()); // What's that???? } delete vecs; @@ -167,7 +167,11 @@ class vasp_soffset: FLEXT_HEADER(vasp_soffset,vasp_search) public: vasp_soffset(I argc,t_atom *argv): vasp_search(argc,argv) {} - virtual Vasp *do_work(OpParam &p) { return VaspOp::m_soffset(p,ref,arg,&dst); } + virtual Vasp *do_work(OpParam &p) + { + CVasp cdst(dst); + return VaspOp::m_soffset(p,CVasp(ref),arg,&cdst); + } }; FLEXT_LIB_V("vasp, vasp.offset= vasp.o=",vasp_soffset) @@ -178,7 +182,11 @@ class vasp_sframes: FLEXT_HEADER(vasp_sframes,vasp_search) public: vasp_sframes(I argc,t_atom *argv): vasp_search(argc,argv) {} - virtual Vasp *do_work(OpParam &p) { return VaspOp::m_sframes(p,ref,arg,&dst); } + virtual Vasp *do_work(OpParam &p) + { + CVasp cdst(dst); + return VaspOp::m_sframes(p,CVasp(ref),arg,&cdst); + } }; FLEXT_LIB_V("vasp, vasp.frames= vasp.f=",vasp_sframes) diff --git a/externals/grill/vasp/source/ops_search.h b/externals/grill/vasp/source/ops_search.h index e7a04e5c..ef199f71 100644 --- a/externals/grill/vasp/source/ops_search.h +++ b/externals/grill/vasp/source/ops_search.h @@ -21,9 +21,9 @@ namespace VecOp { namespace VaspOp { // search functions - Vasp *m_search(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL st); //! find values - inline Vasp *m_soffset(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_search(p,src,arg,dst,true); } - inline Vasp *m_sframes(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_search(p,src,arg,dst,false); } + Vasp *m_search(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL st); //! find values + inline Vasp *m_soffset(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_search(p,src,arg,dst,true); } + inline Vasp *m_sframes(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_search(p,src,arg,dst,false); } } #endif diff --git a/externals/grill/vasp/source/ops_trnsc.cpp b/externals/grill/vasp/source/ops_trnsc.cpp index ac4cea1f..88089fbb 100644 --- a/externals/grill/vasp/source/ops_trnsc.cpp +++ b/externals/grill/vasp/source/ops_trnsc.cpp @@ -33,7 +33,7 @@ template<class T> V f_crpow(T &rv,T &iv,T ra,T ia,T rb,T) BL VecOp::d_rpow(OpParam &p) { d__cbin(f_crpow<S>,p); } -Vasp *VaspOp::m_rpow(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) +Vasp *VaspOp::m_rpow(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { Vasp *ret = NULL; CVecBlock *vecs = GetCVecs(p.opname,src,dst); diff --git a/externals/grill/vasp/source/ops_trnsc.h b/externals/grill/vasp/source/ops_trnsc.h index 81009298..ee919ea9 100644 --- a/externals/grill/vasp/source/ops_trnsc.h +++ b/externals/grill/vasp/source/ops_trnsc.h @@ -29,18 +29,18 @@ namespace VecOp { } namespace VaspOp { - inline Vasp *m_pow(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_pow); } // power + inline Vasp *m_pow(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL) { return m_rbin(p,src,arg,dst,VecOp::d_pow); } // power - Vasp *m_rpow(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst = NULL); // radius power (with each two channels) + Vasp *m_rpow(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst = NULL); // radius power (with each two channels) - inline Vasp *m_sqrt(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_sqrt); } // square root (from abs value) - inline Vasp *m_ssqrt(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_ssqrt); } // square root (from abs value) + inline Vasp *m_sqrt(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_sqrt); } // square root (from abs value) + inline Vasp *m_ssqrt(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_ssqrt); } // square root (from abs value) - inline Vasp *m_exp(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_exp); } // exponential function - inline Vasp *m_log(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_log); } // natural logarithm + inline Vasp *m_exp(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_exp); } // exponential function + inline Vasp *m_log(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_run(p,src,dst,VecOp::d_log); } // natural logarithm -// inline Vasp *m_cexp(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_cexp); } // complex exponential function -// inline Vasp *m_clog(OpParam &p,Vasp &src,Vasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_clog); } // complex logarithm (how about branches?) +// inline Vasp *m_cexp(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_cexp); } // complex exponential function +// inline Vasp *m_clog(OpParam &p,CVasp &src,CVasp *dst = NULL) { return m_cun(p,src,dst,VecOp::d_clog); } // complex logarithm (how about branches?) } diff --git a/externals/grill/vasp/source/ops_wnd.cpp b/externals/grill/vasp/source/ops_wnd.cpp index daee3a9e..278e7bf1 100644 --- a/externals/grill/vasp/source/ops_wnd.cpp +++ b/externals/grill/vasp/source/ops_wnd.cpp @@ -141,7 +141,7 @@ BL VecOp::d_window(OpParam &p) return true; } -Vasp *VaspOp::m_window(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL inv,BL mul,BL symm) +Vasp *VaspOp::m_window(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL inv,BL mul,BL symm) { static const int wndnum = 8; static const char *wndtps[wndnum] = {"lin","sin","hanning","hamming","blackman","connes","welch","lanczos" /*,"gaussian","kaiser"*/}; diff --git a/externals/grill/vasp/source/ops_wnd.h b/externals/grill/vasp/source/ops_wnd.h index 21bafb59..9103d978 100644 --- a/externals/grill/vasp/source/ops_wnd.h +++ b/externals/grill/vasp/source/ops_wnd.h @@ -16,24 +16,26 @@ WARRANTIES, see the file, "license.txt," in this distribution. // Window functions namespace VecOp { +/* BL d_bevel(OpParam &p); BL d_mbevel(OpParam &p); - +*/ BL d_window(OpParam &p); } namespace VaspOp { - Vasp *m_bevelup(OpParam &p,Vasp &src,Vasp *dst,BL up = true,BL mul = false); // bevel up - inline Vasp *m_mbevelup(OpParam &p,Vasp &src,Vasp *dst) { return m_bevelup(p,src,dst,true,true); } // * bevel up (fade in) - inline Vasp *m_beveldn(OpParam &p,Vasp &src,Vasp *dst) { return m_bevelup(p,src,dst,false,false); } // bevel down - inline Vasp *m_mbeveldn(OpParam &p,Vasp &src,Vasp *dst) { return m_bevelup(p,src,dst,false,true); } // * bevel down (fade out) - - Vasp *m_window(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst,BL inv = false,BL mul = false,BL symm = false); // window curve - inline Vasp *m_mwindow(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) { return m_window(p,src,arg,dst,false,true,false); } // * window curve - inline Vasp *m_iwindow(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) { return m_window(p,src,arg,dst,true,false,false); } // inverse window curve - inline Vasp *m_miwindow(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) { return m_window(p,src,arg,dst,true,true,false); } // * inverse window curve - inline Vasp *m_xwindow(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) { return m_window(p,src,arg,dst,false,false,true); } // symmetrical window curve - inline Vasp *m_mxwindow(OpParam &p,Vasp &src,const Argument &arg,Vasp *dst) { return m_window(p,src,arg,dst,false,true,true); } // * symmetrical window curve +/* + Vasp *m_bevelup(OpParam &p,CVasp &src,CVasp *dst,BL up = true,BL mul = false); // bevel up + inline Vasp *m_mbevelup(OpParam &p,CVasp &src,CVasp *dst) { return m_bevelup(p,src,dst,true,true); } // * bevel up (fade in) + inline Vasp *m_beveldn(OpParam &p,CVasp &src,CVasp *dst) { return m_bevelup(p,src,dst,false,false); } // bevel down + inline Vasp *m_mbeveldn(OpParam &p,CVasp &src,CVasp *dst) { return m_bevelup(p,src,dst,false,true); } // * bevel down (fade out) +*/ + Vasp *m_window(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst,BL inv = false,BL mul = false,BL symm = false); // window curve + inline Vasp *m_mwindow(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { return m_window(p,src,arg,dst,false,true,false); } // * window curve + inline Vasp *m_iwindow(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { return m_window(p,src,arg,dst,true,false,false); } // inverse window curve + inline Vasp *m_miwindow(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { return m_window(p,src,arg,dst,true,true,false); } // * inverse window curve + inline Vasp *m_xwindow(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { return m_window(p,src,arg,dst,false,false,true); } // symmetrical window curve + inline Vasp *m_mxwindow(OpParam &p,CVasp &src,const Argument &arg,CVasp *dst) { return m_window(p,src,arg,dst,false,true,true); } // * symmetrical window curve } #endif diff --git a/externals/grill/vasp/source/opvecs.cpp b/externals/grill/vasp/source/opvecs.cpp index 1a226eb3..e29f39bc 100644 --- a/externals/grill/vasp/source/opvecs.cpp +++ b/externals/grill/vasp/source/opvecs.cpp @@ -65,7 +65,7 @@ inline BL corrlen(I &frms,VBuffer &b) \remark working size is maximum common vector size */ -RVecBlock *VaspOp::GetRVecs(const C *op,Vasp &src,Vasp *dst) +RVecBlock *VaspOp::GetRVecs(const C *op,CVasp &src,CVasp *dst) { I nvecs = src.Vectors(); if(dst && dst->Ok() && dst->Vectors() != nvecs) { @@ -116,7 +116,7 @@ RVecBlock *VaspOp::GetRVecs(const C *op,Vasp &src,Vasp *dst) \param full true if imaginary part is compulsory \return struct with vector data */ -CVecBlock *VaspOp::GetCVecs(const C *op,Vasp &src,Vasp *dst,BL full) +CVecBlock *VaspOp::GetCVecs(const C *op,CVasp &src,CVasp *dst,BL full) { I nvecs = src.Vectors(); if(dst && dst->Ok() && dst->Vectors() != nvecs) { @@ -193,7 +193,7 @@ CVecBlock *VaspOp::GetCVecs(const C *op,Vasp &src,Vasp *dst,BL full) \param multi 0 off/1 on/-1 auto... controls whether argument vector is single- or multi-vectored \return struct with vector data */ -RVecBlock *VaspOp::GetRVecs(const C *op,Vasp &src,const Vasp &arg,Vasp *dst,I multi,BL ssize) +RVecBlock *VaspOp::GetRVecs(const C *op,CVasp &src,const CVasp &arg,CVasp *dst,I multi,BL ssize) { if(!arg.Ok()) { post("%s - invalid argument vasp detected and ignored",op); @@ -285,7 +285,7 @@ RVecBlock *VaspOp::GetRVecs(const C *op,Vasp &src,const Vasp &arg,Vasp *dst,I mu \param full true if imaginary part is compulsory \return struct with vector data */ -CVecBlock *VaspOp::GetCVecs(const C *op,Vasp &src,const Vasp &arg,Vasp *dst,I multi,BL ssize,BL full) +CVecBlock *VaspOp::GetCVecs(const C *op,CVasp &src,const CVasp &arg,CVasp *dst,I multi,BL ssize,BL full) { if(!arg.Ok()) { post("%s - invalid argument vasp detected and ignored",op); diff --git a/externals/grill/vasp/source/vasp.cpp b/externals/grill/vasp/source/vasp.cpp index efb3b7a6..66bffccb 100644 --- a/externals/grill/vasp/source/vasp.cpp +++ b/externals/grill/vasp/source/vasp.cpp @@ -54,13 +54,20 @@ Vasp::Vasp(I fr,const Ref &r): refs(0),chns(0),ref(NULL), frames(fr) { - operator +=(r); + AddVector(r); } Vasp::~Vasp() { + Clear(); +} + +Vasp &Vasp::Clear() +{ + refs = frames = chns = 0; if(ref) delete[] ref; + return *this; } @@ -131,7 +138,7 @@ Vasp &Vasp::operator =(const Vasp &v) } -Vasp &Vasp::operator +=(const Ref &r) +Vasp &Vasp::AddVector(const Ref &r) { Resize(chns+1); ref[chns++] = r; @@ -139,23 +146,6 @@ Vasp &Vasp::operator +=(const Ref &r) } -Vasp &Vasp::operator +=(const Vasp &v) -{ - if(v.Ok()) { - if(!Ok()) *this = v; - else { - if(Frames() != v.Frames()) { - post("vasp - Frame count of joined vasps is different - taking the minimum"); - Frames(min(Frames(),v.Frames())); - } - - Resize(Vectors()+v.Vectors()); - for(I i = 0; i < v.Vectors(); ++i) *this += v.Vector(i); - } - } - return *this; -} - // parse argument list Vasp &Vasp::operator ()(I argc,const t_atom *argv) { @@ -291,37 +281,37 @@ V Vasp::Channel(I c) } -V Vasp::Size(I s) +V Vasp::Size(I s,BL keep) { for(I i = 0; i < Vectors(); ++i) { VBuffer *buf = Buffer(i); if(buf) { - buf->Frames(s,true); + buf->Frames(s,keep); delete buf; } } } -V Vasp::SizeD(I sd) +V Vasp::SizeD(I sd,BL keep) { for(I i = 0; i < Vectors(); ++i) { VBuffer *buf = Buffer(i); if(buf) { I s = buf->Frames()+sd; - buf->Frames(s >= 0?s:0,true); + buf->Frames(s >= 0?s:0,keep); delete buf; } } } -V Vasp::SizeM(R f) +V Vasp::SizeM(R f,BL keep) { for(I i = 0; i < Vectors(); ++i) { VBuffer *buf = Buffer(i); if(buf) { I s = (I)(buf->Frames()*f); - buf->Frames(s >= 0?s:0,true); + buf->Frames(s >= 0?s:0,keep); delete buf; } } @@ -359,3 +349,36 @@ I Vasp::ChkFrames() const return frms < 0?0:frms; } + +// ------------------------------------ + +CVasp::CVasp() {} + +CVasp::CVasp(const Vasp &v): + Vasp(v) +{ + if(!Check()) + Clear(); + else + Frames(ChkFrames()); +} + +CVasp &CVasp::operator +=(const CVasp &v) +{ + if(v.Ok()) { + if(!Ok()) *this = v; + else { + I f = Frames(),vf = v.Frames(); + + if(f != vf) { + post("vasp - Frame count of joined vasps is different - taking the minimum"); + Frames(min(f,vf)); + } + + Resize(Vectors()+v.Vectors()); + for(I i = 0; i < v.Vectors(); ++i) AddVector(v.Vector(i)); + } + } + return *this; +} + diff --git a/externals/grill/vasp/source/vasp.h b/externals/grill/vasp/source/vasp.h index 94e1ad73..3f76b5bd 100644 --- a/externals/grill/vasp/source/vasp.h +++ b/externals/grill/vasp/source/vasp.h @@ -60,13 +60,8 @@ public: Vasp &operator =(const Vasp &v); Vasp &operator ()(I argc,const t_atom *argv /*,BL withvasp = false*/); - // add another vector - Vasp &operator +=(const Ref &r); - // add vectors of another vasp - Vasp &operator +=(const Vasp &v); - // set used channels to 0 - Vasp &Clear() { frames = 0; chns = 0; return *this; } + Vasp &Clear(); // used vectors I Vectors() const { return chns; } @@ -83,13 +78,13 @@ public: V FramesR(R f) { if(f) FramesM(1./f); else Frames(0); } // set buffer sizes - V Size(I fr); + V Size(I fr,BL keep = true); // set frame count differentially - V SizeD(I frd); + V SizeD(I frd,BL keep = true); // set frame count - V SizeM(R f); + V SizeM(R f,BL keep = true); // set frame count - V SizeR(R f) { if(f) SizeM(1./f); else Size(0); } + V SizeR(R f,BL keep = true) { if(f) SizeM(1./f,keep); else Size(0,false); } // actual length of the vasp (in frames) I ChkFrames() const; @@ -120,6 +115,9 @@ public: // get buffer associated to a channel VBuffer *Buffer(I ix) const; + // add another vector + Vasp &AddVector(const Ref &r); + // Real/Complex VBuffer *ReBuffer() const { return Buffer(0); } VBuffer *ImBuffer() const { return Buffer(1); } @@ -141,4 +139,20 @@ protected: V Resize(I rcnt); }; +/*! \brief Checked vasp + \remark Only use that for immediate operation! +*/ +class CVasp: + public Vasp +{ +public: + CVasp(); + CVasp(const Vasp &v); + + // add vectors of another vasp + CVasp &operator +=(const CVasp &v); + +}; + + #endif diff --git a/externals/grill/vasp/source/vecblk.cpp b/externals/grill/vasp/source/vecblk.cpp index 8310cc2f..80917237 100644 --- a/externals/grill/vasp/source/vecblk.cpp +++ b/externals/grill/vasp/source/vecblk.cpp @@ -39,7 +39,7 @@ Vasp *VecBlock::_DstVasp(I n) { Vasp *ret = new Vasp; ret->Frames(Frames()); - for(I i = 0; i < n; ++i) *ret += Vasp::Ref(*_Dst(i)); + for(I i = 0; i < n; ++i) ret->AddVector(Vasp::Ref(*_Dst(i))); return ret; } @@ -47,7 +47,7 @@ Vasp *VecBlock::_SrcVasp(I n) { Vasp *ret = new Vasp; ret->Frames(Frames()); - for(I i = 0; i < n; ++i) *ret += Vasp::Ref(*_Src(i)); + for(I i = 0; i < n; ++i) ret->AddVector(Vasp::Ref(*_Src(i))); return ret; } |