This file is indexed.

/usr/include/ignition/math2/ignition/math/Kmeans.hh is in libignition-math2-dev 2.9.0+dfsg1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * Copyright (C) 2014-2015 Open Source Robotics Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/
#ifndef IGNITION_MATH_KMEANS_HH_
#define IGNITION_MATH_KMEANS_HH_

#include <vector>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Helpers.hh>

namespace ignition
{
  namespace math
  {
    // Forward declare private data
    class KmeansPrivate;

    /// \class Kmeans Kmeans.hh math/gzmath.hh
    /// \brief K-Means clustering algorithm. Given a set of observations,
    /// k-means partitions the observations into k sets so as to minimize the
    /// within-cluster sum of squares.
    /// Description based on http://en.wikipedia.org/wiki/K-means_clustering.
    class IGNITION_VISIBLE Kmeans
    {
      /// \brief constructor
      /// \param[in] _obs Set of observations to cluster.
      // cppcheck-suppress noExplicitConstructor
      public: Kmeans(const std::vector<Vector3d> &_obs);

      /// \brief Destructor.
      public: virtual ~Kmeans();

      /// \brief Get the observations to cluster.
      /// \return The vector of observations.
      public: std::vector<Vector3d> Observations() const;

      /// \brief Set the observations to cluster.
      /// \param[in] _obs The new vector of observations.
      /// \return True if the vector is not empty or false otherwise.
      public: bool Observations(const std::vector<Vector3d> &_obs);

      /// \brief Add observations to the cluster.
      /// \param[in] _obs Vector of observations.
      /// \return True if the _obs vector is not empty or false otherwise.
      public: bool AppendObservations(const std::vector<Vector3d> &_obs);

      /// \brief Executes the k-means algorithm.
      /// \param[in] _k Number of partitions to cluster.
      /// \param[out] _centroids Vector of centroids. Each element contains the
      /// centroid of one cluster.
      /// \param[out] _labels Vector of labels. The size of this vector is
      /// equals to the number of observations. Each element represents the
      /// cluster to which observation belongs.
      /// \return True when the operation succeed or false otherwise. The
      /// operation will fail if the number of observations is not positive,
      /// if the number of clusters is non positive, or if the number of
      /// clusters if greater than the number of observations.
      public: bool Cluster(int _k,
                           std::vector<Vector3d> &_centroids,
                           std::vector<unsigned int> &_labels);

      /// \brief Given an observation, it returns the closest centroid to it.
      /// \param[in] _p Point to check.
      /// \return The index of the closest centroid to the point _p.
      private: unsigned int ClosestCentroid(const Vector3d &_p) const;

      /// \brief Private data pointer
      private: KmeansPrivate *dataPtr;
    };
  }
}

#endif