GNU Octave  4.2.1
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-2017 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 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include "ops.h"
28 #include "errwarn.h"
29 #include "xpow.h"
30 #include SINCLUDE
31 #include MINCLUDE
32 
33 // matrix by diag matrix ops.
34 
35 #if ! defined (SCALARV)
36 # define SCALARV SCALAR
37 #endif
38 
39 #if ! defined (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 <typename T>
52 static T
54 {
55  if (x == T ())
57 
58  return x;
59 }
60 
61 DEFBINOP (dmsdiv, MATRIX, SCALAR)
62 {
63  const OCTAVE_MATRIX& v1 = dynamic_cast<const OCTAVE_MATRIX&> (a1);
64  const OCTAVE_SCALAR& v2 = dynamic_cast<const OCTAVE_SCALAR&> (a2);
65 
66  return v1.MATRIX_VALUE () / gripe_if_zero (v2.SCALAR_VALUE ());
67 }
68 
69 DEFBINOP (sdmldiv, SCALAR, MATRIX)
70 {
71  const OCTAVE_SCALAR& v1 = dynamic_cast<const OCTAVE_SCALAR&> (a1);
72  const OCTAVE_MATRIX& v2 = dynamic_cast<const OCTAVE_MATRIX&> (a2);
73 
74  return v2.MATRIX_VALUE () / gripe_if_zero (v1.SCALAR_VALUE ());
75 }
76 
77 DEFBINOP (dmspow, MATRIX, SCALAR)
78 {
79  const OCTAVE_MATRIX& v1 = dynamic_cast<const OCTAVE_MATRIX&> (a1);
80  const OCTAVE_SCALAR& v2 = dynamic_cast<const OCTAVE_SCALAR&> (a2);
81 
82  return xpow (v1.MATRIX_VALUE (), v2.SCALAR_VALUE ());
83 }
84 
85 #define SHORT_NAME CONCAT3(MSHORT, _, SSHORT)
86 #define INST_NAME CONCAT3(install_, SHORT_NAME, _ops)
87 
88 void
89 INST_NAME (void)
90 {
96 }
octave_value xpow(const SparseMatrix &a, double b)
Definition: sparse-xpow.cc:58
#define DEFBINOP(name, t1, t2)
Definition: ops.h:223
#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:1519
#define MATRIXV
#define SCALAR
Definition: op-cdm-cs.cc:26
#define OCTAVE_SCALAR
const octave_base_value & a2
octave_value op_div(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1517
#define INSTALL_BINOP(op, t1, t2, f)
Definition: ops.h:48
#define OCTAVE_MATRIX
#define SCALARV
void warn_divide_by_zero(void)
Definition: errwarn.cc:320
const octave_char_matrix & v2
#define INST_NAME
octave_value op_ldiv(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1520
#define DEFNDBINOP_OP(name, t1, t2, e1, e2, op)
Definition: ops.h:269
octave_value op_mul(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1516
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE * x