Commit 39290274 authored by Davis King's avatar Davis King

Code cleanup

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403591
parent 8896813c
......@@ -3,10 +3,10 @@
#ifndef DLIB_MANIFOLD_REGULARIzATION_HEADER
#define DLIB_MANIFOLD_REGULARIzATION_HEADER
#include "manifold_regularization/sample_pair.h"
#include "manifold_regularization/graph_creation.h"
#include "manifold_regularization/linear_manifold_regularizer.h"
#include "manifold_regularization/function_objects.h"
#include "manifold_regularization/sample_pair.h"
#endif // DLIB_MANIFOLD_REGULARIzATION_HEADER
......
......@@ -12,8 +12,9 @@ namespace dlib
// ----------------------------------------------------------------------------------------
struct sample_pair
class sample_pair
{
public:
sample_pair(
) :
_index1(0),
......
// Copyright (C) 2010 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_SAMPLE_PaIR_ABSTRACT_H__
#ifdef DLIB_SAMPLE_PaIR_ABSTRACT_H__
#include <limits>
#include "../serialize.h"
namespace dlib
{
// ----------------------------------------------------------------------------------------
class sample_pair
{
/*!
WHAT THIS OBJECT REPRESENTS
This object is intended to represent an edge in an undirected graph
that has data samples in its vertices. So it contains two integers
(index1 and index2) which represent the identifying indices of
the samples at the ends of an edge. Note that this object enforces
the constraint that index1 <= index2. This has the effect of
making the edges undirected since a sample_pair is incapable
of representing a single edge in more than one way. That is,
sample_pair(i,j) == sample_pair(j,i) for any value of i and j.
This object also contains a float which can be used for any purpose.
!*/
public:
sample_pair(
);
/*!
ensures
- #index1() == 0
- #index2() == 0
- #distance() == std::numeric_limits<float>::max()
!*/
sample_pair (
const unsigned long idx1,
const unsigned long idx2,
const float dist
);
/*!
ensures
- #index1() == min(idx1,idx2)
- #index2() == max(idx1,idx2)
- #distance() == dist
!*/
const unsigned long& index1 (
) const;
/*!
ensures
- returns the first index value stored in this object
!*/
const unsigned long& index2 (
) const;
/*!
ensures
- returns the second index value stored in this object
!*/
const float& distance (
) const;
/*!
ensures
- returns the floating point number stored in this object
!*/
};
// ----------------------------------------------------------------------------------------
inline bool order_by_index (
const sample_pair& a,
const sample_pair& b
) { return a.index1() < b.index1() || (a.index1() == b.index1() && a.index2() < b.index2()); }
/*!
ensures
- provides a total ordering of sample_pair objects that will cause pairs that are
equal to be adjacent when sorted. This function can be used with std::sort() to
first sort sequences of sample_pair objects and then find duplicate edges.
!*/
inline bool order_by_distance (
const sample_pair& a,
const sample_pair& b
) { return a.distance() < b.distance(); }
/*!
ensures
- provides a total ordering of sample_pair objects that causes pairs with
smallest distance to be the first in a sorted list. This function can be
used with std::sort()
!*/
// ----------------------------------------------------------------------------------------
inline bool operator == (
const sample_pair& a,
const sample_pair& b
);
/*!
ensures
- returns a.index1() == b.index1() && a.index2() == b.index2();
I.e. returns true if a and b both represent the same pair and false otherwise.
Note that the distance field is not involved in this comparison.
!*/
inline bool operator != (
const sample_pair& a,
const sample_pair& b
);
/*!
ensures
- returns !(a == b)
!*/
// ----------------------------------------------------------------------------------------
inline void serialize (
const sample_pair& item,
std::ostream& out
);
/*!
provides serialization support
!*/
inline void deserialize (
sample_pair& item,
std::istream& in
);
/*!
provides deserialization support
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_SAMPLE_PaIR_ABSTRACT_H__
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment