I got tired of A*B == A*B*X for Math.Matrix objects.
Could someone apply this (slightly kludgy, but working) patch?
Index: math_matrix.c
===================================================================
RCS file: /pike/data/cvsroot/Pike/7.8/src/modules/Math/math_matrix.c,v
retrieving revision 1.40
diff -u -r1.40 math_matrix.c
--- math_matrix.c 18 Dec 2007 23:24:49 -0000 1.40
+++ math_matrix.c 14 Mar 2010 12:51:10 -0000
@@ -16,6 +16,7 @@
#include "operators.h"
#include "builtin_functions.h"
#include "module_support.h"
+#include "operators.h"
#include "math_module.h"
Index: matrix_code.h
===================================================================
RCS file: /pike/data/cvsroot/Pike/7.8/src/modules/Math/matrix_code.h,v
retrieving revision 1.21
diff -u -r1.21 matrix_code.h
--- matrix_code.h 17 Sep 2008 12:05:13 -0000 1.21
+++ matrix_code.h 14 Mar 2010 12:51:10 -0000
@@ -493,12 +493,24 @@
{
struct matrixX(_storage) *mx=NULL;
struct matrixX(_storage) *dmx;
- int n;
+ int n,i;
FTYPE *s1,*s2,*d;
if (args<1)
SIMPLE_TOO_FEW_ARGS_ERROR("`+",1);
+ if (args>1) /* one add per argument */
+ {
+ ref_push_object(THISOBJ);
+ for (i=0; i<args; i++)
+ {
+ push_svalue(Pike_sp-args+i);
+ f_add(2);
+ }
+ stack_pop_n_elems_keep_top(args);
+ return;
+ }
+
if (Pike_sp[-1].type!=T_OBJECT ||
!((mx=(struct matrixX(_storage)*)
get_storage(Pike_sp[-1].u.object,XmatrixY(math_,_program)))))
@@ -508,8 +520,6 @@
math_error("`+",Pike_sp-args,args,0,
"Cannot add matrices of different size.\n");
- pop_n_elems(args-1); /* shouldn't be needed */
-
dmx=matrixX(_push_new_)(mx->xsize,mx->ysize);
s1=THIS->m;
@@ -528,11 +538,23 @@
{
struct matrixX(_storage) *mx=NULL;
struct matrixX(_storage) *dmx;
- int n;
+ int n,i;
FTYPE *s1,*s2=NULL,*d;
if (args)
{
+ if (args>1) /* one subtract per argument */
+ {
+ ref_push_object(THISOBJ);
+ for (i=0; i<args; i++)
+ {
+ push_svalue(Pike_sp-args+i);
+ f_minus(2);
+ }
+ stack_pop_n_elems_keep_top(args);
+ return;
+ }
+
if (Pike_sp[-1].type!=T_OBJECT ||
!((mx=(struct matrixX(_storage)*)
get_storage(Pike_sp[-1].u.object,XmatrixY(math_,_program)))))
@@ -543,8 +565,6 @@
math_error("`-",Pike_sp-args,args,0,
"Cannot add matrices of different size.\n");
- pop_n_elems(args-1); /* shouldn't be needed */
-
s2=mx->m;
}
@@ -634,7 +654,17 @@
if (args<1)
SIMPLE_TOO_FEW_ARGS_ERROR("`*",1);
- pop_n_elems(args-1); /* shouldn't be needed */
+ if (args>1) /* one multiply per argument */
+ {
+ ref_push_object(THISOBJ);
+ for (i=0; i<args; i++)
+ {
+ push_svalue(Pike_sp-args+i);
+ f_multiply(2);
+ }
+ stack_pop_n_elems_keep_top(args);
+ return;
+ }
if (Pike_sp[-1].type==T_INT)
{