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

📄 vector.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 5 页
字号:
			Get min and max values and associated indecies of current vector. For complex, the amplitude will be calculated.
		Example:
			vector<int> vTarget = { 5, 6 ,1, 2, 3, 4 };
			double dbMin, dbMax;
			uint nIndexMin;
			uint nIndexMax;
			uint nCountNonMissingValue = vTarget.GetMinMax(dbMin, dbMax, &nIndexMin, &nIndexMax);
			ASSERT(dbMin == 1.0);
			ASSERT(dbMax == 6.0);
			ASSERT(nIndexMin == 2);
			ASSERT(nIndexMax == 1);
			ASSERT(nCountNonMissingValue == 6);
			// here is another example, which shows how to use this in a worksheet
			void show_wks_min_max(string strWks = "Data1")
			{
				Worksheet wks(strWks);
				
				foreach(Column cc in wks.Columns)
				{
					vector vv(cc, 0, cc.GetNumRows()-1); // copy col data into a vector of double
					double min, max;
					uint imin, imax;
					vv.GetMinMax(min, max, &imin, &imax);
					// show index in LabTalk convention of 1-offset
					printf("Col(%s): max[%d] = %f, min[%d] = %f\n", cc.GetName(), imax+1, max, imin+1, min);
				}
			}

		Return:
			The total number of none-missing values in the vector. For complex, 
			if either of real and imaginary part is missing value, the amplitude will be a missing value.
		SeeAlso:
			None.
	*/
	int		GetMinMax(double& min, double& max, uint* pIndexMin = NULL, uint* pIndexMax = NULL);

	/**
			Compute a frequency count of the elements in a vector binning from dMin
			to dMax with a bin size of dInc. Values that fall on the lower edge of a bin
			are included in that bin and values that fall on the upper edge of a bin are
			included in the next higher bin.
		Example:
			// Data1_A (with data between 0 and 1) and Data1_B must exist
			Dataset dsA("Data1_A"), dsB("Data1_B");
			vector  vA(dsA);
			vector<int> vCounts;
			vA.FrequencyCount(0,1,0.05,vCounts);
			dsB = vCounts;
		Parameters:
			dMin=The minimum value of the range
			dMax=The maximum value of the range
			dInc=The bin increment
			vCounts=The result vector containing frequency counts
			wIncludeOutliers=Flag indicating whether or not to include outliers in 
				first and last bins
					0=Don't include outliers (default)
					1=Include outliers < dMin in first bin
					2=Include outliers >= dMax in last bin
					3=Combination of 1 and 2 above
		Return:
			Returns 0 on success and a non-zero error code on failure:
				1=dInc is zero
				2=dInc is greater than (dMax - dMin)
	*/	
	int     FrequencyCount(double dMin, double dMax, double dInc, vector<int>&  vCounts, int wIncludeOutliers = FAB_NOT_INCLUDE_OUTLIERS); // Compute a frequency count of elements in a vector.

	/**
			Copy the elements of this vector into an internal buffer.
		Example:
			vector<int> vTemp = {1,2,3,4,5};
			vector<byte> vResult;
			vTemp.GetBytes(vResult);
			int iSize = vResult.GetSize();
			ASSERT(iSize == 4 * vTemp.GetSize());
		Parameters:
			vStream=Output vector or internal buffer containing bytes copied from this vector
		Return:
			Returns 0 on success and a non-zero error code on failure.
		SeeAlso:
			vectorbase::SetBytes
	*/
 	int     GetBytes(vector<byte>& vStream); // Copy the elements of this vector into an internal buffer.

	/**
			Set the elements of this vector from an internal buffer.
		Example:
			vector<int> vTemp1 = {1,2,3,4,5}, vTemp2;
			vector<byte> vResult;
			vTemp1.GetBytes(vResult);
			int iSize = vResult.GetSize();
			ASSERT(iSize == 4 * vTemp1.GetSize());
			vTemp2.SetSize(vTemp1.GetSize());
			vTemp2.SetBytes(vResult);
		Parameters:
			vStream=Input vector or internal buffer containing bytes copied to this vector
		Return:
			Returns 0 on success and a non-zero error code on failure.
		SeeAlso:
			vectorbase::GetBytes
	*/
 	int     SetBytes(vector<byte>& vStream); // Set the elements of this vector from an internal buffer.

	/**
			Assigns a LabTalk vector to an Origin C vector.
		Example:
			vector<string> vsColumns;
			if( vsColumns.GetLabTalkVectorValue("wks.cname"))
			{
				for(int ii = 0; ii < vsColumns.GetSize(); ii++)
				{
					printf("Column (%d) : %s\n", ii, vsColumns[ii]);
				}
			}
			else
				printf("Could not find wks.cname$\n");
		Parameters:
			lpcszLabTalkVector=Input name of LabTalk vector
		Return:
			Returns TRUE on success and FALSE on failure.
		SeeAlso:
			vectorbase::SetLabTalkVectorValue
	*/
	BOOL	GetLabTalkVectorValue(LPCTSTR lpcszLabTalkVector); // Assigns a LabTalk vector to an Origin C vector.

	/**
			Assigns an Origin C vector to a LabTalk vector.
		Example:
			vector<string> vsExt = {"OPJ", "TXT"};
			vector<string> vsExtSave;
			string strExt;
			
			BOOL bSaved = vsExtSave.GetLabTalkVectorValue("FDlog.Type"); //Save the Current settings
			
			if(vsExt.SetLabTalkVectorValue("FDlog.Type"))
			{
				for(int ii = 0; ii < vsExt.GetSize(); ii++)
				{
					strExt = LabTalk.FDlog.Type$(ii+1)$;
					printf("FDLog Type (%d) : %s\n", ii, strExt);
				}
			}
			else
				printf("Could not find FDlog.Type$\n");
			if(bSaved)
				vsExtSave.SetLabTalkVectorValue("FDlog.Type"); //Restore the older settings
		Parameters:
			lpcszLabTalkVector=Input name of LabTalk vector
		Return:
			Returns TRUE on success and FALSE on failure.
		SeeAlso:
			vectorbase::GetLabTalkVectorValue
	*/
	BOOL	SetLabTalkVectorValue(LPCTSTR lpcszLabTalkVector); // Assigns an Origin C vector to a LabTalk vector.


#ifdef	ORIGIN_COM_SUPPORT
	/**
			Append data from an object of type _VARIANT to a vectorbase derived object.
			_VARIANT is a universal type that exists in COM to hold various types of
			data. It is used to set or get the values of properties of COM objects.
			It can represent individual values of int, double, etc., as well as arrays
			and other composite types.
		Parameters:
			var=A COM data object of type _VARIANT
	Remarks:
		This function is available only for OriginPro versions, or with a special COM enabled license
	*/
	BOOL	Append(_VARIANT& var); // Append a COM object of type _VARIANT to a vector or Dataset.

	/**#
			Assigning a vector or Dataset to a COM object of type _VARIANT generally
			creates a two dimensional array where the second dimension is 1 (vectors
			and Datasets are one dimensional so second dimension of _VARIANT is set to
			1). This is what Excel expects when assigning a _VARIANT to a "Range" object.
			However, some COM objects require one dimensional arrays of type _VARIANT.
			GetDataAsOneDimensionalArray returns a one dimensional array from a vector
			or Dataset. _VARIANT is a universal type that exists in COM to hold various
			types of data. It is used to get the values of properties of COM objects. It
			can represent individual values of int, double, etc., as well as arrays and
			other composite types.
		Example:
			vector<float> v;
			v.SetSize(262);
			for( int ii=0; ii < 262; ii++ )
				v[ii] = sin(ii);
			_VARIANT varYData;
			varYData = v.GetDataAsOneDimensionalArray(); // Put data into one dimensional _VARIANT object
		Parameters:
			lowerBound=The lowest index value in the array (default is 0)
		Returns:
			Returns a one dimensional array of type _VARIANT containg a copy of the data in a vector or Dataset.
	Remarks:
		This function is available only for OriginPro versions, or with a special COM enabled license
	*/
	_VARIANT	GetDataAsOneDimensionalArray(int lowerBound = 0); // Return a copy of a vector or Dataset as a one dimensional array of type _VARIANT.

	/**
		Remarks:
			Assigning a vector or Dataset to a COM object of type _VARIANT generally
			creates a two dimensional array where the second dimension is 1 (vectors
			and Datasets are one dimensional so second dimension of _VARIANT is set to
			1). This is what Excel expects when assigning a _VARIANT to a "Range" object.
			However, some COM objects require one dimensional arrays of type _VARIANT.
			GetAs1DArray returns a one dimensional array from a vector
			or Dataset.
		Example:
			Dataset aa("data1_a");
			Object CW2DGraph = MyDlg.GetItem(IDC_CWGRAPH1).GetActiveXControl();
			CW2DGraph.PlotY(aa.GetAs1DArray());
			
		Returns:
			Returns a one dimensional array of type _VARIANT containg a copy of the data in a vector
	Remarks:
		This function is available only for OriginPro versions, or with a special COM enabled license
	*/
	_VARIANT	GetAs1DArray(); // Return a copy of a vector or Dataset as a one dimensional array of type _VARIANT.


#endif //#ifdef	ORIGIN_COM_SUPPORT

	/**
			Get the internal or underlying base data type of a vectorbase derived object.
		Examples:
			vector vDouble;
			vector<char> vChar;
			vector<int> vInt;
			int nType;
			nType = vDouble.GetInternalDataType(); // Return FSI_DOUBLE
			printf( "nType for double = %d\n", nType ); 
			nType = vChar.GetInternalDataType(); // Return FSI_CHAR
			printf( "nType for char = %d\n", nType ); 
			nType = vInt.GetInternalDataType(); // Return FSI_LONG
			printf( "nType for int = %d\n", nType ); 
		Return:
			Returns FSI_DOUBLE, FSI_REAL, FSI_SHORT, FSI_LONG, FSI_CHAR, FSI_TEXT, FSI_MIXED, FSI_BYTE, FSI_USHORT,
			FSI_ULONG, or FSI_COMPLEX which are enumerated in OC_const.h.
	*/	
	int 	GetInternalDataType(); // Get the internal or underlying base data type of a vectorbase derived object.

	// vectorbase::Data CPY 9/21/02 v7.0403 QA70-3015, need Origin 7 SR3 or later
	/**
		Generate data values in a vector. This function is similar to the LabTalk function
		Data(min, max, inc). The vector will be automatically resized and populated with data
		values such that the first element in the vector will be dStartVal and the last element
		in the vector will be most close data to dEndVal. If dIncVal is passed in as zero
		the function will fail. To set all elements in a vector to the same scalar value first
		set the vector size and then make a scalar assignment using the desired value.
	Example:
		vector vData;
		vData.Data(1,10); // Generate 1,2,... 10 
		ASSERT(vData.GetSize() == 10);
	Parameters:
		dStartVal=Input value assigned to the first element in the vector
		dEndVal=Input value generated for the last element in the vector
		dIncVal=Input increment value used to calculate successive values in the vector
	Return:
		Returns TRUE on success and FALSE on Failure.
	*/
	BOOL	Data(double dStartVal, double dEndVal, double dIncVal = 1.0); // Generate data values in a vector.

#if _OC_VER >= 0x0800
	/**#
	Generate integer values in a vector
	Remark:
	The vector will be automatically resized and populated with data values such that the first element in the vector will be nStartVal and the last element in the vector will be greater than or equal to nEndVal. If nIncVal is passed in as zero the function will fail.    Example:
	       vector<int> vData;
	       vData.Data(1,10); // Generate 1,2,... 10 
	       ASSERT(vData.GetSize() == 10);
	   Parameters:
	       nStartVal= [in]value assigned to the first element in the vector
	       nEndVal= [in] value generated for the last element in the vector
	       nIncVal= in] increment value used to calculate successive values in the vector
	Return:
	   Returns TRUE on success and FALSE on Failure.
	*/
	BOOL    Data(int nStartVal, int nEndVal, int nIncVal = 1);
#endif //_OC_VER >= 0x0800
	
#if  _OC_VER > 0x0703
	/**
		fill the vector with pseudorandom values between 0 and 1 from a uniform distribution.
	Parameters:
	  nSize = number of values
	  nSeed = seed of the random sequence. Using a value of 0 will generate a different seuqence each time this function is called, while using the same seed will generate the same sequence
	Return:
	   Returns TRUE on success and FALSE on Failure.
	Remarks:
		This method is similar to the LabTalk Uniform function. If this method is used on an integer vector, then the resulting vecter will be filled with 0s and 1s.
	Example:
		void run_Uniform()
		{
			vector  vv;
			vv.SetSize(20);
			BOOL bRet = vv.Uniform(vv.GetSize());
			for(int ii=0; ii<vv.GetSize(); ii++)
			{
				out_double("",vv[ii]);
			}	
		}
	*/
	BOOL Uniform(int nSize, int nSeed = 0);
	
	/**
		fill the vector with pseudorandom values from a normal distribution with zero mean and unit standard deviation.
	Parameters:
		nSize = number of values
		nSeed = seed of the random sequence. Using a value of 0 will generate a different seuqence each time this function is called, while using the same seed will generate the same sequence
	Return:
		Returns TRUE on success and FALSE on Failure.
	Remarks:
		This method is similar to the LabTalk Normal function. 
		If this method is used on an integer vector, then the resulting vecter will be filled with nearest iintegers from the distribution which has typical values betwen -3 and 3
	Example:
		void run_Normal()
		{
			vector  vv;
			vv.SetSize(20);
			BOOL bRet = vv.Normal(vv.GetSize());
			for(int ii=0; ii<vv.GetSize(); ii++)
			{
				out_double("",vv[ii]);
			}	
		}	
	*/
	BOOL Normal(int nSize, int nSeed = 0);
#endif //_OC_VER > 0x0703

	/**
			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:
			vector vec = {1,2,3,4,5,6,7,8,9};
			vec.Wrap(4);
			==> vec = {5,6,7,8,9,1,2,3,4}
	*/
	BOOL Wrap(int nNum =0); 

⌨️ 快捷键说明

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