Index: trunk/Ohana/src/opihi/lib.shell/stack_math.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/stack_math.c	(revision 40330)
+++ trunk/Ohana/src/opihi/lib.shell/stack_math.c	(revision 40331)
@@ -599,5 +599,5 @@
 }
 
-// the vector is applied to each column (currently only valid for 2D matrix)
+// the vector is applied to each ROW (currently only valid for 2D matrix), e.g.: M[20,10] * X[20] -> M'[20,10] where M'[2,1] = M[2,1] * X[2]
 int MV_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) {
 
@@ -607,6 +607,7 @@
   Nx = V1[0].buffer[0].matrix.Naxis[0];
   Ny = V1[0].buffer[0].matrix.Naxis[1];
-  if (Ny != V2[0].vector[0].Nelements) {
-    push_error ("dimension mismatch");
+  if (Nx != V2[0].vector[0].Nelements) {
+    snprintf (line, 512, "error: matrix OP vector matrix dimensions do not match: (%d x %d) OP %d", Nx, Ny, V2[0].vector[0].Nelements);
+    push_error (line);
     return (FALSE);
   }
@@ -628,7 +629,7 @@
 # define MV_FUNC(OP) {					\
     if (V2->vector->type == OPIHI_FLT) {		\
-      opihi_flt *M2  =  V2[0].vector[0].elements.Flt;	\
-      for (i = 0; i < Ny; i++, M2++) {			\
-	for (j = 0; j < Nx; j++, out++, M1++) {		\
+      for (i = 0; i < Ny; i++) {			\
+	opihi_flt *M2  =  V2[0].vector[0].elements.Flt;	\
+	for (j = 0; j < Nx; j++, out++, M1++, M2++) {	\
 	  *out = OP;					\
 	}						\
@@ -637,7 +638,7 @@
     }							\
     if (V2->vector->type != OPIHI_FLT) {		\
-      opihi_int *M2  =  V2[0].vector[0].elements.Int;	\
-      for (i = 0; i < Ny; i++, M2++) {			\
-	for (j = 0; j < Nx; j++, out++, M1++) {		\
+      for (i = 0; i < Ny; i++) {			\
+	opihi_int *M2  =  V2[0].vector[0].elements.Int;	\
+	for (j = 0; j < Nx; j++, out++, M1++, M2++) {	\
 	  *out = OP;					\
 	}						\
@@ -695,5 +696,6 @@
 }
 
-// the vector is applied to each row (currently only valid for 2D matrix)
+// the vector is applied to each COLUMN (currently only valid for 2D matrix)
+// e.g.: X[10] * M[20,10] -> M'[20,10] where M'[2,1] = X[1] * M[2,1]
 int VM_binary (StackVar *OUT, StackVar *V1, StackVar *V2, char *op) {
 
@@ -703,5 +705,7 @@
   Nx = V2[0].buffer[0].matrix.Naxis[0];
   Ny = V2[0].buffer[0].matrix.Naxis[1];
-  if (Nx != V1[0].vector[0].Nelements) {
+  if (Ny != V1[0].vector[0].Nelements) {
+    snprintf (line, 512, "error: vector OP matrix dimensions do not match: %d OP (%d x %d)", V1[0].vector[0].Nelements, Nx, Ny);
+    push_error (line);
     return (FALSE);
   }
@@ -722,7 +726,7 @@
 # define VM_FUNC(OP) {					\
     if (V1->vector->type == OPIHI_FLT) {		\
-      for (i = 0; i < Ny; i++) {			\
-	opihi_flt *M1  = V1[0].vector[0].elements.Flt;	\
-	for (j = 0; j < Nx; j++, out++, M1++, M2++) {	\
+      opihi_flt *M1  = V1[0].vector[0].elements.Flt;	\
+      for (i = 0; i < Ny; i++, M1++) {			\
+	for (j = 0; j < Nx; j++, out++, M2++) {	\
 	  *out = OP;					\
 	}						\
@@ -731,7 +735,7 @@
     }							\
     if (V1->vector->type != OPIHI_FLT) {		\
-      for (i = 0; i < Ny; i++) {			\
-	opihi_int *M1  =  V1[0].vector[0].elements.Int;	\
-	for (j = 0; j < Nx; j++, out++, M1++, M2++) {	\
+      opihi_int *M1  =  V1[0].vector[0].elements.Int;	\
+      for (i = 0; i < Ny; i++, M1++) {			\
+	for (j = 0; j < Nx; j++, out++, M2++) {	\
 	  *out = OP;					\
 	}						\
