1 #ifndef vnl_index_sort_h_ 2 #define vnl_index_sort_h_ 13 # include <vcl_msvc_warnings.h> 15 #include "vnl/vnl_export.h" 17 template <
class TValue,
class TIndex>
79 for (
unsigned int vIx = 0;
80 vIx < (direction ==
ByRow ? values.
rows() : values.
cols()); vIx++)
82 getVector(values, direction, vIx, valVect);
84 putVector(sortedValVect, direction, vIx, sorted_values);
85 putVector(indVect, direction, vIx, indices);
92 template <
class T,
class I>
107 c.
data =
v.data_block();
110 for (TIndex ix = 0; ix < (TIndex)
v.size(); ix++) s[ix] = ix;
122 for (TIndex ix = 0; ix < (TIndex) values.
size(); ix++)
123 sorted_values[ix] = values[indices[ix]];
137 toVect = fromMat.
get_row(whichVect);
159 toMat.
set_row(whichVect, fromVect);
unsigned int cols() const
Return the number of columns.
void vector_sort_in_place(SortVectorType &values, SortVectorIndexType &indices)
sort indices, return sorted values in place.
Implementation class - Do Not Use.
void matrix_sort(DirectionType direction, const SortMatrixType &values, SortMatrixType &sorted_values, SortMatrixIndexType &indices)
matrix sort.
void sortIndices(const SortVectorType &v, SortVectorIndexType &s)
sort the indices of a vector.
bool set_size(size_t n)
Resize to n elements.
void vector_sort(const SortVectorType &values, SortVectorIndexType &indices)
just sort indices.
size_t size() const
Return the length, number of elements, dimension of this vector.
vnl_matrix< TValue > SortMatrixType
typedefs for matrix sorting.
vnl_vector< TValue > SortVectorType
typedefs for vector sorting.
enum vnl_index_sort::DirectionType Direction
iterator end()
Iterator pointing to element beyond end of data.
vnl_matrix & set_column(unsigned i, T const *v)
Set the elements of the i'th column to v[i] (No bounds checking).
void putVector(const vnl_vector< T > &fromVect, DirectionType direction, int whichVect, vnl_matrix< T > &toMat)
put specified vector to matrix depending on direction.
void vector_sort(const SortVectorType &values, SortVectorType &sorted_values, SortVectorIndexType &indices)
sort indices and values.
void getVector(const vnl_matrix< T > &fromMat, DirectionType direction, int whichVect, vnl_vector< T > &toVect)
get specified vector from matrix depending on direction.
iterator begin()
Iterator pointing to start of data.
An ordinary mathematical matrix.
void clear()
Make the vector as if it had been default-constructed.
bool operator()(const I &a, const I &b)
vnl_vector< TIndex > SortVectorIndexType
Mathematical vector class, templated by type of element.
vnl_vector< T > get_column(unsigned c) const
Get a vector equal to the given column.
vnl_vector< T > get_row(unsigned r) const
Get a vector equal to the given row.
vnl_matrix & set_row(unsigned i, T const *v)
Set the elements of the i'th row to v[i] (No bounds checking).
DirectionType
matrix sort along rows or columns?.
unsigned int rows() const
Return the number of rows.
void reindexValues(const SortVectorType &values, const SortVectorIndexType &indices, SortVectorType &sorted_values)
reorder values from sorted indices.
bool set_size(unsigned r, unsigned c)
Resize to r rows by c columns. Old data lost.
vnl_matrix< TIndex > SortMatrixIndexType