⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrixfun.hpp

📁 简单的C++计算库.其中实现了矩阵运算,大数运算.矩阵处理中使用lazy calculate,并且封装常见算法,可以将普通matlab程序用SDL改写.
💻 HPP
字号:
#ifndef		_SDL_MATHS_MATRIX_MATRIX_FUN_HPP_
#define		_SDL_MATHS_MATRIX_MATRIX_FUN_HPP_

#ifndef		_SDL_MATHS_MATRIX_MATRIX_HPP_
#error		"must be included by Matrix.hpp"
#endif

SDL_MATHS_MATRIX_BEGIN

/*
*
*	Matrix	transpose
*
*/

template<typename _MatType>
inline
BasicMatrixExpr<TranMatrixExpr<_MatType> >
Tran(const _MatType& _l)
{
	typedef	TranMatrixExpr<_MatType> ContainedMatType;
	return BasicMatrixExpr<ContainedMatType>(ContainedMatType(_l));
}

/*
*
*	Matrix	abs
*
*/

template<typename _MatType>
inline
BasicMatrixExpr<AbsMatrixExpr<_MatType> >
Abs(const _MatType& _l)
{
	typedef	AbsMatrixExpr<_MatType> ContainedMatType;
	return BasicMatrixExpr<ContainedMatType>(ContainedMatType(_l));
}

/*
*
*	Maximum	element
*
*/

template<typename _MatType>
inline
typename _MatType::NumberType
Max(const _MatType& _Mat)
{
	typedef	typename _MatType::NumberType NumberType;

	NumberType	result = _Mat(MIDX(1), MIDX(1));

	for (int i = MIDX(1); i <= MIDX(_Mat.row()); ++i)
	for (int j = MIDX(1); j <= MIDX(_Mat.col()); ++j)
	{
		NumberType t = _Mat(i, j);
		if (t > result)
		{
			result = t;
		}
	}

	return result;
}

/*
*
*	Minimum	element
*
*/

template<typename _MatType>
inline
typename _MatType::NumberType
Min(const _MatType& _Mat)
{
	typedef	typename _MatType::NumberType NumberType;

	NumberType	result = _Mat(MIDX(1), MIDX(1));

	for (int i = MIDX(1); i <= MIDX(_Mat.row()); ++i)
	for (int j = MIDX(1); j <= MIDX(_Mat.col()); ++j)
	{
		NumberType t = _Mat(i, j);
		if (t < result)
		{
			result = t;
		}
	}

	return result;
}

SDL_MATHS_MATRIX_END

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -