メインページ   クラス階層   構成   ファイル一覧   構成メンバ   ファイルメンバ  

intNDArray.cc

解説を見る。
00001 // N-D Array  manipulations.
00002 /*
00003 
00004 Copyright (C) 2004 John W. Eaton
00005 
00006 This file is part of Octave.
00007 
00008 Octave is free software; you can redistribute it and/or modify it
00009 under the terms of the GNU General Public License as published by the
00010 Free Software Foundation; either version 2, or (at your option) any
00011 later version.
00012 
00013 Octave is distributed in the hope that it will be useful, but WITHOUT
00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016 for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Octave; see the file COPYING.  If not, write to the Free
00020 Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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 // unary operations
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 // XXX FIXME XXX -- this is not quite the right thing.
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 // This contains no information on the array structure !!!
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 ;;; Local Variables: ***
00152 ;;; mode: C++ ***
00153 ;;; End: ***
00154 */

Wed Dec 29 11:51:37 2004に生成されました。 doxygen1.2.18
SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送