GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
libinterp
operators
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
43
DEFNDBINOP_OP
(sdmmul,
SCALAR
,
MATRIX
,
SCALARV
,
MATRIXV
, *)
44
DEFNDBINOP_OP
(dmsmul,
MATRIX
,
SCALAR
,
MATRIXV
,
SCALARV
, *)
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
53
gripe_if_zero
(T
x
)
54
{
55
if
(x == T ())
56
gripe_divide_by_zero
();
57
return
x
;
58
}
59
60
DEFBINOP
(dmsdiv, MATRIX, SCALAR)
61
{
62
CAST_BINOP_ARGS
(
const
OCTAVE_MATRIX
&,
const
OCTAVE_SCALAR
&);
63
64
return
v1
.MATRIX_VALUE () /
gripe_if_zero
(
v2
.SCALAR_VALUE ());
65
}
66
67
DEFBINOP
(sdmldiv, SCALAR, MATRIX)
68
{
69
CAST_BINOP_ARGS
(
const
OCTAVE_SCALAR
&,
const
OCTAVE_MATRIX
&);
70
71
return
v2
.MATRIX_VALUE () /
gripe_if_zero
(
v1
.SCALAR_VALUE ());
72
}
73
74
DEFBINOP
(dmspow, MATRIX, SCALAR)
75
{
76
CAST_BINOP_ARGS
(
const
OCTAVE_MATRIX
&,
const
OCTAVE_SCALAR
&);
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
{
87
INSTALL_BINOP
(
op_mul
,
OCTAVE_MATRIX
,
OCTAVE_SCALAR
, dmsmul);
88
INSTALL_BINOP
(
op_div
,
OCTAVE_MATRIX
,
OCTAVE_SCALAR
, dmsdiv);
89
INSTALL_BINOP
(
op_mul
,
OCTAVE_SCALAR
,
OCTAVE_MATRIX
, sdmmul);
90
INSTALL_BINOP
(
op_ldiv
,
OCTAVE_SCALAR
,
OCTAVE_MATRIX
, sdmldiv);
91
INSTALL_BINOP
(
op_pow
,
OCTAVE_MATRIX
,
OCTAVE_SCALAR
, dmspow);
92
}
Generated on Mon Dec 30 2013 03:04:35 for GNU Octave by
1.8.1.2