Mercurial > hg > octave-nkf
annotate liboctave/MArray-defs.h @ 9601:a9b37bae1802
add a couple of missing copyright statements
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 02 Sep 2009 09:21:36 +0200 |
parents | 3a1dd361f978 |
children | 66970dd627f6 |
rev | line source |
---|---|
7016 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1996, 1999, 2000, 2003, 2005, 2006, 2007, 2008, |
4 2009 John W. Eaton | |
9601
a9b37bae1802
add a couple of missing copyright statements
Jaroslav Hajek <highegg@gmail.com>
parents:
9557
diff
changeset
|
5 Copyright (C) 2009 VZLU Prague, a.s. |
7016 | 6 |
7 This file is part of Octave. | |
8 | |
9 Octave is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
11 Free Software Foundation; either version 3 of the License, or (at your | |
12 option) any later version. | |
13 | |
14 Octave is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
20 along with Octave; see the file COPYING. If not, see | |
21 <http://www.gnu.org/licenses/>. | |
22 | |
23 */ | |
24 | |
3741 | 25 #if !defined (octave_MArray_defs_h) |
26 #define octave_MArray_defs_h 1 | |
27 | |
3649 | 28 // Nothing like a little CPP abuse to brighten everyone's day. |
1988 | 29 |
3504 | 30 #define DO_VS_OP(r, l, v, OP, s) \ |
1988 | 31 if (l > 0) \ |
32 { \ | |
5275 | 33 for (octave_idx_type i = 0; i < l; i++) \ |
3504 | 34 r[i] = v[i] OP s; \ |
1988 | 35 } |
36 | |
3504 | 37 #define DO_SV_OP(r, l, s, OP, v) \ |
1988 | 38 if (l > 0) \ |
39 { \ | |
5275 | 40 for (octave_idx_type i = 0; i < l; i++) \ |
3504 | 41 r[i] = s OP v[i]; \ |
1988 | 42 } |
43 | |
3504 | 44 #define DO_VV_OP(r, l, x, OP, y) \ |
1988 | 45 if (l > 0) \ |
46 { \ | |
5275 | 47 for (octave_idx_type i = 0; i < l; i++) \ |
3504 | 48 r[i] = x[i] OP y[i]; \ |
1988 | 49 } |
50 | |
3504 | 51 #define NEG_V(r, l, x) \ |
1988 | 52 if (l > 0) \ |
53 { \ | |
5275 | 54 for (octave_idx_type i = 0; i < l; i++) \ |
3504 | 55 r[i] = -x[i]; \ |
1988 | 56 } |
57 | |
4646 | 58 #define DO_VS_OP2(T, a, OP, s) \ |
5275 | 59 octave_idx_type l = a.length (); \ |
1988 | 60 if (l > 0) \ |
61 { \ | |
62 T *tmp = a.fortran_vec (); \ | |
5275 | 63 for (octave_idx_type i = 0; i < l; i++) \ |
1988 | 64 tmp[i] OP s; \ |
65 } | |
66 | |
4646 | 67 #define DO_VV_OP2(T, a, OP, b) \ |
1988 | 68 do \ |
69 { \ | |
70 T *a_tmp = a.fortran_vec (); \ | |
71 const T *b_tmp = b.data (); \ | |
5275 | 72 for (octave_idx_type i = 0; i < l; i++) \ |
3243 | 73 a_tmp[i] OP b_tmp[i]; \ |
1988 | 74 } \ |
75 while (0) | |
76 | |
3573 | 77 // Instantiate the OP= operators. |
6708 | 78 #define MARRAY_OP_ASSIGN_DEFS(A_T, E_T, RHS_T, API) \ |
79 MARRAY_OP_ASSIGN_DECLS (A_T, E_T, template, API, , RHS_T) | |
3573 | 80 |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
81 #define MARRAY_OP_ASSIGN_DEFS1(A_T, E_T, RHS_T, API) \ |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
82 MARRAY_OP_ASSIGN_DECLS1 (A_T, E_T, template, API, , RHS_T) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
83 |
3573 | 84 // Instantiate the unary operators. |
6708 | 85 #define MARRAY_UNOP_DEFS(A_T, E_T, API) \ |
86 MARRAY_UNOP_DECLS (A_T, E_T, template, API, ) | |
3573 | 87 |
88 // Instantiate the binary operators. | |
6708 | 89 #define MARRAY_BINOP_DEFS(A_T, E_T, API) \ |
90 MARRAY_BINOP_DECLS (A_T, E_T, template, API, , A_T<E_T>, E_T) \ | |
91 MARRAY_BINOP_DECLS (A_T, E_T, template, API, , E_T, A_T<E_T>) \ | |
92 MARRAY_AA_BINOP_DECLS (A_T, E_T, template, API, ) | |
3573 | 93 |
6708 | 94 #define MDIAGARRAY2_BINOP_DEFS(A_T, E_T, API) \ |
95 MDIAGARRAY2_DAS_BINOP_DECLS (A_T, E_T, template, API, , A_T<E_T>, E_T) \ | |
96 MDIAGARRAY2_SDA_BINOP_DECLS (A_T, E_T, template, API, , E_T, A_T<E_T>) \ | |
97 MDIAGARRAY2_DADA_BINOP_DECLS (A_T, E_T, template, API, ) | |
3580 | 98 |
3573 | 99 // The following macros are for external use. |
100 | |
101 // Instantiate all the MArray friends for MArray element type T. | |
6708 | 102 #define INSTANTIATE_MARRAY_FRIENDS(T, API) \ |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
103 MARRAY_OP_ASSIGN_DEFS1 (MArray, T, T, API) \ |
6708 | 104 MARRAY_OP_ASSIGN_DEFS (MArray, T, MArray<T>, API) \ |
105 MARRAY_UNOP_DEFS (MArray, T, API) \ | |
106 MARRAY_BINOP_DEFS (MArray, T, API) | |
3573 | 107 |
4513 | 108 // Instantiate all the MArray2 friends for MArray2 element type T. |
6708 | 109 #define INSTANTIATE_MARRAY2_FRIENDS(T, API) \ |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
110 MARRAY_OP_ASSIGN_DEFS1 (MArray2, T, T, API) \ |
6708 | 111 MARRAY_OP_ASSIGN_DEFS (MArray2, T, MArray2<T>, API) \ |
112 MARRAY_UNOP_DEFS (MArray2, T, API) \ | |
113 MARRAY_BINOP_DEFS (MArray2, T, API) | |
3573 | 114 |
4513 | 115 // Instantiate all the MArrayN friends for MArrayN element type T. |
6708 | 116 #define INSTANTIATE_MARRAYN_FRIENDS(T, API) \ |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
117 MARRAY_OP_ASSIGN_DEFS1 (MArrayN, T, T, API) \ |
6708 | 118 MARRAY_OP_ASSIGN_DEFS (MArrayN, T, MArrayN<T>, API) \ |
119 MARRAY_UNOP_DEFS (MArrayN, T, API) \ | |
120 MARRAY_BINOP_DEFS (MArrayN, T, API) | |
4513 | 121 |
122 // Instantiate all the MDiagArray2 friends for MDiagArray2 element type T. | |
6708 | 123 #define INSTANTIATE_MDIAGARRAY2_FRIENDS(T, API) \ |
124 MARRAY_UNOP_DEFS (MDiagArray2, T, API) \ | |
125 MDIAGARRAY2_BINOP_DEFS (MDiagArray2, T, API) | |
3580 | 126 |
3573 | 127 // Now we have all the definitions we need. |
128 | |
3741 | 129 #endif |