changeset 2829:6655bdca97fb

[project @ 1997-03-25 23:58:24 by jwe]
author jwe
date Tue, 25 Mar 1997 23:58:37 +0000
parents 92826d6e8bd9
children 10a8198b1733
files liboctave/ChangeLog liboctave/Makefile.in liboctave/mx-cdm-cm.cc liboctave/mx-cdm-cm.h liboctave/mx-cdm-cs.cc liboctave/mx-cdm-cs.h liboctave/mx-cdm-dm.cc liboctave/mx-cdm-dm.h liboctave/mx-cdm-m.cc liboctave/mx-cdm-m.h liboctave/mx-cdm-s.cc liboctave/mx-cdm-s.h liboctave/mx-cm-cdm.cc liboctave/mx-cm-cdm.h liboctave/mx-cm-dm.cc liboctave/mx-cm-dm.h liboctave/mx-cm-m.cc liboctave/mx-cm-m.h liboctave/mx-cm-s.cc liboctave/mx-cm-s.h liboctave/mx-cs-cdm.cc liboctave/mx-cs-cdm.h liboctave/mx-cs-dm.cc liboctave/mx-cs-dm.h liboctave/mx-cs-m.cc liboctave/mx-cs-m.h liboctave/mx-dm-cdm.cc liboctave/mx-dm-cdm.h liboctave/mx-dm-cm.cc liboctave/mx-dm-cm.h liboctave/mx-dm-cs.cc liboctave/mx-dm-cs.h liboctave/mx-dm-m.cc liboctave/mx-dm-m.h liboctave/mx-dm-s.cc liboctave/mx-dm-s.h liboctave/mx-m-cdm.cc liboctave/mx-m-cdm.h liboctave/mx-m-cm.cc liboctave/mx-m-cm.h liboctave/mx-m-cs.cc liboctave/mx-m-cs.h liboctave/mx-m-dm.cc liboctave/mx-m-dm.h liboctave/mx-op-defs.h liboctave/mx-s-cdm.cc liboctave/mx-s-cdm.h liboctave/mx-s-cm.cc liboctave/mx-s-cm.h liboctave/mx-s-dm.cc liboctave/mx-s-dm.h
diffstat 51 files changed, 2330 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog
+++ b/liboctave/ChangeLog
@@ -1,3 +1,45 @@
+Tue Mar 25 17:37:25 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* mx-op-defs.h: New file for operator definitions.
+	* mx-cdm-cm.h, mx-cdm-cs.h, mx-cdm-dm.h, mx-cdm-m.h, mx-cdm-s.h,
+	mx-cm-cdm.h, mx-cm-dm.h, mx-cm-m.h, mx-cm-s.h, mx-cs-cdm.h,
+	mx-cs-dm.h, mx-cs-m.h, mx-dm-cdm.h, mx-dm-cm.h, mx-dm-cs.h,
+	mx-dm-m.h, mx-dm-s.h, mx-m-cdm.h, mx-m-cm.h, mx-m-cs.h, mx-m-dm.h,
+	mx-s-cdm.h, mx-s-cm.h, mx-s-dm.h, mx-cdm-cm.cc, mx-cdm-cs.cc,
+	mx-cdm-dm.cc, mx-cdm-m.cc, mx-cdm-s.cc, mx-cm-cdm.cc, mx-cm-dm.cc,
+	mx-cm-m.cc, mx-cm-s.cc, mx-cs-cdm.cc, mx-cs-dm.cc, mx-cs-m.cc,
+	mx-dm-cdm.cc, mx-dm-cm.cc, mx-dm-cs.cc, mx-dm-m.cc, mx-dm-s.cc,
+	mx-m-cdm.cc, mx-m-cm.cc, mx-m-cs.cc, mx-m-dm.cc, mx-s-cdm.cc,
+	mx-s-cm.cc, mx-s-dm.cc:
+	New files for mixed-type operations.
+	* Makefiles.in: Add them to the appropriate lists.
+
+	* mx-inlines.cc: Add bool by bool EQ ops.
+
+	* idx-vector.h, idx-vector.cc: Add constructors for bool and
+	boolMatrix types.
+	(idx_vector::maybe_convert_one_zero_to_idx,
+	idx_vector::idx_vector_rep::maybe_convert_one_zero_to_idx):
+	Delete second arg, prefer_zero_one.  Change all callers.
+
+	* boolMatrix.h, boolMatrix.cc: New files.
+	* mx-base.h: Include boolMatrix.h here.
+	* mx-defs.h: Provide forward declaration for boolMatrix here.
+
+	* chMatrix.h, chMatrix.cc: Delete unused junk.
+
+	* dMatrix.h, CMatrix.h: Delete friend declarations for operator+,
+	operator-, operator*, product, and quotient functions.
+	Add constructor for boolMatrix type.
+	* dMatrix.cc, CMatrix.cc: Delete operator+, operator-, operator*,
+	product, and quotient functions.
+
+	* CDiagMatrix.h: Delete friend declarations for operator+,
+	operator-, and product functions.
+	* CDiagMatrix.h: Delete operator+, operator-, and product functions.
+
+	* Array-b.cc: Also instantiate 2d and 2d diagonal arrays.
+
 Fri Mar 14 00:29:46 1997  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* EIG.cc (EIG::hermitian_init (const ComplexMatrix&)): New function.
--- a/liboctave/Makefile.in
+++ b/liboctave/Makefile.in
@@ -29,11 +29,17 @@
 	Matrix.h base-lu.h mx-base.h mx-defs.h mx-ext.h CColVector.h \
 	CDiagMatrix.h CMatrix.h CRowVector.h CmplxAEPBAL.h \
 	CmplxCHOL.h CmplxDET.h CmplxHESS.h CmplxLU.h CmplxQR.h \
-	CmplxQRP.h CmplxSCHUR.h CmplxSVD.h EIG.h chMatrix.h \
+	CmplxQRP.h CmplxSCHUR.h CmplxSVD.h EIG.h boolMatrix.h chMatrix.h \
 	dColVector.h dDiagMatrix.h dMatrix.h dRowVector.h dbleAEPBAL.h \
 	dbleCHOL.h dbleDET.h dbleGEPBAL.h dbleHESS.h dbleLU.h dbleQR.h \
 	dbleQRP.h dbleSCHUR.h dbleSVD.h
 
+MX_OP_INC := mx-cdm-cm.h mx-cdm-cs.h mx-cdm-dm.h mx-cdm-m.h \
+	mx-cdm-s.h mx-cm-cdm.h mx-cm-dm.h mx-cm-m.h mx-cm-s.h \
+	mx-cs-cdm.h mx-cs-dm.h mx-cs-m.h mx-dm-cdm.h mx-dm-cm.h \
+	mx-dm-cs.h mx-dm-m.h mx-dm-s.h mx-m-cdm.h mx-m-cm.h \
+	mx-m-cs.h mx-m-dm.h mx-s-cdm.h mx-s-cm.h mx-s-dm.h
+
 INCLUDES := Bounds.h CollocWt.h DAE.h DAEFunc.h DASSL.h FEGrid.h FSQP.h \
 	LinConst.h LP.h LPsolve.h LSODE.h NLConst.h NLEqn.h NLFunc.h \
 	NLP.h NPSOL.h ODE.h ODEFunc.h Objective.h QP.h QPSOL.h Quad.h \
@@ -42,22 +48,31 @@
 	lo-ieee.h lo-mappers.h lo-utils.h mach-info.h oct-alloc.h \
 	oct-cmplx.h oct-glob.h oct-math.h oct-term.h pathsearch.h \
 	prog-args.h statdefs.h str-vec.h sun-utils.h sysdir.h \
-	$(MATRIX_INC)
+	$(MATRIX_INC) \
+	$(MX_OP_INC)
 
 TEMPLATE_SRC := Array.cc Array2.cc Array3.cc DiagArray2.cc \
 	MArray.cc MArray2.cc MDiagArray2.cc base-lu.cc
 
 TI_SRC := Array-C.cc Array-b.cc Array-ch.cc Array-i.cc Array-d.cc \
 	Array-s.cc Array-str.cc \
-	MArray-C.cc MArray-ch.cc MArray-i.cc MArray-d.cc MArray-s.cc
+	MArray-C.cc MArray-b.cc MArray-ch.cc MArray-i.cc \
+	MArray-d.cc MArray-s.cc
 
 MATRIX_SRC := Array-flags.cc CColVector.cc CDiagMatrix.cc CMatrix.cc \
 	CRowVector.cc CmplxAEPBAL.cc CmplxCHOL.cc CmplxDET.cc \
 	CmplxHESS.cc CmplxLU.cc CmplxQR.cc CmplxQRP.cc CmplxSCHUR.cc \
-	CmplxSVD.cc EIG.cc MArray-misc.cc chMatrix.cc dColVector.cc \
-	dDiagMatrix.cc dMatrix.cc dRowVector.cc dbleAEPBAL.cc \
-	dbleCHOL.cc dbleDET.cc dbleGEPBAL.cc dbleHESS.cc dbleLU.cc \
-	dbleQR.cc dbleQRP.cc dbleSCHUR.cc dbleSVD.cc
+	CmplxSVD.cc EIG.cc MArray-misc.cc boolMatrix.cc chMatrix.cc \
+	dColVector.cc dDiagMatrix.cc dMatrix.cc dRowVector.cc \
+	dbleAEPBAL.cc dbleCHOL.cc dbleDET.cc dbleGEPBAL.cc \
+	dbleHESS.cc dbleLU.cc dbleQR.cc dbleQRP.cc dbleSCHUR.cc \
+	dbleSVD.cc
+
+MX_OP_SRC := mx-cdm-cm.cc mx-cdm-cs.cc mx-cdm-dm.cc mx-cdm-m.cc \
+	mx-cdm-s.cc mx-cm-cdm.cc mx-cm-dm.cc mx-cm-m.cc mx-cm-s.cc \
+	mx-cs-cdm.cc mx-cs-dm.cc mx-cs-m.cc mx-dm-cdm.cc mx-dm-cm.cc \
+	mx-dm-cs.cc mx-dm-m.cc mx-dm-s.cc mx-m-cdm.cc mx-m-cm.cc \
+	mx-m-cs.cc mx-m-dm.cc mx-s-cdm.cc mx-s-cm.cc mx-s-dm.cc
 
 SOURCES := Bounds.cc CollocWt.cc DAE.cc DASSL.cc FEGrid.cc FSQP.cc \
 	LinConst.cc LPsolve.cc LSODE.cc NLEqn.cc NPSOL.cc QPSOL.cc \
@@ -66,11 +81,11 @@
 	filemode.c gamma.c getopt.c getopt1.c idx-vector.cc lgamma.c \
 	lo-ieee.cc lo-mappers.cc lo-utils.cc mach-info.cc mkdir.c \
 	oct-alloc.cc oct-glob.cc oct-term.cc pathsearch.cc \
-	prog-args.cc rename.c rmdir.c str-vec.cc tempname.c \
-	tempnam.c \
+	prog-args.cc rename.c rmdir.c str-vec.cc tempname.c tempnam.c \
 	$(TEMPLATE_SRC) \
 	$(TI_SRC) \
-	$(MATRIX_SRC)
+	$(MATRIX_SRC) \
+	$(MX_OP_SRC)
 
 EXTRAS := mx-inlines.cc
 
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cdm-cm.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-cdm-cm.h"
+
+#include "CMatrix.h"
+#include "CDiagMatrix.h"
+
+DMM_OPS (ComplexMatrix, ComplexDiagMatrix, ComplexMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cdm-cm.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_cdm_cm_h)
+#define octave_cdm_cm_h 1
+
+class ComplexMatrix;
+class ComplexDiagMatrix;
+
+#include "mx-op-defs.h"
+
+DMM_OP_DECLS (ComplexMatrix, ComplexDiagMatrix, ComplexMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cdm-cs.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-cdm-cs.h"
+
+#include "CMatrix.h"
+#include "CDiagMatrix.h"
+
+DMS_OPS (ComplexMatrix, ComplexDiagMatrix, Complex)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cdm-cs.h
@@ -0,0 +1,41 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_cdm_cs_h)
+#define octave_cdm_cs_h 1
+
+class ComplexMatrix;
+class ComplexDiagMatrix;
+
+#include "oct-cmplx.h"
+
+#include "mx-op-defs.h"
+
+DMS_OP_DECLS (ComplexMatrix, ComplexDiagMatrix, Complex)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cdm-dm.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-cdm-dm.h"
+
+#include "dDiagMatrix.h"
+#include "CDiagMatrix.h"
+
+DMDM_OPS (ComplexDiagMatrix, ComplexDiagMatrix, DiagMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cdm-dm.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_cdm_dm_h)
+#define octave_cdm_dm_h 1
+
+class ComplexDiagMatrix;
+class DiagMatrix;
+
+#include "mx-op-defs.h"
+
+DMDM_OP_DECLS (ComplexDiagMatrix, ComplexDiagMatrix, DiagMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cdm-m.cc
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-cdm-m.h"
+
+#include "dMatrix.h"
+#include "CMatrix.h"
+#include "CDiagMatrix.h"
+
+DMM_OPS (ComplexMatrix, ComplexDiagMatrix, Matrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cdm-m.h
@@ -0,0 +1,40 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_cdm_m_h)
+#define octave_cdm_m_h 1
+
+class Matrix;
+class ComplexMatrix;
+class ComplexDiagMatrix;
+
+#include "mx-op-defs.h"
+
+DMM_OP_DECLS (ComplexMatrix, ComplexDiagMatrix, Matrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cdm-s.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-cdm-s.h"
+
+#include "CMatrix.h"
+#include "CDiagMatrix.h"
+
+DMS_OPS (ComplexMatrix, ComplexDiagMatrix, double)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cdm-s.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_cdm_s_h)
+#define octave_cdm_s_h 1
+
+class ComplexMatrix;
+class ComplexDiagMatrix;
+
+#include "mx-op-defs.h"
+
+DMS_OP_DECLS (ComplexMatrix, ComplexDiagMatrix, double)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cm-cdm.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-cm-cdm.h"
+
+#include "CMatrix.h"
+#include "CDiagMatrix.h"
+
+MDM_OPS (ComplexMatrix, ComplexMatrix, ComplexDiagMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cm-cdm.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_cm_cdm_h)
+#define octave_cm_cdm_h 1
+
+class ComplexMatrix;
+class ComplexDiagMatrix;
+
+#include "mx-op-defs.h"
+
+MDM_OP_DECLS (ComplexMatrix, ComplexMatrix, ComplexDiagMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cm-dm.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-cm-dm.h"
+
+#include "CMatrix.h"
+#include "dDiagMatrix.h"
+
+MDM_OPS (ComplexMatrix, ComplexMatrix, DiagMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cm-dm.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_cm_dm_h)
+#define octave_cm_dm_h 1
+
+class DiagMatrix;
+class ComplexMatrix;
+
+#include "mx-op-defs.h"
+
+MDM_OP_DECLS (ComplexMatrix, ComplexMatrix, DiagMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cm-m.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-cm-m.h"
+
+#include "dMatrix.h"
+#include "CMatrix.h"
+
+MM_OPS (ComplexMatrix, ComplexMatrix, Matrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cm-m.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_cm_m_h)
+#define octave_cm_m_h 1
+
+class Matrix;
+class ComplexMatrix;
+
+#include "mx-op-defs.h"
+
+MM_OP_DECLS (ComplexMatrix, ComplexMatrix, Matrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cm-s.cc
@@ -0,0 +1,37 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-cm-s.h"
+
+#include "CMatrix.h"
+
+MS_OPS (ComplexMatrix, ComplexMatrix, double)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cm-s.h
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_cm_s_h)
+#define octave_cm_s_h 1
+
+class ComplexMatrix;
+
+#include "mx-op-defs.h"
+
+MS_OP_DECLS (ComplexMatrix, ComplexMatrix, double)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cs-cdm.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-cs-cdm.h"
+
+#include "CMatrix.h"
+#include "CDiagMatrix.h"
+
+SDM_OPS (ComplexMatrix, Complex, ComplexDiagMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cs-cdm.h
@@ -0,0 +1,41 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_cs_cdm_h)
+#define octave_cs_cdm_h 1
+
+class ComplexMatrix;
+class ComplexDiagMatrix;
+
+#include "oct-cmplx.h"
+
+#include "mx-op-defs.h"
+
+SDM_OP_DECLS (ComplexMatrix, Complex, ComplexDiagMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cs-dm.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-cs-dm.h"
+
+#include "CMatrix.h"
+#include "dDiagMatrix.h"
+
+SDM_OPS (ComplexMatrix, Complex, DiagMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cs-dm.h
@@ -0,0 +1,41 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_cs_dm_h)
+#define octave_cs_dm_h 1
+
+class DiagMatrix;
+class ComplexMatrix;
+
+#include "oct-cmplx.h"
+
+#include "mx-op-defs.h"
+
+SDM_OP_DECLS (ComplexMatrix, Complex, DiagMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cs-m.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-cs-m.h"
+
+#include "dMatrix.h"
+#include "CMatrix.h"
+
+SM_OPS (ComplexMatrix, Complex, Matrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-cs-m.h
@@ -0,0 +1,41 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_cs_m_h)
+#define octave_cs_m_h 1
+
+class Matrix;
+class ComplexMatrix;
+
+#include "oct-cmplx.h"
+
+#include "mx-op-defs.h"
+
+SM_OP_DECLS (ComplexMatrix, Complex, Matrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-dm-cdm.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-dm-cdm.h"
+
+#include "dDiagMatrix.h"
+#include "CDiagMatrix.h"
+
+DMDM_OPS (ComplexDiagMatrix, DiagMatrix, ComplexDiagMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-dm-cdm.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_dm_cdm_h)
+#define octave_dm_cdm_h 1
+
+class DiagMatrix;
+class ComplexDiagMatrix;
+
+#include "mx-op-defs.h"
+
+DMDM_OP_DECLS (ComplexDiagMatrix, DiagMatrix, ComplexDiagMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-dm-cm.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-dm-cm.h"
+
+#include "CMatrix.h"
+#include "dDiagMatrix.h"
+
+DMM_OPS (ComplexMatrix, DiagMatrix, ComplexMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-dm-cm.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_dm_cm_h)
+#define octave_dm_cm_h 1
+
+class DiagMatrix;
+class ComplexMatrix;
+
+#include "mx-op-defs.h"
+
+DMM_OP_DECLS (ComplexMatrix, DiagMatrix, ComplexMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-dm-cs.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-dm-cs.h"
+
+#include "CMatrix.h"
+#include "dDiagMatrix.h"
+
+DMS_OPS (ComplexMatrix, DiagMatrix, Complex)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-dm-cs.h
@@ -0,0 +1,41 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_dm_cs_h)
+#define octave_dm_cs_h 1
+
+class DiagMatrix;
+class ComplexMatrix;
+
+#include "oct-cmplx.h"
+
+#include "mx-op-defs.h"
+
+DMS_OP_DECLS (ComplexMatrix, DiagMatrix, Complex)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-dm-m.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-dm-m.h"
+
+#include "dMatrix.h"
+#include "dDiagMatrix.h"
+
+DMM_OPS (Matrix, DiagMatrix, Matrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-dm-m.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_dm_m_h)
+#define octave_dm_m_h 1
+
+class Matrix;
+class DiagMatrix;
+
+#include "mx-op-defs.h"
+
+DMM_OP_DECLS (Matrix, DiagMatrix, Matrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-dm-s.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-dm-s.h"
+
+#include "dMatrix.h"
+#include "dDiagMatrix.h"
+
+DMS_OPS (Matrix, DiagMatrix, double)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-dm-s.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_dm_s_h)
+#define octave_dm_s_h 1
+
+class Matrix;
+class DiagMatrix;
+
+#include "mx-op-defs.h"
+
+DMS_OP_DECLS (Matrix, DiagMatrix, double)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-m-cdm.cc
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-m-cdm.h"
+
+#include "dMatrix.h"
+#include "CMatrix.h"
+#include "CDiagMatrix.h"
+
+MDM_OPS (ComplexMatrix, Matrix, ComplexDiagMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-m-cdm.h
@@ -0,0 +1,40 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_m_cdm_h)
+#define octave_m_cdm_h 1
+
+class Matrix;
+class ComplexMatrix;
+class ComplexDiagMatrix;
+
+#include "mx-op-defs.h"
+
+MDM_OP_DECLS (ComplexMatrix, Matrix, ComplexDiagMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-m-cm.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-m-cm.h"
+
+#include "dMatrix.h"
+#include "CMatrix.h"
+
+MM_OPS (ComplexMatrix, Matrix, ComplexMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-m-cm.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_m_cm_h)
+#define octave_m_cm_h 1
+
+class Matrix;
+class ComplexMatrix;
+
+#include "mx-op-defs.h"
+
+MM_OP_DECLS (ComplexMatrix, Matrix, ComplexMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-m-cs.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-m-cs.h"
+
+#include "dMatrix.h"
+#include "CMatrix.h"
+
+MS_OPS (ComplexMatrix, Matrix, Complex)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-m-cs.h
@@ -0,0 +1,41 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_m_cs_h)
+#define octave_m_cs_h 1
+
+class Matrix;
+class ComplexMatrix;
+
+#include "oct-cmplx.h"
+
+#include "mx-op-defs.h"
+
+MS_OP_DECLS (ComplexMatrix, Matrix, Complex)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-m-dm.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-m-dm.h"
+
+#include "dMatrix.h"
+#include "dDiagMatrix.h"
+
+MDM_OPS (Matrix, Matrix, DiagMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-m-dm.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_m_dm_h)
+#define octave_m_dm_h 1
+
+class Matrix;
+class DiagMatrix;
+
+#include "mx-op-defs.h"
+
+MDM_OP_DECLS (Matrix, Matrix, DiagMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-op-defs.h
@@ -0,0 +1,403 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_mx_op_defs_h)
+#define octave_mx_op_defs_h 1
+
+#include "mx-inlines.cc"
+
+#define BIN_OP_DECL(R, OP, X, Y) \
+  extern R OP (const X&, const Y&)
+
+#define MS_OP_DECLS(R, M, S) \
+  BIN_OP_DECL (R, operator +, M, S); \
+  BIN_OP_DECL (R, operator -, M, S); \
+  BIN_OP_DECL (R, operator *, M, S); \
+  BIN_OP_DECL (R, operator /, M, S);
+
+#define SM_OP_DECLS(R, S, M) \
+  BIN_OP_DECL (R, operator +, S, M); \
+  BIN_OP_DECL (R, operator -, S, M); \
+  BIN_OP_DECL (R, operator *, S, M); \
+  BIN_OP_DECL (R, operator /, S, M);
+
+#define MM_OP_DECLS(R, M1, M2) \
+  BIN_OP_DECL (R, operator +, M1, M2); \
+  BIN_OP_DECL (R, operator -, M1, M2); \
+  BIN_OP_DECL (R, product,    M1, M2); \
+  BIN_OP_DECL (R, quotient,   M1, M2);
+
+#define SDM_OP_DECLS(R, S, DM) \
+  BIN_OP_DECL (R, operator +, S, DM); \
+  BIN_OP_DECL (R, operator -, S, DM);
+
+#define DMS_OP_DECLS(R, DM, S) \
+  BIN_OP_DECL (R, operator +, DM, S); \
+  BIN_OP_DECL (R, operator -, DM, S);
+
+#define MDM_OP_DECLS(R, M, DM) \
+  BIN_OP_DECL (R, operator +, M, DM); \
+  BIN_OP_DECL (R, operator -, M, DM); \
+  BIN_OP_DECL (R, operator *, M, DM);
+
+#define DMM_OP_DECLS(R, DM, M) \
+  BIN_OP_DECL (R, operator +, DM, M); \
+  BIN_OP_DECL (R, operator -, DM, M); \
+  BIN_OP_DECL (R, operator *, DM, M);
+
+#define DMDM_OP_DECLS(R, DM1, DM2) \
+  BIN_OP_DECL (R, operator +, DM1, DM2); \
+  BIN_OP_DECL (R, operator -, DM1, DM2); \
+  BIN_OP_DECL (R, product, DM1, DM2);
+
+#define MS_OP(R, OP, M, S, F) \
+  R \
+  OP (const M& m, const S& s) \
+  { \
+    int nr = m.rows (); \
+    int nc = m.cols (); \
+ \
+    R r (nr, nc); \
+ \
+    if (nr > 0 && nc > 0) \
+      F ## _vs (r.fortran_vec (), m.data (), nr * nc, s); \
+ \
+    return r; \
+  }
+
+#define MS_OPS(R, M, S) \
+  MS_OP (R, operator +, M, S, add) \
+  MS_OP (R, operator -, M, S, subtract) \
+  MS_OP (R, operator *, M, S, multiply) \
+  MS_OP (R, operator /, M, S, divide)
+
+#define SM_OP(R, OP, S, M, F) \
+  R \
+  OP (const S& s, const M& m) \
+  { \
+    int nr = m.rows (); \
+    int nc = m.cols (); \
+ \
+    R r (nr, nc); \
+ \
+    if (nr > 0 && nc > 0) \
+      F ## _sv (r.fortran_vec (), s, m.data (), nr * nc); \
+ \
+    return r; \
+  }
+
+#define SM_OPS(R, S, M) \
+  SM_OP (R, operator +, S, M, add) \
+  SM_OP (R, operator -, S, M, subtract) \
+  SM_OP (R, operator *, S, M, multiply) \
+  SM_OP (R, operator /, S, M, divide)
+
+#define MM_OP(R, OP, M1, M2, F) \
+  R \
+  OP (const M1& m1, const M2& m2) \
+  { \
+    R r; \
+ \
+    int m1_nr = m1.rows (); \
+    int m1_nc = m1.cols (); \
+ \
+    int m2_nr = m2.rows (); \
+    int m2_nc = m2.cols (); \
+ \
+    if (m1_nr != m2_nr || m1_nc != m2_nc) \
+      gripe_nonconformant (#OP, m1_nr, m1_nc, m2_nr, m2_nc); \
+    else \
+      { \
+	r.resize (m1_nr, m1_nc); \
+ \
+	if (m1_nr > 0 && m1_nc > 0) \
+	  F ## _vv (r.fortran_vec (), m1.data (), m2.data (), m1_nr * m1_nc); \
+      } \
+ \
+    return r; \
+  }
+
+#define MM_OPS(R, M1, M2) \
+  MM_OP (R, operator +, M1, M2, add) \
+  MM_OP (R, operator -, M1, M2, subtract) \
+  MM_OP (R, product,    M1, M2, multiply) \
+  MM_OP (R, quotient,   M1, M2, divide)
+
+#define SDM_OP(R, OP, S, DM, OPEQ) \
+  R \
+  OP (const S& s, const DM& dm) \
+  { \
+    int nr = dm.rows (); \
+    int nc = dm.cols (); \
+ \
+    R r (nr, nc, s); \
+ \
+    int len = dm.length (); \
+ \
+    for (int i = 0; i < len; i++) \
+      r.elem (i, i) OPEQ dm.elem (i, i); \
+ \
+    return r; \
+}
+
+#define SDM_OPS(R, S, DM) \
+  SDM_OP (R, operator +, S, DM, +=) \
+  SDM_OP (R, operator -, S, DM, -=)
+
+#define DMS_OP(R, OP, DM, S, SGN) \
+  R \
+  OP (const DM& dm, const S& s) \
+  { \
+    int nr = dm.rows (); \
+    int nc = dm.cols (); \
+ \
+    R r (nr, nc, SGN s); \
+ \
+    int len = dm.length (); \
+ \
+    for (int i = 0; i < len; i++) \
+      r.elem (i, i) += dm.elem (i, i); \
+ \
+    return r; \
+  }
+
+#define DMS_OPS(R, DM, S) \
+  DMS_OP (R, operator +, DM, S, ) \
+  DMS_OP (R, operator -, DM, S, -)
+
+#define MDM_OP(R, OP, M, DM, OPEQ) \
+R \
+OP (const M& m, const DM& dm) \
+{ \
+  R r; \
+ \
+  int m_nr = m.rows (); \
+  int m_nc = m.cols (); \
+ \
+  int dm_nr = dm.rows (); \
+  int dm_nc = dm.cols (); \
+ \
+  if (m_nr != dm_nr || m_nc != dm_nc) \
+    gripe_nonconformant (#OP, m_nr, m_nc, dm_nr, dm_nc); \
+  else \
+    { \
+      r.resize (m_nr, m_nc); \
+ \
+      if (m_nr > 0 && m_nc > 0) \
+	{ \
+	  r = m; \
+ \
+	  int len = dm.length (); \
+ \
+	  for (int i = 0; i < len; i++) \
+	    r.elem (i, i) OPEQ dm.elem (i, i); \
+	} \
+    } \
+ \
+  return r; \
+}
+
+#define MDM_MULTIPLY_OP(R, M, DM) \
+R \
+operator * (const M& m, const DM& dm) \
+{ \
+  R r; \
+ \
+  int m_nr = m.rows (); \
+  int m_nc = m.cols (); \
+ \
+  int dm_nr = dm.rows (); \
+  int dm_nc = dm.cols (); \
+ \
+  if (m_nc != dm_nr) \
+    gripe_nonconformant ("operator *", m_nr, m_nc, dm_nr, dm_nc); \
+  else \
+    { \
+      r.resize (m_nr, dm_nc, 0.0); \
+ \
+      if (m_nr > 0 && m_nc > 0 && dm_nc == 0) \
+	{ \
+	  for (int j = 0; j < dm.length (); j++) \
+	    { \
+	      if (dm.elem (j, j) == 1.0) \
+		{ \
+		  for (int i = 0; i < m_nr; i++) \
+		    r.elem (i, j) = m.elem (i, j); \
+		} \
+	      else if (dm.elem (j, j) != 0.0) \
+		{ \
+		  for (int i = 0; i < m_nr; i++) \
+		    r.elem (i, j) = dm.elem (j, j) * m.elem (i, j); \
+		} \
+	    } \
+	} \
+    } \
+ \
+  return r; \
+}
+
+#define MDM_OPS(R, M, DM) \
+  MDM_OP (R, operator +, M, DM, +=) \
+  MDM_OP (R, operator -, M, DM, -=) \
+  MDM_MULTIPLY_OP (R, M, DM)
+
+// XXX FIXME XXX -- DM - M will not give the correct result.
+
+#define DMM_OP(R, OP, DM, M, OPEQ) \
+R \
+OP (const DM& dm, const M& m) \
+{ \
+  R r; \
+ \
+  int dm_nr = dm.rows (); \
+  int dm_nc = dm.cols (); \
+ \
+  int m_nr = m.rows (); \
+  int m_nc = m.cols (); \
+ \
+  if (dm_nr != m_nr || dm_nc != m_nc) \
+    gripe_nonconformant (#OP, dm_nr, dm_nc, m_nr, m_nc); \
+  else \
+    { \
+      if (m_nr > 0 && m_nc > 0) \
+	{ \
+	  r = m; \
+ \
+	  int len = dm.length (); \
+ \
+	  for (int i = 0; i < len; i++) \
+	    r.elem (i, i) OPEQ dm.elem (i, i); \
+	} \
+      else \
+	r.resize (m_nr, m_nc); \
+    } \
+ \
+  return r; \
+}
+
+#define DMM_MULTIPLY_OP(R, DM, M) \
+R \
+operator * (const DM& dm, const M& m) \
+{ \
+  R r; \
+ \
+  int dm_nr = dm.rows (); \
+  int dm_nc = dm.cols (); \
+ \
+  int m_nr = m.rows (); \
+  int m_nc = m.cols (); \
+ \
+  if (dm_nc != m_nr) \
+    gripe_nonconformant ("operator *", dm_nr, dm_nc, m_nr, m_nc); \
+  else \
+    { \
+      r.resize (dm_nr, m_nc, 0.0); \
+ \
+      if (dm_nr > 0 && dm_nc > 0 && m_nc > 0) \
+	{ \
+	  for (int i = 0; i < dm.length (); i++) \
+	    { \
+	      if (dm.elem (i, i) == 1.0) \
+		{ \
+		  for (int j = 0; j < m_nc; j++) \
+		    r.elem (i, j) = m.elem (i, j); \
+		} \
+	      else if (dm.elem (i, i) != 0.0) \
+		{ \
+		  for (int j = 0; j < m_nc; j++) \
+		    r.elem (i, j) = dm.elem (i, i) * m.elem (i, j); \
+		} \
+	    } \
+	} \
+    } \
+ \
+  return r; \
+}
+
+#define DMM_OPS(R, DM, M) \
+  DMM_OP (R, operator +, DM, M, +=) \
+  DMM_OP (R, operator -, DM, M, -=) \
+  DMM_MULTIPLY_OP(R, DM, M)
+
+#define MM_OP(R, OP, M1, M2, F) \
+  R \
+  OP (const M1& m1, const M2& m2) \
+  { \
+    R r; \
+ \
+    int m1_nr = m1.rows (); \
+    int m1_nc = m1.cols (); \
+ \
+    int m2_nr = m2.rows (); \
+    int m2_nc = m2.cols (); \
+ \
+    if (m1_nr != m2_nr || m1_nc != m2_nc) \
+      gripe_nonconformant (#OP, m1_nr, m1_nc, m2_nr, m2_nc); \
+    else \
+      { \
+	r.resize (m1_nr, m1_nc); \
+ \
+	if (m1_nr > 0 && m1_nc > 0) \
+	  F ## _vv (r.fortran_vec (), m1.data (), m2.data (), m1_nr * m1_nc); \
+      } \
+ \
+    return r; \
+  }
+
+#define DMDM_OP(R, OP, DM1, DM2, F) \
+  R \
+  OP (const DM1& dm1, const DM2& dm2) \
+  { \
+    R r; \
+ \
+    int dm1_nr = dm1.rows (); \
+    int dm1_nc = dm1.cols (); \
+ \
+    int dm2_nr = dm2.rows (); \
+    int dm2_nc = dm2.cols (); \
+ \
+    if (dm1_nr != dm2_nr || dm1_nc != dm2_nc) \
+      gripe_nonconformant (#OP, dm1_nr, dm1_nc, dm2_nr, dm2_nc); \
+    else \
+      { \
+	r.resize (dm1_nr, dm1_nc); \
+ \
+	if (dm1_nr > 0 && dm1_nc > 0) \
+	  F ## _vv (r.fortran_vec (), dm1.data (), dm2.data (), \
+		    dm1_nr * dm2_nc); \
+      } \
+ \
+    return r; \
+  }
+
+#define DMDM_OPS(R, DM1, DM2) \
+  DMDM_OP (R, operator +, DM1, DM2, add) \
+  DMDM_OP (R, operator -, DM1, DM2, subtract) \
+  DMDM_OP (R, product,    DM1, DM2, multiply)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-s-cdm.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-s-cdm.h"
+
+#include "CMatrix.h"
+#include "CDiagMatrix.h"
+
+SDM_OPS (ComplexMatrix, double, ComplexDiagMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-s-cdm.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_s_cdm_h)
+#define octave_s_cdm_h 1
+
+class ComplexMatrix;
+class ComplexDiagMatrix;
+
+#include "mx-op-defs.h"
+
+SDM_OP_DECLS (ComplexMatrix, double, ComplexDiagMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-s-cm.cc
@@ -0,0 +1,37 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-s-cm.h"
+
+#include "CMatrix.h"
+
+SM_OPS (ComplexMatrix, double, ComplexMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-s-cm.h
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_s_cm_h)
+#define octave_s_cm_h 1
+
+class ComplexMatrix;
+
+#include "mx-op-defs.h"
+
+SM_OP_DECLS (ComplexMatrix, double, ComplexMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-s-dm.cc
@@ -0,0 +1,38 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "mx-s-dm.h"
+
+#include "dMatrix.h"
+#include "dDiagMatrix.h"
+
+SDM_OPS (Matrix, double, DiagMatrix)
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
new file mode 100644
--- /dev/null
+++ b/liboctave/mx-s-dm.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright (C) 1996 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_s_dm_h)
+#define octave_s_dm_h 1
+
+class Matrix;
+class DiagMatrix;
+
+#include "mx-op-defs.h"
+
+SDM_OP_DECLS (Matrix, double, DiagMatrix)
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/