Mercurial > hg > octave-nkf
comparison liboctave/dNDArray.cc @ 4513:508238e65af7
[project @ 2003-09-19 21:40:57 by jwe]
author | jwe |
---|---|
date | Fri, 19 Sep 2003 21:41:21 +0000 |
parents | 24af46b4ce84 |
children | 01ee68d18069 |
comparison
equal
deleted
inserted
replaced
4512:b55eaa010770 | 4513:508238e65af7 |
---|---|
1 //N-D Array manipulations. | 1 // N-D Array manipulations. |
2 /* | 2 /* |
3 | 3 |
4 Copyright (C) 1996, 1997 John W. Eaton | 4 Copyright (C) 1996, 1997 John W. Eaton |
5 | 5 |
6 This file is part of Octave. | 6 This file is part of Octave. |
27 | 27 |
28 #ifdef HAVE_CONFIG_H | 28 #ifdef HAVE_CONFIG_H |
29 #include <config.h> | 29 #include <config.h> |
30 #endif | 30 #endif |
31 | 31 |
32 #include "NDArray.h" | 32 #include "dNDArray.h" |
33 #include "mx-base.h" | 33 #include "mx-base.h" |
34 #include "lo-error.h" | |
34 #include "lo-ieee.h" | 35 #include "lo-ieee.h" |
36 | |
37 // XXX FIXME XXX -- this is not quite the right thing. | |
38 | |
39 boolMatrix | |
40 NDArray::all (int dim) const | |
41 { | |
42 boolMatrix retval; | |
43 | |
44 if (dimensions.length () == 2) | |
45 { | |
46 Matrix tmp = matrix_value (); | |
47 retval = tmp.all (dim); | |
48 } | |
49 else | |
50 (*current_liboctave_error_handler) | |
51 ("all is not yet implemented for N-d Arrays"); | |
52 | |
53 return retval; | |
54 } | |
55 | |
56 boolMatrix | |
57 NDArray::any (int dim) const | |
58 { | |
59 boolMatrix retval; | |
60 | |
61 if (dimensions.length () == 2) | |
62 { | |
63 Matrix tmp = matrix_value (); | |
64 retval = tmp.any (dim); | |
65 } | |
66 else | |
67 (*current_liboctave_error_handler) | |
68 ("any is not yet implemented for N-d Arrays"); | |
69 | |
70 return retval; | |
71 } | |
35 | 72 |
36 bool | 73 bool |
37 NDArray::any_element_is_negative (bool neg_zero) const | 74 NDArray::any_element_is_negative (bool neg_zero) const |
38 { | 75 { |
39 int n = length (); | 76 int n = length (); |
80 return false; | 117 return false; |
81 } | 118 } |
82 | 119 |
83 return true; | 120 return true; |
84 } | 121 } |
122 | |
123 Matrix | |
124 NDArray::matrix_value (void) const | |
125 { | |
126 Matrix retval; | |
127 | |
128 int nd = ndims (); | |
129 | |
130 switch (nd) | |
131 { | |
132 case 1: | |
133 retval = Matrix (Array2<double> (*this, dimensions(0), 1)); | |
134 break; | |
135 | |
136 case 2: | |
137 retval = Matrix (Array2<double> (*this, dimensions(0), dimensions(1))); | |
138 break; | |
139 | |
140 default: | |
141 (*current_liboctave_error_handler) | |
142 ("invalid converstion of NDArray to Matrix"); | |
143 break; | |
144 } | |
145 | |
146 return retval; | |
147 } | |
148 | |
149 /* | |
150 ;;; Local Variables: *** | |
151 ;;; mode: C++ *** | |
152 ;;; End: *** | |
153 */ |