[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
resize (dim_vector, bool) ????
From: |
John W. Eaton |
Subject: |
resize (dim_vector, bool) ???? |
Date: |
Fri, 4 Jun 2004 17:39:26 -0500 |
On 1-Jun-2004, David Bateman <address@hidden> wrote:
| In mx-inlines.cc there is a call "resize (dim_vector, false)", but I
| can find no definition of the resize function for "resize (dim_vector, bool)".
| I suspect that the false is being cast as the base classes type if the
| relevant constructor exists. It seems to me that this behaviour is wrong
| and confusing (it confused me).... What was really meant by this line
| in mx-inlines.cc???
It's not clear, but I think it is indended as a fill value of zero.
If so, then I think the following is a better way to express this.
jwe
2004-06-04 John W. Eaton <address@hidden>
* mx-inlines.cc (MX_ND_REDUCTION): New arg, RET_ELT_TYPE. Use
"RET_ELT_TYPE ()" rather than "false" as fill value for retval
resize op. Change all uses.
Index: liboctave/mx-inlines.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/liboctave/mx-inlines.cc,v
retrieving revision 1.34
diff -u -r1.34 mx-inlines.cc
--- a/liboctave/mx-inlines.cc 21 Apr 2004 19:05:28 -0000 1.34
+++ b/liboctave/mx-inlines.cc 4 Jun 2004 22:06:51 -0000
@@ -378,7 +378,8 @@
break; \
}
-#define MX_ND_REDUCTION(EVAL_EXPR, END_EXPR, VAL, ACC_DECL, RET_TYPE) \
+#define MX_ND_REDUCTION(EVAL_EXPR, END_EXPR, VAL, ACC_DECL, \
+ RET_TYPE, RET_ELT_TYPE) \
\
RET_TYPE retval; \
\
@@ -456,7 +457,7 @@
int num_iter = (numel () / dim_length); \
\
/* Make sure retval has correct dimensions */ \
- retval.resize (dv, false); \
+ retval.resize (dv, RET_ELT_TYPE ()); \
\
Array<int> iter_idx (dv.length (), 0); \
\
@@ -488,14 +489,14 @@
#define MX_ND_REAL_OP_REDUCTION(ASN_EXPR, INIT_VAL) \
MX_ND_REDUCTION (acc ASN_EXPR, retval.elem (iter_idx) = acc, \
- INIT_VAL, double acc = INIT_VAL, NDArray)
+ INIT_VAL, double acc = INIT_VAL, NDArray, double)
#define MX_ND_COMPLEX_OP_REDUCTION(ASN_EXPR, INIT_VAL) \
MX_ND_REDUCTION (acc ASN_EXPR, retval.elem (iter_idx) = acc, \
- INIT_VAL, Complex acc = INIT_VAL, ComplexNDArray)
+ INIT_VAL, Complex acc = INIT_VAL, ComplexNDArray, Complex)
#define MX_ND_ANY_ALL_REDUCTION(EVAL_EXPR, VAL) \
- MX_ND_REDUCTION (EVAL_EXPR, , VAL, , boolNDArray)
+ MX_ND_REDUCTION (EVAL_EXPR, , VAL, , boolNDArray, bool)
#define MX_ND_CUMULATIVE_OP(RET_TYPE, ACC_TYPE, VAL, OP) \
RET_TYPE retval; \