Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026
00027 #include "ops.h"
00028 #include "gripes.h"
00029 #include "xpow.h"
00030 #include SINCLUDE
00031 #include MINCLUDE
00032
00033
00034
00035 #ifndef SCALARV
00036 #define SCALARV SCALAR
00037 #endif
00038
00039 #ifndef MATRIXV
00040 #define MATRIXV MATRIX
00041 #endif
00042
00043 DEFNDBINOP_OP (sdmmul, SCALAR, MATRIX, SCALARV, MATRIXV, *)
00044 DEFNDBINOP_OP (dmsmul, MATRIX, SCALAR, MATRIXV, SCALARV, *)
00045
00046 #define OCTAVE_MATRIX CONCAT2(octave_, MATRIX)
00047 #define OCTAVE_SCALAR CONCAT2(octave_, SCALAR)
00048 #define MATRIX_VALUE CONCAT2(MATRIXV, _value)
00049 #define SCALAR_VALUE CONCAT2(SCALARV, _value)
00050
00051 template <class T>
00052 static T
00053 gripe_if_zero (T x)
00054 {
00055 if (x == T ())
00056 gripe_divide_by_zero ();
00057 return x;
00058 }
00059
00060 DEFBINOP (dmsdiv, MATRIX, SCALAR)
00061 {
00062 CAST_BINOP_ARGS (const OCTAVE_MATRIX&, const OCTAVE_SCALAR&);
00063
00064 return v1.MATRIX_VALUE () / gripe_if_zero (v2.SCALAR_VALUE ());
00065 }
00066
00067 DEFBINOP (sdmldiv, SCALAR, MATRIX)
00068 {
00069 CAST_BINOP_ARGS (const OCTAVE_SCALAR&, const OCTAVE_MATRIX&);
00070
00071 return v2.MATRIX_VALUE () / gripe_if_zero (v1.SCALAR_VALUE ());
00072 }
00073
00074 DEFBINOP (dmspow, MATRIX, SCALAR)
00075 {
00076 CAST_BINOP_ARGS (const OCTAVE_MATRIX&, const OCTAVE_SCALAR&);
00077
00078 return xpow (v1.MATRIX_VALUE (), v2.SCALAR_VALUE ());
00079 }
00080
00081 #define SHORT_NAME CONCAT3(MSHORT, _, SSHORT)
00082 #define INST_NAME CONCAT3(install_, SHORT_NAME, _ops)
00083
00084 void
00085 INST_NAME (void)
00086 {
00087 INSTALL_BINOP (op_mul, OCTAVE_MATRIX, OCTAVE_SCALAR, dmsmul);
00088 INSTALL_BINOP (op_div, OCTAVE_MATRIX, OCTAVE_SCALAR, dmsdiv);
00089 INSTALL_BINOP (op_mul, OCTAVE_SCALAR, OCTAVE_MATRIX, sdmmul);
00090 INSTALL_BINOP (op_ldiv, OCTAVE_SCALAR, OCTAVE_MATRIX, sdmldiv);
00091 INSTALL_BINOP (op_pow, OCTAVE_MATRIX, OCTAVE_SCALAR, dmspow);
00092 }