changeset 5075:b6a9f78f60e9

[project @ 2004-11-10 03:13:26 by jwe]
author jwe
date Wed, 10 Nov 2004 03:13:27 +0000
parents c348a7236185
children dc5f6082aa74
files src/ChangeLog src/Makefile.in src/OPERATORS/op-int-concat.cc src/OPERATORS/op-int.h src/ops.h
diffstat 5 files changed, 305 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Nov 09 19:41:46 2004 +0000
+++ b/src/ChangeLog	Wed Nov 10 03:13:27 2004 +0000
@@ -1,3 +1,16 @@
+2004-11-09  John W. Eaton  <jwe@octave.org>
+
+	* OPERATORS/op-int-concat.cc: New file for mixed integer/other
+	concatentation operators.
+	* Makefile.in (INTTYPE_OP_XSRC): Add it to the list.
+
+	* ops.h (DEFNDCATOP_FN2): New macro.
+
+	* OPERATORS/op-int.h (OCTAVE_CONCAT_FN2,
+	OCTAVE_INSTALL_CONCAT_FN2, OCTAVE_DOUBLE_INT_CONCAT_FN,
+	OCTAVE_INSTALL_DOUBLE_INT_CONCAT_FN, OCTAVE_INT_DOUBLE_CONCAT_FN,
+	OCTAVE_INSTALL_INT_DOUBLE_CONCAT_FN): New macros.
+
 2004-11-09  David Bateman  <dbateman@free.fr>
 
 	* Cell.cc (concat): Delete.
--- a/src/Makefile.in	Tue Nov 09 19:41:46 2004 +0000
+++ b/src/Makefile.in	Wed Nov 10 03:13:27 2004 +0000
@@ -100,7 +100,7 @@
 
 TI_SRC := $(addprefix TEMPLATE-INST/, $(TI_XSRC))
 
-INTTYPE_OP_XSRC := op-int-conv.cc op-double-conv.cc \
+INTTYPE_OP_XSRC := op-int-concat.cc op-int-conv.cc op-double-conv.cc \
 	op-i8-i8.cc op-i16-i16.cc op-i32-i32.cc op-i64-i64.cc \
 	op-ui8-ui8.cc op-ui16-ui16.cc op-ui32-ui32.cc op-ui64-ui64.cc
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/OPERATORS/op-int-concat.cc	Wed Nov 10 03:13:27 2004 +0000
@@ -0,0 +1,242 @@
+/*
+
+Copyright (C) 2004 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 "gripes.h"
+#include "oct-obj.h"
+#include "ov.h"
+#include "ov-int8.h"
+#include "ov-int16.h"
+#include "ov-int32.h"
+#include "ov-int64.h"
+#include "ov-uint8.h"
+#include "ov-uint16.h"
+#include "ov-uint32.h"
+#include "ov-uint64.h"
+#include "ov-range.h"
+#include "ov-bool.h"
+#include "ov-bool-mat.h"
+#include "ov-scalar.h"
+#include "ov-re-mat.h"
+#include "ov-str-mat.h"
+#include "ov-typeinfo.h"
+#include "op-int.h"
+#include "ops.h"
+
+// Concatentation of mixed integer types:
+
+OCTAVE_CONCAT_FN2 (int8, int16)
+OCTAVE_CONCAT_FN2 (int8, int32)
+OCTAVE_CONCAT_FN2 (int8, int64)
+
+OCTAVE_CONCAT_FN2 (int8, uint8)
+OCTAVE_CONCAT_FN2 (int8, uint16)
+OCTAVE_CONCAT_FN2 (int8, uint32)
+OCTAVE_CONCAT_FN2 (int8, uint64)
+
+OCTAVE_CONCAT_FN2 (int16, int8)
+OCTAVE_CONCAT_FN2 (int16, int32)
+OCTAVE_CONCAT_FN2 (int16, int64)
+
+OCTAVE_CONCAT_FN2 (int16, uint8)
+OCTAVE_CONCAT_FN2 (int16, uint16)
+OCTAVE_CONCAT_FN2 (int16, uint32)
+OCTAVE_CONCAT_FN2 (int16, uint64)
+
+OCTAVE_CONCAT_FN2 (int32, int8)
+OCTAVE_CONCAT_FN2 (int32, int16)
+OCTAVE_CONCAT_FN2 (int32, int64)
+
+OCTAVE_CONCAT_FN2 (int32, uint8)
+OCTAVE_CONCAT_FN2 (int32, uint16)
+OCTAVE_CONCAT_FN2 (int32, uint32)
+OCTAVE_CONCAT_FN2 (int32, uint64)
+
+OCTAVE_CONCAT_FN2 (int64, int8)
+OCTAVE_CONCAT_FN2 (int64, int16)
+OCTAVE_CONCAT_FN2 (int64, int32)
+
+OCTAVE_CONCAT_FN2 (int64, uint8)
+OCTAVE_CONCAT_FN2 (int64, uint16)
+OCTAVE_CONCAT_FN2 (int64, uint32)
+OCTAVE_CONCAT_FN2 (int64, uint64)
+
+OCTAVE_CONCAT_FN2 (uint8, int8)
+OCTAVE_CONCAT_FN2 (uint8, int16)
+OCTAVE_CONCAT_FN2 (uint8, int32)
+OCTAVE_CONCAT_FN2 (uint8, int64)
+
+OCTAVE_CONCAT_FN2 (uint8, uint16)
+OCTAVE_CONCAT_FN2 (uint8, uint32)
+OCTAVE_CONCAT_FN2 (uint8, uint64)
+
+OCTAVE_CONCAT_FN2 (uint16, int8)
+OCTAVE_CONCAT_FN2 (uint16, int16)
+OCTAVE_CONCAT_FN2 (uint16, int32)
+OCTAVE_CONCAT_FN2 (uint16, int64)
+
+OCTAVE_CONCAT_FN2 (uint16, uint8)
+OCTAVE_CONCAT_FN2 (uint16, uint32)
+OCTAVE_CONCAT_FN2 (uint16, uint64)
+
+OCTAVE_CONCAT_FN2 (uint32, int8)
+OCTAVE_CONCAT_FN2 (uint32, int16)
+OCTAVE_CONCAT_FN2 (uint32, int32)
+OCTAVE_CONCAT_FN2 (uint32, int64)
+
+OCTAVE_CONCAT_FN2 (uint32, uint8)
+OCTAVE_CONCAT_FN2 (uint32, uint16)
+OCTAVE_CONCAT_FN2 (uint32, uint64)
+
+OCTAVE_CONCAT_FN2 (uint64, int8)
+OCTAVE_CONCAT_FN2 (uint64, int16)
+OCTAVE_CONCAT_FN2 (uint64, int32)
+OCTAVE_CONCAT_FN2 (uint64, int64)
+
+OCTAVE_CONCAT_FN2 (uint64, uint8)
+OCTAVE_CONCAT_FN2 (uint64, uint16)
+OCTAVE_CONCAT_FN2 (uint64, uint32)
+
+OCTAVE_INT_DOUBLE_CONCAT_FN (int8)
+OCTAVE_INT_DOUBLE_CONCAT_FN (int16)
+OCTAVE_INT_DOUBLE_CONCAT_FN (int32)
+OCTAVE_INT_DOUBLE_CONCAT_FN (int64)
+
+OCTAVE_INT_DOUBLE_CONCAT_FN (uint8)
+OCTAVE_INT_DOUBLE_CONCAT_FN (uint16)
+OCTAVE_INT_DOUBLE_CONCAT_FN (uint32)
+OCTAVE_INT_DOUBLE_CONCAT_FN (uint64)
+
+OCTAVE_DOUBLE_INT_CONCAT_FN (int8)
+OCTAVE_DOUBLE_INT_CONCAT_FN (int16)
+OCTAVE_DOUBLE_INT_CONCAT_FN (int32)
+OCTAVE_DOUBLE_INT_CONCAT_FN (int64)
+	      	   
+OCTAVE_DOUBLE_INT_CONCAT_FN (uint8)
+OCTAVE_DOUBLE_INT_CONCAT_FN (uint16)
+OCTAVE_DOUBLE_INT_CONCAT_FN (uint32)
+OCTAVE_DOUBLE_INT_CONCAT_FN (uint64)
+
+void
+install_int_concat_ops (void)
+{
+  OCTAVE_INSTALL_CONCAT_FN2 (int8, int16);
+  OCTAVE_INSTALL_CONCAT_FN2 (int8, int32);
+  OCTAVE_INSTALL_CONCAT_FN2 (int8, int64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (int8, uint8);
+  OCTAVE_INSTALL_CONCAT_FN2 (int8, uint16);
+  OCTAVE_INSTALL_CONCAT_FN2 (int8, uint32);
+  OCTAVE_INSTALL_CONCAT_FN2 (int8, uint64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (int16, int8);
+  OCTAVE_INSTALL_CONCAT_FN2 (int16, int32);
+  OCTAVE_INSTALL_CONCAT_FN2 (int16, int64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (int16, uint8);
+  OCTAVE_INSTALL_CONCAT_FN2 (int16, uint16);
+  OCTAVE_INSTALL_CONCAT_FN2 (int16, uint32);
+  OCTAVE_INSTALL_CONCAT_FN2 (int16, uint64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (int32, int8);
+  OCTAVE_INSTALL_CONCAT_FN2 (int32, int16);
+  OCTAVE_INSTALL_CONCAT_FN2 (int32, int64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (int32, uint8);
+  OCTAVE_INSTALL_CONCAT_FN2 (int32, uint16);
+  OCTAVE_INSTALL_CONCAT_FN2 (int32, uint32);
+  OCTAVE_INSTALL_CONCAT_FN2 (int32, uint64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (int64, int8);
+  OCTAVE_INSTALL_CONCAT_FN2 (int64, int16);
+  OCTAVE_INSTALL_CONCAT_FN2 (int64, int32);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (int64, uint8);
+  OCTAVE_INSTALL_CONCAT_FN2 (int64, uint16);
+  OCTAVE_INSTALL_CONCAT_FN2 (int64, uint32);
+  OCTAVE_INSTALL_CONCAT_FN2 (int64, uint64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (uint8, int8);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint8, int16);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint8, int32);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint8, int64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (uint8, uint16);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint8, uint32);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint8, uint64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (uint16, int8);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint16, int16);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint16, int32);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint16, int64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (uint16, uint8);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint16, uint32);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint16, uint64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (uint32, int8);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint32, int16);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint32, int32);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint32, int64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (uint32, uint8);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint32, uint16);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint32, uint64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (uint64, int8);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint64, int16);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint64, int32);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint64, int64);
+
+  OCTAVE_INSTALL_CONCAT_FN2 (uint64, uint8);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint64, uint16);
+  OCTAVE_INSTALL_CONCAT_FN2 (uint64, uint32);
+
+  OCTAVE_INSTALL_INT_DOUBLE_CONCAT_FN (int8);
+  OCTAVE_INSTALL_INT_DOUBLE_CONCAT_FN (int16);
+  OCTAVE_INSTALL_INT_DOUBLE_CONCAT_FN (int32);
+  OCTAVE_INSTALL_INT_DOUBLE_CONCAT_FN (int64);
+
+  OCTAVE_INSTALL_INT_DOUBLE_CONCAT_FN (uint8);
+  OCTAVE_INSTALL_INT_DOUBLE_CONCAT_FN (uint16);
+  OCTAVE_INSTALL_INT_DOUBLE_CONCAT_FN (uint32);
+  OCTAVE_INSTALL_INT_DOUBLE_CONCAT_FN (uint64);
+
+  OCTAVE_INSTALL_DOUBLE_INT_CONCAT_FN (int8);
+  OCTAVE_INSTALL_DOUBLE_INT_CONCAT_FN (int16);
+  OCTAVE_INSTALL_DOUBLE_INT_CONCAT_FN (int32);
+  OCTAVE_INSTALL_DOUBLE_INT_CONCAT_FN (int64);
+
+  OCTAVE_INSTALL_DOUBLE_INT_CONCAT_FN (uint8);
+  OCTAVE_INSTALL_DOUBLE_INT_CONCAT_FN (uint16);
+  OCTAVE_INSTALL_DOUBLE_INT_CONCAT_FN (uint32);
+  OCTAVE_INSTALL_DOUBLE_INT_CONCAT_FN (uint64);
+}
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- a/src/OPERATORS/op-int.h	Tue Nov 09 19:41:46 2004 +0000
+++ b/src/OPERATORS/op-int.h	Wed Nov 10 03:13:27 2004 +0000
@@ -22,6 +22,42 @@
 
 #include "quit.h"
 
+#define OCTAVE_CONCAT_FN2(T1, T2) \
+  DEFNDCATOP_FN2 (T1 ## _ ## T2 ## _s_s, T1 ## _scalar, T2 ## _scalar, , T1 ## NDArray, T1 ## _array, T2 ## _array, concat) \
+  DEFNDCATOP_FN2 (T1 ## _ ## T2 ## _s_m, T1 ## _scalar, T2 ## _matrix, , T1 ## NDArray, T1 ## _array, T2 ## _array, concat) \
+  DEFNDCATOP_FN2 (T1 ## _ ## T2 ## _m_s, T1 ## _matrix, T2 ## _scalar, , T1 ## NDArray, T1 ## _array, T2 ## _array, concat) \
+  DEFNDCATOP_FN2 (T1 ## _ ## T2 ## _m_m, T1 ## _matrix, T2 ## _matrix, , T1 ## NDArray, T1 ## _array, T2 ## _array, concat)
+
+#define OCTAVE_INSTALL_CONCAT_FN2(T1, T2) \
+  INSTALL_CATOP (octave_ ## T1 ## _scalar, octave_ ## T2 ## _scalar, T1 ## _ ## T2 ## _s_s) \
+  INSTALL_CATOP (octave_ ## T1 ## _scalar, octave_ ## T2 ## _matrix, T1 ## _ ## T2 ## _s_m) \
+  INSTALL_CATOP (octave_ ## T1 ## _matrix, octave_ ## T2 ## _scalar, T1 ## _ ## T2 ## _m_s) \
+  INSTALL_CATOP (octave_ ## T1 ## _matrix, octave_ ## T2 ## _matrix, T1 ## _ ## T2 ## _m_m)
+
+#define OCTAVE_DOUBLE_INT_CONCAT_FN(TYPE) \
+  DEFNDCATOP_FN2 (double ## _ ## TYPE ## _s_s, scalar, TYPE ## _scalar, TYPE ## NDArray, , array, TYPE ## _array, concat) \
+  DEFNDCATOP_FN2 (double ## _ ## TYPE ## _s_m, scalar, TYPE ## _matrix, TYPE ## NDArray, , array, TYPE ## _array, concat) \
+  DEFNDCATOP_FN2 (double ## _ ## TYPE ## _m_s, matrix, TYPE ## _scalar, TYPE ## NDArray, , array, TYPE ## _array, concat) \
+  DEFNDCATOP_FN2 (double ## _ ## TYPE ## _m_m, matrix, TYPE ## _matrix, TYPE ## NDArray, , array, TYPE ## _array, concat)
+
+#define OCTAVE_INSTALL_DOUBLE_INT_CONCAT_FN(TYPE) \
+  INSTALL_CATOP (octave_scalar, octave_ ## TYPE ## _scalar, double ## _ ## TYPE ## _s_s) \
+  INSTALL_CATOP (octave_scalar, octave_ ## TYPE ## _matrix, double ## _ ## TYPE ## _s_m) \
+  INSTALL_CATOP (octave_matrix, octave_ ## TYPE ## _scalar, double ## _ ## TYPE ## _m_s) \
+  INSTALL_CATOP (octave_matrix, octave_ ## TYPE ## _matrix, double ## _ ## TYPE ## _m_m)
+
+#define OCTAVE_INT_DOUBLE_CONCAT_FN(TYPE) \
+  DEFNDCATOP_FN2 (TYPE ## _ ## double ## _s_s, TYPE ## _scalar, scalar, , TYPE ## NDArray, TYPE ## _array, array, concat) \
+  DEFNDCATOP_FN2 (TYPE ## _ ## double ## _s_m, TYPE ## _scalar, matrix, , TYPE ## NDArray, TYPE ## _array, array, concat) \
+  DEFNDCATOP_FN2 (TYPE ## _ ## double ## _m_s, TYPE ## _matrix, scalar, , TYPE ## NDArray, TYPE ## _array, array, concat) \
+  DEFNDCATOP_FN2 (TYPE ## _ ## double ## _m_m, TYPE ## _matrix, matrix, , TYPE ## NDArray, TYPE ## _array, array, concat)
+
+#define OCTAVE_INSTALL_INT_DOUBLE_CONCAT_FN(TYPE) \
+  INSTALL_CATOP (octave_ ## TYPE ## _scalar, octave_scalar, TYPE ## _ ## double ## _s_s) \
+  INSTALL_CATOP (octave_ ## TYPE ## _scalar, octave_matrix, TYPE ## _ ## double ## _s_m) \
+  INSTALL_CATOP (octave_ ## TYPE ## _matrix, octave_scalar, TYPE ## _ ## double ## _m_s) \
+  INSTALL_CATOP (octave_ ## TYPE ## _matrix, octave_matrix, TYPE ## _ ## double ## _m_m)
+
 #define OCTAVE_CONCAT_FN(TYPE) \
   DEFNDCATOP_FN (TYPE ## _s_s, TYPE ## _scalar, TYPE ## _scalar, TYPE ## _array, TYPE ## _array, concat) \
   DEFNDCATOP_FN (TYPE ## _s_m, TYPE ## _scalar, TYPE ## _matrix, TYPE ## _array, TYPE ## _array, concat) \
--- a/src/ops.h	Tue Nov 09 19:41:46 2004 +0000
+++ b/src/ops.h	Wed Nov 10 03:13:27 2004 +0000
@@ -330,19 +330,29 @@
 // XXX FIXME XXX -- in some cases, the constructor isn't necessary.
 
 #define DEFCATOP_FN(name, t1, t2, f) \
-  CATOPDECL (name, a1, a2)	     \
+  CATOPDECL (name, a1, a2) \
   { \
     CAST_BINOP_ARGS (octave_ ## t1&, const octave_ ## t2&); \
     return octave_value (v1.t1 ## _value (). f (v2.t2 ## _value (), ra_idx)); \
   }
 
-#define DEFNDCATOP_FN(name, t1, t2, e1, e2, f)	\
-  CATOPDECL (name, a1, a2)			\
+#define DEFNDCATOP_FN(name, t1, t2, e1, e2, f) \
+  CATOPDECL (name, a1, a2) \
   { \
     CAST_BINOP_ARGS (octave_ ## t1&, const octave_ ## t2&); \
     return octave_value (v1.e1 ## _value (). f (v2.e2 ## _value (), ra_idx)); \
   }
 
+// For compatibility, the second arg is always converted to the type
+// of the first.  Hmm.
+
+#define DEFNDCATOP_FN2(name, t1, t2, tc1, tc2, e1, e2, f) \
+  CATOPDECL (name, a1, a2) \
+  { \
+    CAST_BINOP_ARGS (octave_ ## t1&, const octave_ ## t2&); \
+    return octave_value (tc1 (v1.e1 ## _value ()) . f (tc2 (v2.e2 ## _value ()), ra_idx)); \
+  }
+
 #define CATOP_NONCONFORMANT(msg) \
   gripe_nonconformant (msg, \
 		       a1.rows (), a1.columns (), \