亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tnt_array3d.h

?? 在MATLAB環境下的level set方法的實現
?? H
字號:
/*
*
* Template Numerical Toolkit (TNT): Three-dimensional numerical array
*
* Mathematical and Computational Sciences Division
* National Institute of Technology,
* Gaithersburg, MD USA
*
*
* This software was developed at the National Institute of Standards and
* Technology (NIST) by employees of the Federal Government in the course
* of their official duties. Pursuant to title 17 Section 105 of the
* United States Code, this software is not subject to copyright protection
* and is in the public domain. NIST assumes no responsibility whatsoever for
* its use by other parties, and makes no guarantees, expressed or implied,
* about its quality, reliability, or any other characteristic.
*
*/



#ifndef TNT_ARRAY3D_H
#define TNT_ARRAY3D_H

#include <cstdlib>
#include <iostream>
#ifdef TNT_BOUNDS_CHECK
#include <assert.h>
#endif

namespace TNT
{

/**
	Tempplated three-dimensional, numerical array which
	looks like a conventional C multiarray. 
	Storage corresponds to conventional C ordering.
	That is the right-most dimension has contiguous
	elements.  Indexing is via the A[i][j][k] notation. 
	
	<p>
	Array assignment is by reference (i.e. shallow assignment).
	That is, B=A implies that the A and B point to the
	same array, so modifications to the elements of A
	will be reflected in B. If an independent copy
	is required, then B = A.copy() can be used.  Note
	that this facilitates returning arrays from functions
	without relying on compiler optimizations to eliminate
	extensive data copying.

	<p>
	The indexing and layout of this array object makes
	it compatible with C and C++ algorithms that utilize
	the familiar C[i][j][k] notation.  This includes numerous
	textbooks, such as Numercial Recipes, and various
	public domain codes.

	<p>
	This class employs its own garbage collection via
	the use of reference counts.  That is, whenever
	an internal array storage no longer has any references
	to it, it is destoryed.
*/
template <class T>
class Array3D 
{


  private:
    T*** v_;                  
	int m_;
    int n_;
	int k_;
    int *ref_count_;

	void initialize_(T* data, int m, int n, int k);
    void copy_(T* p, const T*  q, int len) const;
    void set_(const T& val);
    void destroy_();
	inline const T* begin_() const;
	inline T* begin_();

  public:

    typedef         T   value_type;

	       Array3D();
	       Array3D(int m, int n, int k);
	       Array3D(int m, int n, int k,  T *a);
	       Array3D(int m, int n, int k, const T &a);
    inline Array3D(const Array3D &A);
	inline Array3D & operator=(const T &a);
	inline Array3D & operator=(const Array3D &A);
	inline Array3D & ref(const Array3D &A);
	       Array3D copy() const;
		   Array3D & inject(const Array3D & A);
	inline T** operator[](int i);
	inline const T* const * operator[](int i) const;
	inline int dim1() const;
	inline int dim2() const;
	inline int dim3() const;
	inline int ref_count() const;
               ~Array3D();


};


/**
	Copy constructor. Array data is NOT copied, but shared.
	Thus, in Array3D B(A), subsequent changes to A will
	be reflected in B.  For an indepent copy of A, use
	Array3D B(A.copy()), or B = A.copy(), instead.
*/
template <class T>
Array3D<T>::Array3D(const Array3D<T> &A) : v_(A.v_), m_(A.m_), 
	n_(A.n_), k_(A.k_), ref_count_(A.ref_count_)
{
	(*ref_count_)++;
}



/**
	Create a new (m x n x k) array, WIHOUT initializing array elements.
	To create an initialized array of constants, see Array3D(m,n,k, value).

	<p>
	This version avoids the O(m*n*k) initialization overhead and
	is used just before manual assignment.

	@param m the first dimension of the new matrix.
	@param n the second dimension of the new matrix.
	@param k the third dimension of the new matrix.
*/
template <class T>
Array3D<T>::Array3D(int m, int n, int k) : v_(0), m_(m), n_(n), k_(k), ref_count_(0)
{
	initialize_(new T[m*n*k], m,n,k);
	ref_count_ = new int;
	*ref_count_ = 1;
}



/**
	Create a new (m x n x k) array,  initializing array elements to
	constant specified by argument.  Most often used to
	create an array of zeros, as in A(m, n, k, 0.0).

	@param m the first dimension of the new matrix.
	@param n the second dimension of the new matrix.
	@param k the third dimension of the new matrix.
	@param val the constant value to set all elements of the new array to.
*/
template <class T>
Array3D<T>::Array3D(int m, int n, int k, const T &val) : v_(0), m_(m), n_(n) ,
	k_(k), ref_count_(0)
{
	initialize_(new T[m*n*k], m,n,k);
	set_(val);
	ref_count_ = new int;
	*ref_count_ = 1;

}

/**

	Create a new (m x n x k) array,  as a view of an existing one-dimensional
	array stored in <b>C order</b>, i.e. right-most dimension varying fastest.  
	(Often referred to as "row-major" ordering.)
	Note that the storage for this pre-existing array will
	never be garbage collected by the Array3D class.

	@param m the first dimension of the new matrix.
	@param n the second dimension of the new matrix.
	@param k the third dimension of the new matrix.
	@param a the one dimensional C array to use as data storage for
		the array. 
*/
template <class T>
Array3D<T>::Array3D(int m, int n, int k, T *a) : v_(0), m_(m), n_(n) ,
	k_(k), ref_count_(0)
{
	initialize_(a, m, n, k);
	ref_count_ = new int;
	*ref_count_ = 2;		/* this avoids destorying original data. */

}


/**
	Used for A[i][j][k] indexing.  The first [] operator returns
	a conventional pointer which can be dereferenced using the
	same [] notation.  
	
	If TNT_BOUNDS_CHECK macro is define, the left-most index 
	is checked that it falls within the array bounds (via the
	assert() macro.) 
*/
template <class T>
inline T** Array3D<T>::operator[](int i) 
{ 
#ifdef TNT_BOUNDS_CHECK
	assert(i >= 0);
	assert(i < m_);
#endif

return v_[i]; 

}

template <class T>
inline const T* const * Array3D<T>::operator[](int i) const { return v_[i]; }

/**
	Assign all elemnts of A to a constant scalar.
*/
template <class T>
Array3D<T> & Array3D<T>::operator=(const T &a)
{
	set_(a);
	return *this;
}
/**
	Create a new of existing matrix.  Used in B = A.copy()
	or in the construction of B, e.g. Array3D B(A.copy()), 
	to create a new array that does not share data.

*/
template <class T>
Array3D<T> Array3D<T>::copy() const
{
	Array3D A(m_, n_, k_);
	copy_(A.begin_(), begin_(), m_*n_*k_);

	return A;
}


/**
	Copy the elements to from one array to another, in place.
	That is B.inject(A), both A and B must conform (i.e. have
	identical dimensions).

	This differs from B = A.copy() in that references to B
	before this assignment are also affected.  That is, if
	we have 
	<pre>
	Array3D A(m,n,k);
	Array3D C(m,n,k);
	Array3D B(C);        // elements of B and C are shared. 

</pre>
	then B.inject(A) affects both and C, while B=A.copy() creates
	a new array B which shares no data with C or A.

	@param A the array from elements will be copied
	@return an instance of the modifed array. That is, in B.inject(A),
	it returns B.  If A and B are not conformat, no modifications to 
	B are made.

*/
template <class T>
Array3D<T> & Array3D<T>::inject(const Array3D &A)
{
	if (A.m_ == m_ &&  A.n_ == n_)
		copy_(begin_(), A.begin_(), m_*n_);

	return *this;
}





/**
	Create a reference (shallow assignment) to another existing array.
	In B.ref(A), B and A shared the same data and subsequent changes
	to the array elements of one will be reflected in the other.
	<p>
	This is what operator= calls, and B=A and B.ref(A) are equivalent
	operations.

	@return The new referenced array: in B.ref(A), it returns B.
*/
template <class T>
Array3D<T> & Array3D<T>::ref(const Array3D<T> &A)
{
	if (this != &A)
	{
		(*ref_count_) --;
		if ( *ref_count_ < 1 )
		{
			destroy_();
		}

		m_ = A.m_;
		n_ = A.n_;
		k_ = A.k_;
		v_ = A.v_;
		ref_count_ = A.ref_count_;

		(*ref_count_) ++ ;
		
	}
	return *this;
}

/**
	B = A is shorthand notation for B.ref(A).
*/
template <class T>
Array3D<T> & Array3D<T>::operator=(const Array3D<T> &A)
{
	return ref(A);
}

/**
	@return the size of the first dimension of the array.
*/
template <class T>
inline int Array3D<T>::dim1() const { return m_; }

/**
	@return the size of the second dimension of the array.
*/
template <class T>
inline int Array3D<T>::dim2() const { return n_; }

/**
	@return the size of the third (right-most) dimension of the array.
*/
template <class T>
inline int Array3D<T>::dim3() const { return k_; }


/**
	@return the number of arrays that share the same storage area
	as this one.  (Must be at least one.)
*/
template <class T>
inline int Array3D<T>::ref_count() const
{
	return *ref_count_;
}

template <class T>
Array3D<T>::~Array3D()
{
	(*ref_count_) --;

	if (*ref_count_ < 1)
		destroy_();
}

/* private internal functions */

template <class T>
void Array3D<T>::initialize_( T* data, int m, int n, int k)
{

	v_ = new T**[m];
	v_[0] = new T*[m*n];
	v_[0][0] = data;


	for (int i=0; i<m; i++)
	{
		v_[i] = v_[0] + i * n;
		for (int j=0; j<n; j++)
			v_[i][j] = v_[0][0] + i * (n*k) + j * k;
	}

	m_ = m;
	n_ = n;
	k_ = k;
}

template <class T>
void Array3D<T>::set_(const T& a)
{
	T *begin = &(v_[0][0][0]);
	T *end = begin+ m_*n_*k_;

	for (T* p=begin; p<end; p++)
		*p = a;

}

template <class T>
void Array3D<T>::copy_(T* p, const T* q, int len) const
{
	T *end = p + len;
	while (p<end )
		*p++ = *q++;

}

template <class T>
void Array3D<T>::destroy_()
{

	if (v_ != 0)
	{
		delete[] (v_[0][0]);
		delete[] (v_[0]);
		delete[] (v_);
	}

	if (ref_count_ != 0)
		delete ref_count_;
}

/**
	@returns location of first element, i.e. A[0][0][0] (mutable).
*/
template <class T>
const T* Array3D<T>::begin_() const { return &(v_[0][0][0]); }

/**
	@returns location of first element, i.e. A[0][0][0] (mutable).
*/
template <class T>
T* Array3D<T>::begin_() { return &(v_[0][0][0]); }

/**
	Create a null (0x0x0) array.  
*/
template <class T>
Array3D<T>::Array3D() : v_(0), m_(0), n_(0) 
{
	ref_count_ = new int;
	*ref_count_ = 1;
}

} /* namespace TNT */

#endif
/* TNT_ARRAY3D_H */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲午夜电影在线观看| 视频一区视频二区中文| 国产夫妻精品视频| 国产无一区二区| 高清免费成人av| 国产精品久久久久久久蜜臀| 99久久久久久| 一区二区理论电影在线观看| 在线欧美日韩国产| 天堂久久久久va久久久久| 日韩一区二区三区高清免费看看| 久久精品72免费观看| 久久亚洲综合色一区二区三区| 国产精品影视天天线| 亚洲欧洲av在线| 欧美人伦禁忌dvd放荡欲情| 蜜臀久久久久久久| 久久精品视频免费| 色88888久久久久久影院按摩| 肉色丝袜一区二区| 久久精品无码一区二区三区| 色诱视频网站一区| 蜜臂av日日欢夜夜爽一区| 国产精品三级av| 欧美日韩国产成人在线免费| 国产一本一道久久香蕉| 一区二区在线观看视频 | 国产成人av一区二区三区在线| 中文字幕一区二区三区视频| 69堂精品视频| 99国产精品久久久| 美女视频一区二区| 一区二区在线观看免费视频播放| 欧美一级理论片| 色综合色综合色综合色综合色综合| 青青草97国产精品免费观看无弹窗版| 欧美韩国日本不卡| 欧美日韩精品一区二区三区蜜桃| 国产成人综合视频| 图片区日韩欧美亚洲| 国产精品久久久久久久久动漫 | 制服丝袜成人动漫| 国产不卡在线一区| 亚洲国产日韩精品| 国产精品家庭影院| 精品国产亚洲一区二区三区在线观看| 99久久久国产精品| 国内国产精品久久| 天堂久久一区二区三区| 亚洲欧洲中文日韩久久av乱码| 精品卡一卡二卡三卡四在线| 欧美中文字幕一二三区视频| 国产iv一区二区三区| 蜜桃一区二区三区四区| 一区二区三区四区在线播放| 国产女主播一区| 日韩免费在线观看| 欧美高清视频在线高清观看mv色露露十八 | 亚洲成av人片在线| 中国av一区二区三区| 久久综合五月天婷婷伊人| 欧美日韩免费在线视频| 色综合久久综合网| 成人性生交大片免费看在线播放 | 国产嫩草影院久久久久| 欧美岛国在线观看| 日韩亚洲国产中文字幕欧美| 欧美日韩美女一区二区| 色婷婷av一区二区三区软件| 不卡免费追剧大全电视剧网站| 国产很黄免费观看久久| 国产精品一线二线三线精华| 精品亚洲欧美一区| 国产综合久久久久影院| 韩国女主播成人在线观看| 麻豆精品一二三| 蜜臀精品一区二区三区在线观看 | 丰满少妇久久久久久久| 国产91在线|亚洲| 国产精品香蕉一区二区三区| 国产99久久久国产精品潘金| 国产成人精品影视| av动漫一区二区| 91国偷自产一区二区开放时间| 久久午夜羞羞影院免费观看| 精品美女被调教视频大全网站| 精品国产一区二区三区不卡| 久久久久久久久久久久电影 | 欧美酷刑日本凌虐凌虐| 欧美二区乱c少妇| 欧美一区二区三区四区五区| 日韩一区二区精品葵司在线| 日韩欧美国产一区二区在线播放| 精品久久久影院| 中文字幕精品在线不卡| 最新日韩在线视频| 亚洲乱码国产乱码精品精可以看| 性久久久久久久久久久久| 日韩精品欧美精品| 国产精品影视网| 色婷婷久久久久swag精品| 欧美日韩亚洲另类| 2020国产精品| 亚洲婷婷综合久久一本伊一区| 亚洲五码中文字幕| 麻豆91精品91久久久的内涵| 成人听书哪个软件好| 日本韩国一区二区三区视频| 欧美顶级少妇做爰| 中文字幕第一区综合| 一区二区国产视频| 精品一区二区免费在线观看| 成人av午夜电影| 欧美日韩国产精选| 亚洲国产成人一区二区三区| 亚洲国产综合91精品麻豆| 精品无人区卡一卡二卡三乱码免费卡 | 亚洲一区二区黄色| 黑人巨大精品欧美一区| 91老师片黄在线观看| 91精品国产91综合久久蜜臀| 国产欧美精品国产国产专区| 亚洲18女电影在线观看| 国产精品夜夜嗨| 欧美日韩视频专区在线播放| 久久久另类综合| 亚洲成在人线免费| 国产99久久精品| 欧美肥妇free| 亚洲激情图片小说视频| 狠狠色狠狠色综合系列| 欧美天堂亚洲电影院在线播放| 国产午夜精品一区二区 | 日韩欧美黄色影院| 亚洲精品乱码久久久久久日本蜜臀| 狠狠色狠狠色综合| 欧美精品乱码久久久久久| 一色屋精品亚洲香蕉网站| 麻豆国产欧美日韩综合精品二区 | 精品视频免费看| 国产精品久久久久婷婷二区次| 日韩精品一区第一页| 91黄色免费看| 国产精品网友自拍| 国产综合色产在线精品 | 久久综合九色综合97婷婷| 国产福利一区二区三区| 欧美蜜桃一区二区三区| 自拍偷拍亚洲欧美日韩| 国产成人激情av| 精品国产精品一区二区夜夜嗨| 午夜婷婷国产麻豆精品| 欧美中文字幕亚洲一区二区va在线| 国产精品美日韩| 国产精品456| 久久精品一区四区| 麻豆成人综合网| 6080yy午夜一二三区久久| 一区二区三区四区精品在线视频 | 亚洲一卡二卡三卡四卡五卡| 91亚洲精华国产精华精华液| 国产欧美1区2区3区| 国产成人综合在线| 久久色中文字幕| 国产一级精品在线| 久久精子c满五个校花| 国产黄色精品网站| 欧美激情一区在线| 成人性生交大片免费看在线播放 | 欧美成人女星排名| 久久se精品一区精品二区| 91麻豆精品91久久久久同性| 石原莉奈一区二区三区在线观看| 欧美日韩一区久久| 日韩精品欧美精品| 日韩欧美国产三级电影视频| 激情综合色播激情啊| 久久女同精品一区二区| 国产精品亚洲人在线观看| 国产日韩欧美麻豆| av不卡免费电影| 亚洲最新视频在线播放| 884aa四虎影成人精品一区| 蜜桃视频一区二区三区| 精品国产91久久久久久久妲己| 国产夫妻精品视频| 亚洲欧美怡红院| 欧美日韩黄视频| 精品一区二区三区免费毛片爱 | 91无套直看片红桃| 亚洲色图视频网| 欧美无人高清视频在线观看| 日韩成人伦理电影在线观看| 精品日韩一区二区| 国产.欧美.日韩| 亚洲综合男人的天堂| 欧美va在线播放| av不卡免费在线观看| 亚洲aⅴ怡春院| 久久久精品影视|