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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? tnt_array3d.h

?? fast marching method
?? H
字號(hào):
/*
*
* 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 */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产午夜久久久久| 欧美zozo另类异族| 色噜噜狠狠一区二区三区果冻| 国产成人亚洲精品青草天美 | 色呦呦国产精品| 在线观看亚洲精品| 欧美成人性战久久| 中国av一区二区三区| 亚洲色图在线播放| 天使萌一区二区三区免费观看| 日本亚洲一区二区| 国产精品自拍毛片| 色欧美日韩亚洲| 国产日产欧美一区二区三区| 日韩黄色在线观看| 国产精品白丝jk黑袜喷水| 成a人片国产精品| 91精品国产综合久久福利软件| 国产色婷婷亚洲99精品小说| 亚洲人成在线观看一区二区| 久久国产日韩欧美精品| 91美女片黄在线观看| 久久伊99综合婷婷久久伊| 亚洲综合久久久久| av成人老司机| 久久九九国产精品| 日本成人在线不卡视频| 欧美体内she精高潮| 欧美一级免费大片| 国产精品久久看| 国产大陆a不卡| 精品国产一二三| 日本不卡中文字幕| 91 com成人网| 亚洲成人av资源| 欧美区视频在线观看| 一区二区在线看| 色香蕉久久蜜桃| 亚洲综合久久av| 欧美视频一区二| 日韩电影在线观看网站| 欧美影院一区二区三区| 亚洲午夜激情av| 精品视频在线免费看| 天使萌一区二区三区免费观看| 欧美三级视频在线观看 | 一区二区三区自拍| 91麻豆精东视频| 最新高清无码专区| 91在线你懂得| 一区二区三区精品在线观看| 欧美日韩国产片| 欧美aⅴ一区二区三区视频| 日韩精品一区二区三区三区免费| 精品无人码麻豆乱码1区2区 | 亚洲精品国产无天堂网2021| 欧美亚洲另类激情小说| 青青草一区二区三区| 2021中文字幕一区亚洲| 99久久综合精品| 欧美人牲a欧美精品| 丝袜亚洲另类欧美| 亚洲精品在线网站| av不卡一区二区三区| 亚洲成a人片综合在线| 精品成人免费观看| 91丨porny丨在线| 久久99热99| 亚洲激情综合网| 精品日韩欧美在线| 99国产一区二区三精品乱码| 老司机午夜精品| 一区二区三区精品视频| 国产日产欧美精品一区二区三区| 欧美在线观看视频在线| 成人福利视频在线看| 日韩精品五月天| 免费人成在线不卡| 欧美精品乱码久久久久久| 成人精品视频一区二区三区| 丝袜美腿亚洲一区| 亚洲欧美自拍偷拍色图| 久久影院午夜片一区| 91精品啪在线观看国产60岁| 色94色欧美sute亚洲线路二 | 国产精品第四页| 日韩一区二区在线观看视频| 欧美日韩国产a| 欧美亚洲综合网| 色爱区综合激月婷婷| 91年精品国产| 色天天综合色天天久久| 91丨九色丨尤物| 色综合久久久久久久久久久| 一区二区三区在线视频观看58| 国产欧美日韩不卡免费| 久久婷婷国产综合国色天香| 精品电影一区二区| 2020国产精品自拍| 欧美精品一区二区三区视频 | 久久久99久久| 中文字幕国产一区| 亚洲精品免费电影| 亚洲国产精品久久久久秋霞影院 | av不卡一区二区三区| 91丨九色丨蝌蚪富婆spa| 色综合久久综合中文综合网| 色哟哟国产精品| 5858s免费视频成人| 精品国产网站在线观看| 国产精品色噜噜| 亚洲国产精品久久艾草纯爱| 日韩va亚洲va欧美va久久| 激情亚洲综合在线| 91在线观看免费视频| 欧美精品三级在线观看| 久久美女高清视频| 一区二区三区在线观看视频| 日韩国产欧美一区二区三区| 狠狠v欧美v日韩v亚洲ⅴ| 成人中文字幕合集| 欧美另类一区二区三区| 国产日产欧美一区二区三区| 亚洲777理论| 成人黄色在线网站| 欧美一级高清大全免费观看| 国产精品视频一二三| 亚洲成人av电影| 成人aa视频在线观看| 欧美一区二区在线观看| 亚洲人成亚洲人成在线观看图片| 奇米影视在线99精品| 欧美性大战久久| 亚洲视频免费在线| 国产麻豆一精品一av一免费 | 精品乱人伦小说| 亚洲国产欧美日韩另类综合| 99re这里只有精品首页| 国产亚洲一区二区三区在线观看| 日韩精品电影在线观看| 欧美午夜精品电影| 亚洲欧洲精品天堂一级| 国产精品羞羞答答xxdd| 久久九九影视网| 国产一区在线看| 亚洲精品一区二区三区精华液| 日韩中文字幕麻豆| 欧美一区二区在线视频| 日韩精品一二三四| 91精品国产综合久久香蕉的特点| 一区二区三区**美女毛片| 91网站在线播放| 亚洲精品成人在线| 91国产精品成人| 亚洲国产精品视频| 91麻豆精品国产综合久久久久久| 国产香蕉久久精品综合网| 成年人午夜久久久| 中文字幕日韩一区| 91免费国产在线观看| 一区二区三区欧美激情| 欧美日韩一二区| 日本在线不卡一区| 欧美mv和日韩mv国产网站| 国产乱码精品一区二区三区五月婷| 精品久久一二三区| 成人免费不卡视频| 一区二区三区资源| 精品剧情在线观看| 成人福利在线看| 视频在线观看一区| 亚洲国产精品精华液ab| 色噜噜狠狠成人网p站| 日av在线不卡| 亚洲日本一区二区| 日韩精品中午字幕| 91视频xxxx| 国产一区二区调教| 亚洲综合男人的天堂| 久久久久久久精| 欧美日韩精品一区视频| 国产乱码精品一区二区三区五月婷| 亚洲人妖av一区二区| 欧美tickle裸体挠脚心vk| 欧亚一区二区三区| 国产一区久久久| 捆绑调教美女网站视频一区| 亚洲精品中文在线观看| 精品久久久久久久久久久院品网| 波多野结衣一区二区三区 | 国产乱码精品一区二区三| 亚洲在线一区二区三区| 欧美国产禁国产网站cc| 精品国产乱码久久| 欧美午夜影院一区| 色综合中文综合网| 国产大片一区二区| 亚洲一区二区三区精品在线| 日本一区二区三区国色天香| 91精品国产一区二区三区香蕉|