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 "mx-base.h"
00034 #include "lo-ieee.h"
00035
00036
00037
00038 template <class T>
00039 boolNDArray
00040 intNDArray<T>::operator ! (void) const
00041 {
00042 boolNDArray b (this->dims ());
00043
00044 for (int i = 0; i < this->length (); i++)
00045 b.elem (i) = ! this->elem (i);
00046
00047 return b;
00048 }
00049
00050
00051
00052 template <class T>
00053 boolNDArray
00054 intNDArray<T>::all (int dim) const
00055 {
00056 MX_ND_ANY_ALL_REDUCTION (MX_ND_ALL_EVAL (this->elem (iter_idx) == T (0)), true);
00057 }
00058
00059 template <class T>
00060 boolNDArray
00061 intNDArray<T>::any (int dim) const
00062 {
00063 MX_ND_ANY_ALL_REDUCTION (MX_ND_ALL_EVAL (this->elem (iter_idx) == T (0)), false);
00064 }
00065
00066 template <class T>
00067 void
00068 intNDArray<T>::increment_index (Array<int>& ra_idx,
00069 const dim_vector& dimensions,
00070 int start_dimension)
00071 {
00072 ::increment_index (ra_idx, dimensions, start_dimension);
00073 }
00074
00075 template <class T>
00076 int
00077 intNDArray<T>::compute_index (Array<int>& ra_idx,
00078 const dim_vector& dimensions)
00079 {
00080 return ::compute_index (ra_idx, dimensions);
00081 }
00082
00083 template <class T>
00084 intNDArray<T>
00085 intNDArray<T>::concat (const intNDArray<T>& rb, const Array<int>& ra_idx)
00086 {
00087 if (rb.numel () > 0);
00088 insert (rb, ra_idx);
00089 return *this;
00090 }
00091
00092 template <class T>
00093 intNDArray<T>&
00094 intNDArray<T>::insert (const intNDArray<T>& a, int r, int c)
00095 {
00096 Array<T>::insert (a, r, c);
00097 return *this;
00098 }
00099
00100 template <class T>
00101 intNDArray<T>&
00102 intNDArray<T>::insert (const intNDArray<T>& a, const Array<int>& ra_idx)
00103 {
00104 Array<T>::insert (a, ra_idx);
00105 return *this;
00106 }
00107
00108
00109
00110 template <class T>
00111 std::ostream&
00112 operator << (std::ostream& os, const intNDArray<T>& a)
00113 {
00114 int nel = a.nelem ();
00115
00116 for (int i = 0; i < nel; i++)
00117 os << " " << a.elem (i) << "\n";
00118
00119 return os;
00120 }
00121
00122 template <class T>
00123 std::istream&
00124 operator >> (std::istream& is, intNDArray<T>& a)
00125 {
00126 int nel = a.nelem ();
00127
00128 if (nel < 1 )
00129 is.clear (std::ios::badbit);
00130 else
00131 {
00132 T tmp;
00133
00134 for (int i = 0; i < nel; i++)
00135 {
00136 is >> tmp;
00137
00138 if (is)
00139 a.elem (i) = tmp;
00140 else
00141 goto done;
00142 }
00143 }
00144
00145 done:
00146
00147 return is;
00148 }
00149
00150
00151
00152
00153
00154