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

📄 matrixdata.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 5 页
字号:
			{
				for(jj = 0; jj < mSource.GetNumCols(); jj++)
					printf("%g\t",mSource[ii][jj]);
				printf("\n");
			}
			
			matrix mResult; 
			mSource.GetUpperTriangular(mResult);
						
			printf("Upper Triangular:\n");
			for(ii = 0; ii < mResult.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mResult.GetNumCols(); jj++)
					printf("%g\t",mResult[ii][jj]);
				printf("\n");
			}
		Parameters:
			mbResult=The result matrix containing only the lower part 
			nNthDiagonal=The number specifying N-th diagonal, default 0 is the main diagonal, > 0 is above
				the main diagonal, and < 0 is below the main diagonal.
		Return:
			Returns 0 on success and a non-zero error code on failure.
		   		-1=Internal cast error.
		SeeAlso:
			matrixbase::GetLowerTriangular, matrixbase::MakeIdentity, matrixbase::SetDiagonal, matrixbase::GetDiagonal
	*/
	int		GetUpperTriangular(matrixbase & mbResult, int nNthDiagonal = 0); // Get an upper triangular matrix from this matrix. 

	/**
			Get the diagonal or N-th diagonal of this matrix and place the result
			in a vector. The result vector and this matrix must have the same underlying
			base type or a run time error will be generated.
		Example:
			int ii, jj;

			matrix mSource = {{1,2,3},{4,5,6},{7,8,9}};
			printf("Source:\n");
			for(ii = 0; ii < mSource.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mSource.GetNumCols(); jj++)
					printf("%g\t",mSource[ii][jj]);
				printf("\n");
			}
			
			vector vResult; 
			mSource.GetDiagonal(vResult);
			printf("Diagonal:\n");
			for(ii = 0; ii < vResult.GetSize(); ii++)
				printf("%g\t",vResult[ii]);
			printf("\n");
			
			mSource.GetDiagonal(vResult,-1);
			printf("-1th Diagonal:\n");
			for(ii = 0; ii < vResult.GetSize(); ii++)
				printf("%g\t",vResult[ii]);
			printf("\n");
		Parameters:
			vbDiagonal=The result vector containing the (N-th) diagonal
			nNthDiagonal=The number specifying the N-th diagonal, default 0 is the main diagonal, > 0 is above
				the main diagonal, and < 0 is below the main diagonal.
		Return:
			Returns 0 on success and a non-zero error code on failure.
		SeeAlso:
			matrixbase::SetDiagonal, matrixbase::GetLowerTriangular, matrixbase::GetUpperTriangular, matrixbase::MakeIdentity
	*/
	int		GetDiagonal(vectorbase & vbDiagonal, int nNthDiagonal = 0); // Get the diagonal or N-th diagonal of this matrix.

	/**
			Set the diagonal or N-th diagonal of this matrix from a vector and set all
			other elements to 0. The source vector and this matrix must have the same
			underlying base type or a run time error will be generated.
		Example:
			int ii, jj;

			matrix mResult = {{1,2,3},{4,5,6},{7,8,9}};
			printf("Result:\n");
			for(ii = 0; ii < mResult.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mResult.GetNumCols(); jj++)
					printf("%g\t",mResult[ii][jj]);
				printf("\n");
			}
			
			vector vSource = {1,1}; 
			mResult.SetDiagonal(vSource,1);
			printf("Result after diagonal is set to 0:\n");
			for(ii = 0; ii < mResult.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mResult.GetNumCols(); jj++)
					printf("%g\t",mResult[ii][jj]);
				printf("\n");
			}
		Parameters:
			vbDiagonal=The source vector containing the (N-th) diagonal
			nNthDiagonal=The number specifying the N-th diagonal, default 0 is the main diagonal, > 0 is above
				the main diagonal, and < 0 is below the main diagonal.
		Return:
			Returns 0 on success and a non-zero error code on failure.
		SeeAlso:
			matrixbase::GetDiagonal, matrixbase::GetLowerTriangular, matrixbase::GetUpperTriangular, matrixbase::MakeIdentity
	*/
	int		SetDiagonal(vectorbase & vbDiagonal, int nNthDiagonal = 0); // Set the diagonal or N-th diagonal of this matrix.

	/**
			Cross product of this matrix and the source matrix along the dimension identified by iDim. The iDim
			dimension of both matrices must be three and the underlying base type of the source matrix must be
			less than or equal to the underlying base type of this matrix.
		Example:
			int ii, jj;
			matrix mA = {{1,2,3},{4,5,6}};
			matrix<int> mB = {{1,1,1},{1,1,1}} ;

			mA.Cross(mB,1);
			printf("mA x mB:\n");
			for(ii = 0; ii < mA.GetNumRows();  ii++)
			{
				for(jj = 0; jj < mA.GetNumCols(); jj++)
					printf("%g\t",mA[ii][jj]);
				printf("\n");
			}
		Parameters:
			mbSource=The source matrix
			nDim=Cross product can occur row wise (relative to the first dimension when nDim=1) or column wise (relative
				to the second dimension when nDim=2)
		Returns:
			Returns 0 on success and a non-zero error code on failure.
		SeeAlso:
			matrixbase::DotMultiply, matrixbase::DotDivide, matrixbase::DotPower
	*/
	int		Cross(matrixbase & mbSource, int nDim = 1);

	/**
			Indicates whether or not an entire row or column of this matrix is comprised
			of all non-zero elements. For matrices having an underlying base type of double
			or complex a specified tolerance is used to determine whether or not each element
			is zero.
		Example:
			int ii, jj;

			matrix mA = {{0,2,3},{0,0,6},{7,8,9}};
			vector<BOOL> vRowIsAllNonZeros; 

			mA.AllNonZero(vRowIsAllNonZeros);

			printf("mA:\t\tAll non-zero\n");
			for(ii = 0; ii < mA.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mA.GetNumCols(); jj++)
					printf("%g\t",mA[ii][jj]);
				printf("%d\n",vRowIsAllNonZeros[ii]);
			}
		Parameter:
			vAllNonZero=The result vector
			nDim=The AllNonZero test can occur row wise (relative to the first dimension when nDim=1) or 
				column wise (relative to the second dimension when nDim=2)
			dTol=The tolerance used to decide whether or not an element is zero (if abs(element) < dTol
				then the element is considered to be zero)
		Return:
 			Returns 0 on success and a non-zero error code on failure.
		SeeAlso:
			matrixbase::AnyNonZero

	*/
	int		AllNonZero(vector<BOOL>  & vAllNonZero, int nDim  = 1, double dTol = DEFAULT_TOLERANCE); // Indicates whether or not an entire row or column of this matrix is comprised of all non-zero elements.

	/**
			Indicates whether or not each row or column of this matrix contains any
			(one or more) non-zero elements. For matrices having an underlying base
			type of double or complex the machine based precision is used to determine
			whether or not any element is zero.
		Example:
			int ii, jj;

			matrix mA = {{0,2,0},{0,0,6},{0,8,0}};
			vector<BOOL> vColumnHasAnyNonZeros; 

			mA.AnyNonZero(vColumnHasAnyNonZeros,2);

			printf("mA:\n");
			for(ii = 0; ii < mA.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mA.GetNumCols(); jj++)
					printf("%g\t",mA[ii][jj]);
				printf("\n");
			}
			
			printf("Any non-zero:\n");
			for(ii = 0; ii < mA.GetNumCols(); ii++)
				printf("%d\t",vColumnHasAnyNonZeros[ii]);
			printf("\n");
		Parameter:
			vAnyNonZero=The result vector
			nDim=The AnyNonZero test can occur row wise (relative to the first dimension when nDim=1) or 
				column wise (relative to the second dimension when nDim=2)
			dTol=The tolerance used to decide whether or not an element is zero (if abs(element) < dTol
				then the element is considered to be zero)
		Return:
 			Returns 0 on success and a non-zero error code on failure.
		SeeAlso:
			matrixbase::AllNonZero
	*/
	int		AnyNonZero(vector<BOOL> & vAnyNonZero, int nDim = 1, double dTol = DEFAULT_TOLERANCE); // Indicates whether or not each row or column of this matrix contains any non-zero elements.

	/**
			Compute the cumulative product of this matrix. The underlying base type
			of this matrix must be less than or equal to the underlying base type of
			the result matrix. Currently only the double and complex types are supported
			for the result matrix.
		Example:	
			int ii, jj;

			matrix mA = {{1,2,3},{4,5,6},{7,8,9}}, mB;

			printf("mA:\n");
			for(ii = 0; ii < mA.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mA.GetNumCols(); jj++)
					printf("%g\t",mA[ii][jj]);
				printf("\n");
			}
			
			mA.CumulativeProduct(mB);
			
			printf("mB = Cumulative product of mA:\n");
			for(ii = 0; ii < mB.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mB.GetNumCols(); jj++)
					printf("%g\t",mB[ii][jj]);
				printf("\n");
			}
		Parameters:
			mbProduct=The result matrix containing the cumulative product
			nDim=The CumulativeProduct function can operate row wise (relative to the first dimension when nDim=1) or 
				column wise (relative to the second dimension when nDim=2)
		Returns:
 			Returns 0 on success and a non-zero error code on failure.
 		SeeAlso:
 			matrixbase::CumulativeSum
	*/
	int		CumulativeProduct(matrixbase & mbProduct, int nDim = 1); 

	/**
			Compute the cumulative sum of this matrix. The underlying base type of this
			matrix must be less than or equal to the underlying base type of the result
			matrix. Currently only the double and complex types are supported for the
			result matrix.
		Example:	
			int ii, jj;

			matrix mA = {{1,2,3},{4,5,6},{7,8,9}}, mB;

			printf("mA:\n");
			for(ii = 0; ii < mA.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mA.GetNumCols(); jj++)
					printf("%g\t",mA[ii][jj]);
				printf("\n");
			}

			mA.CumulativeSum(mB);

			printf("mB = Cumulative sum of mA:\n");
			for(ii = 0; ii < mB.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mB.GetNumCols(); jj++)
					printf("%g\t",mB[ii][jj]);
				printf("\n");
			}
		Parameters:
			mbSum=The result matrix containing the cumulative sum
			nDim=The CumulativeSum function can operate row wise (relative to the first dimension when nDim=1) or 
				column wise (relative to the second dimension when nDim=2)
		Returns:
 			Returns 0 on success and a non-zero error code on failure.
 		SeeAlso:
 			matrixbase::CumulativeProduct
	*/
	int		CumulativeSum(matrixbase & mbSum, int nDim = 1);

	/**
			Compute the N-th order row wise or column wise difference of the elements in this
			matrix. The difference matrix is computed by replacing the current element with
			the current element minus the previous element along the dimension specified by
			nDim. The N-th order difference approximates the N-th order derivative. If nOrder
			is greater than or equal to the size of the dimension identified by nDim than an
			empty matrix is returned. The underlying base type of this matrix and the result
			matrix must be the same.
		Example:
			int ii, jj;
			matrix mSource = {{8,2,5,4,2},{1,7,11,9,3}};

			printf("The source matrix:\n");
			for(ii = 0; ii < mSource.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mSource.GetNumCols(); jj++)
					printf("%g\t",mSource[ii][jj]);
				printf("\n");
			}

			matrix mResult;
			mSource.Difference(mResult);


			printf("The result matrix:\n");
			for(ii = 0; ii < mResult.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mResult.GetNumCols(); jj++)
					printf("%g\t",mResult[ii][jj]);
				printf("\n");
			}
		Parameters:
			mbDifference=The result matrix containing the difference
			nOrder=The order of difference to compute, default is 1
			nDim=The Difference function can operate row wise (relative to the first dimension when nDim=1) or 
				column wise (relative to the second dimension when nDim=2), default is 1 or row wise
		Return:
			 Returns 0 on success and a non-zero error code on failure.
	*/
	int		Difference(matrixbase & mbDifference, int nOrder = 1, int nDim = 1); // Compute the N-th order row wise or column wise difference of the elements in this matrix.
	
	/**
			Wrap around elements.
		Parameters:
			when the value is 0, no wrap, when value less than zero, do left_wrap, other wise do right_wrap.
		Examples:
			matrix mat = {{1,2,3,4,5}, {6,7,8,9,10}, {11,12,13,14,15}};
			mat.Wrap(0, 2);
			==> {{3,4,5,1,2}, {8,9,10,6,7}, {13,14,15,11,12}}
			mat.Wrap(2, 0);
			==> {{11,12,13,14,15}, {1,2,3,4,5}, {6,7,8,9,10}}
	*/
	BOOL Wrap(int nRowNum=0, int nColNum =0); 


#if  _OC_VER > 0x0703


#ifdef	ORIGIN_COM_SUPPORT
	/**#
		Set matrix elements from variant encountered in LabView's data.
	Parameters:
		v=variant that is VT_ARRAY|VT_VARIANT type and subvariants are of VT_ARRAY|<numeric> type.
	Examples:
		matrix		mat;        
		
		_VARIANT	var00, var01, var10, var11;
		var00 = 11, var01 = 12;
		var10 = 21, var11 = 22;
		
		_VARIANT	var0, var1;
		var0.CreateAsArray( VT_VARIANT, 2 );
		var0.SetOneVariantInArray( var00, 0 );
		var0.SetOneVariantInArray( var10, 1 );
		var1.CreateAsArray( VT_VARIANT, 2 );
		var1.SetOneVariantInArray( var01, 0 );
		var1.SetOneVariantInArray( var11, 1 );
	
		_VARIANT	var;
		var.CreateAsArray( VT_VARIANT, 2 );
		var.SetOneVariantInArray( var0, 0 );
		var.SetOneVariantInArray( var1, 1 );
		
		BOOL	bRet = mat.SetByArray

⌨️ 快捷键说明

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