4514
|
1 // N-D Array manipulations. |
|
2 /* |
|
3 |
|
4 Copyright (C) 2003 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 |
4588
|
32 #include "Array-util.h" |
4514
|
33 #include "chNDArray.h" |
|
34 #include "mx-base.h" |
|
35 #include "lo-ieee.h" |
|
36 |
|
37 // XXX FIXME XXX -- this is not quite the right thing. |
|
38 |
4556
|
39 boolNDArray |
4514
|
40 charNDArray::all (int dim) const |
|
41 { |
4569
|
42 MX_ND_ANY_ALL_REDUCTION (MX_ND_ALL_EVAL (elem (iter_idx) == ' '), true); |
4514
|
43 } |
|
44 |
4556
|
45 boolNDArray |
4514
|
46 charNDArray::any (int dim) const |
|
47 { |
4569
|
48 MX_ND_ANY_ALL_REDUCTION (MX_ND_ANY_EVAL (elem (iter_idx) != ' '), false); |
4514
|
49 } |
|
50 |
4758
|
51 bool |
4762
|
52 charNDArray::cat (const charNDArray& ra_arg, int dim, int add_dim) |
4758
|
53 { |
|
54 MX_ND_CAT; |
|
55 } |
|
56 |
4514
|
57 charMatrix |
|
58 charNDArray::matrix_value (void) const |
|
59 { |
|
60 charMatrix retval; |
|
61 |
|
62 int nd = ndims (); |
|
63 |
|
64 switch (nd) |
|
65 { |
|
66 case 1: |
|
67 retval = charMatrix (Array2<char> (*this, dimensions(0), 1)); |
|
68 break; |
|
69 |
|
70 case 2: |
|
71 retval = charMatrix (Array2<char> (*this, dimensions(0), |
|
72 dimensions(1))); |
|
73 break; |
|
74 |
|
75 default: |
|
76 (*current_liboctave_error_handler) |
4770
|
77 ("invalid conversion of charNDArray to charMatrix"); |
4514
|
78 break; |
|
79 } |
|
80 |
|
81 return retval; |
|
82 } |
|
83 |
4532
|
84 void |
|
85 charNDArray::increment_index (Array<int>& ra_idx, |
|
86 const dim_vector& dimensions, |
|
87 int start_dimension) |
|
88 { |
|
89 ::increment_index (ra_idx, dimensions, start_dimension); |
|
90 } |
|
91 |
4556
|
92 int |
|
93 charNDArray::compute_index (Array<int>& ra_idx, |
|
94 const dim_vector& dimensions) |
|
95 { |
|
96 return ::compute_index (ra_idx, dimensions); |
|
97 } |
|
98 |
4514
|
99 /* |
|
100 ;;; Local Variables: *** |
|
101 ;;; mode: C++ *** |
|
102 ;;; End: *** |
|
103 */ |