4514
|
1 // N-D Array manipulations. |
|
2 /* |
|
3 |
|
4 Copyright (C) 1996, 1997 John W. Eaton |
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
|
25 #pragma implementation |
|
26 #endif |
|
27 |
|
28 #ifdef HAVE_CONFIG_H |
|
29 #include <config.h> |
|
30 #endif |
|
31 |
|
32 #include "CNDArray.h" |
|
33 #include "mx-base.h" |
|
34 #include "lo-ieee.h" |
|
35 |
4532
|
36 #include "ArrayN-inline.h" |
|
37 |
4543
|
38 // unary operations |
|
39 |
|
40 boolNDArray |
|
41 boolNDArray::operator ! (void) const |
|
42 { |
|
43 boolNDArray b (dims ()); |
|
44 |
|
45 for (int i = 0; i < length (); i++) |
|
46 b.elem (i) = ! elem (i); |
|
47 |
|
48 return b; |
|
49 } |
|
50 |
4514
|
51 // XXX FIXME XXX -- this is not quite the right thing. |
|
52 |
4556
|
53 boolNDArray |
4514
|
54 boolNDArray::all (int dim) const |
|
55 { |
4556
|
56 MX_ND_ALL_ANY (MX_ND_ALL_EVAL (MX_ND_ALL_EXPR)); |
4514
|
57 } |
|
58 |
4556
|
59 boolNDArray |
4514
|
60 boolNDArray::any (int dim) const |
|
61 { |
4556
|
62 MX_ND_ALL_ANY (MX_ND_ANY_EVAL (MX_ND_ANY_EXPR)); |
4514
|
63 } |
|
64 |
|
65 boolMatrix |
|
66 boolNDArray::matrix_value (void) const |
|
67 { |
|
68 boolMatrix retval; |
|
69 |
|
70 int nd = ndims (); |
|
71 |
|
72 switch (nd) |
|
73 { |
|
74 case 1: |
|
75 retval = boolMatrix (Array2<bool> (*this, dimensions(0), 1)); |
|
76 break; |
|
77 |
|
78 case 2: |
|
79 retval = boolMatrix (Array2<bool> (*this, dimensions(0), |
|
80 dimensions(1))); |
|
81 break; |
|
82 |
|
83 default: |
|
84 (*current_liboctave_error_handler) |
|
85 ("invalid converstion of boolNDArray to boolMatrix"); |
|
86 break; |
|
87 } |
|
88 |
|
89 return retval; |
|
90 } |
|
91 |
4532
|
92 void |
|
93 boolNDArray::increment_index (Array<int>& ra_idx, |
|
94 const dim_vector& dimensions, |
|
95 int start_dimension) |
|
96 { |
|
97 ::increment_index (ra_idx, dimensions, start_dimension); |
|
98 } |
|
99 |
4556
|
100 int |
|
101 boolNDArray::compute_index (Array<int>& ra_idx, |
|
102 const dim_vector& dimensions) |
|
103 { |
|
104 return ::compute_index (ra_idx, dimensions); |
|
105 } |
|
106 |
4543
|
107 NDND_CMP_OPS (boolNDArray, , boolNDArray, ) |
|
108 |
4514
|
109 /* |
|
110 ;;; Local Variables: *** |
|
111 ;;; mode: C++ *** |
|
112 ;;; End: *** |
|
113 */ |