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

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

?? matrix.inl

?? 圖像分割算法
?? INL
?? 第 1 頁 / 共 3 頁
字號:
//Copyright (c) 2004-2005, Baris Sumengen
//All rights reserved.
//
// CIMPL Matrix Performance Library
//
//Redistribution and use in source and binary
//forms, with or without modification, are
//permitted provided that the following
//conditions are met:
//
//    * No commercial use is allowed. 
//    This software can only be used
//    for non-commercial purposes. This 
//    distribution is mainly intended for
//    academic research and teaching.
//    * Redistributions of source code must
//    retain the above copyright notice, this
//    list of conditions and the following
//    disclaimer.
//    * Redistributions of binary form must
//    mention the above copyright notice, this
//    list of conditions and the following
//    disclaimer in a clearly visible part 
//    in associated product manual, 
//    readme, and web site of the redistributed 
//    software.
//    * Redistributions in binary form must
//    reproduce the above copyright notice,
//    this list of conditions and the
//    following disclaimer in the
//    documentation and/or other materials
//    provided with the distribution.
//    * The name of Baris Sumengen may not be
//    used to endorse or promote products
//    derived from this software without
//    specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
//HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
//EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
//NOT LIMITED TO, THE IMPLIED WARRANTIES OF
//MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
//CONTRIBUTORS BE LIABLE FOR ANY
//DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
//EXEMPLARY, OR CONSEQUENTIAL DAMAGES
//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
//OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
//DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
//HOWEVER CAUSED AND ON ANY THEORY OF
//LIABILITY, WHETHER IN CONTRACT, STRICT
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
//OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
//OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//POSSIBILITY OF SUCH DAMAGE.



// Template Implementation


template< class T >
Matrix<T>::Matrix()
	: ndims(2), length(0)
{
	data = 0;
	xDim = 0;
	yDim = 0;
	columns = 0;
	clean = 0;

}


template< class T >
Matrix<T>::Matrix(const int rows, const int cols)
{
	if(rows < 1 || cols < 1)
	{
		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
		Utility::RunTimeError("All Matrix dimensions should be larger than 0!");
	}

	ndims = 2;
	length = rows*cols;
	xDim = cols;
	yDim = rows;
	data = new (std::nothrow) T[length];
	Utility::CheckPointer(data);

	columns = new (std::nothrow) Vector<T>[cols];
	Utility::CheckPointer(columns);
	for(int i=0; i<cols; i++)
	{
		columns[i].Set(&(data[i*rows]), rows);
	}
	
	clean = new (std::nothrow) Cleaner<T>(data, columns);
	Utility::CheckPointer(clean);
	
}

template< class T >
Matrix<T>::Matrix(const int rows, const int cols, T init)
{
	if(rows < 1 || cols < 1)
	{
		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
		Utility::RunTimeError("All Matrix dimensions should be larger than 0!");
	}

	ndims = 2;
	length = rows*cols;
	xDim = cols;
	yDim = rows;
	data = new (std::nothrow) T[length];
	Utility::CheckPointer(data);

	columns = new (std::nothrow) Vector<T>[cols];
	Utility::CheckPointer(columns);
	for(int i=0; i<cols; i++)
	{
		columns[i].Set(&(data[i*rows]), rows);
	}
	
	clean = new (std::nothrow) Cleaner<T>(data, columns);
	Utility::CheckPointer(clean);
	
	for(int i=0;i<length;i++)
	{
		data[i] = init;
	}

}




template< class T >
Matrix<T>::Matrix(string str)
{
	if(str.substr(0,1) == "[" && str.substr(str.size()-1,1) == "]")
	{
		str = str.substr(1,str.size()-2);
		vector<string> row_strs = Utility::Split(str, ";");
		if(row_strs.size() < 1 )
		{
			cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
			Utility::RunTimeError("All Matrix dimensions should be larger than 0!");
		}
		int rsize = (int)row_strs.size();
		
		vector<string> dummy = Utility::Split(row_strs[0]);
		if(dummy.size() < 1 )
		{
			cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
			Utility::RunTimeError("All Matrix dimensions should be larger than 0!");
		}
		int csize = (int)dummy.size();
		ndims = 2;
		length = rsize*csize;
		xDim = csize;
		yDim = rsize;
		data = new (std::nothrow) T[length];
		Utility::CheckPointer(data);
		columns = new (std::nothrow) Vector<T>[csize];
		Utility::CheckPointer(columns);
		for(int i=0; i<csize; i++)
		{
			columns[i].Set(&(data[i*rsize]), rsize);
		}
		clean = new (std::nothrow) Cleaner<T>(data, columns);
		Utility::CheckPointer(clean);
		
		for(int i=0; i<rsize; i++)
		{
			vector<string> elem_strs = Utility::Split(row_strs[i]);
			if(elem_strs.size() != xDim )
			{
				cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
				Utility::RunTimeError("String parse error. Matrix dimensions are not consistent!");
			}
			for(int j=0; j<csize; j++)
			{
				columns[j].data[i] = (T)Utility::ToDouble(elem_strs[j]);
			}
		}
	}
	else
	{
			cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
			Utility::RunTimeError("Incorrect initialization. String cannot be parsed!");
	}
}





template< class T >
Matrix<T>::Matrix(Matrix<T> &m) 
{
	ndims = m.ndims;
	length = m.length;
	xDim = m.xDim;
	yDim = m.yDim;

	data = m.data;
	columns = m.columns;

	clean = new (std::nothrow) Cleaner<T>(data, columns);
	Utility::CheckPointer(clean);

}



template< class T >
Matrix<T>::~Matrix()
{
	
	if(clean != 0)
	{
		delete clean;
	}
}


template< class T >
void Matrix<T>::Clean()
{
	if(clean != 0)
	{
		delete clean;
		data = 0;
		columns = 0;
		clean = 0;
	}
}


template< class T >
void Matrix<T>::Set(const int rows, const int cols, T *_data)
{
	if(rows < 1 || cols < 1)
	{
		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
		Utility::RunTimeError("All Matrix dimensions should be larger than 0!");
	}

	ndims = 2;
	length = rows*cols;
	xDim = cols;
	yDim = rows;
	data = _data;

	columns = new (std::nothrow) Vector<T>[cols];
	Utility::CheckPointer(columns);
	for(int i=0; i<cols; i++)
	{
		columns[i].Set(&(data[i*rows]), rows);
	}
	
	delete clean;
	clean = new (std::nothrow) Cleaner<T>(data, columns);
	Utility::CheckPointer(clean);
	
}

template< class T >
inline const T* Matrix<T>::DataPtr()
{
	return data;
}

template< class T >
inline T* Matrix<T>::Data()
{
	return data;
}


template< class T >
Matrix<T> Matrix<T>::Clone() const
{
	Matrix<T> temp(Rows(), Columns());
	
	memcpy(temp.data, data, sizeof(T)*temp.length);

	return temp;
}


template< class T >
void Matrix<T>::SwitchColumns(int i, int j)
{
	T *temp_i = columns[i].data;
	columns[i].data = columns[j].data;
	columns[j].data = temp_i;
}


template< class T >
void Matrix<T>::SyncData2Columns()
{
	T* temp_data = new (std::nothrow) T[length];
	Utility::CheckPointer(temp_data);
	
	for(int i=0; i<xDim; i++)
	{
		memcpy(&(temp_data[i*yDim]), columns[i].data, sizeof(T)*yDim);
	}
	data = temp_data;
	
	columns = new (std::nothrow) Vector<T>[xDim];
	Utility::CheckPointer(columns);
	
	for(int i=0; i<xDim; i++)
	{
		columns[i].data = &(data[i*yDim]);
	}
	
	delete clean;
	clean = new (std::nothrow) Cleaner<T>(data, columns);
	Utility::CheckPointer(clean);
}


template< class T >
Matrix<T> Matrix<T>::Slice(const int row1, const int row2, const int col1, const int col2)
{
	if(row1<0 || row1>=Rows() || row2<0 || row2>=Rows())
	{
		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
		Utility::RunTimeError("Index outside bounds!");
	}
	if(row1 > row2)
	{
		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
		Utility::RunTimeError("Second slice parameter cannot be less than the first parameter!");
	}


	if(col1<0 || col1>=Columns() || col2<0 || col2>=Columns())
	{
		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
		Utility::RunTimeError("Index outside bounds!");
	}
	if(col1 > col2)
	{
		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
		Utility::RunTimeError("Second slice parameter cannot be less than the first parameter!");
	}

	
	Matrix<T> temp(row2-row1+1, col2-col1+1);
	
	for(int j=col1; j<=col2; j++)
	{
		memcpy(temp[ j-col1 ].data, &(columns[j].data[row1]), sizeof(T)*temp.Rows());
	}

	return temp;
}


//template< class T >
//SubMatrix<T> Matrix<T>::Slice(int row1, int row2, int col1, int col2)
//{
//	if(row1<0 || row1>=YDim() || row2<0 || row2>=YDim())
//	{
//		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
//		Utility::RunTimeError("Index outside bounds!");
//	}
//	if(row1 > row2)
//	{
//		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
//		Utility::RunTimeError("Second slice parameter cannot be less than the first parameter!");
//	}
//
//
//	if(col1<0 || col1>=XDim() || col2<0 || col2>=XDim())
//	{
//		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
//		Utility::RunTimeError("Index outside bounds!");
//	}
//	if(col1 > col2)
//	{
//		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
//		Utility::RunTimeError("Second slice parameter cannot be less than the first parameter!");
//	}
//
//	
//	SubMatrix<T> temp;
//	temp.xDim = col2-col1+1;
//	temp.yDim = row2-row1+1;
//	temp.columns = new (std::nothrow) Vector<T>[temp.xDim];
//	Utility::CheckPointer(temp.columns);
//	temp.clean = new (std::nothrow) Cleaner<T>(temp.columns);
//	Utility::CheckPointer(temp.clean);
//
//	for(int j=col1; j<=col2; j++)
//	{
//		temp.columns[j-col1].Set(&(columns[j].data[row1]),  row2-row1+1);
//	}
//
//	return temp;
//}



template< class T >
Matrix<T> Matrix<T>::Slice(string str1, string str2)
{
	int row1, row2, col1, col2;
	vector<string> bounds1 = Utility::Split(str1, ":");
	vector<string> bounds2 = Utility::Split(str2, ":");
	
	if(str1 == ":")
	{
		row1 = 0;
		row2 = yDim-1;
	}
	else if(bounds1.size() == 2)
	{
		row1 = Utility::ToInt(bounds1[0]);
		row2 = Utility::ToInt(bounds1[1]);
	}
	else
	{
		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
		Utility::RunTimeError("Incorrect slice argument. String cannot be parsed!");
	}

	if(str2 == ":")
	{
		col1 = 0;
		col2 = xDim-1;
	}
	else if(bounds2.size() == 2)
	{
		col1 = Utility::ToInt(bounds2[0]);
		col2 = Utility::ToInt(bounds2[1]);
	}
	else
	{
		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
		Utility::RunTimeError("Incorrect slice argument. String cannot be parsed!");
	}
	
	return this->Slice(row1, row2, col1, col2);

}



template< class T >
Vector<T> Matrix<T>::Slice(string str)
{
	Vector<T> temp = (Vector<T>)*this;
	return temp.Slice(str);
}





template< class T >
inline const int Matrix<T>::Columns() const
{
	return xDim;
}

template< class T >
inline const int Matrix<T>::Rows() const
{
	return yDim;
}


template< class T >
inline const int Matrix<T>::XDim() const
{
	return xDim;
}

template< class T >
inline const int Matrix<T>::YDim() const
{
	return yDim;
}




template< class T >
inline const int Matrix<T>::Length() const
{
	return length;
}

template< class T >
inline const int Matrix<T>::Numel() const
{
	return length;
}

template< class T >
inline const int Matrix<T>::NDims() const
{
	return ndims;
}

template< class T >
inline void Matrix<T>::Init(const T init)
{
	for(int i=0;i<length;i++)
	{
		data[i] = init;
	}
}

//template< class T >
//inline Matrix<T>&  Matrix<T>::Rand()
//{
//	if(!RandomGen::Initialized())
//	{
//		RandomGen::Initialize();
//	}
//	for(int i=0;i<length;i++)
//	{
//		data[i] = (T)rand();
//	}
//	return *this;
//}

template< class T >
inline Matrix<T>&  Matrix<T>::Rand(const double max)
{
	if(!RandomGen::Initialized())
	{
		RandomGen::Initialize();
	}
	for(int i=0;i<length;i++)
	{
		data[i] = (T)(rand()/(double)RAND_MAX*max);
	}
	return *this;
}


//template< class T >
//Matrix<T> Matrix<T>::Rand(const int rows, const int cols)
//{
//	Matrix<T> m(rows, cols);
//	if(!RandomGen::Initialized())
//	{
//		RandomGen::Initialize();
//	}
//	for(int i=0;i<rows*cols;i++)
//	{
//		m.data[i] = (T)rand();
//	}
//	return m;
//}

template< class T >
Matrix<T> Matrix<T>::Rand(const int rows, const int cols, const double max)
{
	Matrix<T> m(rows, cols);
	if(!RandomGen::Initialized())
	{
		RandomGen::Initialize();
	}
	for(int i=0;i<rows*cols;i++)
	{
		m.data[i] = (T)(rand()/(double)RAND_MAX*max);
	}
	return m;
}



template< class T >
void Matrix<T>::ReadFromMatrix(const Matrix<T>& m)
{
	if(xDim < m.xDim || yDim < m.yDim)
	{
		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
		Utility::RunTimeError("You can't read from a larger Matrix to a smaller Matrix!");
	}

	for(int i=0;i<m.xDim;i++)
	{
		for(int j=0;j<m.yDim;j++)
		{
			columns[i].data[j] = m.columns[i].data[j];
		}
	}

}

template< class T >
void Matrix<T>::ReadFromMatrix(const Matrix<T>& m, const int rowStart, const int colStart)
{
	if(xDim < m.xDim+colStart || yDim < m.yDim+rowStart)
	{
		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
		Utility::RunTimeError("You can't read from a larger Matrix (from the copy start point) to a smaller Matrix!");
	}

	for(int i=0;i<m.xDim;i++)
	{
		for(int j=0;j<m.yDim;j++)
		{
			columns[i+colStart].data[j+rowStart] = m.columns[i].data[j];
		}
	}

}









template< class T >
Matrix<T> Matrix<T>::Cat(int dimension, Matrix<T>& m1, Matrix<T>& m2)
{
	Matrix<T> temp;
	if(dimension == 1)
	{
		if(m1.Columns() != m2.Columns())
		{
			cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
			Utility::RunTimeError("Matrix sizes are not compatible for concatenation!");
		}
		
		temp = Matrix<T>(m1.Rows()+m2.Rows(), m1.Columns());
		temp.ReadFromMatrix(m1);
		temp.ReadFromMatrix(m2, m1.Rows(), 0);
		
	}
	else if(dimension == 2)
	{
		if(m1.Rows() != m2.Rows())
		{
			cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
			Utility::RunTimeError("Matrix sizes are not compatible for concatenation!");
		}

		temp = Matrix<T>(m1.Rows(), m1.Columns()+m2.Columns());
		temp.ReadFromMatrix(m1);
		temp.ReadFromMatrix(m2, 0, m1.Columns());
	}
	else
	{
		cerr << "Line: " << __LINE__ << " File: " << __FILE__ << endl;
		Utility::RunTimeError("dimension should be either 1 or 2 for matrices!");
	}
	
	return temp;
}

template< class T >
Matrix<T> Matrix<T>::Cat(int dimension, Matrix<T>& m1, Vector<T>& m2)
{
	return Matrix<T>::Cat(dimension, m1, (Matrix<T>)m2);
}

template< class T >

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
毛片av一区二区| 综合激情网...| 精品一区二区在线观看| 日韩精品一区二区三区四区视频 | 欧美色图激情小说| 亚洲综合色网站| 这里只有精品电影| 国产伦精品一区二区三区视频青涩 | 国产精品嫩草影院com| 成人高清视频在线观看| ...av二区三区久久精品| 色播五月激情综合网| 首页综合国产亚洲丝袜| 精品免费视频.| 波多野结衣视频一区| 一区二区三区色| 欧美电影一区二区三区| 国产一区二区视频在线| 日韩毛片视频在线看| 欧美另类videos死尸| 国产一区二区在线免费观看| 欧美激情一区二区在线| 欧美影院一区二区| 色呦呦一区二区三区| 午夜精品成人在线视频| 久久这里只有精品视频网| 一本色道**综合亚洲精品蜜桃冫| 午夜视频一区在线观看| 国产三级一区二区| 欧美日韩一区不卡| 国产福利一区二区三区视频在线| 亚洲男人都懂的| 精品精品国产高清一毛片一天堂| 91在线精品秘密一区二区| 丝袜亚洲精品中文字幕一区| 中文字幕欧美日本乱码一线二线| 欧美色图激情小说| 成人美女视频在线观看18| 日韩成人精品视频| 最新日韩在线视频| 精品黑人一区二区三区久久| 91在线视频18| 国产精品亚洲综合一区在线观看| 亚洲一区在线免费观看| 久久精品日产第一区二区三区高清版 | 国产精品成人一区二区艾草| 4438x亚洲最大成人网| 99re热视频这里只精品| 国产一区不卡视频| 蜜桃久久久久久久| 亚洲第一精品在线| 亚洲免费观看视频| 国产精品网曝门| 精品区一区二区| 91精品久久久久久久91蜜桃| 色天使久久综合网天天| 成人av先锋影音| 国产大陆a不卡| 蜜桃一区二区三区在线| 不卡视频在线看| 久久福利视频一区二区| 首页亚洲欧美制服丝腿| 亚洲激情图片一区| 亚洲日本在线观看| 国产精品福利影院| 国产精品日产欧美久久久久| 精品国产一区a| 日韩免费看的电影| 日韩久久精品一区| 91精品国产综合久久精品| 欧美日韩激情一区| 欧美视频在线一区| 欧美伊人久久久久久午夜久久久久| a级精品国产片在线观看| 成人18视频日本| 成人精品视频.| 成人国产精品免费观看动漫| 成人性视频网站| 成人天堂资源www在线| 国产精品一二三区| 国产毛片精品视频| 岛国精品在线观看| 成人午夜私人影院| 成人h精品动漫一区二区三区| 大尺度一区二区| av一区二区三区四区| www.亚洲激情.com| 91影院在线免费观看| 99久久综合色| 日本高清免费不卡视频| 91福利小视频| 91麻豆精品久久久久蜜臀 | 播五月开心婷婷综合| 丰满白嫩尤物一区二区| 国产成人aaa| 99久久国产免费看| 色噜噜狠狠成人网p站| 精品视频在线看| 欧美一区二区日韩一区二区| 精品人在线二区三区| 国产精品久久三区| 一区二区激情小说| 日韩在线观看一区二区| 国产在线不卡一区| 99re免费视频精品全部| 欧美日韩电影在线| 精品国产伦一区二区三区观看方式 | 国产午夜精品久久| 中文字幕字幕中文在线中不卡视频| 亚洲一二三四在线| 精品一区二区三区视频在线观看| 国产精品正在播放| 色天天综合色天天久久| 日韩精品专区在线| 中文字幕在线不卡| 日韩精品电影在线观看| 国产精品 欧美精品| 91视频在线看| 精品国产a毛片| 亚洲免费观看高清完整| 久久精品国产999大香线蕉| 成人av在线一区二区三区| 在线观看一区不卡| 精品国产乱码久久久久久夜甘婷婷 | 亚洲图片有声小说| 国产激情一区二区三区桃花岛亚洲| 色悠悠久久综合| 日韩你懂的在线播放| 亚洲婷婷综合色高清在线| 麻豆精品在线视频| 91浏览器打开| 久久久久久99久久久精品网站| 一个色在线综合| 国产精品66部| 91精品国产综合久久香蕉麻豆| 国产精品天天看| 久久国产乱子精品免费女| 欧美综合在线视频| 国产精品美日韩| 久久国产麻豆精品| 在线电影一区二区三区| 亚洲图片欧美激情| 国产a久久麻豆| 91麻豆精品国产91久久久久| 亚洲同性同志一二三专区| 国产九九视频一区二区三区| 欧美妇女性影城| 亚洲免费毛片网站| 成人免费视频一区| 国产午夜亚洲精品午夜鲁丝片| 日本不卡123| 91麻豆精品91久久久久同性| 亚洲九九爱视频| 91亚洲资源网| 国产精品美女久久久久久久网站| 国产综合色在线视频区| 欧美成人性战久久| 麻豆视频一区二区| 欧美电影精品一区二区| 美女网站色91| 日韩一区二区在线免费观看| 亚洲成人动漫精品| 欧美在线观看视频一区二区| 亚洲男女一区二区三区| 99视频在线观看一区三区| 国产精品卡一卡二| 成人a区在线观看| 国产精品理论在线观看| caoporm超碰国产精品| 国产精品免费人成网站| 成人av在线电影| 国产精品久久久久影院老司| 成人精品一区二区三区中文字幕 | 国产精品久久久久久久第一福利| 国产精品一区二区你懂的| 久久久亚洲高清| 国产激情视频一区二区三区欧美 | 亚洲精品在线观| 国产精品一区免费在线观看| 日本一区二区三区四区在线视频| 国产精品一区二区果冻传媒| 亚洲国产电影在线观看| www.欧美精品一二区| 亚洲精品伦理在线| 欧美日韩综合不卡| 日本在线不卡视频| 2021久久国产精品不只是精品| 国产精品一区二区无线| 国产精品欧美极品| 欧美在线你懂的| 人人超碰91尤物精品国产| 精品国产成人系列| www.亚洲激情.com| 夜夜嗨av一区二区三区网页| 欧美日韩在线三级| 久久99这里只有精品| 亚洲国产成人一区二区三区| 91精品办公室少妇高潮对白| 婷婷国产在线综合| 久久精品男人的天堂|