3
Copyright (C) 1996-2013 John W. Eaton
5
This file is part of Octave.
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.
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
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/>.
27
#include "mx-fm-fcm.h"
28
#include "mx-fcm-fm.h"
29
#include "mx-fnda-fcnda.h"
30
#include "mx-fcnda-fnda.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"
44
// matrix by complex matrix ops.
46
DEFNDBINOP_OP (add, float_matrix, float_complex_matrix, float_array,
47
float_complex_array, +)
48
DEFNDBINOP_OP (sub, float_matrix, float_complex_matrix, float_array,
49
float_complex_array, -)
51
DEFBINOP_OP (mul, float_matrix, float_complex_matrix, *)
53
DEFBINOP (trans_mul, float_matrix, float_complex_matrix)
55
CAST_BINOP_ARGS (const octave_float_matrix&,
56
const octave_float_complex_matrix&);
58
FloatMatrix m1 = v1.float_matrix_value ();
59
FloatComplexMatrix m2 = v2.float_complex_matrix_value ();
61
return FloatComplexMatrix (xgemm (m1, real (m2), blas_trans, blas_no_trans),
62
xgemm (m1, imag (m2), blas_trans, blas_no_trans));
65
DEFBINOP (div, float_matrix, float_complex_matrix)
67
CAST_BINOP_ARGS (const octave_float_matrix&,
68
const octave_float_complex_matrix&);
69
MatrixType typ = v2.matrix_type ();
71
FloatComplexMatrix ret = xdiv (v1.float_matrix_value (),
72
v2.float_complex_matrix_value (), typ);
78
DEFBINOPX (pow, float_matrix, float_complex_matrix)
80
error ("can't do A ^ B for A and B both matrices");
81
return octave_value ();
84
DEFBINOP (ldiv, float_matrix, float_complex_matrix)
86
CAST_BINOP_ARGS (const octave_float_matrix&,
87
const octave_float_complex_matrix&);
88
MatrixType typ = v1.matrix_type ();
90
FloatComplexMatrix ret = xleftdiv (v1.float_matrix_value (),
91
v2.float_complex_matrix_value (), typ);
97
DEFBINOP (trans_ldiv, float_matrix, float_complex_matrix)
99
CAST_BINOP_ARGS (const octave_float_matrix&,
100
const octave_float_complex_matrix&);
101
MatrixType typ = v1.matrix_type ();
103
FloatComplexMatrix ret = xleftdiv (v1.float_matrix_value (),
104
v2.float_complex_matrix_value (),
107
v1.matrix_type (typ);
111
DEFNDCMPLXCMPOP_FN (lt, float_matrix, float_complex_matrix, float_array,
112
float_complex_array, mx_el_lt)
113
DEFNDCMPLXCMPOP_FN (le, float_matrix, float_complex_matrix, float_array,
114
float_complex_array, mx_el_le)
115
DEFNDCMPLXCMPOP_FN (eq, float_matrix, float_complex_matrix, float_array,
116
float_complex_array, mx_el_eq)
117
DEFNDCMPLXCMPOP_FN (ge, float_matrix, float_complex_matrix, float_array,
118
float_complex_array, mx_el_ge)
119
DEFNDCMPLXCMPOP_FN (gt, float_matrix, float_complex_matrix, float_array,
120
float_complex_array, mx_el_gt)
121
DEFNDCMPLXCMPOP_FN (ne, float_matrix, float_complex_matrix, float_array,
122
float_complex_array, mx_el_ne)
124
DEFNDBINOP_FN (el_mul, float_matrix, float_complex_matrix, float_array,
125
float_complex_array, product)
126
DEFNDBINOP_FN (el_div, float_matrix, float_complex_matrix, float_array,
127
float_complex_array, quotient)
128
DEFNDBINOP_FN (el_pow, float_matrix, float_complex_matrix, float_array,
129
float_complex_array, elem_xpow)
131
DEFBINOP (el_ldiv, float_matrix, float_complex_matrix)
133
CAST_BINOP_ARGS (const octave_float_matrix&,
134
const octave_float_complex_matrix&);
136
return quotient (v2.float_complex_array_value (), v1.float_array_value ());
139
DEFNDBINOP_FN (el_and, float_matrix, float_complex_matrix, float_array,
140
float_complex_array, mx_el_and)
141
DEFNDBINOP_FN (el_or, float_matrix, float_complex_matrix, float_array,
142
float_complex_array, mx_el_or)
144
DEFNDCATOP_FN (fm_fcm, float_matrix, float_complex_matrix, float_array,
145
float_complex_array, concat)
147
DEFNDCATOP_FN (m_fcm, matrix, float_complex_matrix, float_array,
148
float_complex_array, concat)
150
DEFNDCATOP_FN (fm_cm, float_matrix, complex_matrix, float_array,
151
float_complex_array, concat)
153
DEFCONV (float_complex_matrix_conv, float_matrix, float_complex_matrix)
155
CAST_CONV_ARG (const octave_float_matrix&);
157
return new octave_float_complex_matrix (FloatComplexNDArray
158
(v.float_array_value ()));
162
install_fm_fcm_ops (void)
164
INSTALL_BINOP (op_add, octave_float_matrix, octave_float_complex_matrix, add);
165
INSTALL_BINOP (op_sub, octave_float_matrix, octave_float_complex_matrix, sub);
166
INSTALL_BINOP (op_mul, octave_float_matrix, octave_float_complex_matrix, mul);
167
INSTALL_BINOP (op_div, octave_float_matrix, octave_float_complex_matrix, div);
168
INSTALL_BINOP (op_pow, octave_float_matrix, octave_float_complex_matrix, pow);
169
INSTALL_BINOP (op_ldiv, octave_float_matrix,
170
octave_float_complex_matrix, ldiv);
171
INSTALL_BINOP (op_lt, octave_float_matrix, octave_float_complex_matrix, lt);
172
INSTALL_BINOP (op_le, octave_float_matrix, octave_float_complex_matrix, le);
173
INSTALL_BINOP (op_eq, octave_float_matrix, octave_float_complex_matrix, eq);
174
INSTALL_BINOP (op_ge, octave_float_matrix, octave_float_complex_matrix, ge);
175
INSTALL_BINOP (op_gt, octave_float_matrix, octave_float_complex_matrix, gt);
176
INSTALL_BINOP (op_ne, octave_float_matrix, octave_float_complex_matrix, ne);
177
INSTALL_BINOP (op_el_mul, octave_float_matrix,
178
octave_float_complex_matrix, el_mul);
179
INSTALL_BINOP (op_el_div, octave_float_matrix,
180
octave_float_complex_matrix, el_div);
181
INSTALL_BINOP (op_el_pow, octave_float_matrix,
182
octave_float_complex_matrix, el_pow);
183
INSTALL_BINOP (op_el_ldiv, octave_float_matrix,
184
octave_float_complex_matrix, el_ldiv);
185
INSTALL_BINOP (op_el_and, octave_float_matrix,
186
octave_float_complex_matrix, el_and);
187
INSTALL_BINOP (op_el_or, octave_float_matrix,
188
octave_float_complex_matrix, el_or);
189
INSTALL_BINOP (op_trans_mul, octave_float_matrix,
190
octave_float_complex_matrix, trans_mul);
191
INSTALL_BINOP (op_herm_mul, octave_float_matrix,
192
octave_float_complex_matrix, trans_mul);
193
INSTALL_BINOP (op_trans_ldiv, octave_float_matrix,
194
octave_float_complex_matrix, trans_ldiv);
195
INSTALL_BINOP (op_herm_ldiv, octave_float_matrix,
196
octave_float_complex_matrix, trans_ldiv);
198
INSTALL_CATOP (octave_float_matrix, octave_float_complex_matrix, fm_fcm);
199
INSTALL_CATOP (octave_matrix, octave_float_complex_matrix, m_fcm);
200
INSTALL_CATOP (octave_float_matrix, octave_complex_matrix, fm_cm);
202
INSTALL_ASSIGNCONV (octave_float_matrix, octave_float_complex_matrix,
203
octave_float_complex_matrix);
204
INSTALL_ASSIGNCONV (octave_matrix, octave_float_complex_matrix,
205
octave_complex_matrix);
207
INSTALL_WIDENOP (octave_float_matrix, octave_float_complex_matrix,
208
float_complex_matrix_conv);