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

chNDArray.cc

解説を見る。
00001 // N-D Array  manipulations.
00002 /*
00003 
00004 Copyright (C) 2003 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 "chNDArray.h"
00034 #include "mx-base.h"
00035 #include "lo-ieee.h"
00036 #include "lo-mappers.h"
00037 
00038 // XXX FIXME XXX -- this is not quite the right thing.
00039 
00040 boolNDArray
00041 charNDArray::all (int dim) const
00042 {
00043   MX_ND_ANY_ALL_REDUCTION (MX_ND_ALL_EVAL (elem (iter_idx) == ' '), true);
00044 }
00045 
00046 boolNDArray
00047 charNDArray::any (int dim) const
00048 {
00049   MX_ND_ANY_ALL_REDUCTION (MX_ND_ANY_EVAL (elem (iter_idx) != ' '), false);
00050 }
00051 
00052 charNDArray
00053 charNDArray::concat (const charNDArray& rb, const Array<int>& ra_idx)
00054 {
00055   if (rb.numel () > 0)
00056     insert (rb, ra_idx);
00057   return *this;
00058 }
00059 
00060 charNDArray
00061 charNDArray::concat (const NDArray& rb, const Array<int>& ra_idx)
00062 {
00063   charNDArray tmp (rb.dims ());
00064   int nel = rb.numel ();
00065 
00066   if (rb.numel () == 0)
00067     return *this;
00068 
00069   for (int i = 0; i < nel; i++)
00070     {
00071       double d = rb.elem (i);
00072 
00073       if (xisnan (d))
00074         {
00075           (*current_liboctave_error_handler)
00076             ("invalid conversion from NaN to character");
00077           return *this;
00078         }
00079       else
00080         {
00081           int ival = NINT (d);
00082 
00083           if (ival < 0 || ival > UCHAR_MAX)
00084             // XXX FIXME XXX -- is there something
00085             // better we could do? Should we warn the user?
00086             ival = 0;
00087 
00088           tmp.elem (i) = static_cast<char>(ival);
00089         }
00090     }
00091 
00092   insert (tmp, ra_idx);
00093   return *this;
00094 }
00095 
00096 charNDArray&
00097 charNDArray::insert (const charNDArray& a, int r, int c)
00098 {
00099   Array<char>::insert (a, r, c);
00100   return *this;
00101 }
00102 
00103 charNDArray&
00104 charNDArray::insert (const charNDArray& a, const Array<int>& ra_idx)
00105 {
00106   Array<char>::insert (a, ra_idx);
00107   return *this;
00108 }
00109 
00110 charMatrix
00111 charNDArray::matrix_value (void) const
00112 {
00113   charMatrix retval;
00114 
00115   int nd = ndims ();
00116 
00117   switch (nd)
00118     {
00119     case 1:
00120       retval = charMatrix (Array2<char> (*this, dimensions(0), 1));
00121       break;
00122 
00123     case 2:
00124       retval = charMatrix (Array2<char> (*this, dimensions(0),
00125                                                dimensions(1)));
00126       break;
00127 
00128     default:
00129       (*current_liboctave_error_handler)
00130         ("invalid conversion of charNDArray to charMatrix");
00131       break;
00132     }
00133 
00134   return retval;
00135 }
00136 
00137 void
00138 charNDArray::increment_index (Array<int>& ra_idx,
00139                               const dim_vector& dimensions,
00140                               int start_dimension)
00141 {
00142   ::increment_index (ra_idx, dimensions, start_dimension);
00143 }
00144 
00145 int 
00146 charNDArray::compute_index (Array<int>& ra_idx,
00147                             const dim_vector& dimensions)
00148 {
00149   return ::compute_index (ra_idx, dimensions);
00150 }
00151 
00152 /*
00153 ;;; Local Variables: ***
00154 ;;; mode: C++ ***
00155 ;;; End: ***
00156 */

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