5164
|
1 /* |
|
2 |
|
3 Copyright (C) 2004 David Bateman |
|
4 Copyright (C) 1998-2004 Andy Adler |
|
5 |
|
6 Octave is free software; you can redistribute it and/or modify it |
|
7 under the terms of the GNU General Public License as published by the |
|
8 Free Software Foundation; either version 2, or (at your option) any |
|
9 later version. |
|
10 |
|
11 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 for more details. |
|
15 |
|
16 You should have received a copy of the GNU General Public License |
|
17 along with this program; see the file COPYING. If not, write to the Free |
|
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
19 |
|
20 */ |
|
21 |
|
22 #ifdef HAVE_CONFIG_H |
|
23 #include <config.h> |
|
24 #endif |
|
25 |
|
26 #include "gripes.h" |
|
27 #include "oct-obj.h" |
|
28 #include "ov.h" |
|
29 #include "ov-typeinfo.h" |
|
30 #include "ov-bool.h" |
|
31 #include "ov-scalar.h" |
|
32 #include "ops.h" |
|
33 |
|
34 #include "ov-re-sparse.h" |
|
35 |
|
36 // bool by sparse bool matrix ops. |
|
37 |
|
38 DEFBINOP_FN (ne, bool, sparse_bool_matrix, mx_el_ne) |
|
39 DEFBINOP_FN (eq, bool, sparse_bool_matrix, mx_el_eq) |
|
40 |
|
41 DEFBINOP_FN (el_and, bool, sparse_bool_matrix, mx_el_and) |
|
42 DEFBINOP_FN (el_or, bool, sparse_bool_matrix, mx_el_or) |
|
43 |
|
44 DEFCATOP (b_sbm, bool, sparse_bool_matrix) |
|
45 { |
|
46 CAST_BINOP_ARGS (octave_bool&, const octave_sparse_bool_matrix&); |
|
47 SparseBoolMatrix tmp (1, 1, v1.bool_value ()); |
|
48 return octave_value (tmp. concat (v2.sparse_bool_matrix_value (), |
|
49 ra_idx)); |
|
50 } |
|
51 |
|
52 DEFCATOP (b_sm, bool, sparse_matrix) |
|
53 { |
|
54 CAST_BINOP_ARGS (octave_bool&, const octave_sparse_matrix&); |
|
55 SparseMatrix tmp (1, 1, v1.scalar_value ()); |
|
56 return octave_value (tmp. concat (v2.sparse_matrix_value (), ra_idx)); |
|
57 } |
|
58 |
|
59 DEFCATOP (s_sbm, scalar, sparse_bool_matrix) |
|
60 { |
|
61 CAST_BINOP_ARGS (octave_scalar&, const octave_sparse_bool_matrix&); |
|
62 SparseMatrix tmp (1, 1, v1.scalar_value ()); |
|
63 return octave_value(tmp. concat (v2.sparse_matrix_value (), ra_idx)); |
|
64 } |
|
65 |
|
66 DEFCONV (sparse_bool_matrix_conv, bool, sparse_bool_matrix) |
|
67 { |
|
68 CAST_CONV_ARG (const octave_bool&); |
|
69 |
|
70 return new octave_sparse_bool_matrix |
|
71 (SparseBoolMatrix (1, 1, v.bool_value ())); |
|
72 } |
|
73 |
|
74 void |
|
75 install_b_sbm_ops (void) |
|
76 { |
|
77 INSTALL_BINOP (op_eq, octave_bool, octave_sparse_bool_matrix, eq); |
|
78 INSTALL_BINOP (op_ne, octave_bool, octave_sparse_bool_matrix, ne); |
|
79 |
|
80 INSTALL_BINOP (op_el_and, octave_bool, octave_sparse_bool_matrix, el_and); |
|
81 INSTALL_BINOP (op_el_or, octave_bool, octave_sparse_bool_matrix, el_or); |
|
82 |
|
83 INSTALL_CATOP (octave_bool, octave_sparse_bool_matrix, b_sbm); |
|
84 INSTALL_CATOP (octave_bool, octave_sparse_matrix, b_sm); |
|
85 INSTALL_CATOP (octave_scalar, octave_sparse_bool_matrix, s_sbm); |
|
86 |
|
87 INSTALL_ASSIGNCONV (octave_bool, octave_sparse_bool_matrix, octave_sparse_bool_matrix); |
|
88 |
|
89 INSTALL_WIDENOP (octave_bool, octave_sparse_bool_matrix, sparse_bool_matrix_conv); |
|
90 } |
|
91 |
|
92 /* |
|
93 ;;; Local Variables: *** |
|
94 ;;; mode: C++ *** |
|
95 ;;; End: *** |
|
96 */ |