On Fri, 14 Oct 2005, Grégoire Verlut wrote:
So my question is:
will the trigonometric function be implemented in the next version of MathProg
or will they never be there for any reason ?
I can not answer your question, but included is a patch that adds sin and
cos to MathProg.
Regards
/Oscar
Common subdirectories: src/glpk-4.8/doc and glpk-4.8/doc
Common subdirectories: src/glpk-4.8/examples and glpk-4.8/examples
Common subdirectories: src/glpk-4.8/include and glpk-4.8/include
Common subdirectories: src/glpk-4.8/src and glpk-4.8/src
Common subdirectories: src/glpk-4.8/sysdep and glpk-4.8/sysdep
diff -ur src/glpk-4.8/include/glpmpl.h glpk-4.8/include/glpmpl.h
--- src/glpk-4.8/include/glpmpl.h Wed Jan 12 10:00:00 2005
+++ glpk-4.8/include/glpmpl.h Fri May 6 15:22:29 2005
@@ -130,6 +130,8 @@
#define fp_mod glp_mpl_fp_mod
#define fp_power glp_mpl_fp_power
#define fp_exp glp_mpl_fp_exp
+#define fp_sin glp_mpl_fp_sin
+#define fp_cos glp_mpl_fp_cos
#define fp_log glp_mpl_fp_log
#define fp_log10 glp_mpl_fp_log10
#define fp_sqrt glp_mpl_fp_sqrt
@@ -924,6 +926,12 @@
double fp_exp(MPL *mpl, double x);
/* floating-point base-e exponential */
+double fp_sin(MPL *mpl, double x);
+/* floating-point sine */
+
+double fp_cos(MPL *mpl, double x);
+/* floating-point cosine */
+
double fp_log(MPL *mpl, double x);
/* floating-point natural logarithm */
@@ -1943,6 +1951,8 @@
#define O_CEIL 323 /* round upward ("ceiling of x") */
#define O_FLOOR 324 /* round downward ("floor of x") */
#define O_EXP 325 /* base-e exponential */
+#define O_SIN 425 /* sine */
+#define O_COS 426 /* cosine */
#define O_LOG 326 /* natural logarithm */
#define O_LOG10 327 /* common (decimal) logarithm */
#define O_SQRT 328 /* square root */
Only in glpk-4.8/include: glpmpl.h~
diff -ur src/glpk-4.8/src/glpmpl1.c glpk-4.8/src/glpmpl1.c
--- src/glpk-4.8/src/glpmpl1.c Wed Jan 12 10:00:00 2005
+++ glpk-4.8/src/glpmpl1.c Fri May 6 15:24:27 2005
@@ -579,6 +579,8 @@
case O_CEIL:
case O_FLOOR:
case O_EXP:
+ case O_SIN:
+ case O_COS:
case O_LOG:
case O_LOG10:
case O_SQRT:
@@ -1071,6 +1073,8 @@
-- <primary expression> ::= ceil ( <argument> )
-- <primary expression> ::= floor ( <argument> )
-- <primary expression> ::= exp ( <argument> )
+-- <primary expression> ::= sin ( <argument> )
+-- <primary expression> ::= cos ( <argument> )
-- <primary expression> ::= log ( <argument> )
-- <primary expression> ::= log10 ( <argument> )
-- <primary expression> ::= max ( <argument list> )
@@ -1103,6 +1107,10 @@
op = O_FLOOR;
else if (strcmp(mpl->image, "exp") == 0)
op = O_EXP;
+ else if (strcmp(mpl->image, "sin") == 0)
+ op = O_SIN;
+ else if (strcmp(mpl->image, "cos") == 0)
+ op = O_COS;
else if (strcmp(mpl->image, "log") == 0)
op = O_LOG;
else if (strcmp(mpl->image, "log10") == 0)
diff -ur src/glpk-4.8/src/glpmpl3.c glpk-4.8/src/glpmpl3.c
--- src/glpk-4.8/src/glpmpl3.c Wed Jan 12 10:00:00 2005
+++ glpk-4.8/src/glpmpl3.c Fri May 6 15:32:39 2005
@@ -180,6 +180,26 @@
}
/*----------------------------------------------------------------------
+-- fp_sin - floating-point sine.
+--
+-- This routine computes the sine sin x. */
+
+double fp_sin(MPL *mpl, double x)
+{
+ return sin(x);
+}
+
+/*----------------------------------------------------------------------
+-- fp_cos - floating-point cosine.
+--
+-- This routine computes the cosine cos x. */
+
+double fp_cos(MPL *mpl, double x)
+{
+ return cos(x);
+}
+
+/*----------------------------------------------------------------------
-- fp_log - floating-point natural logarithm.
--
-- This routine computes the natural logarithm log x. */
@@ -3394,6 +3414,14 @@
/* base-e exponential */
value = fp_exp(mpl, eval_numeric(mpl, code->arg.arg.x));
break;
+ case O_SIN:
+ /* sine */
+ value = fp_sin(mpl, eval_numeric(mpl, code->arg.arg.x));
+ break;
+ case O_COS:
+ /* cosine */
+ value = fp_cos(mpl, eval_numeric(mpl, code->arg.arg.x));
+ break;
case O_LOG:
/* natural logarithm */
value = fp_log(mpl, eval_numeric(mpl, code->arg.arg.x));
@@ -4447,6 +4475,8 @@
case O_CEIL:
case O_FLOOR:
case O_EXP:
+ case O_SIN:
+ case O_COS:
case O_LOG:
case O_LOG10:
case O_SQRT:
Common subdirectories: src/glpk-4.8/sysdep/gnu and glpk-4.8/sysdep/gnu
Common subdirectories: src/glpk-4.8/sysdep/w32 and glpk-4.8/sysdep/w32
_______________________________________________
Help-glpk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-glpk