migrated math functions in Awk and StdAwk
This commit is contained in:
		| @ -1,5 +1,5 @@ | ||||
| /* | ||||
|  * $Id: Awk.hpp 458 2011-05-13 04:06:55Z hyunghwan.chung $ | ||||
|  * $Id: Awk.hpp 460 2011-05-17 14:56:54Z hyunghwan.chung $ | ||||
|  * | ||||
|     Copyright 2006-2011 Chung, Hyung-Hwan. | ||||
|     This file is part of QSE. | ||||
| @ -1071,10 +1071,19 @@ protected: | ||||
| 	/// @} | ||||
|  | ||||
| 	// primitive handlers  | ||||
| 	virtual real_t pow (real_t x, real_t y) = 0; | ||||
| 	virtual int    vsprintf (char_t* buf, size_t size, | ||||
| 	                         const char_t* fmt, va_list arg) = 0; | ||||
|  | ||||
| 	virtual real_t pow (real_t x, real_t y) = 0; | ||||
| 	virtual real_t sin (real_t x) = 0; | ||||
| 	virtual real_t cos (real_t x) = 0; | ||||
| 	virtual real_t tan (real_t x) = 0; | ||||
| 	virtual real_t atan (real_t x) = 0; | ||||
| 	virtual real_t atan2 (real_t x, real_t y) = 0; | ||||
| 	virtual real_t log (real_t x) = 0; | ||||
| 	virtual real_t exp (real_t x) = 0; | ||||
| 	virtual real_t sqrt (real_t x) = 0; | ||||
|  | ||||
| 	// static glue members for various handlers | ||||
| 	static ssize_t readSource ( | ||||
| 		awk_t* awk, sio_cmd_t cmd, sio_arg_t* arg, | ||||
| @ -1095,9 +1104,17 @@ protected: | ||||
|  | ||||
| 	static int functionHandler (rtx_t* rtx, const cstr_t* name); | ||||
|  | ||||
| 	static real_t pow     (awk_t* data, real_t x, real_t y); | ||||
| 	static int    sprintf (awk_t* data, char_t* buf, size_t size, | ||||
| 	                       const char_t* fmt, ...); | ||||
| 	static real_t pow     (awk_t* data, real_t x, real_t y); | ||||
| 	static real_t sin     (awk_t* data, real_t x); | ||||
| 	static real_t cos     (awk_t* data, real_t x); | ||||
| 	static real_t tan     (awk_t* data, real_t x); | ||||
| 	static real_t atan    (awk_t* data, real_t x); | ||||
| 	static real_t atan2   (awk_t* data, real_t x, real_t y); | ||||
| 	static real_t log     (awk_t* data, real_t x); | ||||
| 	static real_t exp     (awk_t* data, real_t x); | ||||
| 	static real_t sqrt    (awk_t* data, real_t x); | ||||
|  | ||||
| protected: | ||||
| 	awk_t* awk; | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| /* | ||||
|  * $Id: StdAwk.hpp 441 2011-04-22 14:28:43Z hyunghwan.chung $ | ||||
|  * $Id: StdAwk.hpp 460 2011-05-17 14:56:54Z hyunghwan.chung $ | ||||
|  * | ||||
|     Copyright 2006-2011 Chung, Hyung-Hwan. | ||||
|     This file is part of QSE. | ||||
| @ -103,22 +103,6 @@ public: | ||||
|  | ||||
| protected: | ||||
| 	// intrinsic functions  | ||||
| 	int sin (Run& run, Value& ret, const Value* args, size_t nargs,  | ||||
| 		const char_t* name, size_t len); | ||||
| 	int cos (Run& run, Value& ret, const Value* args, size_t nargs,  | ||||
| 		const char_t* name, size_t len); | ||||
| 	int tan (Run& run, Value& ret, const Value* args, size_t nargs,  | ||||
| 		const char_t* name, size_t len); | ||||
| 	int atan (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 		const char_t* name, size_t len); | ||||
| 	int atan2 (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 		const char_t* name, size_t len); | ||||
| 	int log (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 		const char_t* name, size_t len); | ||||
| 	int exp (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 		const char_t* name, size_t len); | ||||
| 	int sqrt (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 		const char_t* name, size_t len); | ||||
| 	int fnint (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 		const char_t* name, size_t len); | ||||
| 	int rand (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| @ -155,10 +139,19 @@ protected: | ||||
| 	void* reallocMem (void* ptr, size_t n); | ||||
| 	void  freeMem    (void* ptr); | ||||
|  | ||||
| 	real_t pow (real_t x, real_t y); | ||||
| 	int    vsprintf (char_t* buf, size_t size, | ||||
| 	                 const char_t* fmt, va_list arg); | ||||
|  | ||||
| 	real_t pow (real_t x, real_t y); | ||||
| 	real_t sin (real_t x); | ||||
| 	real_t cos (real_t x); | ||||
| 	real_t tan (real_t x); | ||||
| 	real_t atan (real_t x); | ||||
| 	real_t atan2 (real_t x, real_t y); | ||||
| 	real_t log (real_t x); | ||||
| 	real_t exp (real_t x); | ||||
| 	real_t sqrt (real_t x); | ||||
|  | ||||
| protected: | ||||
| 	unsigned int seed;  | ||||
|  | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| /* | ||||
|  * $Id: Awk.cpp 458 2011-05-13 04:06:55Z hyunghwan.chung $ | ||||
|  * $Id: Awk.cpp 460 2011-05-17 14:56:54Z hyunghwan.chung $ | ||||
|  *  | ||||
|     Copyright 2006-2011 Chung, Hyung-Hwan. | ||||
|     This file is part of QSE. | ||||
| @ -1073,8 +1073,9 @@ int Awk::open () | ||||
| 	QSE_ASSERT (awk == QSE_NULL && functionMap == QSE_NULL); | ||||
|  | ||||
| 	qse_awk_prm_t prm; | ||||
| 	prm.pow     = pow; | ||||
| 	prm.sprintf = sprintf; | ||||
| 	memset (&prm, 0, QSE_SIZEOF(prm)); | ||||
| 	prm.sprintf  = sprintf; | ||||
| 	prm.math.pow = pow; | ||||
|  | ||||
| 	awk = qse_awk_open (this->getMmgr(), QSE_SIZEOF(xtn_t), &prm); | ||||
| 	if (awk == QSE_NULL) | ||||
| @ -1751,12 +1752,6 @@ int Awk::functionHandler (rtx_t* rtx, const cstr_t* name) | ||||
| 	rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx); | ||||
| 	return rxtn->run->awk->dispatch_function (rxtn->run, name); | ||||
| }	 | ||||
|  | ||||
| Awk::real_t Awk::pow (awk_t* awk, real_t x, real_t y) | ||||
| { | ||||
| 	xtn_t* xtn = (xtn_t*) QSE_XTN (awk); | ||||
| 	return xtn->awk->pow (x, y); | ||||
| } | ||||
| 	 | ||||
| int Awk::sprintf (awk_t* awk, char_t* buf, size_t size, | ||||
|                   const char_t* fmt, ...) | ||||
| @ -1770,6 +1765,60 @@ int Awk::sprintf (awk_t* awk, char_t* buf, size_t size, | ||||
| 	return n; | ||||
| } | ||||
|  | ||||
| Awk::real_t Awk::pow (awk_t* awk, real_t x, real_t y) | ||||
| { | ||||
| 	xtn_t* xtn = (xtn_t*) QSE_XTN (awk); | ||||
| 	return xtn->awk->pow (x, y); | ||||
| } | ||||
|  | ||||
| Awk::real_t Awk::sin (awk_t* awk, real_t x) | ||||
| { | ||||
| 	xtn_t* xtn = (xtn_t*) QSE_XTN (awk); | ||||
| 	return xtn->awk->sin (x); | ||||
| } | ||||
|  | ||||
| Awk::real_t Awk::cos (awk_t* awk, real_t x) | ||||
| { | ||||
| 	xtn_t* xtn = (xtn_t*) QSE_XTN (awk); | ||||
| 	return xtn->awk->cos (x); | ||||
| } | ||||
|  | ||||
| Awk::real_t Awk::tan (awk_t* awk, real_t x) | ||||
| { | ||||
| 	xtn_t* xtn = (xtn_t*) QSE_XTN (awk); | ||||
| 	return xtn->awk->tan (x); | ||||
| } | ||||
|  | ||||
| Awk::real_t Awk::atan (awk_t* awk, real_t x) | ||||
| { | ||||
| 	xtn_t* xtn = (xtn_t*) QSE_XTN (awk); | ||||
| 	return xtn->awk->atan (x); | ||||
| } | ||||
|  | ||||
| Awk::real_t Awk::atan2 (awk_t* awk, real_t x, real_t y) | ||||
| { | ||||
| 	xtn_t* xtn = (xtn_t*) QSE_XTN (awk); | ||||
| 	return xtn->awk->atan2 (x, y); | ||||
| } | ||||
|  | ||||
| Awk::real_t Awk::log (awk_t* awk, real_t x) | ||||
| { | ||||
| 	xtn_t* xtn = (xtn_t*) QSE_XTN (awk); | ||||
| 	return xtn->awk->log (x); | ||||
| } | ||||
|  | ||||
| Awk::real_t Awk::exp (awk_t* awk, real_t x) | ||||
| { | ||||
| 	xtn_t* xtn = (xtn_t*) QSE_XTN (awk); | ||||
| 	return xtn->awk->exp (x); | ||||
| } | ||||
|  | ||||
| Awk::real_t Awk::sqrt (awk_t* awk, real_t x) | ||||
| { | ||||
| 	xtn_t* xtn = (xtn_t*) QSE_XTN (awk); | ||||
| 	return xtn->awk->sqrt (x); | ||||
| } | ||||
|  | ||||
| ///////////////////////////////// | ||||
| QSE_END_NAMESPACE(QSE) | ||||
| ///////////////////////////////// | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| /* | ||||
|  * $Id: StdAwk.cpp 441 2011-04-22 14:28:43Z hyunghwan.chung $ | ||||
|  * $Id: StdAwk.cpp 460 2011-05-17 14:56:54Z hyunghwan.chung $ | ||||
|  * | ||||
|     Copyright 2006-2011 Chung, Hyung-Hwan. | ||||
|     This file is part of QSE. | ||||
| @ -56,14 +56,6 @@ int StdAwk::open () | ||||
| 	int n = Awk::open (); | ||||
| 	if (n == -1) return n; | ||||
|  | ||||
| 	ADDFNC (QSE_T("sin"),        1, 1, &StdAwk::sin); | ||||
| 	ADDFNC (QSE_T("cos"),        1, 1, &StdAwk::cos); | ||||
| 	ADDFNC (QSE_T("tan"),        1, 1, &StdAwk::tan); | ||||
| 	ADDFNC (QSE_T("atan"),       1, 1, &StdAwk::atan); | ||||
| 	ADDFNC (QSE_T("atan2"),      2, 2, &StdAwk::atan2); | ||||
| 	ADDFNC (QSE_T("log"),        1, 1, &StdAwk::log); | ||||
| 	ADDFNC (QSE_T("exp"),        1, 1, &StdAwk::exp); | ||||
| 	ADDFNC (QSE_T("sqrt"),       1, 1, &StdAwk::sqrt); | ||||
| 	ADDFNC (QSE_T("int"),        1, 1, &StdAwk::fnint); | ||||
| 	ADDFNC (QSE_T("rand"),       0, 0, &StdAwk::rand); | ||||
| 	ADDFNC (QSE_T("srand"),      0, 1, &StdAwk::srand); | ||||
| @ -84,134 +76,6 @@ void StdAwk::close () | ||||
| 	Awk::close (); | ||||
| } | ||||
|  | ||||
| int StdAwk::sin (Run& run, Value& ret, const Value* args, size_t nargs,  | ||||
| 	const char_t* name, size_t len) | ||||
| { | ||||
| 	return ret.setReal ( | ||||
| 	#if defined(HAVE_SINL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 		(real_t)::sinl(args[0].toReal()) | ||||
| 	#elif defined(HAVE_SIN) | ||||
| 		(real_t)::sin(args[0].toReal()) | ||||
| 	#elif defined(HAVE_SINF) | ||||
| 		(real_t)::sinf(args[0].toReal()) | ||||
| 	#else | ||||
| 		#error ### no sin function available ### | ||||
| 	#endif | ||||
| 	); | ||||
| } | ||||
|  | ||||
| int StdAwk::cos (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 	const char_t* name, size_t len) | ||||
| { | ||||
| 	return ret.setReal ( | ||||
| 	#if defined(HAVE_COSL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 		(real_t)::cosl(args[0].toReal()) | ||||
| 	#elif defined(HAVE_COS) | ||||
| 		(real_t)::cos(args[0].toReal()) | ||||
| 	#elif defined(HAVE_COSF) | ||||
| 		(real_t)::cosf(args[0].toReal()) | ||||
| 	#else | ||||
| 		#error ### no cos function available ### | ||||
| 	#endif | ||||
| 	); | ||||
| } | ||||
|  | ||||
| int StdAwk::tan (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 	const char_t* name, size_t len) | ||||
| { | ||||
| 	return ret.setReal ( | ||||
| 	#if defined(HAVE_TANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 		(real_t)::tanl(args[0].toReal()) | ||||
| 	#elif defined(HAVE_TAN) | ||||
| 		(real_t)::tan(args[0].toReal()) | ||||
| 	#elif defined(HAVE_TANF) | ||||
| 		(real_t)::tanf(args[0].toReal()) | ||||
| 	#else | ||||
| 		#error ### no tan function available ### | ||||
| 	#endif | ||||
| 	); | ||||
| } | ||||
|  | ||||
| int StdAwk::atan (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 	const char_t* name, size_t len) | ||||
| { | ||||
| 	return ret.setReal ( | ||||
| 	#if defined(HAVE_ATANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 		(real_t)::atanl(args[0].toReal()) | ||||
| 	#elif defined(HAVE_ATAN) | ||||
| 		(real_t)::atan(args[0].toReal()) | ||||
| 	#elif defined(HAVE_ATANF) | ||||
| 		(real_t)::atanf(args[0].toReal()) | ||||
| 	#else | ||||
| 		#error ### no atan function available ### | ||||
| 	#endif | ||||
| 	); | ||||
| } | ||||
|  | ||||
| int StdAwk::atan2 (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 	const char_t* name, size_t len) | ||||
| { | ||||
| 	return ret.setReal ( | ||||
| 	#if defined(HAVE_ATAN2L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 		(real_t)::atan2l(args[0].toReal(), args[1].toReal()) | ||||
| 	#elif defined(HAVE_ATAN2) | ||||
| 		(real_t)::atan2(args[0].toReal(), args[1].toReal()) | ||||
| 	#elif defined(HAVE_ATAN2F) | ||||
| 		(real_t)::atan2f(args[0].toReal(), args[1].toReal()) | ||||
| 	#else | ||||
| 		#error ### no atan2 function available ### | ||||
| 	#endif | ||||
| 	); | ||||
| } | ||||
|  | ||||
| int StdAwk::log (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 	const char_t* name, size_t len) | ||||
| { | ||||
| 	return ret.setReal ( | ||||
| 	#if defined(HAVE_LOGL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 		(real_t)::logl(args[0].toReal()) | ||||
| 	#elif defined(HAVE_LOG) | ||||
| 		(real_t)::log(args[0].toReal()) | ||||
| 	#elif defined(HAVE_LOGF) | ||||
| 		(real_t)::logf(args[0].toReal()) | ||||
| 	#else | ||||
| 		#error ### no log function available ### | ||||
| 	#endif | ||||
| 	); | ||||
| } | ||||
|  | ||||
| int StdAwk::exp (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 	const char_t* name, size_t len) | ||||
| { | ||||
| 	return ret.setReal ( | ||||
| 	#if defined(HAVE_EXPL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 		(real_t)::expl(args[0].toReal()) | ||||
| 	#elif defined(HAVE_EXP) | ||||
| 		(real_t)::exp(args[0].toReal()) | ||||
| 	#elif defined(HAVE_EXPF) | ||||
| 		(real_t)::expf(args[0].toReal()) | ||||
| 	#else | ||||
| 		#error ### no exp function available ### | ||||
| 	#endif | ||||
| 	); | ||||
| } | ||||
|  | ||||
| int StdAwk::sqrt (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 	const char_t* name, size_t len) | ||||
| { | ||||
| 	return ret.setReal ( | ||||
| 	#if defined(HAVE_SQRTL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 		(real_t)::sqrtl(args[0].toReal()) | ||||
| 	#elif defined(HAVE_SQRT) | ||||
| 		(real_t)::sqrt(args[0].toReal()) | ||||
| 	#elif defined(HAVE_SQRTF) | ||||
| 		(real_t)::sqrtf(args[0].toReal()) | ||||
| 	#else | ||||
| 		#error ### no sqrt function available ### | ||||
| 	#endif | ||||
| 	); | ||||
| } | ||||
|  | ||||
| int StdAwk::fnint (Run& run, Value& ret, const Value* args, size_t nargs, | ||||
| 	const char_t* name, size_t len) | ||||
| { | ||||
| @ -783,17 +647,129 @@ void  StdAwk::freeMem (void* ptr) | ||||
| } | ||||
|  | ||||
| // miscellaneous primitive | ||||
| StdAwk::real_t StdAwk::pow (real_t x, real_t y)  | ||||
| {  | ||||
| 	return ::pow (x, y);  | ||||
| } | ||||
|  | ||||
| int StdAwk::vsprintf ( | ||||
| 	char_t* buf, size_t size, const char_t* fmt, va_list arg)  | ||||
| { | ||||
| 	return qse_vsprintf (buf, size, fmt, arg); | ||||
| } | ||||
|  | ||||
| StdAwk::real_t StdAwk::pow (real_t x, real_t y)  | ||||
| {  | ||||
| #if defined(HAVE_POWL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 	return ::powl (x, y); | ||||
| #elif defined(HAVE_POW) | ||||
| 	return ::pow (x, y); | ||||
| #elif defined(HAVE_POWF) | ||||
| 	return ::powf (x, y); | ||||
| #else | ||||
| 	#error ### no pow function available ### | ||||
| #endif | ||||
| } | ||||
|  | ||||
| StdAwk::real_t StdAwk::sin (real_t x) | ||||
| {  | ||||
| #if defined(HAVE_SINL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 	return ::sinl (x); | ||||
| #elif defined(HAVE_SIN) | ||||
| 	return ::sin (x); | ||||
| #elif defined(HAVE_SINF) | ||||
| 	return ::sinf (x); | ||||
| #else | ||||
| 	#error ### no sin function available ### | ||||
| #endif | ||||
| } | ||||
|  | ||||
| StdAwk::real_t StdAwk::cos (real_t x) | ||||
| {  | ||||
| #if defined(HAVE_COSL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 	return ::cosl (x); | ||||
| #elif defined(HAVE_COS) | ||||
| 	return ::cos (x); | ||||
| #elif defined(HAVE_COSF) | ||||
| 	return ::cosf (x); | ||||
| #else | ||||
| 	#error ### no cos function available ### | ||||
| #endif | ||||
| } | ||||
|  | ||||
| StdAwk::real_t StdAwk::tan (real_t x) | ||||
| {  | ||||
| #if defined(HAVE_TANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 	return ::tanl (x); | ||||
| #elif defined(HAVE_TAN) | ||||
| 	return ::tan (x); | ||||
| #elif defined(HAVE_TANF) | ||||
| 	return ::tanf (x); | ||||
| #else | ||||
| 	#error ### no tan function available ### | ||||
| #endif | ||||
| } | ||||
|  | ||||
| StdAwk::real_t StdAwk::atan (real_t x) | ||||
| {  | ||||
| #if defined(HAVE_ATANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 	return ::atanl (x); | ||||
| #elif defined(HAVE_ATAN) | ||||
| 	return ::atan (x); | ||||
| #elif defined(HAVE_ATANF) | ||||
| 	return ::atanf (x); | ||||
| #else | ||||
| 	#error ### no atan function available ### | ||||
| #endif | ||||
| } | ||||
|  | ||||
| StdAwk::real_t StdAwk::atan2 (real_t x, real_t y)  | ||||
| {  | ||||
| #if defined(HAVE_ATAN2L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 	return ::atan2l (x, y); | ||||
| #elif defined(HAVE_ATAN2) | ||||
| 	return ::atan2 (x, y); | ||||
| #elif defined(HAVE_ATAN2F) | ||||
| 	return ::atan2f (x, y); | ||||
| #else | ||||
| 	#error ### no atan2 function available ### | ||||
| #endif | ||||
| } | ||||
|  | ||||
| StdAwk::real_t StdAwk::log (real_t x) | ||||
| {  | ||||
| #if defined(HAVE_LOGL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 	return ::logl (x); | ||||
| #elif defined(HAVE_LOG) | ||||
| 	return ::log (x); | ||||
| #elif defined(HAVE_LOGF) | ||||
| 	return ::logf (x); | ||||
| #else | ||||
| 	#error ### no log function available ### | ||||
| #endif | ||||
| } | ||||
|  | ||||
| StdAwk::real_t StdAwk::exp (real_t x) | ||||
| {  | ||||
| #if defined(HAVE_EXPL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 	return ::expl (x); | ||||
| #elif defined(HAVE_EXP) | ||||
| 	return ::exp (x); | ||||
| #elif defined(HAVE_EXPF) | ||||
| 	return ::expf (x); | ||||
| #else | ||||
| 	#error ### no exp function available ### | ||||
| #endif | ||||
| } | ||||
|  | ||||
| StdAwk::real_t StdAwk::sqrt (real_t x) | ||||
| {  | ||||
| #if defined(HAVE_SQRTL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE) | ||||
| 	return ::sqrtl (x); | ||||
| #elif defined(HAVE_SQRT) | ||||
| 	return ::sqrt (x); | ||||
| #elif defined(HAVE_SQRTF) | ||||
| 	return ::sqrtf (x); | ||||
| #else | ||||
| 	#error ### no sqrt function available ### | ||||
| #endif | ||||
| } | ||||
|  | ||||
| int StdAwk::SourceFile::open (Data& io) | ||||
| { | ||||
| 	qse_sio_t* sio; | ||||
|  | ||||
| @ -105,6 +105,8 @@ EXTRA_DIST = \ | ||||
| 	lang-041.awk \ | ||||
| 	lang-042.awk \ | ||||
| 	lang-043.awk \ | ||||
| 	lang-044.awk \ | ||||
| 	lang-045.awk \ | ||||
| 	columnate.awk \ | ||||
| 	levenshtein.awk \ | ||||
| 	levenshtein-utests.awk \ | ||||
| @ -119,6 +121,7 @@ EXTRA_DIST = \ | ||||
| 	lang-036.dat \ | ||||
| 	lang-037.dat \ | ||||
| 	lang-043.dat \ | ||||
| 	lang-044.dat \ | ||||
| 	adr.dat \ | ||||
| 	asm.dat \ | ||||
| 	cou.dat \ | ||||
|  | ||||
							
								
								
									
										13
									
								
								qse/regress/awk/lang-045.awk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								qse/regress/awk/lang-045.awk
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,13 @@ | ||||
| BEGIN { | ||||
| 	for (i = -10.0; i < 10.0; i++) | ||||
| 	{ | ||||
| 		print sin(i); | ||||
| 		print cos(i); | ||||
| 		print tan(i); | ||||
| 		print atan(i); | ||||
| 		print atan2(i, 1); | ||||
| 		print log(i); | ||||
| 		print exp(i); | ||||
| 		print sqrt(i); | ||||
| 	} | ||||
| } | ||||
| @ -2119,6 +2119,183 @@ this is the second second line] | ||||
| [   ttttt | ||||
| killer] | ||||
| -------------------------------------------------------------------------------- | ||||
| [CMD]  qseawk  --newline=on -o- -f lang-045.awk  </dev/stdin 2>&1  | ||||
| -------------------------------------------------------------------------------- | ||||
| BEGIN { | ||||
| 	for (i = (-(10.0)); (i < 10.0); (i)++) | ||||
| 	{ | ||||
| 		print sin(i); | ||||
| 		print cos(i); | ||||
| 		print tan(i); | ||||
| 		print atan(i); | ||||
| 		print atan2(i,1); | ||||
| 		print log(i); | ||||
| 		print exp(i); | ||||
| 		print sqrt(i); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| 0.544021 | ||||
| -0.839072 | ||||
| -0.648361 | ||||
| -1.47113 | ||||
| -1.47113 | ||||
| nan | ||||
| 4.53999e-05 | ||||
| -nan | ||||
| -0.412118 | ||||
| -0.91113 | ||||
| 0.452316 | ||||
| -1.46014 | ||||
| -1.46014 | ||||
| nan | ||||
| 0.00012341 | ||||
| -nan | ||||
| -0.989358 | ||||
| -0.1455 | ||||
| 6.79971 | ||||
| -1.44644 | ||||
| -1.44644 | ||||
| nan | ||||
| 0.000335463 | ||||
| -nan | ||||
| -0.656987 | ||||
| 0.753902 | ||||
| -0.871448 | ||||
| -1.4289 | ||||
| -1.4289 | ||||
| nan | ||||
| 0.000911882 | ||||
| -nan | ||||
| 0.279415 | ||||
| 0.96017 | ||||
| 0.291006 | ||||
| -1.40565 | ||||
| -1.40565 | ||||
| nan | ||||
| 0.00247875 | ||||
| -nan | ||||
| 0.958924 | ||||
| 0.283662 | ||||
| 3.38052 | ||||
| -1.3734 | ||||
| -1.3734 | ||||
| nan | ||||
| 0.00673795 | ||||
| -nan | ||||
| 0.756802 | ||||
| -0.653644 | ||||
| -1.15782 | ||||
| -1.32582 | ||||
| -1.32582 | ||||
| nan | ||||
| 0.0183156 | ||||
| -nan | ||||
| -0.14112 | ||||
| -0.989992 | ||||
| 0.142547 | ||||
| -1.24905 | ||||
| -1.24905 | ||||
| nan | ||||
| 0.0497871 | ||||
| -nan | ||||
| -0.909297 | ||||
| -0.416147 | ||||
| 2.18504 | ||||
| -1.10715 | ||||
| -1.10715 | ||||
| nan | ||||
| 0.135335 | ||||
| -nan | ||||
| -0.841471 | ||||
| 0.540302 | ||||
| -1.55741 | ||||
| -0.785398 | ||||
| -0.785398 | ||||
| nan | ||||
| 0.367879 | ||||
| -nan | ||||
| 0 | ||||
| 1 | ||||
| 0 | ||||
| 0 | ||||
| 0 | ||||
| -inf | ||||
| 1 | ||||
| 0 | ||||
| 0.841471 | ||||
| 0.540302 | ||||
| 1.55741 | ||||
| 0.785398 | ||||
| 0.785398 | ||||
| 0 | ||||
| 2.71828 | ||||
| 1 | ||||
| 0.909297 | ||||
| -0.416147 | ||||
| -2.18504 | ||||
| 1.10715 | ||||
| 1.10715 | ||||
| 0.693147 | ||||
| 7.38906 | ||||
| 1.41421 | ||||
| 0.14112 | ||||
| -0.989992 | ||||
| -0.142547 | ||||
| 1.24905 | ||||
| 1.24905 | ||||
| 1.09861 | ||||
| 20.0855 | ||||
| 1.73205 | ||||
| -0.756802 | ||||
| -0.653644 | ||||
| 1.15782 | ||||
| 1.32582 | ||||
| 1.32582 | ||||
| 1.38629 | ||||
| 54.5982 | ||||
| 2 | ||||
| -0.958924 | ||||
| 0.283662 | ||||
| -3.38052 | ||||
| 1.3734 | ||||
| 1.3734 | ||||
| 1.60944 | ||||
| 148.413 | ||||
| 2.23607 | ||||
| -0.279415 | ||||
| 0.96017 | ||||
| -0.291006 | ||||
| 1.40565 | ||||
| 1.40565 | ||||
| 1.79176 | ||||
| 403.429 | ||||
| 2.44949 | ||||
| 0.656987 | ||||
| 0.753902 | ||||
| 0.871448 | ||||
| 1.4289 | ||||
| 1.4289 | ||||
| 1.94591 | ||||
| 1096.63 | ||||
| 2.64575 | ||||
| 0.989358 | ||||
| -0.1455 | ||||
| -6.79971 | ||||
| 1.44644 | ||||
| 1.44644 | ||||
| 2.07944 | ||||
| 2980.96 | ||||
| 2.82843 | ||||
| 0.412118 | ||||
| -0.91113 | ||||
| -0.452316 | ||||
| 1.46014 | ||||
| 1.46014 | ||||
| 2.19722 | ||||
| 8103.08 | ||||
| 3 | ||||
| -------------------------------------------------------------------------------- | ||||
| [CMD]  qseawk  --newline=on -F: -f columnate.awk ./passwd.dat </dev/stdin 2>&1  | ||||
| -------------------------------------------------------------------------------- | ||||
| root               x  0      0      root                                /root                       /bin/bash | ||||
|  | ||||
| @ -2119,6 +2119,183 @@ this is the second second line] | ||||
| [   ttttt | ||||
| killer] | ||||
| -------------------------------------------------------------------------------- | ||||
| [CMD]  qseawk -m 500000 --newline=on -o- -f lang-045.awk  </dev/stdin 2>&1  | ||||
| -------------------------------------------------------------------------------- | ||||
| BEGIN { | ||||
| 	for (i = (-(10.0)); (i < 10.0); (i)++) | ||||
| 	{ | ||||
| 		print sin(i); | ||||
| 		print cos(i); | ||||
| 		print tan(i); | ||||
| 		print atan(i); | ||||
| 		print atan2(i,1); | ||||
| 		print log(i); | ||||
| 		print exp(i); | ||||
| 		print sqrt(i); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| 0.544021 | ||||
| -0.839072 | ||||
| -0.648361 | ||||
| -1.47113 | ||||
| -1.47113 | ||||
| nan | ||||
| 4.53999e-05 | ||||
| -nan | ||||
| -0.412118 | ||||
| -0.91113 | ||||
| 0.452316 | ||||
| -1.46014 | ||||
| -1.46014 | ||||
| nan | ||||
| 0.00012341 | ||||
| -nan | ||||
| -0.989358 | ||||
| -0.1455 | ||||
| 6.79971 | ||||
| -1.44644 | ||||
| -1.44644 | ||||
| nan | ||||
| 0.000335463 | ||||
| -nan | ||||
| -0.656987 | ||||
| 0.753902 | ||||
| -0.871448 | ||||
| -1.4289 | ||||
| -1.4289 | ||||
| nan | ||||
| 0.000911882 | ||||
| -nan | ||||
| 0.279415 | ||||
| 0.96017 | ||||
| 0.291006 | ||||
| -1.40565 | ||||
| -1.40565 | ||||
| nan | ||||
| 0.00247875 | ||||
| -nan | ||||
| 0.958924 | ||||
| 0.283662 | ||||
| 3.38052 | ||||
| -1.3734 | ||||
| -1.3734 | ||||
| nan | ||||
| 0.00673795 | ||||
| -nan | ||||
| 0.756802 | ||||
| -0.653644 | ||||
| -1.15782 | ||||
| -1.32582 | ||||
| -1.32582 | ||||
| nan | ||||
| 0.0183156 | ||||
| -nan | ||||
| -0.14112 | ||||
| -0.989992 | ||||
| 0.142547 | ||||
| -1.24905 | ||||
| -1.24905 | ||||
| nan | ||||
| 0.0497871 | ||||
| -nan | ||||
| -0.909297 | ||||
| -0.416147 | ||||
| 2.18504 | ||||
| -1.10715 | ||||
| -1.10715 | ||||
| nan | ||||
| 0.135335 | ||||
| -nan | ||||
| -0.841471 | ||||
| 0.540302 | ||||
| -1.55741 | ||||
| -0.785398 | ||||
| -0.785398 | ||||
| nan | ||||
| 0.367879 | ||||
| -nan | ||||
| 0 | ||||
| 1 | ||||
| 0 | ||||
| 0 | ||||
| 0 | ||||
| -inf | ||||
| 1 | ||||
| 0 | ||||
| 0.841471 | ||||
| 0.540302 | ||||
| 1.55741 | ||||
| 0.785398 | ||||
| 0.785398 | ||||
| 0 | ||||
| 2.71828 | ||||
| 1 | ||||
| 0.909297 | ||||
| -0.416147 | ||||
| -2.18504 | ||||
| 1.10715 | ||||
| 1.10715 | ||||
| 0.693147 | ||||
| 7.38906 | ||||
| 1.41421 | ||||
| 0.14112 | ||||
| -0.989992 | ||||
| -0.142547 | ||||
| 1.24905 | ||||
| 1.24905 | ||||
| 1.09861 | ||||
| 20.0855 | ||||
| 1.73205 | ||||
| -0.756802 | ||||
| -0.653644 | ||||
| 1.15782 | ||||
| 1.32582 | ||||
| 1.32582 | ||||
| 1.38629 | ||||
| 54.5982 | ||||
| 2 | ||||
| -0.958924 | ||||
| 0.283662 | ||||
| -3.38052 | ||||
| 1.3734 | ||||
| 1.3734 | ||||
| 1.60944 | ||||
| 148.413 | ||||
| 2.23607 | ||||
| -0.279415 | ||||
| 0.96017 | ||||
| -0.291006 | ||||
| 1.40565 | ||||
| 1.40565 | ||||
| 1.79176 | ||||
| 403.429 | ||||
| 2.44949 | ||||
| 0.656987 | ||||
| 0.753902 | ||||
| 0.871448 | ||||
| 1.4289 | ||||
| 1.4289 | ||||
| 1.94591 | ||||
| 1096.63 | ||||
| 2.64575 | ||||
| 0.989358 | ||||
| -0.1455 | ||||
| -6.79971 | ||||
| 1.44644 | ||||
| 1.44644 | ||||
| 2.07944 | ||||
| 2980.96 | ||||
| 2.82843 | ||||
| 0.412118 | ||||
| -0.91113 | ||||
| -0.452316 | ||||
| 1.46014 | ||||
| 1.46014 | ||||
| 2.19722 | ||||
| 8103.08 | ||||
| 3 | ||||
| -------------------------------------------------------------------------------- | ||||
| [CMD]  qseawk -m 500000 --newline=on -F: -f columnate.awk ./passwd.dat </dev/stdin 2>&1  | ||||
| -------------------------------------------------------------------------------- | ||||
| root               x  0      0      root                                /root                       /bin/bash | ||||
|  | ||||
| @ -167,6 +167,7 @@ PROGS=" | ||||
| 	lang-042.awk!!!--newline=on -o- | ||||
| 	lang-043.awk!lang-043.dat!!--newline=on -o- | ||||
| 	lang-044.awk!lang-044.dat!!--newline=on -o- | ||||
| 	lang-045.awk!!!--newline=on -o- | ||||
|  | ||||
| 	columnate.awk!./passwd.dat!!--newline=on -F: | ||||
| 	levenshtein-utests.awk!!!--newline=on --include=on | ||||
|  | ||||
		Reference in New Issue
	
	Block a user