~gabriel1984sibiu/octave/octave

« back to all changes in this revision

Viewing changes to libinterp/operators/op-fm-fcm.cc

  • Committer: Grevutiu Gabriel
  • Date: 2014-01-02 13:05:54 UTC
  • Revision ID: gabriel1984sibiu@gmail.com-20140102130554-3r7ivdjln1ni6kcg
New version (3.8.0) from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-fm-fcm.h"
 
28
#include "mx-fcm-fm.h"
 
29
#include "mx-fnda-fcnda.h"
 
30
#include "mx-fcnda-fnda.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, 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, -)
 
50
 
 
51
DEFBINOP_OP (mul, float_matrix, float_complex_matrix, *)
 
52
 
 
53
DEFBINOP (trans_mul, float_matrix, float_complex_matrix)
 
54
{
 
55
  CAST_BINOP_ARGS (const octave_float_matrix&,
 
56
                   const octave_float_complex_matrix&);
 
57
 
 
58
  FloatMatrix m1 = v1.float_matrix_value ();
 
59
  FloatComplexMatrix m2 = v2.float_complex_matrix_value ();
 
60
 
 
61
  return FloatComplexMatrix (xgemm (m1, real (m2), blas_trans, blas_no_trans),
 
62
                             xgemm (m1, imag (m2), blas_trans, blas_no_trans));
 
63
}
 
64
 
 
65
DEFBINOP (div, float_matrix, float_complex_matrix)
 
66
{
 
67
  CAST_BINOP_ARGS (const octave_float_matrix&,
 
68
                   const octave_float_complex_matrix&);
 
69
  MatrixType typ = v2.matrix_type ();
 
70
 
 
71
  FloatComplexMatrix ret = xdiv (v1.float_matrix_value (),
 
72
                                 v2.float_complex_matrix_value (), typ);
 
73
 
 
74
  v2.matrix_type (typ);
 
75
  return ret;
 
76
}
 
77
 
 
78
DEFBINOPX (pow, float_matrix, float_complex_matrix)
 
79
{
 
80
  error ("can't do A ^ B for A and B both matrices");
 
81
  return octave_value ();
 
82
}
 
83
 
 
84
DEFBINOP (ldiv, float_matrix, float_complex_matrix)
 
85
{
 
86
  CAST_BINOP_ARGS (const octave_float_matrix&,
 
87
                   const octave_float_complex_matrix&);
 
88
  MatrixType typ = v1.matrix_type ();
 
89
 
 
90
  FloatComplexMatrix ret = xleftdiv (v1.float_matrix_value (),
 
91
                                     v2.float_complex_matrix_value (), typ);
 
92
 
 
93
  v1.matrix_type (typ);
 
94
  return ret;
 
95
}
 
96
 
 
97
DEFBINOP (trans_ldiv, float_matrix, float_complex_matrix)
 
98
{
 
99
  CAST_BINOP_ARGS (const octave_float_matrix&,
 
100
                   const octave_float_complex_matrix&);
 
101
  MatrixType typ = v1.matrix_type ();
 
102
 
 
103
  FloatComplexMatrix ret = xleftdiv (v1.float_matrix_value (),
 
104
                                     v2.float_complex_matrix_value (),
 
105
                                     typ, blas_trans);
 
106
 
 
107
  v1.matrix_type (typ);
 
108
  return ret;
 
109
}
 
110
 
 
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)
 
123
 
 
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)
 
130
 
 
131
DEFBINOP (el_ldiv, float_matrix, float_complex_matrix)
 
132
{
 
133
  CAST_BINOP_ARGS (const octave_float_matrix&,
 
134
                   const octave_float_complex_matrix&);
 
135
 
 
136
  return quotient (v2.float_complex_array_value (), v1.float_array_value ());
 
137
}
 
138
 
 
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)
 
143
 
 
144
DEFNDCATOP_FN (fm_fcm, float_matrix, float_complex_matrix, float_array,
 
145
               float_complex_array, concat)
 
146
 
 
147
DEFNDCATOP_FN (m_fcm, matrix, float_complex_matrix, float_array,
 
148
               float_complex_array, concat)
 
149
 
 
150
DEFNDCATOP_FN (fm_cm, float_matrix, complex_matrix, float_array,
 
151
               float_complex_array, concat)
 
152
 
 
153
DEFCONV (float_complex_matrix_conv, float_matrix, float_complex_matrix)
 
154
{
 
155
  CAST_CONV_ARG (const octave_float_matrix&);
 
156
 
 
157
  return new octave_float_complex_matrix (FloatComplexNDArray
 
158
                                           (v.float_array_value ()));
 
159
}
 
160
 
 
161
void
 
162
install_fm_fcm_ops (void)
 
163
{
 
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);
 
197
 
 
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);
 
201
 
 
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);
 
206
 
 
207
  INSTALL_WIDENOP (octave_float_matrix, octave_float_complex_matrix,
 
208
                   float_complex_matrix_conv);
 
209
}