GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
op-dms-template.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2008-2013 Jaroslav Hajek
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include "ops.h"
28 #include "gripes.h"
29 #include "xpow.h"
30 #include SINCLUDE
31 #include MINCLUDE
32 
33 // matrix by diag matrix ops.
34 
35 #ifndef SCALARV
36 #define SCALARV SCALAR
37 #endif
38 
39 #ifndef MATRIXV
40 #define MATRIXV MATRIX
41 #endif
42 
45 
46 #define OCTAVE_MATRIX CONCAT2(octave_, MATRIX)
47 #define OCTAVE_SCALAR CONCAT2(octave_, SCALAR)
48 #define MATRIX_VALUE CONCAT2(MATRIXV, _value)
49 #define SCALAR_VALUE CONCAT2(SCALARV, _value)
50 
51 template <class T>
52 static T
54 {
55  if (x == T ())
57  return x;
58 }
59 
60 DEFBINOP (dmsdiv, MATRIX, SCALAR)
61 {
63 
64  return v1.MATRIX_VALUE () / gripe_if_zero (v2.SCALAR_VALUE ());
65 }
66 
67 DEFBINOP (sdmldiv, SCALAR, MATRIX)
68 {
70 
71  return v2.MATRIX_VALUE () / gripe_if_zero (v1.SCALAR_VALUE ());
72 }
73 
74 DEFBINOP (dmspow, MATRIX, SCALAR)
75 {
77 
78  return xpow (v1.MATRIX_VALUE (), v2.SCALAR_VALUE ());
79 }
80 
81 #define SHORT_NAME CONCAT3(MSHORT, _, SSHORT)
82 #define INST_NAME CONCAT3(install_, SHORT_NAME, _ops)
83 
84 void
85 INST_NAME (void)
86 {
92 }