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

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

?? tnt_array2d.h

?? fast marching method
?? H
字號:
/*
*
* Template Numerical Toolkit (TNT): Two-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_ARRAY2D_H
#define TNT_ARRAY2D_H

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

namespace TNT
{

/**
	Tempplated two-dimensional, numerical array which
	looks like a conventional C multiarray. 
	Storage corresponds to C (row-major) ordering.
	Elements are accessed via A[i][j] 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] 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 Array2D 
{


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

	void initialize_(int m, 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;

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


};


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



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

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

	@param m the first (row) dimension of the new matrix.
	@param n the second (column) dimension of the new matrix.
*/
template <class T>
Array2D<T>::Array2D(int m, int n) : v_(0), m_(m), n_(n), ref_count_(0)
{
	initialize_(m,n);
	ref_count_ = new int;
	*ref_count_ = 1;
}



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

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

}

/**
	Create a new (m x n) 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 Array2D class.

	@param m the first (row) dimension of the new matrix.
	@param n the second (column) dimension of the new matrix.
	@param a the one dimensional C array to use as data storage for
		the array. 
*/
template <class T>
Array2D<T>::Array2D(int m, int n, T *a) : v_(0), m_(m), n_(n) ,
	ref_count_(0)
{
	T* p = a;
	v_ = new T*[m];
	for (int i=0; i<m; i++)
	{
		v_[i] = p;
		p += n;
	}
	ref_count_ = new int;
	*ref_count_ = 2;		/* this avoid destorying original data. */

}


/**
	Used for A[i][j] 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 (row index)
	is checked that it falls within the array bounds (via the
	assert() macro.) Note that bounds checking can occur in
	the row dimension, but the not column, since
	this is just a C pointer.
*/
template <class T>
inline T* Array2D<T>::operator[](int i) 
{ 
#ifdef TNT_BOUNDS_CHECK
	assert(i >= 0);
	assert(i < m_);
#endif

return v_[i]; 

}

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

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

*/
template <class T>
Array2D<T> Array2D<T>::copy() const
{
	Array2D A(m_, n_);
	copy_(A.begin_(), begin_(), m_*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>
	Array2D A(m,n);
	Array2D C(m,n);
	Array2D 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>
Array2D<T> & Array2D<T>::inject(const Array2D &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>
Array2D<T> & Array2D<T>::ref(const Array2D<T> &A)
{
	if (this != &A)
	{
		(*ref_count_) --;
		if ( *ref_count_ < 1 )
		{
			destroy_();
		}

		m_ = A.m_;
		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>
Array2D<T> & Array2D<T>::operator=(const Array2D<T> &A)
{
	return ref(A);
}

/**
	@return the size of the first dimension of the array, i.e.
	the number of rows.
*/
template <class T>
inline int Array2D<T>::dim1() const { return m_; }

/**
	@return the size of the second dimension of the array, i.e.
	the number of columns.
*/
template <class T>
inline int Array2D<T>::dim2() 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 Array2D<T>::ref_count() const
{
	return *ref_count_;
}

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

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

/* private internal functions */

template <class T>
void Array2D<T>::initialize_(int m, int n)
{


	T* p = new T[m*n];
	v_ = new T*[m];
	for (int i=0; i<m; i++)
	{
		v_[i] = p;
		p+=n;
	}
	m_ = m;
	n_ = n;
}

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

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

}

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

}

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

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

	if (ref_count_ != 0)
		delete ref_count_;
}

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

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

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





} /* namespace TNT */

#endif
/* TNT_ARRAY2D_H */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲啪啪综合av一区二区三区| 欧美精品日韩精品| 日韩午夜激情av| 五月天亚洲婷婷| 色8久久人人97超碰香蕉987| 亚洲免费在线看| 日日摸夜夜添夜夜添精品视频| 精品影院一区二区久久久| 欧美日韩精品专区| 亚洲人成伊人成综合网小说| 国产一区二区在线观看视频| 国产精品国产三级国产专播品爱网| 欧美中文一区二区三区| 国产福利视频一区二区三区| 中文一区二区在线观看| 成人精品免费网站| 日韩一区在线看| 成人黄页毛片网站| 激情六月婷婷久久| 一区二区三区免费| 91麻豆6部合集magnet| 久久99久久99精品免视看婷婷| 一区二区三区四区不卡视频| 亚洲国产成人私人影院tom| 日韩免费高清av| 欧美一区二区三区小说| 欧美日韩免费视频| 欧美日韩综合一区| 欧美亚洲高清一区| 日本高清不卡aⅴ免费网站| 播五月开心婷婷综合| 粉嫩一区二区三区性色av| 国产一区二区看久久| 久久99久久精品欧美| 久久成人羞羞网站| 精品制服美女丁香| 九九热在线视频观看这里只有精品| 日韩av高清在线观看| 午夜成人免费视频| 人妖欧美一区二区| 蜜桃传媒麻豆第一区在线观看| 日本亚洲视频在线| 理论电影国产精品| 麻豆freexxxx性91精品| 九色综合国产一区二区三区| 久久精品国产免费看久久精品| 免费精品视频最新在线| 裸体在线国模精品偷拍| 老司机精品视频一区二区三区| 久久国产三级精品| 国产一区二区女| 成人免费av资源| 99久久国产综合精品女不卡| 日本高清不卡在线观看| 精品视频在线免费看| 欧美一区二区三区小说| 精品乱人伦小说| 国产欧美精品一区| 日韩毛片视频在线看| 亚洲国产视频直播| 首页欧美精品中文字幕| 久久精品国产精品青草| 国产成人亚洲综合a∨婷婷| 成人一区在线观看| 91蝌蚪porny九色| 欧美日本国产一区| 26uuuu精品一区二区| 1000精品久久久久久久久| 亚洲国产美女搞黄色| 麻豆精品一二三| www.欧美日韩国产在线| 欧美日韩一区在线观看| 欧美成人r级一区二区三区| 国产日韩v精品一区二区| 亚洲精品你懂的| 久久国产乱子精品免费女| 成人av综合在线| 欧洲精品在线观看| 精品国产露脸精彩对白| 国产精品超碰97尤物18| 日韩精品电影在线| 97久久精品人人澡人人爽| 4438亚洲最大| 国产精品久久久久久久久动漫| 五月综合激情婷婷六月色窝| 国产福利一区在线| 欧美日本免费一区二区三区| 亚洲国产成人在线| 免费看黄色91| 欧美性色综合网| 久久精品人人做人人爽97| 亚洲电影视频在线| 不卡av免费在线观看| 日韩视频免费观看高清在线视频| 亚洲日本va午夜在线影院| 蜜臀91精品一区二区三区 | 亚洲视频每日更新| 久久av资源网| 色就色 综合激情| 久久综合九色综合欧美就去吻| 日韩精品一二三| 97久久超碰国产精品| 国产亚洲一区二区三区| 视频一区二区三区在线| 91浏览器打开| 国产精品毛片久久久久久久| 久久电影国产免费久久电影| 欧美三区在线视频| 综合久久久久综合| 国产精品系列在线播放| 欧美一区二区三区视频免费| 一区二区三区精品在线观看| 高清视频一区二区| 26uuu欧美| 久草中文综合在线| 91精品国产综合久久久久久久| 亚洲最大成人网4388xx| 成人激情开心网| 国产欧美日本一区视频| 国内外精品视频| 精品久久一区二区| 青青草原综合久久大伊人精品优势| 在线观看亚洲专区| 一区二区三区日韩欧美精品| 91在线国内视频| 亚洲天堂av一区| jizzjizzjizz欧美| 中国av一区二区三区| 国产激情精品久久久第一区二区 | 91福利小视频| 成人欧美一区二区三区小说| 国产ts人妖一区二区| 亚洲精品在线观看视频| 久久精品久久99精品久久| 欧美一区二区三区播放老司机| 亚洲成av人在线观看| 欧美三级日韩三级国产三级| 午夜精品一区在线观看| 欧美日韩一区二区欧美激情 | 日韩中文欧美在线| 欧美一区二区三区在线观看视频| 免费高清在线一区| 欧美精品视频www在线观看 | 国产成人免费高清| 国产午夜亚洲精品羞羞网站| 国产成人精品免费网站| 中文成人av在线| 99精品欧美一区二区三区综合在线| 中文字幕中文在线不卡住| 91色视频在线| 亚洲国产精品久久不卡毛片| 欧美精品v日韩精品v韩国精品v| 亚洲r级在线视频| 日韩亚洲欧美在线观看| 国产一级精品在线| 国产精品乱人伦中文| 色视频成人在线观看免| 婷婷丁香久久五月婷婷| 精品国产网站在线观看| 岛国一区二区三区| 亚洲久本草在线中文字幕| 欧美日韩国产综合草草| 美女被吸乳得到大胸91| 日本一区二区成人| 色诱亚洲精品久久久久久| 日本午夜一区二区| 国产午夜一区二区三区| 色吧成人激情小说| 另类调教123区| 亚洲人成在线观看一区二区| 正在播放一区二区| 国产成a人亚洲| 亚洲高清不卡在线观看| 亚洲精品一区二区三区蜜桃下载| 成人高清免费在线播放| 亚洲国产欧美一区二区三区丁香婷 | 国产99久久久国产精品| 亚洲靠逼com| 久久久久久亚洲综合影院红桃 | 成人av网站免费观看| 亚洲国产精品一区二区久久| 亚洲精品一区在线观看| 在线观看日韩高清av| 国产一区二区在线看| 亚洲综合色成人| 欧美精品一区在线观看| 欧美亚洲国产一区在线观看网站| 激情五月婷婷综合| 亚洲一二三区在线观看| 国产亚洲1区2区3区| 欧美精品色综合| 一本大道久久a久久综合婷婷 | 精品视频一区三区九区| 国产一区二区影院| 三级亚洲高清视频| 国产精品久久久久久久久快鸭 | 久久精品人人做人人综合| 欧美色综合网站| 粉嫩aⅴ一区二区三区四区五区| 日韩精品一二区|