2928
|
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-str-mat.h" |
|
34 #include "ov-typeinfo.h" |
|
35 #include "ops.h" |
|
36 |
|
37 // string by string ops. |
|
38 |
|
39 DEFBINOP (eq, char_matrix_str, char_matrix_str) |
|
40 { |
|
41 CAST_BINOP_ARGS (const octave_char_matrix_str&, |
|
42 const octave_char_matrix_str&); |
|
43 |
|
44 charMatrix cm1 = v1.char_matrix_value (); |
|
45 charMatrix cm2 = v2.char_matrix_value (); |
|
46 |
|
47 if (cm1.rows () == 1 && cm1.columns () == 1) |
|
48 { |
|
49 if (cm2.rows () == 1 && cm2.columns () == 1) |
|
50 return octave_value (cm1 (0, 0) == cm2 (0, 0)); |
|
51 else |
|
52 SC_MX_BOOL_OP (char, c, cm1 (0, 0), charMatrix, m, cm2, |
|
53 c == m (i, j), 0.0); |
|
54 } |
|
55 else |
|
56 { |
|
57 int cm2_nr = cm2.rows (); |
|
58 int cm2_nc = cm2.cols (); |
|
59 |
|
60 if (cm2_nr == 1 && cm2_nc == 1) |
|
61 MX_SC_BOOL_OP (charMatrix, m, cm1, char, c, cm2 (0, 0), |
|
62 c == m (i, j), 0.0); |
|
63 else |
|
64 MX_MX_BOOL_OP (charMatrix, m1, cm1, charMatrix, m2, cm2, |
|
65 m1 (i, j) == m2 (i, j), "==", 0.0, 1.0); |
|
66 } |
|
67 } |
|
68 |
|
69 DEFBINOP (ne, char_matrix_str, char_matrix_str) |
|
70 { |
|
71 CAST_BINOP_ARGS (const octave_char_matrix_str&, |
|
72 const octave_char_matrix_str&); |
|
73 |
|
74 charMatrix cm1 = v1.char_matrix_value (); |
|
75 charMatrix cm2 = v2.char_matrix_value (); |
|
76 |
|
77 if (cm1.rows () == 1 && cm1.columns () == 1) |
|
78 { |
|
79 if (cm2.rows () == 1 && cm2.columns () == 1) |
|
80 return octave_value (cm1 (0, 0) != cm2 (0, 0)); |
|
81 else |
|
82 SC_MX_BOOL_OP (char, c, cm1 (0, 0), charMatrix, m, cm2, |
|
83 c != m (i, j), 1.0); |
|
84 } |
|
85 else |
|
86 { |
|
87 if (cm2.rows () == 1 && cm2.columns () == 1) |
|
88 MX_SC_BOOL_OP (charMatrix, m, cm1, char, c, cm2 (0, 0), |
|
89 c != m (i, j), 1.0); |
|
90 else |
|
91 MX_MX_BOOL_OP (charMatrix, m1, cm1, charMatrix, m2, cm2, |
|
92 m1 (i, j) != m2 (i, j), "!=", 1.0, 0.0); |
|
93 } |
|
94 } |
|
95 |
|
96 DEFASSIGNOP (assign, char_matrix_str, char_matrix_str) |
|
97 { |
|
98 CAST_BINOP_ARGS (octave_char_matrix_str&, const octave_char_matrix_str&); |
|
99 |
|
100 v1.assign (idx, v2.char_matrix_value ()); |
|
101 return octave_value (); |
|
102 } |
|
103 |
|
104 void |
|
105 install_str_str_ops (void) |
|
106 { |
|
107 INSTALL_BINOP (eq, octave_char_matrix_str, octave_char_matrix_str, eq); |
|
108 INSTALL_BINOP (ne, octave_char_matrix_str, octave_char_matrix_str, ne); |
|
109 |
|
110 INSTALL_ASSIGNOP (asn_eq, octave_char_matrix_str, octave_char_matrix_str, assign); |
|
111 } |
|
112 |
|
113 /* |
|
114 ;;; Local Variables: *** |
|
115 ;;; mode: C++ *** |
|
116 ;;; End: *** |
|
117 */ |