示例#1
0
//template <class F> inline istream& operator>>(istream& is, OffTns<F>& tns);
//template <class F> inline ostrema& operator<<(ostream& os, const OffTns<F>& tns);
template <class F> inline void setvalue(OffTns<F>& T, F val)
{
  for(int i=T.s(); i<T.m()+T.s(); i++)
	 for(int j=T.t(); j<T.n()+T.t(); j++)
		for(int k=T.u(); k<T.p()+T.u(); k++)
		  T(i,j,k) = val;
}
示例#2
0
template <class T> inline void cpp2mex(const OffTns<T>& cd, mxArray*& md)
{
  int m = cd.m();  int n = cd.n();  int p = cd.p();
  int s = -m/2;  int t = -n/2;  int u = -p/2;
  int dims[3];  dims[0] = m;  dims[1] = n;  dims[2] = p;
  md = mxCreateCellArray(3,dims);
  int cnt = 0;
  for(int k=u; k<u+p; k++)
	 for(int j=t; j<t+n; j++)
		for(int i=s; i<s+m; i++) {
		  mxArray* ss;		cpp2mex(cd(i,j,k), ss);		mxSetCell(md, cnt, ss);
		  cnt++;
		}
  return;
}
示例#3
0
//----------------------offtns<...>
template <class T> inline void mex2cpp(const mxArray*& md, OffTns<T>& cd)
{
  const int* dims = mxGetDimensions(md);
  int m = dims[0];  int n = dims[1];  int p = dims[2];
  int s = -m/2;  int t = -n/2;  int u = -p/2;
  cd.resize(m,n,p,s,t,u);
  int cnt = 0;
  for(int k=u; k<u+p; k++)
	 for(int j=t; j<t+n; j++)
		for(int i=s; i<s+m; i++) {
		  const mxArray* tt = mxGetCell(md, cnt);		  mex2cpp(tt, cd(i,j,k));
		  cnt++;
		}
  return;
}
示例#4
0
template <class F> inline void clear(OffTns<F>& T)
{
  memset(T.data(), 0, T.m()*T.n()*T.p()*sizeof(F));
}