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-m-cm.cc
Go to the documentation of this file.
1
/*
2
3
Copyright (C) 1996-2013 John W. Eaton
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 "
mx-m-cm.h
"
28
#include "
mx-cm-m.h
"
29
#include "
mx-nda-cnda.h
"
30
#include "
mx-cnda-nda.h
"
31
32
#include "
gripes.h
"
33
#include "
oct-obj.h
"
34
#include "
ov.h
"
35
#include "
ov-re-mat.h
"
36
#include "
ov-flt-re-mat.h
"
37
#include "
ov-cx-mat.h
"
38
#include "
ov-flt-cx-mat.h
"
39
#include "
ov-typeinfo.h
"
40
#include "
ops.h
"
41
#include "
xdiv.h
"
42
#include "
xpow.h
"
43
44
// matrix by complex matrix ops.
45
46
DEFNDBINOP_OP
(add, matrix, complex_matrix, array, complex_array, +)
47
DEFNDBINOP_OP
(sub, matrix, complex_matrix, array, complex_array, -)
48
49
DEFBINOP_OP
(mul, matrix, complex_matrix, *)
50
51
DEFBINOP
(
trans_mul
, matrix, complex_matrix)
52
{
53
CAST_BINOP_ARGS
(
const
octave_matrix
&,
const
octave_complex_matrix
&);
54
55
Matrix
m1 =
v1
.
matrix_value
();
56
ComplexMatrix
m2 =
v2
.
complex_matrix_value
();
57
58
return
ComplexMatrix
(
xgemm
(m1,
real
(m2),
blas_trans
,
blas_no_trans
),
59
xgemm
(m1,
imag
(m2),
blas_trans
,
blas_no_trans
));
60
}
61
62
DEFBINOP
(div, matrix, complex_matrix)
63
{
64
CAST_BINOP_ARGS
(
const
octave_matrix
&,
const
octave_complex_matrix
&);
65
MatrixType
typ =
v2
.
matrix_type
();
66
67
ComplexMatrix
ret =
xdiv
(
v1
.
matrix_value
(),
68
v2
.
complex_matrix_value
(), typ);
69
70
v2
.
matrix_type
(typ);
71
return
ret;
72
}
73
74
DEFBINOPX
(
pow
, matrix, complex_matrix)
75
{
76
error
(
"can't do A ^ B for A and B both matrices"
);
77
return
octave_value
();
78
}
79
80
DEFBINOP
(ldiv, matrix, complex_matrix)
81
{
82
CAST_BINOP_ARGS
(
const
octave_matrix
&,
const
octave_complex_matrix
&);
83
MatrixType
typ =
v1
.
matrix_type
();
84
85
ComplexMatrix
ret =
xleftdiv
(
v1
.
matrix_value
(),
86
v2
.
complex_matrix_value
(), typ);
87
88
v1
.
matrix_type
(typ);
89
return
ret;
90
}
91
92
DEFBINOP
(trans_ldiv, matrix, complex_matrix)
93
{
94
CAST_BINOP_ARGS
(
const
octave_matrix
&,
const
octave_complex_matrix
&);
95
MatrixType
typ =
v1
.
matrix_type
();
96
97
ComplexMatrix
ret =
xleftdiv
(
v1
.
matrix_value
(),
98
v2
.
complex_matrix_value
(), typ,
blas_trans
);
99
100
v1
.
matrix_type
(typ);
101
return
ret;
102
}
103
104
DEFNDCMPLXCMPOP_FN
(lt, matrix, complex_matrix, array, complex_array,
mx_el_lt
)
105
DEFNDCMPLXCMPOP_FN
(le, matrix, complex_matrix, array, complex_array,
mx_el_le
)
106
DEFNDCMPLXCMPOP_FN
(eq, matrix, complex_matrix, array, complex_array,
mx_el_eq
)
107
DEFNDCMPLXCMPOP_FN
(ge, matrix, complex_matrix, array, complex_array,
mx_el_ge
)
108
DEFNDCMPLXCMPOP_FN
(gt, matrix, complex_matrix, array, complex_array,
mx_el_gt
)
109
DEFNDCMPLXCMPOP_FN
(ne, matrix, complex_matrix, array, complex_array,
mx_el_ne
)
110
111
DEFNDBINOP_FN
(el_mul, matrix, complex_matrix, array, complex_array,
product
)
112
DEFNDBINOP_FN
(el_div, matrix, complex_matrix, array, complex_array,
quotient
)
113
DEFNDBINOP_FN
(el_pow, matrix, complex_matrix, array, complex_array,
elem_xpow
)
114
115
DEFBINOP
(el_ldiv, matrix, complex_matrix)
116
{
117
CAST_BINOP_ARGS
(
const
octave_matrix
&,
const
octave_complex_matrix
&);
118
119
return
quotient
(
v2
.
complex_array_value
(),
v1
.
array_value
());
120
}
121
122
DEFNDBINOP_FN
(el_and, matrix, complex_matrix, array, complex_array,
mx_el_and
)
123
DEFNDBINOP_FN
(el_or, matrix, complex_matrix, array, complex_array,
mx_el_or
)
124
125
DEFNDCATOP_FN
(m_cm, matrix, complex_matrix, array, complex_array,
concat
)
126
127
DEFCONV
(complex_matrix_conv, matrix, complex_matrix)
128
{
129
CAST_CONV_ARG
(
const
octave_matrix
&);
130
131
return
new
octave_complex_matrix
(
ComplexNDArray
(v.array_value ()));
132
}
133
134
void
135
install_m_cm_ops
(
void
)
136
{
137
INSTALL_BINOP
(
op_add
,
octave_matrix
,
octave_complex_matrix
, add);
138
INSTALL_BINOP
(
op_sub
,
octave_matrix
,
octave_complex_matrix
, sub);
139
INSTALL_BINOP
(
op_mul
,
octave_matrix
,
octave_complex_matrix
, mul);
140
INSTALL_BINOP
(
op_div
,
octave_matrix
,
octave_complex_matrix
, div);
141
INSTALL_BINOP
(
op_pow
,
octave_matrix
,
octave_complex_matrix
,
pow
);
142
INSTALL_BINOP
(
op_ldiv
,
octave_matrix
,
octave_complex_matrix
, ldiv);
143
INSTALL_BINOP
(
op_lt
,
octave_matrix
,
octave_complex_matrix
, lt);
144
INSTALL_BINOP
(
op_le
,
octave_matrix
,
octave_complex_matrix
, le);
145
INSTALL_BINOP
(
op_eq
,
octave_matrix
,
octave_complex_matrix
, eq);
146
INSTALL_BINOP
(
op_ge
,
octave_matrix
,
octave_complex_matrix
, ge);
147
INSTALL_BINOP
(
op_gt
,
octave_matrix
,
octave_complex_matrix
, gt);
148
INSTALL_BINOP
(
op_ne
,
octave_matrix
,
octave_complex_matrix
, ne);
149
INSTALL_BINOP
(
op_el_mul
,
octave_matrix
,
octave_complex_matrix
, el_mul);
150
INSTALL_BINOP
(
op_el_div
,
octave_matrix
,
octave_complex_matrix
, el_div);
151
INSTALL_BINOP
(
op_el_pow
,
octave_matrix
,
octave_complex_matrix
, el_pow);
152
INSTALL_BINOP
(
op_el_ldiv
,
octave_matrix
,
octave_complex_matrix
, el_ldiv);
153
INSTALL_BINOP
(
op_el_and
,
octave_matrix
,
octave_complex_matrix
, el_and);
154
INSTALL_BINOP
(
op_el_or
,
octave_matrix
,
octave_complex_matrix
, el_or);
155
INSTALL_BINOP
(
op_trans_mul
,
octave_matrix
,
octave_complex_matrix
,
trans_mul
);
156
INSTALL_BINOP
(
op_herm_mul
,
octave_matrix
,
octave_complex_matrix
,
trans_mul
);
157
INSTALL_BINOP
(
op_trans_ldiv
,
octave_matrix
,
octave_complex_matrix
,
158
trans_ldiv);
159
INSTALL_BINOP
(
op_herm_ldiv
,
octave_matrix
,
octave_complex_matrix
,
160
trans_ldiv);
161
162
INSTALL_CATOP
(
octave_matrix
,
octave_complex_matrix
, m_cm);
163
164
INSTALL_ASSIGNCONV
(
octave_matrix
,
octave_complex_matrix
,
165
octave_complex_matrix
);
166
INSTALL_ASSIGNCONV
(
octave_float_matrix
,
octave_complex_matrix
,
167
octave_float_complex_matrix
);
168
169
INSTALL_WIDENOP
(
octave_matrix
,
octave_complex_matrix
, complex_matrix_conv);
170
}
Generated on Mon Dec 30 2013 03:04:36 for GNU Octave by
1.8.1.2