changeset 2364:5eb0af0730d6

[project @ 1996-10-11 22:57:03 by jwe]
author jwe
date Fri, 11 Oct 1996 22:57:03 +0000
parents 74f9c8283d31
children 7c60f8a6e6a0
files src/xdiv.cc
diffstat 1 files changed, 42 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdiv.cc
+++ b/src/xdiv.cc
@@ -51,30 +51,54 @@
     return 1;
 }
 
-static inline int
-mx_leftdiv_conform (int a_nr, int b_nr)
+template <class T1, class T2>
+bool
+mx_leftdiv_conform (T1 a, T2 b)
 {
+  int a_nr = a.rows ();
+  int b_nr = b.rows ();
+
   if (a_nr != b_nr)
     {
-      error ("number of rows must be the same for left division");
-      return 0;
+      int a_nc = a.cols ();
+      int b_nc = b.cols ();
+
+      gripe_nonconformant ("operator \\", a_nr, a_nc, b_nr, b_nc);
+      return false;
     }
 
-  return 1;
+  return true;
 }
 
-static inline int
-mx_div_conform (int b_nc, int a_nc)
+template bool mx_leftdiv_conform (const Matrix&, const Matrix&);
+template bool mx_leftdiv_conform (const Matrix&, const ComplexMatrix&);
+template bool mx_leftdiv_conform (const ComplexMatrix&, const ComplexMatrix&);
+template bool mx_leftdiv_conform (const ComplexMatrix&, const Matrix&);
+
+template <class T1, class T2>
+bool
+mx_div_conform (T1 a, T2 b)
 {
+  int a_nc = a.cols ();
+  int b_nc = b.cols ();
+
   if (a_nc != b_nc)
     {
-      error ("number of columns must be the same for right division");
-      return 0;
+      int a_nr = a.rows ();
+      int b_nr = b.rows ();
+
+      gripe_nonconformant ("operator /", a_nr, a_nc, b_nr, b_nc);
+      return false;
     }
 
-  return 1;
+  return true;
 }
 
+template bool mx_div_conform (const Matrix&, const Matrix&);
+template bool mx_div_conform (const Matrix&, const ComplexMatrix&);
+template bool mx_div_conform (const ComplexMatrix&, const ComplexMatrix&);
+template bool mx_div_conform (const ComplexMatrix&, const Matrix&);
+
 // Right division functions.
 //
 //       op2 / op1:   m   cm
@@ -88,7 +112,7 @@
 Matrix
 xdiv (const Matrix& a, const Matrix& b)
 {
-  if (! mx_div_conform (b.columns (), a.columns ()))
+  if (! mx_div_conform (a, b))
     return Matrix ();
 
   Matrix atmp = a.transpose ();
@@ -113,7 +137,7 @@
 ComplexMatrix
 xdiv (const Matrix& a, const ComplexMatrix& b)
 {
-  if (! mx_div_conform (b.columns (), a.columns ()))
+  if (! mx_div_conform (a, b))
     return ComplexMatrix ();
 
   Matrix atmp = a.transpose ();
@@ -138,7 +162,7 @@
 ComplexMatrix
 xdiv (const ComplexMatrix& a, const Matrix& b)
 {
-  if (! mx_div_conform (b.columns (), a.columns ()))
+  if (! mx_div_conform (a, b))
     return ComplexMatrix ();
 
   ComplexMatrix atmp = a.hermitian ();
@@ -163,7 +187,7 @@
 ComplexMatrix
 xdiv (const ComplexMatrix& a, const ComplexMatrix& b)
 {
-  if (! mx_div_conform (b.columns (), a.columns ()))
+  if (! mx_div_conform (a, b))
     return ComplexMatrix ();
 
   ComplexMatrix atmp = a.hermitian ();
@@ -266,7 +290,7 @@
 Matrix
 xleftdiv (const Matrix& a, const Matrix& b)
 {
-  if (! mx_leftdiv_conform (a.rows (), b.rows ()))
+  if (! mx_leftdiv_conform (a, b))
     return Matrix ();
 
   int info;
@@ -286,7 +310,7 @@
 ComplexMatrix
 xleftdiv (const Matrix& a, const ComplexMatrix& b)
 {
-  if (! mx_leftdiv_conform (a.rows (), b.rows ()))
+  if (! mx_leftdiv_conform (a, b))
     return ComplexMatrix ();
 
   int info;
@@ -306,7 +330,7 @@
 ComplexMatrix
 xleftdiv (const ComplexMatrix& a, const Matrix& b)
 {
-  if (! mx_leftdiv_conform (a.rows (), b.rows ()))
+  if (! mx_leftdiv_conform (a, b))
     return ComplexMatrix ();
 
   int info;
@@ -326,7 +350,7 @@
 ComplexMatrix
 xleftdiv (const ComplexMatrix& a, const ComplexMatrix& b)
 {
-  if (! mx_leftdiv_conform (a.rows (), b.rows ()))
+  if (! mx_leftdiv_conform (a, b))
     return ComplexMatrix ();
 
   int info;