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