mx-op-decl.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-2012 John W. Eaton
00004 Copyright (C) 2008-2009 Jaroslav Hajek
00005 Copyright (C) 2009 VZLU Prague, a.s.
00006 
00007 This file is part of Octave.
00008 
00009 Octave is free software; you can redistribute it and/or modify it
00010 under the terms of the GNU General Public License as published by the
00011 Free Software Foundation; either version 3 of the License, or (at your
00012 option) any later version.
00013 
00014 Octave is distributed in the hope that it will be useful, but WITHOUT
00015 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00017 for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with Octave; see the file COPYING.  If not, see
00021 <http://www.gnu.org/licenses/>.
00022 
00023 */
00024 
00025 #if !defined (octave_mx_op_decl_h)
00026 #define octave_mx_op_decl_h 1
00027 
00028 #define BIN_OP_DECL(R, OP, X, Y, API) \
00029   extern API R OP (const X&, const Y&)
00030 
00031 class boolMatrix;
00032 class boolNDArray;
00033 
00034 #define CMP_OP_DECL(OP, X, Y, API) \
00035   extern API boolMatrix OP (const X&, const Y&)
00036 
00037 #define NDCMP_OP_DECL(OP, X, Y, API) \
00038   extern API boolNDArray OP (const X&, const Y&)
00039 
00040 #define BOOL_OP_DECL(OP, X, Y, API) \
00041   extern API boolMatrix OP (const X&, const Y&)
00042 
00043 #define NDBOOL_OP_DECL(OP, X, Y, API) \
00044   extern API boolNDArray OP (const X&, const Y&)
00045 
00046 // vector by scalar operations.
00047 
00048 #define VS_BIN_OP_DECLS(R, V, S, API) \
00049   BIN_OP_DECL (R, operator +, V, S, API); \
00050   BIN_OP_DECL (R, operator -, V, S, API); \
00051   BIN_OP_DECL (R, operator *, V, S, API); \
00052   BIN_OP_DECL (R, operator /, V, S, API);
00053 
00054 #define VS_OP_DECLS(R, V, S, API) \
00055   VS_BIN_OP_DECLS(R, V, S, API)
00056 
00057 // scalar by vector by operations.
00058 
00059 #define SV_BIN_OP_DECLS(R, S, V, API) \
00060   BIN_OP_DECL (R, operator +, S, V, API); \
00061   BIN_OP_DECL (R, operator -, S, V, API); \
00062   BIN_OP_DECL (R, operator *, S, V, API); \
00063   BIN_OP_DECL (R, operator /, S, V, API);
00064 
00065 #define SV_OP_DECLS(R, S, V, API) \
00066   SV_BIN_OP_DECLS(R, S, V, API)
00067 
00068 // vector by vector operations.
00069 
00070 #define VV_BIN_OP_DECLS(R, V1, V2, API) \
00071   BIN_OP_DECL (R, operator +, V1, V2, API); \
00072   BIN_OP_DECL (R, operator -, V1, V2, API); \
00073   BIN_OP_DECL (R, product,    V1, V2, API); \
00074   BIN_OP_DECL (R, quotient,   V1, V2, API);
00075 
00076 #define VV_OP_DECLS(R, V1, V2, API) \
00077   VV_BIN_OP_DECLS(R, V1, V2, API)
00078 
00079 // matrix by scalar operations.
00080 
00081 #define MS_BIN_OP_DECLS(R, M, S, API) \
00082   BIN_OP_DECL (R, operator +, M, S, API); \
00083   BIN_OP_DECL (R, operator -, M, S, API); \
00084   BIN_OP_DECL (R, operator *, M, S, API); \
00085   BIN_OP_DECL (R, operator /, M, S, API);
00086 
00087 #define MS_CMP_OP_DECLS(M, S, API) \
00088   CMP_OP_DECL (mx_el_lt, M, S, API); \
00089   CMP_OP_DECL (mx_el_le, M, S, API); \
00090   CMP_OP_DECL (mx_el_ge, M, S, API); \
00091   CMP_OP_DECL (mx_el_gt, M, S, API); \
00092   CMP_OP_DECL (mx_el_eq, M, S, API); \
00093   CMP_OP_DECL (mx_el_ne, M, S, API);
00094 
00095 #define MS_BOOL_OP_DECLS(M, S, API) \
00096   BOOL_OP_DECL (mx_el_and, M, S, API); \
00097   BOOL_OP_DECL (mx_el_or,  M, S, API); \
00098 
00099 #define MS_OP_DECLS(R, M, S, API) \
00100   MS_BIN_OP_DECLS (R, M, S, API) \
00101   MS_CMP_OP_DECLS (M, S, API) \
00102   MS_BOOL_OP_DECLS (M, S, API) \
00103 
00104 // scalar by matrix operations.
00105 
00106 #define SM_BIN_OP_DECLS(R, S, M, API) \
00107   BIN_OP_DECL (R, operator +, S, M, API); \
00108   BIN_OP_DECL (R, operator -, S, M, API); \
00109   BIN_OP_DECL (R, operator *, S, M, API); \
00110   BIN_OP_DECL (R, operator /, S, M, API);
00111 
00112 #define SM_CMP_OP_DECLS(S, M, API) \
00113   CMP_OP_DECL (mx_el_lt, S, M, API); \
00114   CMP_OP_DECL (mx_el_le, S, M, API); \
00115   CMP_OP_DECL (mx_el_ge, S, M, API); \
00116   CMP_OP_DECL (mx_el_gt, S, M, API); \
00117   CMP_OP_DECL (mx_el_eq, S, M, API); \
00118   CMP_OP_DECL (mx_el_ne, S, M, API);
00119 
00120 #define SM_BOOL_OP_DECLS(S, M, API) \
00121   BOOL_OP_DECL (mx_el_and, S, M, API); \
00122   BOOL_OP_DECL (mx_el_or,  S, M, API); \
00123 
00124 #define SM_OP_DECLS(R, S, M, API) \
00125   SM_BIN_OP_DECLS (R, S, M, API) \
00126   SM_CMP_OP_DECLS (S, M, API) \
00127   SM_BOOL_OP_DECLS (S, M, API) \
00128 
00129 // matrix by matrix operations.
00130 
00131 #define MM_BIN_OP_DECLS(R, M1, M2, API) \
00132   BIN_OP_DECL (R, operator +, M1, M2, API); \
00133   BIN_OP_DECL (R, operator -, M1, M2, API); \
00134   BIN_OP_DECL (R, product,    M1, M2, API); \
00135   BIN_OP_DECL (R, quotient,   M1, M2, API);
00136 
00137 #define MM_CMP_OP_DECLS(M1, M2, API) \
00138   CMP_OP_DECL (mx_el_lt, M1, M2, API); \
00139   CMP_OP_DECL (mx_el_le, M1, M2, API); \
00140   CMP_OP_DECL (mx_el_ge, M1, M2, API); \
00141   CMP_OP_DECL (mx_el_gt, M1, M2, API); \
00142   CMP_OP_DECL (mx_el_eq, M1, M2, API); \
00143   CMP_OP_DECL (mx_el_ne, M1, M2, API);
00144 
00145 #define MM_BOOL_OP_DECLS(M1, M2, API) \
00146   BOOL_OP_DECL (mx_el_and, M1, M2, API); \
00147   BOOL_OP_DECL (mx_el_or,  M1, M2, API);
00148 
00149 #define MM_OP_DECLS(R, M1, M2, API) \
00150   MM_BIN_OP_DECLS (R, M1, M2, API) \
00151   MM_CMP_OP_DECLS (M1, M2, API) \
00152   MM_BOOL_OP_DECLS (M1, M2, API)
00153 
00154 // N-d matrix by scalar operations.
00155 
00156 #define NDS_BIN_OP_DECLS(R, ND, S, API) \
00157   BIN_OP_DECL (R, operator +, ND, S, API); \
00158   BIN_OP_DECL (R, operator -, ND, S, API); \
00159   BIN_OP_DECL (R, operator *, ND, S, API); \
00160   BIN_OP_DECL (R, operator /, ND, S, API);
00161 
00162 #define NDS_CMP_OP_DECLS(ND, S, API) \
00163   NDCMP_OP_DECL (mx_el_lt, ND, S, API); \
00164   NDCMP_OP_DECL (mx_el_le, ND, S, API); \
00165   NDCMP_OP_DECL (mx_el_ge, ND, S, API); \
00166   NDCMP_OP_DECL (mx_el_gt, ND, S, API); \
00167   NDCMP_OP_DECL (mx_el_eq, ND, S, API); \
00168   NDCMP_OP_DECL (mx_el_ne, ND, S, API);
00169 
00170 #define NDS_BOOL_OP_DECLS(ND, S, API) \
00171   NDBOOL_OP_DECL (mx_el_and, ND, S, API); \
00172   NDBOOL_OP_DECL (mx_el_or,  ND, S, API); \
00173   NDBOOL_OP_DECL (mx_el_not_and, ND, S, API); \
00174   NDBOOL_OP_DECL (mx_el_not_or,  ND, S, API);
00175 
00176 #define NDS_OP_DECLS(R, ND, S, API) \
00177   NDS_BIN_OP_DECLS (R, ND, S, API) \
00178   NDS_CMP_OP_DECLS (ND, S, API) \
00179   NDS_BOOL_OP_DECLS (ND, S, API)
00180 
00181 // scalar by N-d matrix operations.
00182 
00183 #define SND_BIN_OP_DECLS(R, S, ND, API) \
00184   BIN_OP_DECL (R, operator +, S, ND, API); \
00185   BIN_OP_DECL (R, operator -, S, ND, API); \
00186   BIN_OP_DECL (R, operator *, S, ND, API); \
00187   BIN_OP_DECL (R, operator /, S, ND, API);
00188 
00189 #define SND_CMP_OP_DECLS(S, ND, API) \
00190   NDCMP_OP_DECL (mx_el_lt, S, ND, API); \
00191   NDCMP_OP_DECL (mx_el_le, S, ND, API); \
00192   NDCMP_OP_DECL (mx_el_ge, S, ND, API); \
00193   NDCMP_OP_DECL (mx_el_gt, S, ND, API); \
00194   NDCMP_OP_DECL (mx_el_eq, S, ND, API); \
00195   NDCMP_OP_DECL (mx_el_ne, S, ND, API);
00196 
00197 #define SND_BOOL_OP_DECLS(S, ND, API) \
00198   NDBOOL_OP_DECL (mx_el_and, S, ND, API); \
00199   NDBOOL_OP_DECL (mx_el_or,  S, ND, API); \
00200   NDBOOL_OP_DECL (mx_el_and_not, S, ND, API); \
00201   NDBOOL_OP_DECL (mx_el_or_not,  S, ND, API);
00202 
00203 #define SND_OP_DECLS(R, S, ND, API) \
00204   SND_BIN_OP_DECLS (R, S, ND, API) \
00205   SND_CMP_OP_DECLS (S, ND, API) \
00206   SND_BOOL_OP_DECLS (S, ND, API)
00207 
00208 // N-d matrix by N-d matrix operations.
00209 
00210 #define NDND_BIN_OP_DECLS(R, ND1, ND2, API) \
00211   BIN_OP_DECL (R, operator +, ND1, ND2, API); \
00212   BIN_OP_DECL (R, operator -, ND1, ND2, API); \
00213   BIN_OP_DECL (R, product,    ND1, ND2, API); \
00214   BIN_OP_DECL (R, quotient,   ND1, ND2, API);
00215 
00216 #define NDND_CMP_OP_DECLS(ND1, ND2, API) \
00217   NDCMP_OP_DECL (mx_el_lt, ND1, ND2, API); \
00218   NDCMP_OP_DECL (mx_el_le, ND1, ND2, API); \
00219   NDCMP_OP_DECL (mx_el_ge, ND1, ND2, API); \
00220   NDCMP_OP_DECL (mx_el_gt, ND1, ND2, API); \
00221   NDCMP_OP_DECL (mx_el_eq, ND1, ND2, API); \
00222   NDCMP_OP_DECL (mx_el_ne, ND1, ND2, API);
00223 
00224 #define NDND_BOOL_OP_DECLS(ND1, ND2, API) \
00225   NDBOOL_OP_DECL (mx_el_and, ND1, ND2, API); \
00226   NDBOOL_OP_DECL (mx_el_or,  ND1, ND2, API); \
00227   NDBOOL_OP_DECL (mx_el_and_not, ND1, ND2, API); \
00228   NDBOOL_OP_DECL (mx_el_or_not,  ND1, ND2, API); \
00229   NDBOOL_OP_DECL (mx_el_not_and, ND1, ND2, API); \
00230   NDBOOL_OP_DECL (mx_el_not_or,  ND1, ND2, API);
00231 
00232 #define NDND_OP_DECLS(R, ND1, ND2, API) \
00233   NDND_BIN_OP_DECLS (R, ND1, ND2, API) \
00234   NDND_CMP_OP_DECLS (ND1, ND2, API) \
00235   NDND_BOOL_OP_DECLS (ND1, ND2, API)
00236 
00237 // scalar by diagonal matrix operations.
00238 
00239 #define SDM_BIN_OP_DECLS(R, S, DM, API) \
00240   BIN_OP_DECL (R, operator *, S, DM, API); \
00241 
00242 #define SDM_OP_DECLS(R, S, DM, API) \
00243   SDM_BIN_OP_DECLS(R, S, DM, API)
00244 
00245 // diagonal matrix by scalar operations.
00246 
00247 #define DMS_BIN_OP_DECLS(R, DM, S, API) \
00248   BIN_OP_DECL (R, operator *, DM, S, API); \
00249   BIN_OP_DECL (R, operator /, DM, S, API);
00250 
00251 #define DMS_OP_DECLS(R, DM, S, API) \
00252   DMS_BIN_OP_DECLS(R, DM, S, API)
00253 
00254 // matrix by diagonal matrix operations.
00255 
00256 #define MDM_BIN_OP_DECLS(R, M, DM, API) \
00257   BIN_OP_DECL (R, operator +, M, DM, API); \
00258   BIN_OP_DECL (R, operator -, M, DM, API); \
00259   BIN_OP_DECL (R, operator *, M, DM, API);
00260 
00261 #define MDM_OP_DECLS(R, M, DM, API) \
00262   MDM_BIN_OP_DECLS(R, M, DM, API)
00263 
00264 // diagonal matrix by matrix operations.
00265 
00266 #define DMM_BIN_OP_DECLS(R, DM, M, API) \
00267   BIN_OP_DECL (R, operator +, DM, M, API); \
00268   BIN_OP_DECL (R, operator -, DM, M, API); \
00269   BIN_OP_DECL (R, operator *, DM, M, API);
00270 
00271 #define DMM_OP_DECLS(R, DM, M, API) \
00272   DMM_BIN_OP_DECLS(R, DM, M, API)
00273 
00274 // diagonal matrix by diagonal matrix operations.
00275 
00276 #define DMDM_BIN_OP_DECLS(R, DM1, DM2, API) \
00277   BIN_OP_DECL (R, operator +, DM1, DM2, API); \
00278   BIN_OP_DECL (R, operator -, DM1, DM2, API); \
00279   BIN_OP_DECL (R, product, DM1, DM2, API);
00280 
00281 #define DMDM_OP_DECLS(R, DM1, DM2, API) \
00282   DMDM_BIN_OP_DECLS (R, DM1, DM2, API)
00283 
00284 // scalar by N-d array min/max ops
00285 
00286 #define MINMAX_DECLS(T, S, API) \
00287   extern API T min (S d, const T& m); \
00288   extern API T min (const T& m, S d); \
00289   extern API T min (const T& a, const T& b); \
00290   extern API T max (S d, const T& m); \
00291   extern API T max (const T& m, S d); \
00292   extern API T max (const T& a, const T& b);
00293 
00294 // permutation matrix by matrix ops and vice versa
00295 
00296 #define PMM_BIN_OP_DECLS(R, PM, M, API) \
00297   BIN_OP_DECL (R, operator *, PM, M, API);
00298 
00299 #define MPM_BIN_OP_DECLS(R, M, PM, API) \
00300   BIN_OP_DECL (R, operator *, M, PM, API);
00301 
00302 #endif
00303 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines