aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/vasp/source/oppermute.h
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2009-04-01 21:13:09 +0000
committerThomas Grill <xovo@users.sourceforge.net>2009-04-01 21:13:09 +0000
commit0ed7a8b68dd73e2b0473b8127aeca99f3bac9061 (patch)
tree5c67818b38a5cc2f9caa5ca7f8640ca356adf02b /externals/grill/vasp/source/oppermute.h
parentbb4c7f6a245394d09dac9adfb2efb093d3d98452 (diff)
cleaned up grill externals - replaced with svn:externals to svn.grrrr.org/ext/trunk/
svn path=/trunk/; revision=10951
Diffstat (limited to 'externals/grill/vasp/source/oppermute.h')
-rw-r--r--externals/grill/vasp/source/oppermute.h121
1 files changed, 0 insertions, 121 deletions
diff --git a/externals/grill/vasp/source/oppermute.h b/externals/grill/vasp/source/oppermute.h
deleted file mode 100644
index 45221a1f..00000000
--- a/externals/grill/vasp/source/oppermute.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-
-VASP modular - vector assembling signal processor / objects for Max/MSP and PD
-
-Copyright (c) 2002 Thomas Grill (xovo@gmx.net)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-
-*/
-
-#ifndef __VASP_OPPERMUTE_H
-#define __VASP_OPPERMUTE_H
-
-#include "opparam.h"
-#include "oploop.h"
-
-#define PERMTMPL
-#define MAXPERMDIM 2
-
-template<class T>
-inline void permswap(T &a,T &b) { register T t = a; a = b; b = t; }
-
-#ifdef PERMTMPL
-template<class T,int origination(int pos, int sz,OpParam &p)>
-void permutation1(OpParam &p)
-#else
-template<class T>
-void permutation1(OpParam &p,int (*origination)(int pos, int sz,OpParam &p))
-#endif
-{
- T *ddt = p.rddt;
- const I ds = p.rds;
- const I sz = p.frames;
-
- if(ddt != p.rsdt) {
- // not in place
- const T *sdt = p.rsdt;
- const I ss = p.rss;
- I i;
- _DE_LOOP(i,sz, ( ddt[origination(i,sz,p)*ds] = sdt[i*ss] ) )
- }
- else {
- // in place
- // \todo try to come from both sides!
- I i;
- _D_LOOP(i,sz-1)
- int cur = i;
- do { cur = origination(cur,sz,p); } while(cur < i);
- if(cur > i) {
- // swap
- permswap(ddt[cur*ds],ddt[i*ds]);
- }
- _E_LOOP
- }
-}
-
-#ifdef PERMTMPL
-template<class T,int origination(int pos, int sz,OpParam &p)>
-void permutation2(OpParam &p)
-#else
-template<class T>
-void permutation2(OpParam &p,int (*origination)(int pos, int sz,OpParam &p))
-#endif
-{
- T *rddt = p.rddt,*iddt = p.iddt;
- const I rds = p.rds,ids = p.ids;
- const I sz = p.frames;
- bool rinpl = rddt == p.rsdt,iinpl = iddt == p.isdt;
-
- if(rinpl == iinpl) {
- // re and im both in place
- I i;
- _D_LOOP(i,sz-1)
- int cur = i;
- do { cur = origination(cur,sz,p); } while(cur < i);
- if(cur > i) {
- // swap
- permswap(rddt[cur*rds],rddt[i*rds]);
- permswap(iddt[cur*ids],iddt[i*ids]);
- }
- _E_LOOP
- }
- else {
- if(!rinpl) {
- const T *sdt = p.rsdt;
- const I ss = p.rss;
- I i;
- if(ss == 1 && rds == 1)
- _DE_LOOP(i,sz, ( *(rddt++) = *(sdt++) ) )
- else
- _DE_LOOP(i,sz, ( *rddt = *sdt,rddt += rds,sdt += ss ) )
- rddt = p.rddt;
- }
- else permutation1<T>(p,origination);
-
- if(!iinpl) {
- const T *sdt = p.isdt;
- const I ss = p.iss;
- I i;
- if(ss == 1 && ids == 1)
- _DE_LOOP(i,sz, ( *(iddt++) = *(sdt++) ) )
- else
- _DE_LOOP(i,sz, ( *iddt = *sdt,iddt += ids,sdt += ss ) )
- iddt = p.iddt;
- }
- else {
- permswap(p.rddt,p.iddt); permswap(p.rds,p.ids);
- permutation1<T>(p,origination);
- permswap(p.rddt,p.iddt); permswap(p.rds,p.ids);
- }
- }
-}
-
-#ifdef PERMTMPL
-#define PERMUTATION(tp,dim,p,func) permutation ## dim <tp,func>(p)
-#else
-#define PERMUTATION(tp,dim,p,func) permutation ## dim <tp>(p,func)
-#endif
-
-#endif
-