4901
|
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__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
|
31 #include "gripes.h" |
|
32 #include "oct-obj.h" |
|
33 #include "ov.h" |
|
34 #include "ov-uint8.h" |
|
35 #include "ov-typeinfo.h" |
|
36 #include "ops.h" |
|
37 #include "xdiv.h" |
|
38 #include "xpow.h" |
|
39 |
|
40 // matrix unary ops. |
|
41 |
|
42 DEFNDUNOP_OP (not, uint8_matrix, uint8_array, !) |
|
43 DEFNDUNOP_OP (uminus, uint8_matrix, uint8_array, -) |
|
44 |
|
45 DEFUNOP (transpose, uint8_matrix) |
|
46 { |
|
47 CAST_UNOP_ARG (const octave_uint8_matrix&); |
|
48 |
|
49 if (v.ndims () > 2) |
|
50 { |
|
51 error ("transpose not defined for N-d objects"); |
|
52 return octave_value (); |
|
53 } |
|
54 else |
|
55 return octave_value (v.uint8_array_value().transpose ()); |
|
56 } |
|
57 |
|
58 //DEFNCUNOP_METHOD (incr, uint8_matrix, increment) |
|
59 //DEFNCUNOP_METHOD (decr, uint8_matrix, decrement) |
|
60 |
|
61 // matrix by matrix ops. |
|
62 |
|
63 DEFNDBINOP_OP (add, uint8_matrix, uint8_matrix, uint8_array, uint8_array, +) |
|
64 DEFNDBINOP_OP (sub, uint8_matrix, uint8_matrix, uint8_array, uint8_array, -) |
|
65 |
|
66 //DEFBINOP_OP (mul, uint8_matrix, uint8_matrix, *) |
|
67 //DEFBINOP_FN (div, uint8_matrix, uint8_matrix, xdiv) |
|
68 |
|
69 DEFBINOPX (pow, uint8_matrix, uint8_matrix) |
|
70 { |
|
71 error ("can't do A ^ B for A and B both matrices"); |
|
72 return octave_value (); |
|
73 } |
|
74 |
|
75 //DEFBINOP_FN (ldiv, uint8_matrix, uint8_matrix, xleftdiv) |
|
76 |
|
77 DEFNDBINOP_FN (lt, uint8_matrix, uint8_matrix, uint8_array, uint8_array, mx_el_lt) |
|
78 DEFNDBINOP_FN (le, uint8_matrix, uint8_matrix, uint8_array, uint8_array, mx_el_le) |
|
79 DEFNDBINOP_FN (eq, uint8_matrix, uint8_matrix, uint8_array, uint8_array, mx_el_eq) |
|
80 DEFNDBINOP_FN (ge, uint8_matrix, uint8_matrix, uint8_array, uint8_array, mx_el_ge) |
|
81 DEFNDBINOP_FN (gt, uint8_matrix, uint8_matrix, uint8_array, uint8_array, mx_el_gt) |
|
82 DEFNDBINOP_FN (ne, uint8_matrix, uint8_matrix, uint8_array, uint8_array, mx_el_ne) |
|
83 |
|
84 DEFNDBINOP_FN (el_mul, uint8_matrix, uint8_matrix, uint8_array, uint8_array, product) |
|
85 |
|
86 DEFNDBINOP_FN (el_div, uint8_matrix, uint8_matrix, uint8_array, uint8_array, quotient) |
|
87 |
|
88 //DEFNDBINOP_FN (el_pow, uint8_matrix, uint8_matrix, uint8_array, uint8_array, elem_xpow) |
|
89 |
|
90 //DEFBINOP (el_ldiv, uint8_matrix, uint8_matrix) |
|
91 //{ |
|
92 // CAST_BINOP_ARGS (const octave_matrix&, const octave_matrix&); |
|
93 // |
|
94 // return octave_value (quotient (v2.array_value (), v1.array_value ())); |
|
95 //} |
|
96 |
|
97 DEFNDBINOP_FN (el_and, uint8_matrix, uint8_matrix, uint8_array, uint8_array, mx_el_and) |
|
98 DEFNDBINOP_FN (el_or, uint8_matrix, uint8_matrix, uint8_array, uint8_array, mx_el_or) |
|
99 |
|
100 DEFNDASSIGNOP_FN (assign, uint8_matrix, uint8_matrix, uint8_array, assign) |
|
101 |
|
102 void |
|
103 install_ui8_ui8_ops (void) |
|
104 { |
|
105 INSTALL_UNOP (op_not, octave_uint8_matrix, not); |
|
106 INSTALL_UNOP (op_uminus, octave_uint8_matrix, uminus); |
|
107 INSTALL_UNOP (op_transpose, octave_uint8_matrix, transpose); |
|
108 INSTALL_UNOP (op_hermitian, octave_uint8_matrix, transpose); |
|
109 |
|
110 // INSTALL_NCUNOP (op_incr, octave_uint8_matrix, incr); |
|
111 // INSTALL_NCUNOP (op_decr, octave_uint8_matrix, decr); |
|
112 |
|
113 INSTALL_BINOP (op_add, octave_uint8_matrix, octave_uint8_matrix, add); |
|
114 INSTALL_BINOP (op_sub, octave_uint8_matrix, octave_uint8_matrix, sub); |
|
115 // INSTALL_BINOP (op_mul, octave_uint8_matrix, octave_uint8_matrix, mul); |
|
116 // INSTALL_BINOP (op_div, octave_uint8_matrix, octave_uint8_matrix, div); |
|
117 // INSTALL_BINOP (op_pow, octave_uint8_matrix, octave_uint8_matrix, pow); |
|
118 // INSTALL_BINOP (op_ldiv, octave_uint8_matrix, octave_uint8_matrix, ldiv); |
|
119 INSTALL_BINOP (op_lt, octave_uint8_matrix, octave_uint8_matrix, lt); |
|
120 INSTALL_BINOP (op_le, octave_uint8_matrix, octave_uint8_matrix, le); |
|
121 INSTALL_BINOP (op_eq, octave_uint8_matrix, octave_uint8_matrix, eq); |
|
122 INSTALL_BINOP (op_ge, octave_uint8_matrix, octave_uint8_matrix, ge); |
|
123 INSTALL_BINOP (op_gt, octave_uint8_matrix, octave_uint8_matrix, gt); |
|
124 INSTALL_BINOP (op_ne, octave_uint8_matrix, octave_uint8_matrix, ne); |
|
125 INSTALL_BINOP (op_el_mul, octave_uint8_matrix, octave_uint8_matrix, el_mul); |
|
126 INSTALL_BINOP (op_el_div, octave_uint8_matrix, octave_uint8_matrix, el_div); |
|
127 // INSTALL_BINOP (op_el_pow, octave_uint8_matrix, octave_uint8_matrix, el_pow); |
|
128 // INSTALL_BINOP (op_el_ldiv, octave_uint8_matrix, octave_uint8_matrix, el_ldiv); |
|
129 INSTALL_BINOP (op_el_and, octave_uint8_matrix, octave_uint8_matrix, el_and); |
|
130 INSTALL_BINOP (op_el_or, octave_uint8_matrix, octave_uint8_matrix, el_or); |
|
131 |
|
132 INSTALL_ASSIGNOP (op_asn_eq, octave_uint8_matrix, octave_uint8_matrix, assign); |
|
133 } |
|
134 |
|
135 /* |
|
136 ;;; Local Variables: *** |
|
137 ;;; mode: C++ *** |
|
138 ;;; End: *** |
|
139 */ |