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 |
4514
|
38 // XXX FIXME XXX -- this is not quite the right thing. |
|
39 |
|
40 boolMatrix |
|
41 boolNDArray::all (int dim) const |
|
42 { |
|
43 boolMatrix retval; |
|
44 |
|
45 if (dimensions.length () == 2) |
|
46 { |
|
47 boolMatrix tmp = matrix_value (); |
|
48 retval = tmp.all (dim); |
|
49 } |
|
50 else |
|
51 (*current_liboctave_error_handler) |
|
52 ("all is not yet implemented for N-d Arrays"); |
|
53 |
|
54 return retval; |
|
55 } |
|
56 |
|
57 boolMatrix |
|
58 boolNDArray::any (int dim) const |
|
59 { |
|
60 boolMatrix retval; |
|
61 |
|
62 if (dimensions.length () == 2) |
|
63 { |
|
64 boolMatrix tmp = matrix_value (); |
|
65 retval = tmp.any (dim); |
|
66 } |
|
67 else |
|
68 (*current_liboctave_error_handler) |
|
69 ("any is not yet implemented for N-d Arrays"); |
|
70 |
|
71 return retval; |
|
72 } |
|
73 |
|
74 boolMatrix |
|
75 boolNDArray::matrix_value (void) const |
|
76 { |
|
77 boolMatrix retval; |
|
78 |
|
79 int nd = ndims (); |
|
80 |
|
81 switch (nd) |
|
82 { |
|
83 case 1: |
|
84 retval = boolMatrix (Array2<bool> (*this, dimensions(0), 1)); |
|
85 break; |
|
86 |
|
87 case 2: |
|
88 retval = boolMatrix (Array2<bool> (*this, dimensions(0), |
|
89 dimensions(1))); |
|
90 break; |
|
91 |
|
92 default: |
|
93 (*current_liboctave_error_handler) |
|
94 ("invalid converstion of boolNDArray to boolMatrix"); |
|
95 break; |
|
96 } |
|
97 |
|
98 return retval; |
|
99 } |
|
100 |
4532
|
101 void |
|
102 boolNDArray::increment_index (Array<int>& ra_idx, |
|
103 const dim_vector& dimensions, |
|
104 int start_dimension) |
|
105 { |
|
106 ::increment_index (ra_idx, dimensions, start_dimension); |
|
107 } |
|
108 |
4514
|
109 /* |
|
110 ;;; Local Variables: *** |
|
111 ;;; mode: C++ *** |
|
112 ;;; End: *** |
|
113 */ |