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

📄 math.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 2 页
字号:
/*------------------------------------------------------------------------------*
 *	File Name: 	Math.h	     													*
 *	Purpose:	Math function prototypes for calling standard C functions		*
 *				in msvcrt.dll and etc.											*
 *  Creation:	Feb 11, 2001 by CPY												* 
 *  Copyright (c) OriginLab Corp. 2001, 2002, 2003								*
 *	All Rights Reserved															*
 *------------------------------------------------------------------------------*/  
#ifndef _MATH_H
#define _MATH_H


// Origin's internal missing value
#define		NANUM		get_missing_value()

#define		PI			3.1415926535897932384626
#define		Pi	PI
#define		pi	PI


// The following functions are implemented in internal.c
/** >Mathematical
		Returns the larger of two doubles.
	Paramaters:
		da, db = the two double values whose maximum is sought
	Returns:
		the greater of the two values supplied
	Example:
		void	run_max()
		{
			double		r1 = 7., r2 = 9.;
			
			double		rmax = max(r1, r2);
			
			printf("max of %f and %f is %f\n", r1, r2, rmax);
		}
*/
double max(double da, double db);

/** >Mathematical
		Returns the larger of two floats.
	Paramaters:
		fa, fb = the two float values whose maximum is sought
	Returns:
		the greater of the two values supplied
	Example:
		void	run_max()
		{
			float		r1 = 7., r2 = 9.;
			
			float		rmax = max(r1, r2);
			
			printf("max of %f and %f is %f\n", r1, r2, rmax);
		}
*/
float max(float fa, float fb);

/** >Mathematical
		Returns the larger of two ints.
	Paramaters:
		ia, ib = the two integer values whose maximum is sought
	Returns:
		the greater of the two values supplied
	Example:
		void	run_max()
		{
			int		n1 = 7, n2 = 9;
			
			int		nmax = max(n1, n2);
			
			printf("max of %d and %d is %d\n", n1, n2, nmax);
		}
*/
int max(int ia, int ib);

/** >Mathematical
		Returns the larger of two uints.
	Paramaters:
		na, nb = the two unsigned integer values whose maximum is sought
	Returns:
		the greater of the two values supplied
	Example:
		void	run_max()
		{
			uint		n1 = 7, n2 = 9;
			
			uint		nmax = max(n1, n2);
			
			printf("max of %d and %d is %d\n", n1, n2, nmax);
		}
*/
uint max(uint na, uint nb);

/** >Mathematical
		Returns the larger of two shorts.
	Paramaters:
		na, nb = the two short values whose maximum is sought
	Returns:
		the greater of the two values supplied
	Example:
		void	run_max()
		{
			short	n1 = 7, n2 = 9;
			
			short	nmax = max(n1, n2);
			
			printf("max of %d and %d is %d\n", n1, n2, nmax);
		}

*/
short max(short na, short nb);

/** >Mathematical
		Returns the larger of two ushorts.
	Paramaters:
		wa, wb = the two unsigned short values whose maximum is sought
	Returns:
		the greater of the two values supplied
	Example:
		void	run_max()
		{
			short	n1 = 7, n2 = 9;
			
			short	nmax = max(n1, n2);
			
			printf("max of %d and %d is %d\n", n1, n2, nmax);
		}
*/
ushort max(ushort wa, ushort wb);

/** >Mathematical
		Returns the smaller of two doubles.
	Paramaters:
		da, db = the two double values whose minimum is sought
	Returns:
		the smaller of the two values supplied
	Example:
		void	run_min()
		{
			double		r1 = 7., r2 = 9.;
			
			double		rmin = min(r1, r2);
			
			printf("min of %f and %f is %f\n", r1, r2, rmin);
		}
*/
double min(double da, double db);

/** >Mathematical
		Returns the smaller of two floats.
	Paramaters:
		fa, fb = the two float values whose minimum is sought
	Returns:
		the smaller of the two values supplied
	Example:
		void	run_min()
		{
			float		r1 = 7., r2 = 9.;
			
			float		rmin = min(r1, r2);
			
			printf("min of %f and %f is %f\n", r1, r2, rmin);
		}
*/
float min(float fa, float fb);

/** >Mathematical
		Returns the smaller of two ints.
	Paramaters:
		ia, ib = the two integer values whose minimum is sought
	Returns:
		the smaller of the two values supplied
	Example:
		void	run_min()
		{
			int			n1 = 7, n2 = 9;
			
			int			nmin = min(n1, n2);
			
			printf("min of %d and %d is %d\n", n1, n2, nmin);
		}
*/
int min(int ia, int ib);

/** >Mathematical
		Returns the smaller of two uints.
	Paramaters:
		na, nb = the two unsigned integer values whose minimum is sought
	Returns:
		the smaller of the two values supplied
	Example:
		void	run_min()
		{
			uint		n1 = 7, n2 = 9;
			
			uint		nmin = min(n1, n2);
			
			printf("min of %d and %d is %d\n", n1, n2, nmin);
		}
*/
uint min(uint na, uint nb);

/** >Mathematical
		Returns the smaller of two shorts.
	Paramaters:
		na, nb = the two short values whose minimum is sought
	Returns:
		the smaller of the two values supplied
	Example:
		void	run_min()
		{
			short			n1 = 7, n2 = 9;
			
			short			nmin = min(n1, n2);
			
			printf("min of %d and %d is %d\n", n1, n2, nmin);
		}
*/
short min(short na, short nb);

/** >Mathematical
		Returns the smaller of two ushorts.
	Paramaters:
		wa, wb = the two unsigned short values whose minimum is sought
	Returns:
		the smaller of the two values supplied
	Example:
		void	run_min()
		{
			ushort			n1 = 7, n2 = 9;
			
			ushort			nmin = min(n1, n2);
			
			printf("min of %d and %d is %d\n", n1, n2, nmin);
		}
*/
ushort min(ushort wa, ushort wb);

/** >Mathematical
		Absolute value of a floating-point (double). This function is implemented in internal.c
		as a compatibility function for the labtalk version of abs(x) function. Please note that
		this function will simply call the fabs(x) function
	Paramaters:
		x=Input value whose absolute value is returned
	Return:
		Returns the absolute value of x.
	Example:
		void	run_abs()
		{
			double		x = -5.9;
			double		val = abs(x);
			
			printf("abs(%f) = %f\n", x, val);
		}
	SeeAlso:
		fabs
*/
double	abs(double x);


#pragma dll(@OUTL)

/** >Mathematical
		Calculates x raised to the power of y.
	Parameters:
		x = base
		y = exponent
	Returns:
		x to the power of y
	Examples:
		void run_pow( void )
		{
		   double x = 2.0, y = 3.0, z;
		
		   z = pow( x, y );
		   printf( "%.1f to the power of %.1f is %.1f\n", x, y, z );
		}

		Output
		2.0 to the power of 3.0 is 8.0
*/
double pow(double x, double y);

/** >Mathematical
		Also defined as ran(_nSeed).
		On every call it generates a random double value between 0. and 1.
	Parameters:
		nSeed = (optional) pass any nonzero value to set the seed for random number generation, or 0
				to use the current seed.
	Returns:
		A uniformly random number between 0. and 1.
	Example:
		// The example displays 10 random numbers between 0. and 1.
		void	run_rnd()
		{
			for (int ii = 0; ii < 10; ii++)
			{
				double	rr = rnd();
				out_double("value = ", rr);
			}
		}
*/
double rnd(int nSeed=0);
// the ran function is implemented in sys_utils.c, so must move to sys_utils.h
//#define ran(_nSeed) rnd(_nSeed)


/** >Mathematical
		On every call it generates a normally distributed random double value with mean = 0. and
		standard deviation = 1.
	Parameters:
		nSeed = (optional) pass any nonzero value to set the seed for random number generation, or 0
				to use the current seed.
	Returns:
		A normally distributed random number.
	Example:
		// The example displays 10 normally distributes random numbers with mean=0 and
		// standard deviation = 1.
		void	run_grnd()
		{
			for (int ii = 0; ii < 10; ii++)
			{
				double	rr = grnd();
				out_double("value = ", rr);
			}
		}
*/
double grnd(int nSeed=0);	// normally distributed random number with mean=0 and sd=1, nSeed > 0 to set random seed (returns 0)

/** >Mathematical
		Test given double value to determine whether it is a missing value recorgnized by Origin
	Parameters:
		x = the double value to test
	Return: 
		TRUE if missing value, otherwise FALSE.
	Example:
		void	run_is_missing_value()
		{
			// Deliberately generate a missing value:
			double		rr = 7./0.;
			
			if (is_missing_value(rr))
				out_str("Missing value!");
			else
				out_str("Not missing value");
		}
*/
BOOL	is_missing_value(double x); // return TRUE if given value is a missing value

/** >Mathematical
		Used to get the missing value as a value recognized by Origin.
	Parameters:
		nOption = (optional) not used, must be 0
	Returns: 
		the missing value as a double value recognized by Origin.
	Example:
		void	run_get_missing_value()
		{
			// Deliberately generate a missing value:
			double		rr = 7./0.;
			
			if (get_missing_value() == rr)
				out_str("Missing value!");
			else
				out_str("Not missing value");
		}
*/
double get_missing_value(int nOption =0);

/** >Mathematical
		Divides x by y and returns the remainder.
	Parameter:
		x = dividend
		y = divisor
	Returns:
		remainder of division of x by y
	Example:
		void	run_mod()
		{
			int		m = 36, n = 10;
			int		nmod = mod(m, n);
			
			printf("mod(%d, %d) = %d\n", m, n, nmod);
		}
*/
long mod( long x, long y );  

/** >Mathematical
		Returns the closest int to the double argument.
	Parameter:
		x = double value the nearest integer to which is sought.
	Returns:
		the nearest integer to x
	Example:
		void	run_nint()
		{
			double	r1 = 3.6;
			double	r2 = 3.4;
			
			printf("nearest integer to %f is %d\nnearest integer to %f is %d\n", r1, nint(r1), r2, nint(r2));
		}
*/
int nint( double x );

/** >Mathematical
		Returns the phase (angle) in radians of a planar vector with coordinates (x, y)
	Parameter:
		x = x-coordinate
		y = y-coordinate
	Returns:
		the phase (angle)
	Example:
		void	run_angle()
		{
			double		x = 1.;
			double		y = 1.;
			double		rAngle = angle(x, y);
			printf("angle(%f, %f) = %f\n", x, y, rAngle);
		}
*/
double angle( double x, double y);

/** >Mathematical
		Divides double x by double y and returns the remainder.
	Parameters:
		x = dividend
		y = divisor
	Example:
		void	run_rmod()
		{
			double		x = 6.9, y = 2.1;
			double		val = rmod(x, y);
			printf("rmod(%f, %f) = %f\n", x, y, val);
		}
*/
double rmod( double x, double y ); 

/** >Mathematical
		This function returns the natural logarithm of the gamma function.
	Parameters:
		x = the double value
	Returns:
		the natural logarithm of the gamma function of x.
	Example:
		void	run_gammaln()
		{
			double		x = 17.;
			double		val = gammaln(x);
			printf("gammaln(%f) = %f\n", x, val);
		}
*/
double gammaln( double x );

/** >Mathematical
		Computes the incomplete beta function.
	Parameters:
		x, a, b are standard arguments of incomplete beta function
	Returns:
		incomplete beta function of x, a, b
	Example:
		void	run_incbeta()
		{
			double	x = 0.5., a = 3, b = 5.;
			double	val = incbeta(x, a, b);
			printf("incomplete beta(%f, %f, %f) = %f\n", x, a, b, val);
		}
*/
double incbeta( double x, double a, double b );

/** >Mathematical
		computes the beta function
	Parameters:
		a, b are standard arguments of beta function
	Returns:
		beta function of a, b
	Example:
		void	run_beta()
		{
			double	a = 2, b = 4.;
			double	val = beta(a, b);

⌨️ 快捷键说明

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