comparison liboctave/MArray-defs.h @ 1988:7b56630a1e05

[project @ 1996-03-02 00:33:22 by jwe] Initial revision
author jwe
date Sat, 02 Mar 1996 00:33:22 +0000
parents
children dd00769643ae
comparison
equal deleted inserted replaced
1987:6df7b42db205 1988:7b56630a1e05
1 // Nothing like a little CPP abuse to brighten everyone's day. Would
2 // have been nice to do this with template functions but as of 2.5.x,
3 // g++ seems to fail to resolve them properly.
4
5 #define DO_VS_OP(OP) \
6 int l = a.length (); \
7 T *result = 0; \
8 if (l > 0) \
9 { \
10 result = new T [l]; \
11 const T *x = a.data (); \
12 for (int i = 0; i < l; i++) \
13 result[i] = x[i] OP s; \
14 }
15
16 #define DO_SV_OP(OP) \
17 int l = a.length (); \
18 T *result = 0; \
19 if (l > 0) \
20 { \
21 result = new T [l]; \
22 const T *x = a.data (); \
23 for (int i = 0; i < l; i++) \
24 result[i] = s OP x[i]; \
25 }
26
27 #define DO_VV_OP(OP) \
28 T *result = 0; \
29 if (l > 0) \
30 { \
31 result = new T [l]; \
32 const T *x = a.data (); \
33 const T *y = b.data (); \
34 for (int i = 0; i < l; i++) \
35 result[i] = x[i] OP y[i]; \
36 }
37
38 #define NEG_V \
39 int l = a.length (); \
40 T *result = 0; \
41 if (l > 0) \
42 { \
43 result = new T [l]; \
44 const T *x = a.data (); \
45 for (int i = 0; i < l; i++) \
46 result[i] = -x[i]; \
47 }
48
49 #define DO_VS_OP2(OP) \
50 int l = a.length (); \
51 if (l > 0) \
52 { \
53 T *tmp = a.fortran_vec (); \
54 for (int i = 0; i < l; i++) \
55 tmp[i] OP s; \
56 }
57
58 #define DO_VV_OP2(OP) \
59 do \
60 { \
61 T *a_tmp = a.fortran_vec (); \
62 const T *b_tmp = b.data (); \
63 for (int i = 0; i < l; i++) \
64 a_tmp[i] += b_tmp[i]; \
65 } \
66 while (0)
67