Modernize typedefs in docs

This commit is contained in:
Martin Lambertsen
2024-10-25 11:20:47 +02:00
parent db14293137
commit 855a22f267
13 changed files with 40 additions and 38 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ types cannot be used.
easily defined as below:
```c++
typedef typename MatType::elem_type ElemType;
using ElemType = typename MatType::elem_type;
```
and otherwise a template parameter with the name `ElemType` can be used. It is
+1 -1
View File
@@ -202,7 +202,7 @@ class ExampleTree
public:
// This is the element type held by the matrix.
// It will generally either be `double`, or `float`.
typedef typename MatType::elem_type ElemType;
using ElemType = typename MatType::elem_type;
//////////////////////
//// Constructors ////
+4 -3
View File
@@ -386,8 +386,9 @@ IPMetric<PolynomialKernel> metric(pk);
// the custom base of 1.5 (default is 1.3). We have to be sure to use the right
// type here -- FastMKS needs the FastMKSStat object as the tree's
// StatisticType.
typedef CoverTree<IPMetric<PolynomialKernel>, FirstPointIsRoot, FastMKSStat>
TreeType; // Convenience typedef.
// Convenience typedef.
using TreeType =
CoverTree<IPMetric<PolynomialKernel>, FirstPointIsRoot, FastMKSStat>;
TreeType* tree = new TreeType(data, metric, 1.5);
// Now initialize FastMKS with that statistic. We don't need to specify the
@@ -455,7 +456,7 @@ extern arma::mat data;
// The custom tree type. We'll assume that the first template parameter is the
// statistic type.
typedef CustomTree<FastMKSStat> TreeType;
using TreeType = CustomTree<FastMKSStat>;
// The FastMKS constructor will create the tree.
FastMKS<LinearKernel, arma::mat, TreeType> f(data);
+1 -1
View File
@@ -213,7 +213,7 @@ The `KNN` class is, specifically, a typedef of the more extensible
distance.
```c++
typedef NeighborSearch<NearestNeighborSort, EuclideanDistance> KNN;
using KNN = NeighborSearch<NearestNeighborSort, EuclideanDistance>;
```
Using the `KNN` class is particularly simple; first, the object must be
+3 -3
View File
@@ -553,9 +553,9 @@ find the number of leaf nodes with fewer than 10 children.
// above).
// This convenient typedef saves us a long type name!
typedef mlpack::BallTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::fmat> TreeType;
using TreeType = mlpack::BallTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::fmat>;
TreeType tree;
mlpack::data::Load("tree.bin", "tree", tree);
+10 -10
View File
@@ -1850,11 +1850,11 @@ arma::mat dataset;
mlpack::data::Load("corel-histogram.csv", dataset, true);
// Convenience typedef for the tree type.
typedef mlpack::BinarySpaceTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::mat,
mlpack::HRectBound,
mlpack::MidpointSplit> TreeType;
using TreeType = mlpack::BinarySpaceTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::mat,
mlpack::HRectBound,
mlpack::MidpointSplit>;
// Build trees on the first half and the second half of points.
TreeType tree1(dataset.cols(0, dataset.n_cols / 2));
@@ -1947,11 +1947,11 @@ manually and find the number of leaf nodes with less than 10 children.
// above).
// This convenient typedef saves us a long type name!
typedef mlpack::BinarySpaceTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::fmat,
mlpack::HRectBound,
mlpack::MidpointSplit> TreeType;
using TreeType = mlpack::BinarySpaceTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::fmat,
mlpack::HRectBound,
mlpack::MidpointSplit>;
TreeType tree;
mlpack::data::Load("tree.bin", "tree", tree);
+3 -3
View File
@@ -547,9 +547,9 @@ find the number of leaf nodes with fewer than 10 children.
// above).
// This convenient typedef saves us a long type name!
typedef mlpack::KDTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::fmat> TreeType;
using TreeType = mlpack::KDTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::fmat>;
TreeType tree;
mlpack::data::Load("tree.bin", "tree", tree);
+3 -3
View File
@@ -551,9 +551,9 @@ find the number of leaf nodes with fewer than 10 children.
// above).
// This convenient typedef saves us a long type name!
typedef mlpack::MeanSplitBallTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::fmat> TreeType;
using TreeType = mlpack::MeanSplitBallTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::fmat>;
TreeType tree;
mlpack::data::Load("tree.bin", "tree", tree);
+3 -3
View File
@@ -560,9 +560,9 @@ manually and find the number of leaf nodes with fewer than 10 children.
// above).
// This convenient typedef saves us a long type name!
typedef mlpack::MeanSplitKDTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::fmat> TreeType;
using TreeType = mlpack::MeanSplitKDTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::fmat>;
TreeType tree;
mlpack::data::Load("tree.bin", "tree", tree);
+3 -3
View File
@@ -558,9 +558,9 @@ find the number of leaf nodes with less than 10 children.
// above).
// This convenient typedef saves us a long type name!
typedef mlpack::VPTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::fmat> TreeType;
using TreeType = mlpack::VPTree<mlpack::EuclideanDistance,
mlpack::EmptyStatistic,
arma::fmat>;
TreeType tree;
mlpack::data::Load("tree.bin", "tree", tree);
+2 -2
View File
@@ -256,10 +256,10 @@ arma::Row<size_t> labels =
// Train in the constructor, using floating-point data.
// The weak learner type is now a floating-point Perceptron.
typedef mlpack::Perceptron<
using PerceptronType = mlpack::Perceptron<
mlpack::SimpleWeightUpdate,
mlpack::ZeroInitialization,
arma::fmat> PerceptronType;
arma::fmat>;
mlpack::AdaBoost<PerceptronType, arma::fmat> ab(dataset, labels, 5);
// Create test data (500 points).
+3 -3
View File
@@ -418,9 +418,9 @@ arma::Row<size_t> labels =
// Train in the constructor, using floating-point data.
// The weak learner type is now a floating-point Perceptron.
typedef mlpack::Perceptron<mlpack::SimpleWeightUpdate,
mlpack::ZeroInitialization,
arma::fmat> PerceptronType;
using PerceptronType = mlpack::Perceptron<mlpack::SimpleWeightUpdate,
mlpack::ZeroInitialization,
arma::fmat>;
mlpack::AdaBoost<PerceptronType, arma::fmat> ab(dataset, labels, 5);
// Create test data (500 points).
+3 -2
View File
@@ -659,8 +659,9 @@ mlpack::RandomAcolInitialization<5> initW;
mlpack::RandomAMFInitialization initH;
// Combine the two initializations so we can pass it to the AMF class.
typedef mlpack::MergeInitialization<mlpack::RandomAcolInitialization<5>,
mlpack::RandomAMFInitialization> InitType;
using InitType =
mlpack::MergeInitialization<mlpack::RandomAcolInitialization<5>,
mlpack::RandomAMFInitialization>;
InitType init(initW, initH);
// Create an AMF object with the custom initialization.