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

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

?? tnt_array1d.h.svn-base

?? fast marching method
?? SVN-BASE
字號:
/*
*
* Template Numerical Toolkit (TNT)
*
* 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_ARRAY1D_H
#define TNT_ARRAY1D_H

#include <cstdlib>
#include <iostream>

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

namespace TNT
{

/**
	Tempplated one-dimensional, numerical array which
	looks like a conventional C array. 
	Elements are accessed via the familiar A[i] 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] 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 Array1D 
{


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

	void initialize_(int n);
    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;

	         Array1D();
	explicit Array1D(int n);
	         Array1D(int n,  T *a);
	         Array1D(int n, const T &a);
    inline   Array1D(const Array1D &A);
	inline   Array1D & operator=(const T &a);
	inline   Array1D & operator=(const Array1D &A);
	inline   Array1D & ref(const Array1D &A);
	         Array1D copy() const;
		     Array1D & inject(const Array1D & A);
	inline   T& operator[](int i);
	inline   const T& operator[](int i) const;
	inline 	 int dim1() const;
	inline   int dim() const;
	inline   int ref_count() const;
               ~Array1D();


};

/**
	Null constructor.  Creates a 0-length (NULL) array.
	(Reference count is also zero.)
*/

template <class T>
Array1D<T>::Array1D() : v_(0), n_(0), ref_count_(0) 
{
	ref_count_ = new int;
	*ref_count_ = 1;
}

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



/**
	Create a new array (vector) of length <b>n</b>,  
	WIHOUT initializing array elements.
	To create an initialized array of constants, see Array1D(n,value).

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

	@param n the dimension (length) of the new matrix.
*/
template <class T>
Array1D<T>::Array1D(int n) : v_(0), n_(n), ref_count_(0)
{
	initialize_(n);
	ref_count_ = new int;
	*ref_count_ = 1;
}



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

	@param n the dimension (length) of the new matrix.  
	@param val the constant value to set all elements of the new array to.
*/
template <class T>
Array1D<T>::Array1D(int n, const T &val) : v_(0), n_(n) ,
	ref_count_(0)
{
	initialize_(n);
	set_(val);
	ref_count_ = new int;
	*ref_count_ = 1;

}

/**
	Create a new n-length array,  as a view of an existing one-dimensional
	C array.  (Note that the storage for this pre-existing array will
	never be destroyed by the Aray1DRef class.)

	@param n the dimension (length) of the new matrix.
	@param a the one dimensional C array to use as data storage for
		the array. 
*/
template <class T>
Array1D<T>::Array1D(int n, T *a) : v_(a), n_(n) ,
	ref_count_(0)
{
	ref_count_ = new int;
	*ref_count_ = 2;		/* this avoid destorying original data. */

}

/**
	A[i] indexes the ith element of A.  The first element is
	A[0]. If TNT_BOUNDS_CHECK is defined, then the index is
	checked that it falls within the array bounds.
*/
template <class T>
inline T& Array1D<T>::operator[](int i) 
{ 
#ifdef TNT_BOUNDS_CHECK
	assert(i>= 0);
	assert(i < n_);
#endif
	return v_[i]; 
}

/**
	A[i] indexes the ith element of A.  The first element is
	A[0]. If TNT_BOUNDS_CHECK is defined, then the index is
	checked that it fall within the array bounds.
*/
template <class T>
inline const T& Array1D<T>::operator[](int i) const 
{ 
#ifdef TNT_BOUNDS_CHECK
	assert(i>= 0);
	assert(i < n_);
#endif
	return v_[i]; 
}

/**
	Assign all elemnts of A to a constant scalar.
*/
template <class T>
Array1D<T> & Array1D<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. Array1D B(A.copy()), 
	to create a new array that does not share data.

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

	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 row and column dimensions).

	This differs from B = A.copy() in that references to B
	before this assignment are also affected.  That is, if
	we have 
	<pre>
	Array1D A(n);
	Array1D C(n);
	Array1D 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 which 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>
Array1D<T> & Array1D<T>::inject(const Array1D &A)
{
	if (A.n_ == n_)
		copy_(begin_(), A.begin_(), 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>
Array1D<T> & Array1D<T>::ref(const Array1D<T> &A)
{
	if (this != &A)
	{
		(*ref_count_) --;
		if ( *ref_count_ < 1)
		{
			destroy_();
		}

		n_ = A.n_;
		v_ = A.v_;
		ref_count_ = A.ref_count_;

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

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

/**
	@return the dimension (number of elements) of the array.
	This is equivalent to dim() and dim1().
*/
template <class T>
inline int Array1D<T>::dim1() const { return n_; }

/**
	@return the dimension (number of elements) of the array.
	This is equivalent to dim1() and dim1().
*/
template <class T>
inline int Array1D<T>::dim() const { return n_; }



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

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

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

/* private internal functions */

template <class T>
void Array1D<T>::initialize_(int n)
{


	v_ = new T[n];
	n_ = n;
}

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

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

}

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

}

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

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

	if (ref_count_ != 0)
		delete ref_count_;
}

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

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




} /* namespace TNT */

#endif
/* TNT_ARRAY1D_H */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美国产日韩在线观看| 国产欧美中文在线| 日韩一区日韩二区| 免费成人av资源网| www.成人网.com| 日韩欧美亚洲一区二区| 亚洲人吸女人奶水| 精品亚洲成av人在线观看| 日本道免费精品一区二区三区| 欧美精品一区二区三区蜜桃 | 99国产一区二区三精品乱码| 日韩精品一区二区三区在线观看| 亚洲免费色视频| 国产一区啦啦啦在线观看| 欧美日韩午夜影院| 亚洲欧洲另类国产综合| 国产精品亚洲专一区二区三区| 欧美亚日韩国产aⅴ精品中极品| 国产亚洲精品bt天堂精选| 蜜臀久久99精品久久久久宅男| 91在线观看免费视频| 久久久亚洲欧洲日产国码αv| 午夜精品成人在线视频| 色999日韩国产欧美一区二区| 国产欧美日韩另类视频免费观看| 蜜臀av国产精品久久久久| 欧美日韩国产中文| 亚洲国产一区二区在线播放| 99久久婷婷国产综合精品| 国产日韩精品一区二区三区| 国产资源精品在线观看| 日韩亚洲欧美高清| 亚洲妇熟xx妇色黄| 在线观看视频91| 亚洲欧美乱综合| 99vv1com这只有精品| 中文字幕人成不卡一区| 成人免费黄色大片| 国产精品无圣光一区二区| 国产精品中文字幕日韩精品| 精品国产制服丝袜高跟| 蜜臀91精品一区二区三区| 欧美一区二区三区公司| 五月天丁香久久| 欧美日韩视频在线第一区 | 2020日本不卡一区二区视频| 轻轻草成人在线| 日韩午夜激情免费电影| 男人的天堂久久精品| 日韩午夜小视频| 久久国产精品第一页| 久久这里只有精品首页| 国产九九视频一区二区三区| 久久久蜜桃精品| 国产成人夜色高潮福利影视| 久久在线免费观看| 成人毛片在线观看| 国产精品每日更新在线播放网址| www.欧美.com| 一区二区三区小说| 欧美理论在线播放| 蜜桃一区二区三区在线观看| www一区二区| 国产成人精品免费看| 中文字幕 久热精品 视频在线| 波多野结衣在线一区| 亚洲精品五月天| 欧美日韩午夜在线视频| 日本vs亚洲vs韩国一区三区| 精品久久久久久久人人人人传媒| 国产老妇另类xxxxx| 中文字幕制服丝袜一区二区三区| 97久久精品人人爽人人爽蜜臀| 伊人色综合久久天天人手人婷| 欧美日韩中文字幕一区二区| 老司机午夜精品99久久| 久久久久久9999| 91免费精品国自产拍在线不卡| 亚洲午夜视频在线观看| 欧美一区二区三区视频| 国产精品一区二区久久精品爱涩| 国产精品美女久久久久av爽李琼| 色哟哟国产精品| 亚洲国产va精品久久久不卡综合| 正在播放亚洲一区| 国产福利一区二区三区视频在线 | 在线观看视频91| 麻豆成人av在线| 国产精品嫩草影院av蜜臀| 欧洲精品一区二区| 美女视频第一区二区三区免费观看网站| 久久嫩草精品久久久精品| 99在线热播精品免费| 日韩福利视频导航| 久久久久久久久久久久久女国产乱| 菠萝蜜视频在线观看一区| 亚洲尤物在线视频观看| 久久综合九色综合欧美亚洲| 色偷偷成人一区二区三区91 | 国产精品网站在线播放| 欧美日韩免费视频| 国产成人在线视频网址| 亚洲.国产.中文慕字在线| 久久综合久久综合亚洲| 一道本成人在线| 国产一区二区三区av电影| 亚洲黄色av一区| 欧美大片在线观看一区二区| 99re视频这里只有精品| 麻豆国产精品官网| 亚洲欧美日韩精品久久久久| 欧美mv日韩mv亚洲| 在线一区二区观看| 国产麻豆精品在线观看| 亚洲国产成人高清精品| 中文一区在线播放| 日韩欧美一级精品久久| 色一区在线观看| 国产传媒一区在线| 麻豆极品一区二区三区| 亚洲永久精品大片| 亚洲国产精品av| 欧美成人精品高清在线播放| 日本韩国一区二区三区| 国产高清在线观看免费不卡| 日日夜夜精品视频天天综合网| 国产精品美女久久久久久久网站| 欧美成人一区二区三区片免费| 日本道精品一区二区三区| 成人午夜短视频| 极品少妇xxxx精品少妇偷拍| 亚洲成a人v欧美综合天堂 | 欧美高清激情brazzers| 99热99精品| 国产精品69毛片高清亚洲| 日韩电影一二三区| 一区二区三区国产| 中文字幕在线一区免费| 久久麻豆一区二区| 日韩精品一区二区三区视频在线观看| 欧美色综合影院| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 色综合天天做天天爱| 国产一区 二区 三区一级| 青青草97国产精品免费观看| 亚洲成人中文在线| 一区二区久久久久| 一区二区三区四区五区视频在线观看| 欧美激情在线看| 久久久久久97三级| 久久久久久久久久看片| 久久综合精品国产一区二区三区| 日韩一区二区三区视频在线| 欧美日韩国产一二三| 欧美亚男人的天堂| 欧美艳星brazzers| 欧美在线色视频| 欧美日韩在线精品一区二区三区激情 | 国产日产精品1区| 国产亚洲女人久久久久毛片| 久久久久青草大香线综合精品| 久久综合五月天婷婷伊人| 精品福利一区二区三区| 精品久久久久一区二区国产| xf在线a精品一区二区视频网站| 26uuu色噜噜精品一区二区| 日韩午夜激情av| 精品久久免费看| 久久这里只有精品视频网| 国产亚洲欧美日韩在线一区| 国产亚洲精品超碰| 国产精品天干天干在线综合| 国产精品三级av| 自拍偷拍欧美精品| 一区二区三区 在线观看视频| 一区二区高清免费观看影视大全| 亚洲国产视频在线| 丝袜a∨在线一区二区三区不卡| 日韩精品一区第一页| 蓝色福利精品导航| 国产精品一二三在| www.欧美色图| 在线精品视频一区二区三四| 欧美午夜精品一区二区三区 | 国产成人在线观看免费网站| www.亚洲色图.com| 色88888久久久久久影院野外| 欧美精品久久99久久在免费线| 91精品欧美福利在线观看| 欧美成人猛片aaaaaaa| 国产欧美精品一区二区三区四区 | 欧美高清性hdvideosex| 欧美成人精品福利| 国产精品色哟哟| 亚洲影视在线播放| 免费在线看成人av| 成人综合日日夜夜| 欧美日韩免费视频| 久久九九久久九九| 亚洲另类一区二区|