comparison src/OPERATORS/op-m-m.cc @ 2928:295f037b4b3e

[project @ 1997-05-05 05:32:33 by jwe]
author jwe
date Mon, 05 May 1997 05:33:54 +0000
parents
children bc61b0e8d60e
comparison
equal deleted inserted replaced
2927:8722c6284b72 2928:295f037b4b3e
1 /*
2
3 Copyright (C) 1996, 1997 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 2, or (at your option) any
10 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, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 */
22
23 #if defined (__GNUG__)
24 #pragma implementation
25 #endif
26
27 #ifdef HAVE_CONFIG_H
28 #include <config.h>
29 #endif
30
31 #include "gripes.h"
32 #include "ov.h"
33 #include "ov-re-mat.h"
34 #include "ov-typeinfo.h"
35 #include "ops.h"
36 #include "xdiv.h"
37 #include "xpow.h"
38
39 // matrix by matrix ops.
40
41 DEFBINOP_OP (add, matrix, matrix, +)
42 DEFBINOP_OP (sub, matrix, matrix, -)
43 DEFBINOP_OP (mul, matrix, matrix, *)
44
45 DEFBINOP (div, matrix, matrix)
46 {
47 CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&);
48
49 return xdiv (v1.matrix_value (), v2.matrix_value ());
50 }
51
52 DEFBINOPX (pow, matrix, matrix)
53 {
54 error ("can't do A ^ B for A and B both matrices");
55 return octave_value ();
56 }
57
58 DEFBINOP_FN (ldiv, matrix, matrix, xleftdiv)
59
60 DEFBINOP_FN (lt, matrix, matrix, mx_el_lt)
61 DEFBINOP_FN (le, matrix, matrix, mx_el_le)
62 DEFBINOP_FN (eq, matrix, matrix, mx_el_eq)
63 DEFBINOP_FN (ge, matrix, matrix, mx_el_ge)
64 DEFBINOP_FN (gt, matrix, matrix, mx_el_gt)
65 DEFBINOP_FN (ne, matrix, matrix, mx_el_ne)
66
67 DEFBINOP_FN (el_mul, matrix, matrix, product)
68 DEFBINOP_FN (el_div, matrix, matrix, quotient)
69 DEFBINOP_FN (el_pow, matrix, matrix, elem_xpow)
70
71 DEFBINOP (el_ldiv, matrix, matrix)
72 {
73 CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&);
74
75 return octave_value (quotient (v2.matrix_value (), v1.matrix_value ()));
76 }
77
78 DEFBINOP_FN (el_and, matrix, matrix, mx_el_and)
79 DEFBINOP_FN (el_or, matrix, matrix, mx_el_or)
80
81 DEFASSIGNOP_FN (assign, matrix, matrix, assign)
82
83 void
84 install_m_m_ops (void)
85 {
86 INSTALL_BINOP (add, octave_matrix, octave_matrix, add);
87 INSTALL_BINOP (sub, octave_matrix, octave_matrix, sub);
88 INSTALL_BINOP (mul, octave_matrix, octave_matrix, mul);
89 INSTALL_BINOP (div, octave_matrix, octave_matrix, div);
90 INSTALL_BINOP (pow, octave_matrix, octave_matrix, pow);
91 INSTALL_BINOP (ldiv, octave_matrix, octave_matrix, ldiv);
92 INSTALL_BINOP (lt, octave_matrix, octave_matrix, lt);
93 INSTALL_BINOP (le, octave_matrix, octave_matrix, le);
94 INSTALL_BINOP (eq, octave_matrix, octave_matrix, eq);
95 INSTALL_BINOP (ge, octave_matrix, octave_matrix, ge);
96 INSTALL_BINOP (gt, octave_matrix, octave_matrix, gt);
97 INSTALL_BINOP (ne, octave_matrix, octave_matrix, ne);
98 INSTALL_BINOP (el_mul, octave_matrix, octave_matrix, el_mul);
99 INSTALL_BINOP (el_div, octave_matrix, octave_matrix, el_div);
100 INSTALL_BINOP (el_pow, octave_matrix, octave_matrix, el_pow);
101 INSTALL_BINOP (el_ldiv, octave_matrix, octave_matrix, el_ldiv);
102 INSTALL_BINOP (el_and, octave_matrix, octave_matrix, el_and);
103 INSTALL_BINOP (el_or, octave_matrix, octave_matrix, el_or);
104
105 INSTALL_ASSIGNOP (asn_eq, octave_matrix, octave_matrix, assign);
106 }
107
108 /*
109 ;;; Local Variables: ***
110 ;;; mode: C++ ***
111 ;;; End: ***
112 */