00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
00025 #pragma implementation
00026 #endif
00027
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031
00032 #include "Array-util.h"
00033 #include "CNDArray.h"
00034 #include "mx-base.h"
00035 #include "lo-ieee.h"
00036
00037
00038
00039 boolNDArray
00040 boolNDArray::operator ! (void) const
00041 {
00042 boolNDArray b (dims ());
00043
00044 for (int i = 0; i < length (); i++)
00045 b.elem (i) = ! elem (i);
00046
00047 return b;
00048 }
00049
00050
00051
00052 boolNDArray
00053 boolNDArray::all (int dim) const
00054 {
00055 MX_ND_ANY_ALL_REDUCTION (MX_ND_ALL_EVAL (MX_ND_ALL_EXPR), true);
00056 }
00057
00058 boolNDArray
00059 boolNDArray::any (int dim) const
00060 {
00061 MX_ND_ANY_ALL_REDUCTION (MX_ND_ANY_EVAL (MX_ND_ANY_EXPR), false);
00062 }
00063
00064 boolNDArray
00065 boolNDArray::concat (const boolNDArray& rb, const Array<int>& ra_idx)
00066 {
00067 if (rb.numel () > 0)
00068 insert (rb, ra_idx);
00069 return *this;
00070 }
00071
00072 boolNDArray&
00073 boolNDArray::insert (const boolNDArray& a, int r, int c)
00074 {
00075 Array<bool>::insert (a, r, c);
00076 return *this;
00077 }
00078
00079 boolNDArray&
00080 boolNDArray::insert (const boolNDArray& a, const Array<int>& ra_idx)
00081 {
00082 Array<bool>::insert (a, ra_idx);
00083 return *this;
00084 }
00085
00086
00087
00088 boolMatrix
00089 boolNDArray::matrix_value (void) const
00090 {
00091 boolMatrix retval;
00092
00093 int nd = ndims ();
00094
00095 switch (nd)
00096 {
00097 case 1:
00098 retval = boolMatrix (Array2<bool> (*this, dimensions(0), 1));
00099 break;
00100
00101 case 2:
00102 retval = boolMatrix (Array2<bool> (*this, dimensions(0),
00103 dimensions(1)));
00104 break;
00105
00106 default:
00107 (*current_liboctave_error_handler)
00108 ("invalid conversion of boolNDArray to boolMatrix");
00109 break;
00110 }
00111
00112 return retval;
00113 }
00114
00115 void
00116 boolNDArray::increment_index (Array<int>& ra_idx,
00117 const dim_vector& dimensions,
00118 int start_dimension)
00119 {
00120 ::increment_index (ra_idx, dimensions, start_dimension);
00121 }
00122
00123 int
00124 boolNDArray::compute_index (Array<int>& ra_idx,
00125 const dim_vector& dimensions)
00126 {
00127 return ::compute_index (ra_idx, dimensions);
00128 }
00129
00130 NDND_BOOL_OPS (boolNDArray, boolNDArray, false)
00131 NDND_CMP_OPS (boolNDArray, , boolNDArray, )
00132
00133 NDS_BOOL_OPS (boolNDArray, bool, false)
00134 NDS_CMP_OPS (boolNDArray, , bool, )
00135
00136 SND_BOOL_OPS (bool, boolNDArray, false)
00137 SND_CMP_OPS (bool, , boolNDArray, )
00138
00139
00140
00141
00142
00143