Array-util.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2000-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_Array_util_h)
00024 #define octave_Array_util_h 1
00025 
00026 #include "Array.h"
00027 #include "dim-vector.h"
00028 #include "idx-vector.h"
00029 #include "lo-array-gripes.h"
00030 
00031 extern OCTAVE_API bool index_in_bounds (const Array<octave_idx_type>& ra_idx,
00032                              const dim_vector& dimensions);
00033 
00034 extern OCTAVE_API void increment_index (Array<octave_idx_type>& ra_idx,
00035                              const dim_vector& dimensions,
00036                              int start_dimension = 0);
00037 
00038 extern OCTAVE_API octave_idx_type get_scalar_idx (Array<octave_idx_type>& idx, dim_vector& dims);
00039 
00040 extern OCTAVE_API octave_idx_type num_ones (const Array<octave_idx_type>& ra_idx);
00041 
00042 extern OCTAVE_API bool is_scalar (const dim_vector& dim);
00043 
00044 extern OCTAVE_API bool is_vector (const dim_vector& dim);
00045 
00046 extern OCTAVE_API bool any_ones (const Array<octave_idx_type>& arr);
00047 
00048 // These four compute a linear index for given dimensions, throwing
00049 // exceptions on invalid indices.
00050 extern OCTAVE_API octave_idx_type
00051 compute_index (octave_idx_type n, const dim_vector& dims);
00052 
00053 extern OCTAVE_API octave_idx_type
00054 compute_index (octave_idx_type i, octave_idx_type j, const dim_vector& dims);
00055 
00056 extern OCTAVE_API octave_idx_type
00057 compute_index (octave_idx_type i, octave_idx_type j, octave_idx_type k,
00058                const dim_vector& dims);
00059 
00060 extern OCTAVE_API octave_idx_type
00061 compute_index (const Array<octave_idx_type>& ra_idx, const dim_vector& dims);
00062 
00063 extern OCTAVE_API Array<octave_idx_type> conv_to_int_array (const Array<idx_vector>& a);
00064 
00065 extern OCTAVE_API Array<idx_vector> conv_to_array (const idx_vector *tmp, const octave_idx_type len);
00066 
00067 extern OCTAVE_API dim_vector freeze (Array<idx_vector>& ra_idx,
00068                           const dim_vector& dimensions, int resize_ok);
00069 
00070 extern OCTAVE_API bool vector_equivalent (const dim_vector& dv);
00071 
00072 extern OCTAVE_API bool all_ok (const Array<idx_vector>& ra_idx);
00073 
00074 extern OCTAVE_API bool any_orig_empty (const Array<idx_vector>& ra_idx);
00075 
00076 extern OCTAVE_API bool all_colon_equiv (const Array<idx_vector>& ra_idx,
00077                              const dim_vector& frozen_lengths);
00078 
00079 extern OCTAVE_API bool all_ones (const Array<octave_idx_type>& arr);
00080 
00081 extern OCTAVE_API Array<octave_idx_type> get_elt_idx (const Array<idx_vector>& ra_idx,
00082                                const Array<octave_idx_type>& result_idx);
00083 
00084 extern OCTAVE_API Array<octave_idx_type> get_ra_idx (octave_idx_type idx, const dim_vector& dims);
00085 
00086 extern OCTAVE_API dim_vector zero_dims_inquire (const Array<idx_vector>& ia,
00087                                                 const dim_vector& rhdv);
00088 
00089 extern OCTAVE_API dim_vector zero_dims_inquire (const idx_vector& i, const idx_vector& j,
00090                                                 const dim_vector& rhdv);
00091 
00092 extern OCTAVE_API idx_vector sub2ind (const dim_vector& dv, const Array<idx_vector>& idxa);
00093 
00094 extern OCTAVE_API Array<idx_vector> ind2sub (const dim_vector& dv, const idx_vector& idx);
00095 
00096 struct
00097 permute_vector
00098 {
00099   octave_idx_type pidx;
00100   octave_idx_type iidx;
00101 };
00102 
00103 extern int OCTAVE_API permute_vector_compare (const void *a, const void *b);
00104 
00105 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines