extern value cupl_min(value, value);
extern value cupl_rand(value);
+extern value cupl_sgm(value right);
+
#define DEBUG_PARSEDUMP 1
#define DEBUG_CHECKDUMP 2
#define DEBUG_ALLOCATE 3
RETURN_WRAP(tree, tree->car, tree->cdr, result)
return(result);
+ case SGM:
+ rightside = EVAL_WRAP(cupl_eval(tree->cdr));
+ result = cupl_sgm(rightside);
+ deallocate_value(&rightside);
+ RETURN_WRAP(tree, tree->car, tree->cdr, result)
+ return(result);
+
case STOP:
longjmp(jmpbuf, 1);
/* no fall through */
value cupl_min(value, value)
value cupl_rand(value)
+ value cupl_sgm(value right)
+
DESCRIPTION
Runtime support. This is segregated from the execute() code in case anyone
ever wants to write a back end that is a compiler. For the same reason
/* apply absolute-value function */
{
value result;
+ int n;
- if (right.rank != 0)
- die("ABS is only defined for scalar arguments\n");
- else
- {
- value result;
- int n;
-
- result = copy_value(right);
- for (n = 0; n < right.width * right.depth; n++)
- result.elements[n] = fabs(right.elements[n]);
- return(result);
- }
+ result = copy_value(right);
+ for (n = 0; n < right.width * right.depth; n++)
+ result.elements[n] = fabs(right.elements[n]);
+ return(result);
}
value cupl_atan(value right)
*
****************************************************************************/
-/* FIXME: not yet implemented */
+/* FIXME: most not yet implemented */
+
+value cupl_sgm(value right)
+/* compute the sum of the elements of a matrix */
+{
+ value result;
+ int n;
+
+ make_scalar(&result, 0);
+ for (n = 0; n < right.width * right.depth; n++)
+ result.elements[0] += fabs(right.elements[n]);
+ return(result);
+}
/* monitor.c ends here */
+
+