GNU Octave  4.0.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-2015 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 }
octave_value xpow(const SparseMatrix &a, double b)
Definition: sparse-xpow.cc:59
#define DEFBINOP(name, t1, t2)
Definition: ops.h:279
#define MATRIX
Definition: op-cdm-cs.cc:27
static T gripe_if_zero(T x)
octave_value op_pow(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1328
const octave_base_value const Array< octave_idx_type > &ra_idx octave_int16_scalar & v1
#define MATRIXV
#define SCALAR
Definition: op-cdm-cs.cc:26
#define OCTAVE_SCALAR
#define CAST_BINOP_ARGS(t1, t2)
Definition: ops.h:79
octave_value op_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1326
#define INSTALL_BINOP(op, t1, t2, f)
Definition: ops.h:46
#define OCTAVE_MATRIX
#define SCALARV
const octave_char_matrix & v2
#define INST_NAME
octave_value op_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1329
#define DEFNDBINOP_OP(name, t1, t2, e1, e2, op)
Definition: ops.h:313
octave_value op_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1325
void gripe_divide_by_zero(void)
Definition: gripes.cc:195
F77_RET_T const double * x