From c1c61579c82c527516051205ba2cf779818a4d26 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Wed, 16 Oct 2024 15:16:44 -0400 Subject: [PATCH 01/25] Add documentation for RPTree and MaxRPTree. --- doc/user/core/trees/max_rp_tree.md | 635 +++++++++++++++++++++++++++++ doc/user/core/trees/rp_tree.md | 635 +++++++++++++++++++++++++++++ 2 files changed, 1270 insertions(+) create mode 100644 doc/user/core/trees/max_rp_tree.md create mode 100644 doc/user/core/trees/rp_tree.md diff --git a/doc/user/core/trees/max_rp_tree.md b/doc/user/core/trees/max_rp_tree.md new file mode 100644 index 0000000000..bb8fc5c32a --- /dev/null +++ b/doc/user/core/trees/max_rp_tree.md @@ -0,0 +1,635 @@ +# `MaxRPTree` + + + +The `MaxRPTree` class represents a random projection tree, a variant of the +[`k`-d tree](kdtree.md) based on random projections. The random projection tree +is a well-known data structure for efficient distance operations (such as +nearest neighbor search) in low dimensions---typically less than 100. + +An `MaxRPTree` (or the similar [`RPTree`](rp_tree.md)) may be preferred over +a [`KDTree`](kdtree.md) or other tree structures as it is theoretically known to +adapt to the intrinsic dimension of the data. This is similar to the cover +tree, but the implementation is far simpler and as a result, more efficient. + + + +mlpack's `MaxRPTree` implementation supports three template parameters for +configurable behavior, and implements all the functionality required by the +[TreeType API](../../../developer/trees.md#the-treetype-api), plus some +additional functionality specific to random projection trees. + + * [Template parameters](#template-parameters) + * [Constructors](#constructors) + * [Basic tree properties](#basic-tree-properties) + * [Bounding distances with the tree](#bounding-distances-with-the-tree) + * [Tree traversals](#tree-traversals) + * [Example usage](#example-usage) + +## See also + + + + * [`RPTree`](rp_tree.md) + * [kd-tree on Wikipedia](https://en.wikipedia.org/wiki/Kd-tree) + * [Random projection on Wikipedia](https://en.wikipedia.org/wiki/Random_projection) + * [`BinarySpaceTree`](binary_space_tree.md) + * [Binary space partitioning on Wikipedia](https://dl.acm.org/doi/pdf/10.1145/361002.361007) + * [Random Projection Trees and Low Dimensional Manifolds (pdf)](https://www.cs.cornell.edu/~abrahao/tdg/papers/p537.pdf) + * [Tree-Independent Dual-Tree Algorithms (pdf)](https://www.ratml.org/pub/pdf/2013tree.pdf) + +## Template parameters + +In accordance with the [TreeType +API](../../../developer/trees.md#template-parameters-required-by-the-treetype-policy) +(see also [this more detailed section](../../../developer/trees.md#template-parameters)), +the `MaxRPTree` class takes three template parameters: + +``` +MaxRPTree +``` + + * `DistanceType`: the [distance metric](../distances.md) to use for distance + computations. For the `MaxRPTree`, this must be an + [`LMetric`](../distances.md#lmetric). By default, this is + [`EuclideanDistance`](../distances.md#lmetric). + * [`StatisticType`](binary_space_tree.md#statistictype): this holds auxiliary + information in each tree node. By default, + [`EmptyStatistic`](binary_space_tree.md#emptystatistic) is used, which holds + no information. + * `MatType`: the type of matrix used to represent points. Must be a type + matching the [Armadillo API](../../matrices.md). By default, `arma::mat` is + used, but other types such as `arma::fmat` or similar will work just fine. + +The `MaxRPTree` class itself is a convenience typedef of the generic +[`BinarySpaceTree`](binary_space_tree.md) class, using the +[`HRectBound`](binary_space_tree.md#hrectbound) class as the bounding structure, +and using the [`RPTreeMaxSplit`](binary_space_tree.md#rptreemaxsplit) +splitting strategy for construction, which splits a node along a random +projection, or, in some cases, based on the distance from the vector-valued mean +of points in the node. + +If no template parameters are explicitly specified, then defaults are used: + +``` +MaxRPTree<> = MaxRPTree +``` + +## Constructors + +`MaxRPTree`s are efficiently constructed by permuting points in a dataset in a +quicksort-like algorithm. However, this means that the ordering of points in +the tree's dataset (accessed with `node.Dataset()`) after construction may be +different. + +--- + + * `node = MaxRPTree(data, maxLeafSize=20)` + * `node = MaxRPTree(data, oldFromNew, maxLeafSize=20)` + * `node = MaxRPTree(data, oldFromNew, newFromOld, maxLeafSize=20)` + - Construct a `MaxRPTree` on the given `data`, using `maxLeafSize` as the + maximum number of points held in a leaf. + - By default, `data` is copied. Avoid a copy by using `std::move()` (e.g. + `std::move(data)`); when doing this, `data` will be set to an empty matrix. + - Optionally, construct mappings from old points to new points. `oldFromNew` + and `newFromOld` will have length `data.n_cols`, and: + * `oldFromNew[i]` indicates that point `i` in the tree's dataset was + originally point `oldFromNew[i]` in `data`; that is, + `node.Dataset().col(i)` is the point `data.col(oldFromNew[i])`. + * `newFromOld[i]` indicates that point `i` in `data` is now point + `newFromOld[i]` in the tree's dataset; that is, + `node.Dataset().col(newFromOld[i])` is the point `data.col(i)`. + +--- + + * `node = MaxRPTree(data, maxLeafSize=20)` + * `node = MaxRPTree(data, oldFromNew, maxLeafSize=20)` + * `node = MaxRPTree(data, oldFromNew, newFromOld, maxLeafSize=20)` + - Construct a `MaxRPTree` on the given `data`, using custom template + parameters to control the behavior of the tree, using `maxLeafSize` as the + maximum number of points held in a leaf. + - By default, `data` is copied. Avoid a copy by using `std::move()` (e.g. + `std::move(data)`); when doing this, `data` will be set to an empty matrix. + - Optionally, construct mappings from old points to new points. `oldFromNew` + and `newFromOld` will have length `data.n_cols`, and: + * `oldFromNew[i]` indicates that point `i` in the tree's dataset was + originally point `oldFromNew[i]` in `data`; that is, + `node.Dataset().col(i)` is the point `data.col(oldFromNew[i])`. + * `newFromOld[i]` indicates that point `i` in `data` is now point + `newFromOld[i]` in the tree's dataset; that is, + `node.Dataset().col(newFromOld[i])` is the point `data.col(i)`. + +--- + + * `node = MaxRPTree()` + - Construct an empty random projection tree with no children and no points. + +--- + +***Notes:*** + + - The name `node` is used here for `MaxRPTree` objects instead of `tree`, + because each `MaxRPTree` object is a single node in the tree. The + constructor returns the node that is the root of the tree. + + - Inserting individual points or removing individual points from a `MaxRPTree` + is not supported, because this generally results in a random projection tree + with very loose bounding boxes. It is better to simply build a new + `MaxRPTree` on the modified dataset. For trees that support individual + insertion and deletions, see the `RectangleTree` class and all its variants + (e.g. `RTree`, `RStarTree`, etc.). + + - See also the + [developer documentation on tree constructors](../../../developer/trees.md#constructors-and-destructors). + + + +--- + +### Constructor parameters: + +| **name** | **type** | **description** | **default** | +|----------|----------|-----------------|-------------| +| `data` | [`arma::mat`](../../matrices.md) | [Column-major](../../matrices.md#representing-data-in-mlpack) matrix to build the tree on. Pass with `std::move(data)` to avoid copying the matrix. | _(N/A)_ | +| `maxLeafSize` | `size_t` | Maximum number of points to store in each leaf. | `20` | +| `oldFromNew` | `std::vector` | Mappings from points in `node.Dataset()` to points in `data`. | _(N/A)_ | +| `newFromOld` | `std::vector` | Mappings from points in `data` to points in `node.Dataset()`. | _(N/A)_ | + +## Basic tree properties + +Once a `MaxRPTree` object is constructed, various properties of the tree can be +accessed or inspected. Many of these functions are required by the [TreeType +API](../../../developer/trees.md#the-treetype-api). + +### Navigating the tree + + * `node.NumChildren()` returns the number of children in `node`. This is + either `2` if `node` has children, or `0` if `node` is a leaf. + + * `node.IsLeaf()` returns a `bool` indicating whether or not `node` is a leaf. + + * `node.Child(i)` returns a `MaxRPTree&` that is the `i`th child. + - `i` must be `0` or `1`. + - This function should only be called if `node.NumChildren()` is not `0` + (e.g. if `node` is not a leaf). Note that this returns a valid + `MaxRPTree&` that can itself be used just like the root node of the tree! + - `node.Left()` and `node.Right()` are convenience functions specific to + `MaxRPTree` that will return `MaxRPTree*` (pointers) to the left and right + children, respectively, or `NULL` if `node` has no children. + + * `node.Parent()` will return a `MaxRPTree*` that points to the parent of + `node`, or `NULL` if `node` is the root of the `MaxRPTree`. + +--- + +### Accessing members of a tree + + * `node.Bound()` will return an + [`HRectBound&`](binary_space_tree.md#hrectbound) object that represents the + hyperrectangle bounding box of `node`. This is the smallest hyperrectangle + that encloses all the descendant points of `node`. + + * `node.Stat()` will return an `EmptyStatistic&` (or a `StatisticType&` if a + [custom `StatisticType`](#template-parameters) was specified as a template + parameter) holding the statistics of the node that were computed during tree + construction. + + * `node.Distance()` will return a + [`EuclideanDistance&`](../distances.md#lmetric) (or a `DistanceType&` if a + [custom `DistanceType`](#template-parameters) was specified as a template + parameter). + - This function is required by the + [TreeType API](../../../developer/trees.md#the-treetype-api), but given + that `MaxRPTree` requires an [`LMetric`](../distances.md#lmetric) to be + used, and `LMetric` only has `static` functions and holds no state, this + function is not likely to be useful. + +See also the +[developer documentation](../../../developer/trees.md#basic-tree-functionality) +for basic tree functionality in mlpack. + +--- + +### Accessing data held in a tree + + * `node.Dataset()` will return a `const arma::mat&` that is the dataset the + tree was built on. Note that this is a permuted version of the `data` matrix + passed to the constructor. + - If a [custom `MatType`](#template-parameters) is being used, the return + type will be `const MatType&` instead of `const arma::mat&`. + + * `node.NumPoints()` returns a `size_t` indicating the number of points held + directly in `node`. + - If `node` is not a leaf, this will return `0`, as `MaxRPTree` only holds + points directly in its leaves. + - If `node` is a leaf, then the number of points will be less than or equal + to the `maxLeafSize` that was specified when the tree was constructed. + + * `node.Point(i)` returns a `size_t` indicating the index of the `i`'th point + in `node.Dataset()`. + - `i` must be in the range `[0, node.NumPoints() - 1]` (inclusive). + - `node` must be a leaf (as non-leaves do not hold any points). + - The `i`'th point in `node` can then be accessed as + `node.Dataset().col(node.Point(i))`. + - In a `MaxRPTree`, because of the permutation of points done [during + construction](#constructors), point indices are contiguous: + `node.Point(i + j)` is the same as `node.Point(i) + j` for valid `i` and + `j`. + - Accessing the actual `i`'th point itself can be done with, e.g., + `node.Dataset().col(node.Point(i))`. + + * `node.NumDescendants()` returns a `size_t` indicating the number of points + held in all descendant leaves of `node`. + - If `node` is the root of the tree, then `node.NumDescendants()` will be + equal to `node.Dataset().n_cols`. + + * `node.Descendant(i)` returns a `size_t` indicating the index of the `i`'th + descendant point in `node.Dataset()`. + - `i` must be in the range `[0, node.NumDescendants() - 1]` (inclusive). + - `node` does not need to be a leaf. + - The `i`'th descendant point in `node` can then be accessed as + `node.Dataset().col(node.Descendant(i))`. + - In a `MaxRPTree`, because of the permutation of points done [during + construction](#constructors), point indices are contiguous: + `node.Descendant(i + j)` is the same as `node.Descendant(i) + j` for valid + `i` and `j`. + - Accessing the actual `i`'th descendant itself can be done with, e.g., + `node.Dataset().col(node.Descendant(i))`. + + * `node.Begin()` returns a `size_t` indicating the index of the first + descendant point of `node`. + - This is equivalent to `node.Descendant(0)`. + + * `node.Count()` returns a `size_t` indicating the number of descendant points of `node`. + - This is equivalent to `node.NumDescendants()`. + +--- + +### Accessing computed bound quantities of a tree + +The following quantities are cached for each node in a `MaxRPTree`, and so +accessing them does not require any computation. + + * `node.FurthestPointDistance()` returns a `double` representing the distance + between the center of the bounding hyperrectangle of `node` and the furthest + point held by `node`. + - If `node` is not a leaf, this returns 0 (because `node` does not hold any + points). + + * `node.FurthestDescendantDistance()` returns a `double` representing the + distance between the center of the bounding hyperrectangle of `node` and the + furthest descendant point held by `node`. + + * `node.MinimumBoundDistance()` returns a `double` representing minimum + possible distance from the center of the node to any edge of the + hyperrectangle bound. + - This quantity is half the width of the smallest dimension of + `node.Bound()`. + + * `node.ParentDistance()` returns a `double` representing the distance between + the center of the bounding hyperrectangle of `node` and the center of the + bounding hyperrectangle of its parent. + - If `node` is the root of the tree, `0` is returned. + +***Notes:*** + + - If a [custom `MatType`](#template-parameters) was specified when constructing + the `MaxRPTree`, then the return type of each method is the element type of + the given `MatType` instead of `double`. (e.g., if `MatType` is + `arma::fmat`, then the return type is `float`.) + + - For more details on each bound quantity, see the + [developer documentation](../../../developer/trees.md#complex-tree-functionality-and-bounds) + on bound quantities for trees. + +--- + +### Other functionality + + * `node.Center(center)` computes the center of the bounding hyperrectangle of + `node` and stores it in `center`. + - `center` should be of type `arma::vec&`. (If a [custom + `MatType`](#template-parameters) was specified when constructing the + `MaxRPTree`, the type is instead the column vector type for the given + `MatType`; e.g., `arma::fvec&` when `MatType` is `arma::fmat`.) + - `center` will be set to have size equivalent to the dimensionality of the + dataset held by `node`. + - This is equivalent to calling `node.Bound().Center(center)`. + + * A `MaxRPTree` can be serialized with + [`data::Save()` and `data::Load()`](../../load_save.md#mlpack-objects). + +## Bounding distances with the tree + +The primary use of trees in mlpack is bounding distances to points or other tree +nodes. The following functions can be used for these tasks. + + * `node.GetNearestChild(point)` + * `node.GetFurthestChild(point)` + - Return a `size_t` indicating the index of the child (`0` for left, `1` for + right) that is closest to (or furthest from) `point`, with respect + to the `MinDistance()` (or `MaxDistance()`) function. + - If there is a tie, `0` (the left child) is returned. + - If `node` is a leaf, `0` is returned. + - `point` should be of type `arma::vec`. (If a [custom + `MatType`](#template-parameters) was specified when constructing the + `MaxRPTree`, the type is instead the column vector type for the given + `MatType`; e.g., `arma::fvec` when `MatType` is `arma::fmat`.) + + * `node.GetNearestChild(other)` + * `node.GetFurthestChild(other)` + - Return a `size_t` indicating the index of the child (`0` for left, `1` for + right) that is closest to (or furthest from) the `MaxRPTree` node `other`, + with respect to the `MinDistance()` (or `MaxDistance()`) function. + - If there is a tie, `2` (an invalid index) is returned. ***Note that this + behavior differs from the version above that takes a point.*** + - If `node` is a leaf, `0` is returned. + +--- + + * `node.MinDistance(point)` + * `node.MinDistance(other)` + - Return a `double` indicating the minimum possible distance between `node` + and `point`, or the `MaxRPTree` node `other`. + - This is equivalent to the minimum possible distance between any point + contained in the bounding hyperrectangle of `node` and `point`, or between + any point contained in the bounding hyperrectangle of `node` and any point + contained in the bounding hyperrectangle of `other`. + - `point` should be of type `arma::vec`. (If a [custom + `MatType`](#template-parameters) was specified when constructing the + `MaxRPTree`, the type is instead the column vector type for the given + `MatType`, and the return type is the element type of `MatType`; e.g., + `point` should be `arma::fvec` when `MatType` is `arma::fmat`, and the + returned distance is `float`). + + * `node.MaxDistance(point)` + * `node.MaxDistance(other)` + - Return a `double` indicating the maximum possible distance between `node` + and `point`, or the `MaxRPTree` node `other`. + - This is equivalent to the maximum possible distance between any point + contained in the bounding hyperrectangle of `node` and `point`, or between + any point contained in the bounding hyperrectangle of `node` and any point + contained in the bounding hyperrectangle of `other`. + - `point` should be of type `arma::vec`. (If a [custom + `MatType`](#template-parameters) was specified when constructing the + `MaxRPTree`, the type is instead the column vector type for the given + `MatType`, and the return type is the element type of `MatType`; e.g., + `point` should be `arma::fvec` when `MatType` is `arma::fmat`, and the + returned distance is `float`). + + * `node.RangeDistance(point)` + * `node.RangeDistance(other)` + - Return a [`Range`](../math.md#range) whose lower bound is + `node.MinDistance(point)` or `node.MinDistance(other)`, and whose upper + bound is `node.MaxDistance(point)` or `node.MaxDistance(other)`. + - `point` should be of type `arma::vec`. (If a + [custom `MatType`](#template-parameters) was specified when constructing + the `MaxRPTree`, the type is instead the column vector type for the given + `MatType`, and the return type is a `RangeType` with element type the same + as `MatType`; e.g., `point` should be `arma::fvec` when `MatType` is + `arma::fmat`, and the returned type is + [`RangeType`](../math.md#range)). + +### Tree traversals + +Like every mlpack tree, the `MaxRPTree` class provides a [single-tree and +dual-tree traversal](../../../developer/trees.md#traversals) that can be paired +with a [`RuleType` class](../../../developer/trees.md#rules) to implement a +single-tree or dual-tree algorithm. + + * `MaxRPTree::SingleTreeTraverser` + - Implements a depth-first single-tree traverser. + + * `MaxRPTree::DualTreeTraverser` + - Implements a dual-depth-first dual-tree traverser. + +In addition to those two classes, which are required by the +[`TreeType` policy](../../../developer/trees.md), an additional traverser is +available: + + * `MaxRPTree::BreadthFirstDualTreeTraverser` + - Implements a dual-breadth-first dual-tree traverser. + - ***Note:*** this traverser is not useful for all tasks; because the + `MaxRPTree` only holds points in the leaves, this means that no base cases + (e.g. comparisons between points) will be called until *all* pairs of + intermediate nodes have been scored! + +## Example usage + +Build a `MaxRPTree` on the `cloud` dataset and print basic statistics about the +tree. + +```c++ +// See https://datasets.mlpack.org/cloud.csv. +arma::mat dataset; +mlpack::data::Load("cloud.csv", dataset, true); + +// Build the random projection tree with a leaf size of 10. (This means that +// nodes are split until they contain 10 or fewer points.) +// +// The std::move() means that `dataset` will be empty after this call, and no +// data will be copied during tree building. +// +// Note that the '<>' isn't necessary if C++20 is being used (e.g. +// `mlpack::MaxRPTree tree(...)` will work fine in C++20 or newer). +mlpack::MaxRPTree<> tree(std::move(dataset)); + +// Print the bounding box of the root node. +std::cout << "Bounding box of root node:" << std::endl; +for (size_t i = 0; i < tree.Bound().Dim(); ++i) +{ + std::cout << " - Dimension " << i << ": [" << tree.Bound()[i].Lo() << ", " + << tree.Bound()[i].Hi() << "]." << std::endl; +} +std::cout << std::endl; + +// Print the number of descendant points of the root, and of each of its +// children. +std::cout << "Descendant points of root: " + << tree.NumDescendants() << "." << std::endl; +std::cout << "Descendant points of left child: " + << tree.Left()->NumDescendants() << "." << std::endl; +std::cout << "Descendant points of right child: " + << tree.Right()->NumDescendants() << "." << std::endl; +std::cout << std::endl; + +// Compute the center of the rp-tree. +arma::vec center; +tree.Center(center); +std::cout << "Center of random projection tree: " << center.t(); +``` + +--- + +Build two `MaxRPTree`s on subsets of the corel dataset and compute minimum and +maximum distances between different nodes in the tree. + +```c++ +// See https://datasets.mlpack.org/corel-histogram.csv. +arma::mat dataset; +mlpack::data::Load("corel-histogram.csv", dataset, true); + +// Build rp-trees on the first half and the second half of points. +mlpack::MaxRPTree<> tree1(dataset.cols(0, dataset.n_cols / 2)); +mlpack::MaxRPTree<> tree2(dataset.cols(dataset.n_cols / 2 + 1, + dataset.n_cols - 1)); + +// Compute the maximum distance between the trees. +std::cout << "Maximum distance between tree root nodes: " + << tree1.MaxDistance(tree2) << "." << std::endl; + +// Get the leftmost grandchild of the first tree's root---if it exists. +if (!tree1.IsLeaf() && !tree1.Child(0).IsLeaf()) +{ + mlpack::MaxRPTree<>& node1 = tree1.Child(0).Child(0); + + // Get the rightmost grandchild of the second tree's root---if it exists. + if (!tree2.IsLeaf() && !tree2.Child(1).IsLeaf()) + { + mlpack::MaxRPTree<>& node2 = tree2.Child(1).Child(1); + + // Print the minimum and maximum distance between the nodes. + mlpack::Range dists = node1.RangeDistance(node2); + std::cout << "Possible distances between two grandchild nodes: [" + << dists.Lo() << ", " << dists.Hi() << "]." << std::endl; + + // Print the minimum distance between the first node and the first + // descendant point of the second node. + const size_t descendantIndex = node2.Descendant(0); + const double descendantMinDist = + node1.MinDistance(node2.Dataset().col(descendantIndex)); + std::cout << "Minimum distance between grandchild node and descendant " + << "point: " << descendantMinDist << "." << std::endl; + + // Which child of node2 is closer to node1? + const size_t closerIndex = node2.GetNearestChild(node1); + if (closerIndex == 0) + std::cout << "The left child of node2 is closer to node1." << std::endl; + else if (closerIndex == 1) + std::cout << "The right child of node2 is closer to node1." << std::endl; + else // closerIndex == 2 in this case. + std::cout << "Both children of node2 are equally close to node1." + << std::endl; + + // And which child of node1 is further from node2? + const size_t furtherIndex = node1.GetFurthestChild(node2); + if (furtherIndex == 0) + std::cout << "The left child of node1 is further from node2." + << std::endl; + else if (furtherIndex == 1) + std::cout << "The right child of node1 is further from node2." + << std::endl; + else // furtherIndex == 2 in this case. + std::cout << "Both children of node1 are equally far from node2." + << std::endl; + } +} +``` + +--- + +Build a `MaxRPTree` on 32-bit floating point data and save it to disk. + +```c++ +// See https://datasets.mlpack.org/corel-histogram.csv. +arma::fmat dataset; +mlpack::data::Load("corel-histogram.csv", dataset); + +// Build the MaxRPTree using 32-bit floating point data as the matrix type. +// We will still use the default EmptyStatistic and EuclideanDistance +// parameters. A leaf size of 100 is used here. +mlpack::MaxRPTree tree(std::move(dataset), 100); + +// Save the MaxRPTree to disk with the name 'tree'. +mlpack::data::Save("tree.bin", "tree", tree); + +std::cout << "Saved tree with " << tree.Dataset().n_cols << " points to " + << "'tree.bin'." << std::endl; +``` + +--- + +Load a 32-bit floating point `MaxRPTree` from disk, then traverse it manually +and find the number of leaf nodes with fewer than 10 points. + +```c++ +// This assumes the tree has already been saved to 'tree.bin' (as in the example +// above). + +// This convenient typedef saves us a long type name! +typedef mlpack::MaxRPTree TreeType; + +TreeType tree; +mlpack::data::Load("tree.bin", "tree", tree); +std::cout << "Tree loaded with " << tree.NumDescendants() << " points." + << std::endl; + +// Recurse in a depth-first manner. Count both the total number of leaves, and +// the number of leaves with fewer than 10 points. +size_t leafCount = 0; +size_t totalLeafCount = 0; +std::stack stack; +stack.push(&tree); +while (!stack.empty()) +{ + TreeType* node = stack.top(); + stack.pop(); + + if (node->NumPoints() < 10) + ++leafCount; + ++totalLeafCount; + + if (!node->IsLeaf()) + { + stack.push(node->Left()); + stack.push(node->Right()); + } +} + +// Note that it would be possible to use TreeType::SingleTreeTraverser to +// perform the recursion above, but that is more well-suited for more complex +// tasks that require pruning and other non-trivial behavior; so using a simple +// stack is the better option here. + +// Print the results. +std::cout << leafCount << " out of " << totalLeafCount << " leaves have fewer " + << "than 10 points." << std::endl; +``` + +--- + +Build a `MaxRPTree` and map between original points and new points. + +```c++ +// See https://datasets.mlpack.org/cloud.csv. +arma::mat dataset; +mlpack::data::Load("cloud.csv", dataset, true); + +// Build the tree. +std::vector oldFromNew, newFromOld; +mlpack::MaxRPTree<> tree(dataset, oldFromNew, newFromOld); + +// oldFromNew and newFromOld will be set to the same size as the dataset. +std::cout << "Number of points in dataset: " << dataset.n_cols << "." + << std::endl; +std::cout << "Size of oldFromNew: " << oldFromNew.size() << "." << std::endl; +std::cout << "Size of newFromOld: " << newFromOld.size() << "." << std::endl; +std::cout << std::endl; + +// See where point 42 in the tree's dataset came from. +std::cout << "Point 42 in the permuted tree's dataset:" << std::endl; +std::cout << " " << tree.Dataset().col(42).t(); +std::cout << "Was originally point " << oldFromNew[42] << ":" << std::endl; +std::cout << " " << dataset.col(oldFromNew[42]).t(); +std::cout << std::endl; + +// See where point 7 in the original dataset was mapped. +std::cout << "Point 7 in original dataset:" << std::endl; +std::cout << " " << dataset.col(7).t(); +std::cout << "Mapped to point " << newFromOld[7] << ":" << std::endl; +std::cout << " " << tree.Dataset().col(newFromOld[7]).t(); +``` diff --git a/doc/user/core/trees/rp_tree.md b/doc/user/core/trees/rp_tree.md new file mode 100644 index 0000000000..032c90b253 --- /dev/null +++ b/doc/user/core/trees/rp_tree.md @@ -0,0 +1,635 @@ +# `RPTree` + + + +The `RPTree` class represents a random projection tree, a variant of the +[`k`-d tree](kdtree.md) based on random projections. The random projection tree +is a well-known data structure for efficient distance operations (such as +nearest neighbor search) in low dimensions---typically less than 100. + +An `RPTree` (or the similar [`MaxRPTree`](max_rp_tree.md)) may be preferred over +a [`KDTree`](kdtree.md) or other tree structures as it is theoretically known to +adapt to the intrinsic dimension of the data. This is similar to the cover +tree, but the implementation is far simpler and as a result, more efficient. + + + +mlpack's `RPTree` implementation supports three template parameters for +configurable behavior, and implements all the functionality required by the +[TreeType API](../../../developer/trees.md#the-treetype-api), plus some +additional functionality specific to random projection trees. + + * [Template parameters](#template-parameters) + * [Constructors](#constructors) + * [Basic tree properties](#basic-tree-properties) + * [Bounding distances with the tree](#bounding-distances-with-the-tree) + * [Tree traversals](#tree-traversals) + * [Example usage](#example-usage) + +## See also + + + + * [`MaxRPTree`](max_rp_tree.md) + * [kd-tree on Wikipedia](https://en.wikipedia.org/wiki/Kd-tree) + * [Random projection on Wikipedia](https://en.wikipedia.org/wiki/Random_projection) + * [`BinarySpaceTree`](binary_space_tree.md) + * [Binary space partitioning on Wikipedia](https://dl.acm.org/doi/pdf/10.1145/361002.361007) + * [Random Projection Trees and Low Dimensional Manifolds (pdf)](https://www.cs.cornell.edu/~abrahao/tdg/papers/p537.pdf) + * [Tree-Independent Dual-Tree Algorithms (pdf)](https://www.ratml.org/pub/pdf/2013tree.pdf) + +## Template parameters + +In accordance with the [TreeType +API](../../../developer/trees.md#template-parameters-required-by-the-treetype-policy) +(see also [this more detailed section](../../../developer/trees.md#template-parameters)), +the `RPTree` class takes three template parameters: + +``` +RPTree +``` + + * `DistanceType`: the [distance metric](../distances.md) to use for distance + computations. For the `RPTree`, this must be an + [`LMetric`](../distances.md#lmetric). By default, this is + [`EuclideanDistance`](../distances.md#lmetric). + * [`StatisticType`](binary_space_tree.md#statistictype): this holds auxiliary + information in each tree node. By default, + [`EmptyStatistic`](binary_space_tree.md#emptystatistic) is used, which holds + no information. + * `MatType`: the type of matrix used to represent points. Must be a type + matching the [Armadillo API](../../matrices.md). By default, `arma::mat` is + used, but other types such as `arma::fmat` or similar will work just fine. + +The `RPTree` class itself is a convenience typedef of the generic +[`BinarySpaceTree`](binary_space_tree.md) class, using the +[`HRectBound`](binary_space_tree.md#hrectbound) class as the bounding structure, +and using the [`RPTreeMeanSplit`](binary_space_tree.md#rptreemeansplit) +splitting strategy for construction, which splits a node along a random +projection, or, in some cases, based on the distance from the vector-valued mean +of points in the node. + +If no template parameters are explicitly specified, then defaults are used: + +``` +RPTree<> = RPTree +``` + +## Constructors + +`RPTree`s are efficiently constructed by permuting points in a dataset in a +quicksort-like algorithm. However, this means that the ordering of points in +the tree's dataset (accessed with `node.Dataset()`) after construction may be +different. + +--- + + * `node = RPTree(data, maxLeafSize=20)` + * `node = RPTree(data, oldFromNew, maxLeafSize=20)` + * `node = RPTree(data, oldFromNew, newFromOld, maxLeafSize=20)` + - Construct an `RPTree` on the given `data`, using `maxLeafSize` as the + maximum number of points held in a leaf. + - By default, `data` is copied. Avoid a copy by using `std::move()` (e.g. + `std::move(data)`); when doing this, `data` will be set to an empty matrix. + - Optionally, construct mappings from old points to new points. `oldFromNew` + and `newFromOld` will have length `data.n_cols`, and: + * `oldFromNew[i]` indicates that point `i` in the tree's dataset was + originally point `oldFromNew[i]` in `data`; that is, + `node.Dataset().col(i)` is the point `data.col(oldFromNew[i])`. + * `newFromOld[i]` indicates that point `i` in `data` is now point + `newFromOld[i]` in the tree's dataset; that is, + `node.Dataset().col(newFromOld[i])` is the point `data.col(i)`. + +--- + + * `node = RPTree(data, maxLeafSize=20)` + * `node = RPTree(data, oldFromNew, maxLeafSize=20)` + * `node = RPTree(data, oldFromNew, newFromOld, maxLeafSize=20)` + - Construct an `RPTree` on the given `data`, using custom template parameters + to control the behavior of the tree, using `maxLeafSize` as the maximum + number of points held in a leaf. + - By default, `data` is copied. Avoid a copy by using `std::move()` (e.g. + `std::move(data)`); when doing this, `data` will be set to an empty matrix. + - Optionally, construct mappings from old points to new points. `oldFromNew` + and `newFromOld` will have length `data.n_cols`, and: + * `oldFromNew[i]` indicates that point `i` in the tree's dataset was + originally point `oldFromNew[i]` in `data`; that is, + `node.Dataset().col(i)` is the point `data.col(oldFromNew[i])`. + * `newFromOld[i]` indicates that point `i` in `data` is now point + `newFromOld[i]` in the tree's dataset; that is, + `node.Dataset().col(newFromOld[i])` is the point `data.col(i)`. + +--- + + * `node = RPTree()` + - Construct an empty random projection tree with no children and no points. + +--- + +***Notes:*** + + - The name `node` is used here for `RPTree` objects instead of `tree`, because + each `RPTree` object is a single node in the tree. The constructor returns + the node that is the root of the tree. + + - Inserting individual points or removing individual points from an `RPTree` is + not supported, because this generally results in a random projection tree + with very loose bounding boxes. It is better to simply build a new `RPTree` + on the modified dataset. For trees that support individual insertion and + deletions, see the `RectangleTree` class and all its variants (e.g. `RTree`, + `RStarTree`, etc.). + + - See also the + [developer documentation on tree constructors](../../../developer/trees.md#constructors-and-destructors). + + + +--- + +### Constructor parameters: + +| **name** | **type** | **description** | **default** | +|----------|----------|-----------------|-------------| +| `data` | [`arma::mat`](../../matrices.md) | [Column-major](../../matrices.md#representing-data-in-mlpack) matrix to build the tree on. Pass with `std::move(data)` to avoid copying the matrix. | _(N/A)_ | +| `maxLeafSize` | `size_t` | Maximum number of points to store in each leaf. | `20` | +| `oldFromNew` | `std::vector` | Mappings from points in `node.Dataset()` to points in `data`. | _(N/A)_ | +| `newFromOld` | `std::vector` | Mappings from points in `data` to points in `node.Dataset()`. | _(N/A)_ | + +## Basic tree properties + +Once an `RPTree` object is constructed, various properties of the tree can be +accessed or inspected. Many of these functions are required by the [TreeType +API](../../../developer/trees.md#the-treetype-api). + +### Navigating the tree + + * `node.NumChildren()` returns the number of children in `node`. This is + either `2` if `node` has children, or `0` if `node` is a leaf. + + * `node.IsLeaf()` returns a `bool` indicating whether or not `node` is a leaf. + + * `node.Child(i)` returns an `RPTree&` that is the `i`th child. + - `i` must be `0` or `1`. + - This function should only be called if `node.NumChildren()` is not `0` + (e.g. if `node` is not a leaf). Note that this returns a valid `RPTree&` + that can itself be used just like the root node of the tree! + - `node.Left()` and `node.Right()` are convenience functions specific to + `RPTree` that will return `RPTree*` (pointers) to the left and right + children, respectively, or `NULL` if `node` has no children. + + * `node.Parent()` will return an `RPTree*` that points to the parent of `node`, + or `NULL` if `node` is the root of the `RPTree`. + +--- + +### Accessing members of a tree + + * `node.Bound()` will return an + [`HRectBound&`](binary_space_tree.md#hrectbound) object that represents the + hyperrectangle bounding box of `node`. This is the smallest hyperrectangle + that encloses all the descendant points of `node`. + + * `node.Stat()` will return an `EmptyStatistic&` (or a `StatisticType&` if a + [custom `StatisticType`](#template-parameters) was specified as a template + parameter) holding the statistics of the node that were computed during tree + construction. + + * `node.Distance()` will return a + [`EuclideanDistance&`](../distances.md#lmetric) (or a `DistanceType&` if a + [custom `DistanceType`](#template-parameters) was specified as a template + parameter). + - This function is required by the + [TreeType API](../../../developer/trees.md#the-treetype-api), but given + that `RPTree` requires an [`LMetric`](../distances.md#lmetric) to be used, + and `LMetric` only has `static` functions and holds no state, this function + is not likely to be useful. + +See also the +[developer documentation](../../../developer/trees.md#basic-tree-functionality) +for basic tree functionality in mlpack. + +--- + +### Accessing data held in a tree + + * `node.Dataset()` will return a `const arma::mat&` that is the dataset the + tree was built on. Note that this is a permuted version of the `data` matrix + passed to the constructor. + - If a [custom `MatType`](#template-parameters) is being used, the return + type will be `const MatType&` instead of `const arma::mat&`. + + * `node.NumPoints()` returns a `size_t` indicating the number of points held + directly in `node`. + - If `node` is not a leaf, this will return `0`, as `RPTree` only holds + points directly in its leaves. + - If `node` is a leaf, then the number of points will be less than or equal + to the `maxLeafSize` that was specified when the tree was constructed. + + * `node.Point(i)` returns a `size_t` indicating the index of the `i`'th point + in `node.Dataset()`. + - `i` must be in the range `[0, node.NumPoints() - 1]` (inclusive). + - `node` must be a leaf (as non-leaves do not hold any points). + - The `i`'th point in `node` can then be accessed as + `node.Dataset().col(node.Point(i))`. + - In an `RPTree`, because of the permutation of points done [during + construction](#constructors), point indices are contiguous: + `node.Point(i + j)` is the same as `node.Point(i) + j` for valid `i` and + `j`. + - Accessing the actual `i`'th point itself can be done with, e.g., + `node.Dataset().col(node.Point(i))`. + + * `node.NumDescendants()` returns a `size_t` indicating the number of points + held in all descendant leaves of `node`. + - If `node` is the root of the tree, then `node.NumDescendants()` will be + equal to `node.Dataset().n_cols`. + + * `node.Descendant(i)` returns a `size_t` indicating the index of the `i`'th + descendant point in `node.Dataset()`. + - `i` must be in the range `[0, node.NumDescendants() - 1]` (inclusive). + - `node` does not need to be a leaf. + - The `i`'th descendant point in `node` can then be accessed as + `node.Dataset().col(node.Descendant(i))`. + - In an `RPTree`, because of the permutation of points done [during + construction](#constructors), point indices are contiguous: + `node.Descendant(i + j)` is the same as `node.Descendant(i) + j` for valid + `i` and `j`. + - Accessing the actual `i`'th descendant itself can be done with, e.g., + `node.Dataset().col(node.Descendant(i))`. + + * `node.Begin()` returns a `size_t` indicating the index of the first + descendant point of `node`. + - This is equivalent to `node.Descendant(0)`. + + * `node.Count()` returns a `size_t` indicating the number of descendant points of `node`. + - This is equivalent to `node.NumDescendants()`. + +--- + +### Accessing computed bound quantities of a tree + +The following quantities are cached for each node in an `RPTree`, and so +accessing them does not require any computation. + + * `node.FurthestPointDistance()` returns a `double` representing the distance + between the center of the bounding hyperrectangle of `node` and the furthest + point held by `node`. + - If `node` is not a leaf, this returns 0 (because `node` does not hold any + points). + + * `node.FurthestDescendantDistance()` returns a `double` representing the + distance between the center of the bounding hyperrectangle of `node` and the + furthest descendant point held by `node`. + + * `node.MinimumBoundDistance()` returns a `double` representing minimum + possible distance from the center of the node to any edge of the + hyperrectangle bound. + - This quantity is half the width of the smallest dimension of + `node.Bound()`. + + * `node.ParentDistance()` returns a `double` representing the distance between + the center of the bounding hyperrectangle of `node` and the center of the + bounding hyperrectangle of its parent. + - If `node` is the root of the tree, `0` is returned. + +***Notes:*** + + - If a [custom `MatType`](#template-parameters) was specified when constructing + the `RPTree`, then the return type of each method is the element type of the + given `MatType` instead of `double`. (e.g., if `MatType` is `arma::fmat`, + then the return type is `float`.) + + - For more details on each bound quantity, see the + [developer documentation](../../../developer/trees.md#complex-tree-functionality-and-bounds) + on bound quantities for trees. + +--- + +### Other functionality + + * `node.Center(center)` computes the center of the bounding hyperrectangle of + `node` and stores it in `center`. + - `center` should be of type `arma::vec&`. (If a [custom + `MatType`](#template-parameters) was specified when constructing the + `RPTree`, the type is instead the column vector type for the given + `MatType`; e.g., `arma::fvec&` when `MatType` is `arma::fmat`.) + - `center` will be set to have size equivalent to the dimensionality of the + dataset held by `node`. + - This is equivalent to calling `node.Bound().Center(center)`. + + * A `RPTree` can be serialized with + [`data::Save()` and `data::Load()`](../../load_save.md#mlpack-objects). + +## Bounding distances with the tree + +The primary use of trees in mlpack is bounding distances to points or other tree +nodes. The following functions can be used for these tasks. + + * `node.GetNearestChild(point)` + * `node.GetFurthestChild(point)` + - Return a `size_t` indicating the index of the child (`0` for left, `1` for + right) that is closest to (or furthest from) `point`, with respect + to the `MinDistance()` (or `MaxDistance()`) function. + - If there is a tie, `0` (the left child) is returned. + - If `node` is a leaf, `0` is returned. + - `point` should be of type `arma::vec`. (If a [custom + `MatType`](#template-parameters) was specified when constructing the + `RPTree`, the type is instead the column vector type for the given + `MatType`; e.g., `arma::fvec` when `MatType` is `arma::fmat`.) + + * `node.GetNearestChild(other)` + * `node.GetFurthestChild(other)` + - Return a `size_t` indicating the index of the child (`0` for left, `1` for + right) that is closest to (or furthest from) the `RPTree` node `other`, + with respect to the `MinDistance()` (or `MaxDistance()`) function. + - If there is a tie, `2` (an invalid index) is returned. ***Note that this + behavior differs from the version above that takes a point.*** + - If `node` is a leaf, `0` is returned. + +--- + + * `node.MinDistance(point)` + * `node.MinDistance(other)` + - Return a `double` indicating the minimum possible distance between `node` + and `point`, or the `RPTree` node `other`. + - This is equivalent to the minimum possible distance between any point + contained in the bounding hyperrectangle of `node` and `point`, or between + any point contained in the bounding hyperrectangle of `node` and any point + contained in the bounding hyperrectangle of `other`. + - `point` should be of type `arma::vec`. (If a [custom + `MatType`](#template-parameters) was specified when constructing the + `RPTree`, the type is instead the column vector type for the given + `MatType`, and the return type is the element type of `MatType`; e.g., + `point` should be `arma::fvec` when `MatType` is `arma::fmat`, and the + returned distance is `float`). + + * `node.MaxDistance(point)` + * `node.MaxDistance(other)` + - Return a `double` indicating the maximum possible distance between `node` + and `point`, or the `RPTree` node `other`. + - This is equivalent to the maximum possible distance between any point + contained in the bounding hyperrectangle of `node` and `point`, or between + any point contained in the bounding hyperrectangle of `node` and any point + contained in the bounding hyperrectangle of `other`. + - `point` should be of type `arma::vec`. (If a [custom + `MatType`](#template-parameters) was specified when constructing the + `RPTree`, the type is instead the column vector type for the given + `MatType`, and the return type is the element type of `MatType`; e.g., + `point` should be `arma::fvec` when `MatType` is `arma::fmat`, and the + returned distance is `float`). + + * `node.RangeDistance(point)` + * `node.RangeDistance(other)` + - Return a [`Range`](../math.md#range) whose lower bound is + `node.MinDistance(point)` or `node.MinDistance(other)`, and whose upper + bound is `node.MaxDistance(point)` or `node.MaxDistance(other)`. + - `point` should be of type `arma::vec`. (If a + [custom `MatType`](#template-parameters) was specified when constructing + the `RPTree`, the type is instead the column vector type for the given + `MatType`, and the return type is a `RangeType` with element type the same + as `MatType`; e.g., `point` should be `arma::fvec` when `MatType` is + `arma::fmat`, and the returned type is + [`RangeType`](../math.md#range)). + +### Tree traversals + +Like every mlpack tree, the `RPTree` class provides a [single-tree and dual-tree +traversal](../../../developer/trees.md#traversals) that can be paired with a +[`RuleType` class](../../../developer/trees.md#rules) to implement a single-tree +or dual-tree algorithm. + + * `RPTree::SingleTreeTraverser` + - Implements a depth-first single-tree traverser. + + * `RPTree::DualTreeTraverser` + - Implements a dual-depth-first dual-tree traverser. + +In addition to those two classes, which are required by the +[`TreeType` policy](../../../developer/trees.md), an additional traverser is +available: + + * `RPTree::BreadthFirstDualTreeTraverser` + - Implements a dual-breadth-first dual-tree traverser. + - ***Note:*** this traverser is not useful for all tasks; because the + `RPTree` only holds points in the leaves, this means that no base cases + (e.g. comparisons between points) will be called until *all* pairs of + intermediate nodes have been scored! + +## Example usage + +Build an `RPTree` on the `cloud` dataset and print basic statistics about the +tree. + +```c++ +// See https://datasets.mlpack.org/cloud.csv. +arma::mat dataset; +mlpack::data::Load("cloud.csv", dataset, true); + +// Build the random projection tree with a leaf size of 10. (This means that +// nodes are split until they contain 10 or fewer points.) +// +// The std::move() means that `dataset` will be empty after this call, and no +// data will be copied during tree building. +// +// Note that the '<>' isn't necessary if C++20 is being used (e.g. +// `mlpack::RPTree tree(...)` will work fine in C++20 or newer). +mlpack::RPTree<> tree(std::move(dataset)); + +// Print the bounding box of the root node. +std::cout << "Bounding box of root node:" << std::endl; +for (size_t i = 0; i < tree.Bound().Dim(); ++i) +{ + std::cout << " - Dimension " << i << ": [" << tree.Bound()[i].Lo() << ", " + << tree.Bound()[i].Hi() << "]." << std::endl; +} +std::cout << std::endl; + +// Print the number of descendant points of the root, and of each of its +// children. +std::cout << "Descendant points of root: " + << tree.NumDescendants() << "." << std::endl; +std::cout << "Descendant points of left child: " + << tree.Left()->NumDescendants() << "." << std::endl; +std::cout << "Descendant points of right child: " + << tree.Right()->NumDescendants() << "." << std::endl; +std::cout << std::endl; + +// Compute the center of the rp-tree. +arma::vec center; +tree.Center(center); +std::cout << "Center of random projection tree: " << center.t(); +``` + +--- + +Build two `RPTree`s on subsets of the corel dataset and compute minimum and +maximum distances between different nodes in the tree. + +```c++ +// See https://datasets.mlpack.org/corel-histogram.csv. +arma::mat dataset; +mlpack::data::Load("corel-histogram.csv", dataset, true); + +// Build rp-trees on the first half and the second half of points. +mlpack::RPTree<> tree1(dataset.cols(0, dataset.n_cols / 2)); +mlpack::RPTree<> tree2(dataset.cols(dataset.n_cols / 2 + 1, + dataset.n_cols - 1)); + +// Compute the maximum distance between the trees. +std::cout << "Maximum distance between tree root nodes: " + << tree1.MaxDistance(tree2) << "." << std::endl; + +// Get the leftmost grandchild of the first tree's root---if it exists. +if (!tree1.IsLeaf() && !tree1.Child(0).IsLeaf()) +{ + mlpack::RPTree<>& node1 = tree1.Child(0).Child(0); + + // Get the rightmost grandchild of the second tree's root---if it exists. + if (!tree2.IsLeaf() && !tree2.Child(1).IsLeaf()) + { + mlpack::RPTree<>& node2 = tree2.Child(1).Child(1); + + // Print the minimum and maximum distance between the nodes. + mlpack::Range dists = node1.RangeDistance(node2); + std::cout << "Possible distances between two grandchild nodes: [" + << dists.Lo() << ", " << dists.Hi() << "]." << std::endl; + + // Print the minimum distance between the first node and the first + // descendant point of the second node. + const size_t descendantIndex = node2.Descendant(0); + const double descendantMinDist = + node1.MinDistance(node2.Dataset().col(descendantIndex)); + std::cout << "Minimum distance between grandchild node and descendant " + << "point: " << descendantMinDist << "." << std::endl; + + // Which child of node2 is closer to node1? + const size_t closerIndex = node2.GetNearestChild(node1); + if (closerIndex == 0) + std::cout << "The left child of node2 is closer to node1." << std::endl; + else if (closerIndex == 1) + std::cout << "The right child of node2 is closer to node1." << std::endl; + else // closerIndex == 2 in this case. + std::cout << "Both children of node2 are equally close to node1." + << std::endl; + + // And which child of node1 is further from node2? + const size_t furtherIndex = node1.GetFurthestChild(node2); + if (furtherIndex == 0) + std::cout << "The left child of node1 is further from node2." + << std::endl; + else if (furtherIndex == 1) + std::cout << "The right child of node1 is further from node2." + << std::endl; + else // furtherIndex == 2 in this case. + std::cout << "Both children of node1 are equally far from node2." + << std::endl; + } +} +``` + +--- + +Build an `RPTree` on 32-bit floating point data and save it to disk. + +```c++ +// See https://datasets.mlpack.org/corel-histogram.csv. +arma::fmat dataset; +mlpack::data::Load("corel-histogram.csv", dataset); + +// Build the RPTree using 32-bit floating point data as the matrix type. +// We will still use the default EmptyStatistic and EuclideanDistance +// parameters. A leaf size of 100 is used here. +mlpack::RPTree tree(std::move(dataset), 100); + +// Save the RPTree to disk with the name 'tree'. +mlpack::data::Save("tree.bin", "tree", tree); + +std::cout << "Saved tree with " << tree.Dataset().n_cols << " points to " + << "'tree.bin'." << std::endl; +``` + +--- + +Load a 32-bit floating point `RPTree` from disk, then traverse it manually and +find the number of leaf nodes with fewer than 10 points. + +```c++ +// This assumes the tree has already been saved to 'tree.bin' (as in the example +// above). + +// This convenient typedef saves us a long type name! +typedef mlpack::RPTree TreeType; + +TreeType tree; +mlpack::data::Load("tree.bin", "tree", tree); +std::cout << "Tree loaded with " << tree.NumDescendants() << " points." + << std::endl; + +// Recurse in a depth-first manner. Count both the total number of leaves, and +// the number of leaves with fewer than 10 points. +size_t leafCount = 0; +size_t totalLeafCount = 0; +std::stack stack; +stack.push(&tree); +while (!stack.empty()) +{ + TreeType* node = stack.top(); + stack.pop(); + + if (node->NumPoints() < 10) + ++leafCount; + ++totalLeafCount; + + if (!node->IsLeaf()) + { + stack.push(node->Left()); + stack.push(node->Right()); + } +} + +// Note that it would be possible to use TreeType::SingleTreeTraverser to +// perform the recursion above, but that is more well-suited for more complex +// tasks that require pruning and other non-trivial behavior; so using a simple +// stack is the better option here. + +// Print the results. +std::cout << leafCount << " out of " << totalLeafCount << " leaves have fewer " + << "than 10 points." << std::endl; +``` + +--- + +Build an `RPTree` and map between original points and new points. + +```c++ +// See https://datasets.mlpack.org/cloud.csv. +arma::mat dataset; +mlpack::data::Load("cloud.csv", dataset, true); + +// Build the tree. +std::vector oldFromNew, newFromOld; +mlpack::RPTree<> tree(dataset, oldFromNew, newFromOld); + +// oldFromNew and newFromOld will be set to the same size as the dataset. +std::cout << "Number of points in dataset: " << dataset.n_cols << "." + << std::endl; +std::cout << "Size of oldFromNew: " << oldFromNew.size() << "." << std::endl; +std::cout << "Size of newFromOld: " << newFromOld.size() << "." << std::endl; +std::cout << std::endl; + +// See where point 42 in the tree's dataset came from. +std::cout << "Point 42 in the permuted tree's dataset:" << std::endl; +std::cout << " " << tree.Dataset().col(42).t(); +std::cout << "Was originally point " << oldFromNew[42] << ":" << std::endl; +std::cout << " " << dataset.col(oldFromNew[42]).t(); +std::cout << std::endl; + +// See where point 7 in the original dataset was mapped. +std::cout << "Point 7 in original dataset:" << std::endl; +std::cout << " " << dataset.col(7).t(); +std::cout << "Mapped to point " << newFromOld[7] << ":" << std::endl; +std::cout << " " << tree.Dataset().col(newFromOld[7]).t(); +``` From 4e98582dcff565fc028ee91ef9b97864e13f69e5 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Wed, 16 Oct 2024 15:16:58 -0400 Subject: [PATCH 02/25] Fix wording for other trees. --- doc/user/core/trees/ball_tree.md | 2 +- doc/user/core/trees/binary_space_tree.md | 70 ++++++++++++++++++++- doc/user/core/trees/kdtree.md | 2 +- doc/user/core/trees/mean_split_ball_tree.md | 2 +- doc/user/core/trees/mean_split_kdtree.md | 2 +- 5 files changed, 72 insertions(+), 6 deletions(-) diff --git a/doc/user/core/trees/ball_tree.md b/doc/user/core/trees/ball_tree.md index fdca730b6c..8d36419adc 100644 --- a/doc/user/core/trees/ball_tree.md +++ b/doc/user/core/trees/ball_tree.md @@ -546,7 +546,7 @@ std::cout << "Saved tree with " << tree.Dataset().n_cols << " points to " --- Load a 32-bit floating point `BallTree` from disk, then traverse it manually and -find the number of leaf nodes with fewer than 10 children. +find the number of leaf nodes with fewer than 10 points. ```c++ // This assumes the tree has already been saved to 'tree.bin' (as in the example diff --git a/doc/user/core/trees/binary_space_tree.md b/doc/user/core/trees/binary_space_tree.md index 4c49dbc4c4..4c7c0fdb4d 100644 --- a/doc/user/core/trees/binary_space_tree.md +++ b/doc/user/core/trees/binary_space_tree.md @@ -1261,6 +1261,11 @@ to write a fully custom split: with maximum width * [`MeanSplit`](#meansplit): splits on the mean value of the points in the dimension with maximum width + * [`RPTreeMeanSplit`](#rptreemeansplit): projects points onto a random vector, + splitting on the median value of the projections, or in some cases on the + distance from the mean value + * [`RPTreeMaxSplit`](#rptreemaxsplit): projects points onto a random vector, + splitting on a random offset of the median of projected points * [Custom `SplitType`s](#custom-splittypes): implement a fully custom `SplitType` class @@ -1296,7 +1301,7 @@ The splitting strategy for the `MeanSplit` class is, given a set of points: * Compute the mean value `m` of the points in dimension `d`. * Split in dimension `d`. * Points less than `m` will go to the left child. - * Points greater than `m` will go to the right child. + * Points greater than or equal to `m` will go to the right child. In practice, the `MeanSplit` splitting strategy often results in a tree with fewer leaf nodes than `MidpointSplit`, because each split is more likely to be @@ -1309,6 +1314,67 @@ task*. For implementation details, see [the source code](/src/mlpack/core/tree/binary_space_tree/mean_split_impl.hpp). +### `RPTreeMeanSplit` + +The `RPTreeMeanSplit` class is a splitting strategy that can be used by +[`BinarySpaceTree`](#binaryspacetree). It is the splitting strategy used by the +[`RPTree`](rp_tree.md) class, and uses a random projection to split points. The +general idea is described in the paper by +[Dasgupta and Freund](https://www.cs.cornell.edu/~abrahao/tdg/papers/p537.pdf), +as the `RPTree-Mean` version of the `ChooseRule()` function. + +The splitting strategy for the `RPTreeMeanSplit` class is, given a set of +points: + + * Draw a random vector `z`. + * Sample up to 100 points and compute `d`, the average pairwise distance + between the points. + * If `10 * d` is less than or equal to the squared diameter of the bounding box + of the points: + - Project all points onto the vector `z`, and compute the median `v` of the + projected values. + - Points with projected value less than `v` will go to the left child. + - Points with projected value greater than or equal to `v` will go to the + right child. + * Otherwise: + - Compute the mean `s` of all points. + - Points with distance from `s` less than the median distance from `s` + will go to the left child. + - Points with distance from `s` greater than or equal to the median distance + from `s` will go to the right child. + +The implementation strategy differs slightly from the `RPTree-Mean` version in +the paper: instead of computing the true average pairwise distance between all +points, a sample of 100 points is used. + +For implementation details, see +[the source code](/src/mlpack/core/tree/binary_space_tree/rp_tree_mean_split_impl.hpp). + +### `RPTreeMaxSplit` + +The `RPTreeMaxSplit` class is a splitting strategy that can be used by +[`BinarySpaceTree`](#binaryspacetree). It is the splitting strategy used by the +[`MaxRPTree`](max_rp_tree.md) class, and uses a random projection to split +points. The general idea is described in the paper by +[Dasgupta and Freund](https://www.cs.cornell.edu/~abrahao/tdg/papers/p537.pdf), +as the `RPTree-Max` version of the `ChooseRule()` function. + +The splitting strategy for the `RPTreeMaxSplit` class is, given a set of points, + + * Draw a random vector `z`. + * Sample up to 100 points (call this sample `S`). + * Compute `v`, the median value of projections of points in `S` onto `z`. + * Points with projection onto `z` less than `v` will go to the left child. + * Points with projection onto `z` greater than or equal to `v` will go to the + right child. + +The implementation strategy differs slightly from the `RPTree-Max` version in +the paper: instead of computing the median on all points, a sample of 100 points +is used. + +For implementation details, see +[the source code](/src/mlpack/core/tree/binary_space_tree/rp_tree_max_split_impl.hpp). + ### Custom `SplitType`s Custom split strategies for a binary space tree can be implemented via the @@ -1529,7 +1595,7 @@ std::cout << "Saved tree with " << tree.Dataset().n_cols << " points to " --- Load a 32-bit floating point `BinarySpaceTree` from disk, then traverse it -manually and find the number of leaf nodes with less than 10 children. +manually and find the number of leaf nodes with less than 10 points. ```c++ // This assumes the tree has already been saved to 'tree.bin' (as in the example diff --git a/doc/user/core/trees/kdtree.md b/doc/user/core/trees/kdtree.md index 84c997dde9..3228b74dfe 100644 --- a/doc/user/core/trees/kdtree.md +++ b/doc/user/core/trees/kdtree.md @@ -540,7 +540,7 @@ std::cout << "Saved tree with " << tree.Dataset().n_cols << " points to " --- Load a 32-bit floating point `KDTree` from disk, then traverse it manually and -find the number of leaf nodes with fewer than 10 children. +find the number of leaf nodes with fewer than 10 points. ```c++ // This assumes the tree has already been saved to 'tree.bin' (as in the example diff --git a/doc/user/core/trees/mean_split_ball_tree.md b/doc/user/core/trees/mean_split_ball_tree.md index d7ad1055b2..a08fec9fd6 100644 --- a/doc/user/core/trees/mean_split_ball_tree.md +++ b/doc/user/core/trees/mean_split_ball_tree.md @@ -544,7 +544,7 @@ std::cout << "Saved tree with " << tree.Dataset().n_cols << " points to " --- Load a 32-bit floating point `BallTree` from disk, then traverse it manually and -find the number of leaf nodes with fewer than 10 children. +find the number of leaf nodes with fewer than 10 points. ```c++ // This assumes the tree has already been saved to 'tree.bin' (as in the example diff --git a/doc/user/core/trees/mean_split_kdtree.md b/doc/user/core/trees/mean_split_kdtree.md index d49912a90a..92ef675685 100644 --- a/doc/user/core/trees/mean_split_kdtree.md +++ b/doc/user/core/trees/mean_split_kdtree.md @@ -553,7 +553,7 @@ std::cout << "Saved tree with " << tree.Dataset().n_cols << " points to " --- Load a 32-bit floating point `MeanSplitKDTree` from disk, then traverse it -manually and find the number of leaf nodes with fewer than 10 children. +manually and find the number of leaf nodes with fewer than 10 points. ```c++ // This assumes the tree has already been saved to 'tree.bin' (as in the example From 58a5cc0f5e5acbfd228782fc793ecbde7b782105 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Wed, 16 Oct 2024 15:17:21 -0400 Subject: [PATCH 03/25] Templatize RandVector() for use by RPTreeMaxSplit and RPTreeMeanSplit. --- doc/user/core/math.md | 5 ++++- src/mlpack/core/math/rand_vector.hpp | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/user/core/math.md b/doc/user/core/math.md index 263e585f53..29f4b6073f 100644 --- a/doc/user/core/math.md +++ b/doc/user/core/math.md @@ -447,7 +447,10 @@ std::cout << "Trigamma(1.0): " << t2 << "." << std::endl; ## `RandVector()` * `RandVector(v)` generates a random vector on the unit sphere (i.e. with an - L2-norm of 1) and stores it in `v` (an `arma::vec`). + L2-norm of 1) and stores it in the vector `v`. + + * `v` should be a dense floating-point Armadillo vector (e.g. `arma::vec` or + `arma::fvec`). * The [Box-Muller transform](https://en.wikipedia.org/wiki/Box-Muller_transform) is used to generate the vector. diff --git a/src/mlpack/core/math/rand_vector.hpp b/src/mlpack/core/math/rand_vector.hpp index ca92db91c2..118a7c933b 100644 --- a/src/mlpack/core/math/rand_vector.hpp +++ b/src/mlpack/core/math/rand_vector.hpp @@ -17,7 +17,8 @@ namespace mlpack { /** * Overwrites a dimension-N vector to a random vector on the unit sphere in R^N. */ -inline void RandVector(arma::vec& v) +template +inline void RandVector(arma::Col& v) { for (size_t i = 0; i + 1 < v.n_elem; i += 2) { From d545a997138af11674899b2ff7efefa2381630d9 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Wed, 16 Oct 2024 15:17:37 -0400 Subject: [PATCH 04/25] Update sidebar. --- doc/developer/trees.md | 2 ++ doc/sidebar.html | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/doc/developer/trees.md b/doc/developer/trees.md index 9c266725e4..739b1d5538 100644 --- a/doc/developer/trees.md +++ b/doc/developer/trees.md @@ -1270,6 +1270,8 @@ TreeType policy API: - [`MeanSplitKDTree`](../user/core/trees/mean_split_kdtree.md) - [`BallTree`](../user/core/trees/ball_tree.md) - [`MeanSplitBallTree`](../user/core/trees/mean_split_ball_tree.md) + - [`RPTree`](../user/core/trees/rp_tree.md) + - [`MaxRPTree`](../user/core/trees/max_rp_tree.md) - `RTree` - `RStarTree` - `StandardCoverTree` diff --git a/doc/sidebar.html b/doc/sidebar.html index 28a4f637ad..fe44f066e6 100644 --- a/doc/sidebar.html +++ b/doc/sidebar.html @@ -96,6 +96,16 @@ when the sidebar is built for each page. MeanSplitBallTree +
  • + + RPTree + +
  • +
  • + + MaxRPTree + +
  • BinarySpaceTree From 8853d2b8606d7f1a021ab0272126d5510304b068 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Wed, 16 Oct 2024 15:18:18 -0400 Subject: [PATCH 05/25] Update list of trees. --- doc/user/core/trees.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/user/core/trees.md b/doc/user/core/trees.md index fee2475558..a35ed3b1fd 100644 --- a/doc/user/core/trees.md +++ b/doc/user/core/trees.md @@ -7,9 +7,11 @@ different trees. The following tree types are available in mlpack: * [`KDTree`](trees/kdtree.md) * [`MeanSplitKDTree`](trees/mean_split_kdtree.md) - * [`MeanSplitBallTree`](trees/mean_split_ball_tree.md) - * [`BinarySpaceTree`](trees/binary_space_tree.md) * [`BallTree`](trees/ball_tree.md) + * [`MeanSplitBallTree`](trees/mean_split_ball_tree.md) + * [`RPTree`](trees/rp_tree.md) + * [`MaxRPTree`](trees/max_rp_tree.md) + * [`BinarySpaceTree`](trees/binary_space_tree.md) *Note:* this documentation is a work in progress. Not all trees are documented yet. From 32290feeda2061be05d17a7dd2d14c96b088219c Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Wed, 16 Oct 2024 15:18:51 -0400 Subject: [PATCH 06/25] Minor formatting fixes. --- .../tree/binary_space_tree/rp_tree_mean_split_impl.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mlpack/core/tree/binary_space_tree/rp_tree_mean_split_impl.hpp b/src/mlpack/core/tree/binary_space_tree/rp_tree_mean_split_impl.hpp index 9e92ff993b..a85538ef51 100644 --- a/src/mlpack/core/tree/binary_space_tree/rp_tree_mean_split_impl.hpp +++ b/src/mlpack/core/tree/binary_space_tree/rp_tree_mean_split_impl.hpp @@ -18,11 +18,11 @@ namespace mlpack { template -bool RPTreeMeanSplit::SplitNode(const BoundType& bound, - MatType& data, - const size_t begin, - const size_t count, - SplitInfo& splitInfo) +bool RPTreeMeanSplit::SplitNode(const BoundType& bound, + MatType& data, + const size_t begin, + const size_t count, + SplitInfo& splitInfo) { const size_t maxNumSamples = 100; const size_t numSamples = std::min(maxNumSamples, count); From cb7b798b81d12776dec4e574b5b2127a17dca4f3 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Wed, 16 Oct 2024 15:18:59 -0400 Subject: [PATCH 07/25] Add default template parameters to template typedefs. --- src/mlpack/core/tree/binary_space_tree/typedef.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mlpack/core/tree/binary_space_tree/typedef.hpp b/src/mlpack/core/tree/binary_space_tree/typedef.hpp index 81b071b400..7a5eca8edf 100644 --- a/src/mlpack/core/tree/binary_space_tree/typedef.hpp +++ b/src/mlpack/core/tree/binary_space_tree/typedef.hpp @@ -230,8 +230,9 @@ using VPTree = BinarySpaceTree +template using MaxRPTree = BinarySpaceTree +template using RPTree = BinarySpaceTree Date: Wed, 16 Oct 2024 20:45:51 -0400 Subject: [PATCH 08/25] Fix merge artifact (duplicate BinarySpaceTree). --- doc/sidebar.html | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/sidebar.html b/doc/sidebar.html index fe44f066e6..6c16944f3e 100644 --- a/doc/sidebar.html +++ b/doc/sidebar.html @@ -111,11 +111,6 @@ when the sidebar is built for each page. BinarySpaceTree
  • -
  • - - BinarySpaceTree - -
  • From f286aec94d2fbf724042529d13bbef781240d702 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Wed, 2 Oct 2024 15:08:01 -0400 Subject: [PATCH 09/25] Make sure that Go installed on MacOS CI builds. --- .ci/macos-steps.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.ci/macos-steps.yaml b/.ci/macos-steps.yaml index d6f177f28a..c29979479a 100644 --- a/.ci/macos-steps.yaml +++ b/.ci/macos-steps.yaml @@ -24,6 +24,10 @@ steps: brew install --cask julia fi + if [ "$BINDING" = "go" ]; then + brew install go + fi + displayName: 'Install Build Dependencies' # Configure mlpack (CMake) From 73df406f33684540cd62d3afd6242bb1dd208b7e Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Wed, 2 Oct 2024 17:28:37 -0400 Subject: [PATCH 10/25] I think the -t option is not necessary (it sets the timeout?). --- .ci/macos-steps.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/macos-steps.yaml b/.ci/macos-steps.yaml index c29979479a..b250b6e690 100644 --- a/.ci/macos-steps.yaml +++ b/.ci/macos-steps.yaml @@ -36,7 +36,7 @@ steps: if [ "$BINDING" = "go" ]; then export GOPATH=$PWD/src/mlpack/bindings/go export GO111MODULE=off - go get -u -t gonum.org/v1/gonum/... + go get -u gonum.org/v1/gonum/... fi if [ "$BINDING" = "python" ]; then cmake $CMAKEARGS -DPYTHON_EXECUTABLE=$(which python) .. From b1dd075f53ead87ab7dc9a173fb90e570f15b2d9 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Mon, 7 Oct 2024 10:57:13 -0400 Subject: [PATCH 11/25] Don't search for gonum anymore; it's automatically installed by Go modules. --- .ci/linux-steps.yaml | 5 ----- .ci/macos-steps.yaml | 5 ----- README.md | 3 ++- src/mlpack/bindings/go/CMakeLists.txt | 7 ++----- src/mlpack/bindings/go/tests/CMakeLists.txt | 3 --- 5 files changed, 4 insertions(+), 19 deletions(-) diff --git a/.ci/linux-steps.yaml b/.ci/linux-steps.yaml index cb669ba27e..b5e208e265 100644 --- a/.ci/linux-steps.yaml +++ b/.ci/linux-steps.yaml @@ -69,11 +69,6 @@ steps: # Configure mlpack (CMake) - script: | mkdir build && cd build - if [ "$BINDING" = "go" ]; then - export GOPATH=$PWD/src/mlpack/bindings/go - export GO111MODULE=off - go get -u -t gonum.org/v1/gonum/... - fi cmake $CMAKEARGS -DPYTHON_EXECUTABLE=`which python` -DCEREAL_INCLUDE_DIR=/usr/include/ .. displayName: 'CMake' diff --git a/.ci/macos-steps.yaml b/.ci/macos-steps.yaml index b250b6e690..f94c273da6 100644 --- a/.ci/macos-steps.yaml +++ b/.ci/macos-steps.yaml @@ -33,11 +33,6 @@ steps: # Configure mlpack (CMake) - script: | mkdir build && cd build - if [ "$BINDING" = "go" ]; then - export GOPATH=$PWD/src/mlpack/bindings/go - export GO111MODULE=off - go get -u gonum.org/v1/gonum/... - fi if [ "$BINDING" = "python" ]; then cmake $CMAKEARGS -DPYTHON_EXECUTABLE=$(which python) .. else diff --git a/README.md b/README.md index 4fb8659634..495b0e13a7 100644 --- a/README.md +++ b/README.md @@ -396,7 +396,8 @@ and then `using mlpack` should work. *See also the [Go quickstart](doc/quickstart/go.md).* To build mlpack's Go bindings, ensure that Go >= 1.11.0 is installed, and that -the Gonum package is available. You can use `go get` to install mlpack for Go: +the Gonum package is available. You can use `go get` to install mlpack as a +module in a Go project: ```sh go get -u -d mlpack.org/v1/mlpack diff --git a/src/mlpack/bindings/go/CMakeLists.txt b/src/mlpack/bindings/go/CMakeLists.txt index 079348cad0..50fa4677f3 100644 --- a/src/mlpack/bindings/go/CMakeLists.txt +++ b/src/mlpack/bindings/go/CMakeLists.txt @@ -40,20 +40,17 @@ endif () if (BUILD_GO_BINDINGS) + # Gonum will automatically be installed by Go's module support during build. find_package(Go 1.11.0) if (NOT GO_FOUND) set(GO_NOT_FOUND_MSG "${GO_NOT_FOUND_MSG}\n - Go") endif () - find_package(Gonum) - if (NOT GONUM_FOUND) - set(GO_NOT_FOUND_MSG "${GO_NOT_FOUND_MSG}\n - Gonum") - endif () ## We need to check here if Golang is even available. Although actually ## technically, I'm not sure if we even need to know! For the tests though we ## do. So it's probably a good idea to check. if (FORCE_BUILD_GO_BINDINGS) - if (NOT GO_FOUND OR NOT GONUM_FOUND) + if (NOT GO_FOUND) unset(BUILD_GO_BINDINGS CACHE) set(BUILD_GO_SHLIB OFF) message(FATAL_ERROR "\nCould not Build Go Bindings; the following modules are not available: ${GO_NOT_FOUND_MSG}") diff --git a/src/mlpack/bindings/go/tests/CMakeLists.txt b/src/mlpack/bindings/go/tests/CMakeLists.txt index 17b6aa85a2..1bf80326eb 100644 --- a/src/mlpack/bindings/go/tests/CMakeLists.txt +++ b/src/mlpack/bindings/go/tests/CMakeLists.txt @@ -5,7 +5,4 @@ if (BUILD_GO_BINDINGS) add_test(NAME go_binding_test COMMAND ${GO_EXECUTABLE} test -v ${CMAKE_CURRENT_SOURCE_DIR}/go_binding_test.go WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/mlpack/bindings/go/src/mlpack.org/v1/mlpack/) -set_tests_properties(go_binding_test - PROPERTIES ENVIRONMENT "GOPATH=$ENV{GOPATH}:${CMAKE_BINARY_DIR}/src/mlpack/bindings/go/; - LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_BINARY_DIR}/src/mlpack/bindings/go/src/mlpack.org/v1/mlpack/") endif() From 8e2e01efb9f3053e0394ed832723df5c228e8642 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Mon, 7 Oct 2024 11:50:35 -0400 Subject: [PATCH 12/25] Update documentation for how to use Go bindings with modules. --- README.md | 15 ++++++++++++--- doc/quickstart/go.md | 14 +++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 495b0e13a7..2c95a012aa 100644 --- a/README.md +++ b/README.md @@ -400,11 +400,20 @@ the Gonum package is available. You can use `go get` to install mlpack as a module in a Go project: ```sh -go get -u -d mlpack.org/v1/mlpack -cd ${GOPATH}/src/mlpack.org/v1/mlpack -make install +go get -u mlpack.org/v1/mlpack ``` +The Go bindings themselves will then need to be compiled. Find the mlpack +directory under `$GOMODCACHE/mlpack.org/v1/mlpack` and run these commands: + +```sh +make +sudo make install +``` + +Then, `go run my_code.go` will be able to correctly link against mlpack's Go +bindings and run. + The process of building the Go bindings by hand is a little tedious, so following the steps above is recommended. However, if you wish to build the Go bindings by hand anyway, you can do this by running the following commands from diff --git a/doc/quickstart/go.md b/doc/quickstart/go.md index bdb6ea62ca..ffb6fbe2c9 100644 --- a/doc/quickstart/go.md +++ b/doc/quickstart/go.md @@ -9,13 +9,21 @@ This quickstart guide is also available for [C++](cpp.md), [Python](python.md), ## Installing mlpack Installing the mlpack bindings for Go is somewhat time-consuming as the library -must be built; you can run the following code: +must be built; you can run the following to add mlpack as a dependency inside of +a Go module: ```sh go get -u -d mlpack.org/v1/mlpack -cd ${GOPATH}/src/mlpack.org/v1/mlpack -make install ``` + +The Go bindings themselves will then need to be compiled. Find the mlpack +directory under `$GOMODCACHE/mlpack.org/v1/mlpack` and run these commands: + +```sh +make +sudo make install +``` + Building the Go bindings from scratch is a little more in-depth, though. For information on that, follow the instructions in the [main README](../../README.md). From c826d21aea0603289b121594d48abc6f22ef8ed8 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Mon, 21 Oct 2024 21:31:26 -0400 Subject: [PATCH 13/25] Fix link to HMM regression PDF. --- doc/user/core/distributions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user/core/distributions.md b/doc/user/core/distributions.md index 5fcedd558c..a01057b1ab 100644 --- a/doc/user/core/distributions.md +++ b/doc/user/core/distributions.md @@ -849,7 +849,7 @@ regression model's prediction on `x`. This class is meant to be used with mlpack's [HMM](/src/mlpack/methods/hmm/hmm.hpp) class for the task of -[HMM regression (pdf)](https://conservancy.umn.edu/bitstream/handle/11299/2532/1195.pdf). +[HMM regression (pdf)](https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=93a56eb64e77ac83404fddfd0036e95a742fcee6). ### Constructors From 00c6ef1486328e0b3c1eecedb753887f234dc6e7 Mon Sep 17 00:00:00 2001 From: Martin Lambertsen Date: Thu, 24 Oct 2024 08:17:34 +0200 Subject: [PATCH 14/25] Modernize typedefs The `using` keyword improves readability simply be letting people read from left to right. Additionally some `typename` keywords have been removed, when they have not been required. --- src/mlpack/bindings/R/print_R.cpp | 2 +- .../bindings/R/tests/test_r_binding_main.cpp | 2 +- .../bindings/cli/delete_allocated_memory.hpp | 2 +- .../bindings/cli/get_allocated_memory.hpp | 2 +- src/mlpack/bindings/cli/get_param.hpp | 6 +- .../bindings/cli/get_printable_param_impl.hpp | 4 +- src/mlpack/bindings/cli/get_raw_param.hpp | 4 +- src/mlpack/bindings/cli/in_place_copy.hpp | 4 +- src/mlpack/bindings/cli/output_param_impl.hpp | 6 +- src/mlpack/bindings/cli/parameter_type.hpp | 16 +- src/mlpack/bindings/cli/set_param.hpp | 4 +- .../bindings/go/mlpack/capi/arma_util.cpp | 8 +- src/mlpack/bindings/go/print_go.cpp | 2 +- .../go/tests/test_go_binding_main.cpp | 2 +- src/mlpack/bindings/julia/print_jl.cpp | 2 +- .../julia/tests/test_julia_binding_main.cpp | 2 +- src/mlpack/bindings/python/mlpack/io_util.hpp | 6 +- .../python/print_output_processing.hpp | 2 +- src/mlpack/bindings/python/print_pyx.cpp | 4 +- .../python/tests/test_python_binding_main.cpp | 2 +- .../bindings/tests/test_function_map.hpp | 4 +- .../core/data/check_categorical_param.hpp | 2 +- src/mlpack/core/data/dataset_mapper.hpp | 4 +- src/mlpack/core/data/load_arff_impl.hpp | 4 +- .../data/map_policies/increment_policy.hpp | 2 +- .../core/data/map_policies/missing_policy.hpp | 2 +- src/mlpack/core/distances/iou_distance.hpp | 2 +- src/mlpack/core/distances/lmetric.hpp | 8 +- .../core/distances/mahalanobis_distance.hpp | 2 +- .../diagonal_gaussian_distribution.hpp | 4 +- .../distributions/discrete_distribution.hpp | 8 +- .../core/distributions/gamma_distribution.hpp | 4 +- .../distributions/gaussian_distribution.hpp | 4 +- .../distributions/laplace_distribution.hpp | 4 +- .../distributions/regression_distribution.hpp | 6 +- src/mlpack/core/kernels/cosine_similarity.hpp | 2 +- src/mlpack/core/math/ccov_impl.hpp | 2 +- src/mlpack/core/math/log_add_impl.hpp | 2 +- src/mlpack/core/math/range.hpp | 2 +- src/mlpack/core/metrics/bleu_impl.hpp | 2 +- .../metrics/non_maximal_suppression_impl.hpp | 2 +- src/mlpack/core/tree/address.hpp | 16 +- src/mlpack/core/tree/ballbound.hpp | 2 +- .../binary_space_tree/binary_space_tree.hpp | 6 +- .../breadth_first_dual_tree_traverser.hpp | 4 +- .../binary_space_tree/rp_tree_max_split.hpp | 2 +- .../binary_space_tree/rp_tree_mean_split.hpp | 2 +- .../tree/binary_space_tree/ub_tree_split.hpp | 5 +- .../binary_space_tree/vantage_point_split.hpp | 4 +- src/mlpack/core/tree/cellbound.hpp | 5 +- .../core/tree/cosine_tree/cosine_tree.hpp | 2 +- .../core/tree/cover_tree/cover_tree.hpp | 4 +- .../cover_tree/single_tree_traverser_impl.hpp | 4 +- src/mlpack/core/tree/hollow_ball_bound.hpp | 2 +- src/mlpack/core/tree/octree/octree.hpp | 4 +- .../rectangle_tree/discrete_hilbert_value.hpp | 6 +- .../discrete_hilbert_value_impl.hpp | 2 +- .../hilbert_r_tree_auxiliary_information.hpp | 2 +- .../rectangle_tree/minimal_coverage_sweep.hpp | 2 +- .../minimal_coverage_sweep_impl.hpp | 8 +- .../minimal_splits_number_sweep.hpp | 2 +- .../minimal_splits_number_sweep_impl.hpp | 2 +- ...r_plus_plus_tree_auxiliary_information.hpp | 4 +- ...s_plus_tree_auxiliary_information_impl.hpp | 2 +- .../r_plus_tree_descent_heuristic_impl.hpp | 2 +- .../tree/rectangle_tree/r_plus_tree_split.hpp | 2 +- .../rectangle_tree/r_plus_tree_split_impl.hpp | 9 +- .../r_star_tree_descent_heuristic_impl.hpp | 4 +- .../rectangle_tree/r_star_tree_split_impl.hpp | 12 +- .../r_tree_descent_heuristic_impl.hpp | 4 +- .../tree/rectangle_tree/r_tree_split_impl.hpp | 6 +- .../tree/rectangle_tree/rectangle_tree.hpp | 6 +- .../x_tree_auxiliary_information.hpp | 4 +- .../tree/rectangle_tree/x_tree_split_impl.hpp | 6 +- .../core/tree/space_split/hyperplane.hpp | 4 +- .../core/tree/spill_tree/spill_tree.hpp | 6 +- src/mlpack/core/util/arma_traits.hpp | 34 +- src/mlpack/core/util/ens_traits.hpp | 4 +- .../core/util/first_element_is_arma.hpp | 4 +- src/mlpack/core/util/io.hpp | 4 +- src/mlpack/core/util/params.hpp | 4 +- src/mlpack/core/util/timers.hpp | 4 +- src/mlpack/core/util/timers_impl.hpp | 2 +- src/mlpack/methods/adaboost/adaboost.hpp | 2 +- src/mlpack/methods/amf/amf.hpp | 6 +- .../update_rules/incremental_iterators.hpp | 2 +- .../ann/convolution_rules/fft_convolution.hpp | 2 +- .../convolution_rules/naive_convolution.hpp | 4 +- .../ann/convolution_rules/svd_convolution.hpp | 4 +- .../kathirvalavakumar_subavathi_init.hpp | 4 +- .../ann/init_rules/orthogonal_init.hpp | 4 +- .../ann/layer/adaptive_max_pooling.hpp | 2 +- .../ann/layer/adaptive_mean_pooling.hpp | 2 +- src/mlpack/methods/ann/layer/add.hpp | 2 +- src/mlpack/methods/ann/layer/add_merge.hpp | 2 +- .../methods/ann/layer/alpha_dropout.hpp | 2 +- src/mlpack/methods/ann/layer/base_layer.hpp | 34 +- src/mlpack/methods/ann/layer/batch_norm.hpp | 2 +- src/mlpack/methods/ann/layer/c_relu.hpp | 2 +- src/mlpack/methods/ann/layer/celu.hpp | 2 +- src/mlpack/methods/ann/layer/concat.hpp | 2 +- src/mlpack/methods/ann/layer/concatenate.hpp | 2 +- src/mlpack/methods/ann/layer/convolution.hpp | 12 +- src/mlpack/methods/ann/layer/dropconnect.hpp | 2 +- src/mlpack/methods/ann/layer/dropout.hpp | 2 +- src/mlpack/methods/ann/layer/elu.hpp | 4 +- .../methods/ann/layer/flexible_relu.hpp | 2 +- src/mlpack/methods/ann/layer/ftswish.hpp | 2 +- .../methods/ann/layer/grouped_convolution.hpp | 7 +- src/mlpack/methods/ann/layer/hard_tanh.hpp | 2 +- src/mlpack/methods/ann/layer/identity.hpp | 2 +- src/mlpack/methods/ann/layer/layer_norm.hpp | 2 +- src/mlpack/methods/ann/layer/leaky_relu.hpp | 2 +- src/mlpack/methods/ann/layer/linear.hpp | 2 +- src/mlpack/methods/ann/layer/linear3d.hpp | 2 +- .../methods/ann/layer/linear3d_impl.hpp | 6 +- .../methods/ann/layer/linear_no_bias.hpp | 2 +- src/mlpack/methods/ann/layer/log_softmax.hpp | 2 +- src/mlpack/methods/ann/layer/lstm.hpp | 2 +- src/mlpack/methods/ann/layer/max_pooling.hpp | 2 +- src/mlpack/methods/ann/layer/mean_pooling.hpp | 2 +- .../methods/ann/layer/multihead_attention.hpp | 4 +- .../ann/layer/multihead_attention_impl.hpp | 6 +- .../ann/layer/nearest_interpolation.hpp | 2 +- src/mlpack/methods/ann/layer/noisylinear.hpp | 2 +- .../not_adapted/bicubic_interpolation.hpp | 2 +- .../not_adapted/bilinear_interpolation.hpp | 2 +- .../ann/layer/not_adapted/constant.hpp | 2 +- .../ann/layer/not_adapted/fast_lstm.hpp | 6 +- .../methods/ann/layer/not_adapted/glimpse.hpp | 2 +- .../ann/layer/not_adapted/hardshrink.hpp | 2 +- .../methods/ann/layer/not_adapted/highway.hpp | 2 +- .../methods/ann/layer/not_adapted/join.hpp | 2 +- .../methods/ann/layer/not_adapted/lookup.hpp | 4 +- .../ann/layer/not_adapted/lookup_impl.hpp | 2 +- .../layer/not_adapted/multiply_constant.hpp | 2 +- .../ann/layer/not_adapted/multiply_merge.hpp | 2 +- .../layer/not_adapted/positional_encoding.hpp | 2 +- .../layer/not_adapted/reinforce_normal.hpp | 2 +- .../layer/not_adapted/reparametrization.hpp | 2 +- .../methods/ann/layer/not_adapted/select.hpp | 2 +- .../ann/layer/not_adapted/sequential.hpp | 4 +- .../ann/layer/not_adapted/softshrink.hpp | 2 +- .../ann/layer/not_adapted/spatial_dropout.hpp | 2 +- .../methods/ann/layer/not_adapted/subview.hpp | 2 +- .../not_adapted/transposed_convolution.hpp | 13 +- .../transposed_convolution_impl.hpp | 2 +- .../layer/not_adapted/virtual_batch_norm.hpp | 2 +- .../ann/layer/not_adapted/weight_norm.hpp | 2 +- src/mlpack/methods/ann/layer/padding.hpp | 2 +- .../methods/ann/layer/parametric_relu.hpp | 2 +- .../ann/layer/radial_basis_function.hpp | 2 +- src/mlpack/methods/ann/layer/relu6.hpp | 2 +- src/mlpack/methods/ann/layer/repeat.hpp | 6 +- src/mlpack/methods/ann/layer/softmax.hpp | 2 +- src/mlpack/methods/ann/layer/softmin.hpp | 2 +- .../binary_cross_entropy_loss.hpp | 4 +- .../binary_cross_entropy_loss_impl.hpp | 2 +- .../loss_functions/cosine_embedding_loss.hpp | 2 +- .../cosine_embedding_loss_impl.hpp | 4 +- .../methods/ann/loss_functions/dice_loss.hpp | 2 +- .../loss_functions/earth_mover_distance.hpp | 2 +- .../methods/ann/loss_functions/empty_loss.hpp | 2 +- .../loss_functions/hinge_embedding_loss.hpp | 2 +- .../methods/ann/loss_functions/hinge_loss.hpp | 2 +- .../methods/ann/loss_functions/huber_loss.hpp | 2 +- .../ann/loss_functions/huber_loss_impl.hpp | 4 +- .../ann/loss_functions/kl_divergence.hpp | 2 +- .../methods/ann/loss_functions/l1_loss.hpp | 2 +- .../ann/loss_functions/log_cosh_loss.hpp | 2 +- .../loss_functions/margin_ranking_loss.hpp | 2 +- .../mean_absolute_percentage_error.hpp | 2 +- .../ann/loss_functions/mean_bias_error.hpp | 2 +- .../ann/loss_functions/mean_squared_error.hpp | 2 +- .../mean_squared_logarithmic_error.hpp | 3 +- .../multilabel_softmargin_loss.hpp | 2 +- .../negative_log_likelihood.hpp | 2 +- .../negative_log_likelihood_impl.hpp | 2 +- .../ann/loss_functions/poisson_nll_loss.hpp | 2 +- .../loss_functions/reconstruction_loss.hpp | 2 +- .../sigmoid_cross_entropy_error.hpp | 2 +- .../sigmoid_cross_entropy_error_impl.hpp | 2 +- .../ann/loss_functions/soft_margin_loss.hpp | 2 +- .../loss_functions/triplet_margin_loss.hpp | 2 +- .../ann/loss_functions/vr_class_reward.hpp | 2 +- .../methods/ann/not_adapted/rbm/rbm.hpp | 2 +- .../methods/ann/regularizer/lregularizer.hpp | 4 +- .../approx_kfn/drusilla_select_impl.hpp | 2 +- .../bayesian_linear_regression.hpp | 6 +- src/mlpack/methods/cf/cf.hpp | 4 +- src/mlpack/methods/cf/cf_impl.hpp | 4 +- src/mlpack/methods/cf/cf_model.hpp | 2 +- src/mlpack/methods/cf/svd_wrapper.hpp | 2 +- src/mlpack/methods/dbscan/dbscan.hpp | 4 +- .../methods/decision_tree/decision_tree.hpp | 23 +- .../decision_tree/decision_tree_main.cpp | 2 +- .../decision_tree/decision_tree_regressor.hpp | 13 +- .../decision_tree_regressor_impl.hpp | 4 +- .../fitness_functions/mse_gain.hpp | 8 +- .../splits/best_binary_categorical_split.hpp | 6 +- .../splits/best_binary_numeric_split_impl.hpp | 8 +- src/mlpack/methods/decision_tree/utils.hpp | 4 +- src/mlpack/methods/det/dt_utils.hpp | 4 +- src/mlpack/methods/det/dtree.hpp | 6 +- src/mlpack/methods/det/dtree_impl.hpp | 8 +- src/mlpack/methods/emst/dtb.hpp | 2 +- src/mlpack/methods/emst/dtb_impl.hpp | 2 +- src/mlpack/methods/emst/dtb_rules.hpp | 2 +- src/mlpack/methods/fastmks/fastmks.hpp | 8 +- src/mlpack/methods/fastmks/fastmks_impl.hpp | 6 +- src/mlpack/methods/fastmks/fastmks_rules.hpp | 4 +- .../methods/fastmks/fastmks_rules_impl.hpp | 2 +- src/mlpack/methods/gmm/gmm_train_main.cpp | 2 +- .../gmm/positive_definite_constraint.hpp | 6 +- .../hoeffding_trees/binary_numeric_split.hpp | 2 +- .../hoeffding_categorical_split.hpp | 2 +- .../hoeffding_numeric_split.hpp | 2 +- .../hoeffding_trees/hoeffding_tree.hpp | 4 +- .../hoeffding_trees/hoeffding_tree_main.cpp | 2 +- .../hoeffding_trees/hoeffding_tree_model.hpp | 16 +- .../methods/hoeffding_trees/typedef.hpp | 2 +- src/mlpack/methods/kde/kde.hpp | 2 +- src/mlpack/methods/kde/kde_impl.hpp | 6 +- src/mlpack/methods/kde/kde_model.hpp | 2 +- src/mlpack/methods/kde/kde_rules.hpp | 4 +- .../methods/kmeans/dual_tree_kmeans.hpp | 2 +- .../methods/kmeans/dual_tree_kmeans_impl.hpp | 2 +- .../methods/kmeans/dual_tree_kmeans_rules.hpp | 2 +- .../methods/kmeans/pelleg_moore_kmeans.hpp | 2 +- .../kmeans/pelleg_moore_kmeans_impl.hpp | 2 +- src/mlpack/methods/lars/lars.hpp | 6 +- .../linear_regression/linear_regression.hpp | 4 +- src/mlpack/methods/linear_svm/linear_svm.hpp | 6 +- .../linear_svm/linear_svm_function.hpp | 10 +- src/mlpack/methods/lmnn/constraints.hpp | 12 +- src/mlpack/methods/lmnn/constraints_impl.hpp | 2 +- src/mlpack/methods/lmnn/lmnn_function.hpp | 10 +- .../methods/local_coordinate_coding/lcc.hpp | 4 +- .../logistic_regression.hpp | 6 +- .../logistic_regression_function_impl.hpp | 14 +- src/mlpack/methods/lsh/lsh_search.hpp | 6 +- .../methods/mean_shift/mean_shift_impl.hpp | 10 +- .../naive_bayes/naive_bayes_classifier.hpp | 2 +- .../nca/nca_softmax_error_function.hpp | 4 +- .../methods/neighbor_search/kfn_main.cpp | 2 +- .../methods/neighbor_search/knn_main.cpp | 2 +- .../neighbor_search/neighbor_search.hpp | 4 +- .../neighbor_search/neighbor_search_impl.hpp | 6 +- .../neighbor_search/neighbor_search_rules.hpp | 10 +- .../methods/neighbor_search/ns_model.hpp | 12 +- .../methods/neighbor_search/typedef.hpp | 6 +- src/mlpack/methods/pca/pca_impl.hpp | 10 +- src/mlpack/methods/perceptron/perceptron.hpp | 2 +- src/mlpack/methods/radical/radical_impl.hpp | 10 +- .../methods/random_forest/random_forest.hpp | 4 +- .../methods/range_search/range_search.hpp | 6 +- .../range_search/range_search_impl.hpp | 6 +- .../range_search/range_search_rules.hpp | 6 +- src/mlpack/methods/range_search/rs_model.hpp | 2 +- src/mlpack/methods/rann/ra_model.hpp | 8 +- src/mlpack/methods/rann/ra_search.hpp | 2 +- src/mlpack/methods/rann/ra_search_impl.hpp | 6 +- src/mlpack/methods/rann/ra_search_rules.hpp | 8 +- src/mlpack/methods/rann/ra_typedef.hpp | 4 +- .../softmax_regression/softmax_regression.hpp | 8 +- .../softmax_regression_function.hpp | 6 +- .../methods/sparse_coding/sparse_coding.hpp | 4 +- src/mlpack/tests/adaboost_test.cpp | 134 ++++---- src/mlpack/tests/aknn_test.cpp | 8 +- src/mlpack/tests/ann/layer/repeat.cpp | 14 +- .../tests/bayesian_linear_regression_test.cpp | 4 +- src/mlpack/tests/cli_binding_test.cpp | 26 +- .../tests/decision_tree_regressor_test.cpp | 2 +- src/mlpack/tests/distance_test.cpp | 12 +- src/mlpack/tests/distribution_test.cpp | 306 +++++++++--------- src/mlpack/tests/emst_test.cpp | 2 +- src/mlpack/tests/hoeffding_tree_test.cpp | 14 +- src/mlpack/tests/io_test.cpp | 2 +- src/mlpack/tests/kde_test.cpp | 21 +- src/mlpack/tests/kfn_test.cpp | 12 +- src/mlpack/tests/knn_test.cpp | 64 ++-- src/mlpack/tests/krann_search_test.cpp | 32 +- src/mlpack/tests/lars_test.cpp | 20 +- src/mlpack/tests/linear_regression_test.cpp | 18 +- src/mlpack/tests/linear_svm_test.cpp | 22 +- src/mlpack/tests/lmnn_test.cpp | 40 +-- .../tests/local_coordinate_coding_test.cpp | 10 +- src/mlpack/tests/logistic_regression_test.cpp | 4 +- src/mlpack/tests/mean_shift_test.cpp | 12 +- src/mlpack/tests/metric_test.cpp | 2 +- src/mlpack/tests/nbc_test.cpp | 4 +- src/mlpack/tests/nca_test.cpp | 20 +- src/mlpack/tests/nmf_test.cpp | 2 +- src/mlpack/tests/pca_test.cpp | 10 +- src/mlpack/tests/perceptron_test.cpp | 2 +- src/mlpack/tests/radical_test.cpp | 6 +- src/mlpack/tests/range_search_test.cpp | 4 +- src/mlpack/tests/rectangle_tree_test.cpp | 97 +++--- src/mlpack/tests/serialization_test.cpp | 18 +- src/mlpack/tests/softmax_regression_test.cpp | 10 +- src/mlpack/tests/sort_policy_test.cpp | 8 +- src/mlpack/tests/sparse_coding_test.cpp | 14 +- src/mlpack/tests/spill_tree_test.cpp | 20 +- src/mlpack/tests/svd_batch_test.cpp | 6 +- src/mlpack/tests/svd_incremental_test.cpp | 6 +- src/mlpack/tests/tree_test.cpp | 56 ++-- src/mlpack/tests/tree_traits_test.cpp | 2 +- src/mlpack/tests/ub_tree_test.cpp | 26 +- src/mlpack/tests/vantage_point_tree_test.cpp | 8 +- 309 files changed, 1096 insertions(+), 1110 deletions(-) diff --git a/src/mlpack/bindings/R/print_R.cpp b/src/mlpack/bindings/R/print_R.cpp index 259766427a..2f51175afa 100644 --- a/src/mlpack/bindings/R/print_R.cpp +++ b/src/mlpack/bindings/R/print_R.cpp @@ -35,7 +35,7 @@ void PrintR(util::Params& params, const util::BindingDetails& doc = params.Doc(); map& parameters = params.Parameters(); - typedef map::iterator ParamIter; + using ParamIter = map::iterator; // First, let's get a list of input and output options. We'll take two passes // so that the required input options are the first in the list. diff --git a/src/mlpack/bindings/R/tests/test_r_binding_main.cpp b/src/mlpack/bindings/R/tests/test_r_binding_main.cpp index e661bf9c6f..9d5cf1170d 100644 --- a/src/mlpack/bindings/R/tests/test_r_binding_main.cpp +++ b/src/mlpack/bindings/R/tests/test_r_binding_main.cpp @@ -195,7 +195,7 @@ void BINDING_FUNCTION(util::Params& params, util::Timers& /* timers */) // All numeric elements should be multiplied by 3. if (params.Has("matrix_and_info_in")) { - typedef tuple TupleType; + using TupleType = tuple; TupleType tuple = std::move(params.Get("matrix_and_info_in")); const data::DatasetInfo& di = std::get<0>(tuple); diff --git a/src/mlpack/bindings/cli/delete_allocated_memory.hpp b/src/mlpack/bindings/cli/delete_allocated_memory.hpp index d73715fa59..910fc7636c 100644 --- a/src/mlpack/bindings/cli/delete_allocated_memory.hpp +++ b/src/mlpack/bindings/cli/delete_allocated_memory.hpp @@ -42,7 +42,7 @@ void DeleteAllocatedMemoryImpl( const std::enable_if_t::value>* = 0) { // Delete the allocated memory (hopefully we actually own it). - typedef std::tuple TupleType; + using TupleType = std::tuple; delete std::get<0>(*std::any_cast(&d.value)); } diff --git a/src/mlpack/bindings/cli/get_allocated_memory.hpp b/src/mlpack/bindings/cli/get_allocated_memory.hpp index 6cc4d2e94e..56e3492b65 100644 --- a/src/mlpack/bindings/cli/get_allocated_memory.hpp +++ b/src/mlpack/bindings/cli/get_allocated_memory.hpp @@ -44,7 +44,7 @@ void* GetAllocatedMemory( { // Here we have a model, which is a tuple, and we need the address of the // memory. - typedef std::tuple TupleType; + using TupleType = std::tuple; return std::get<0>(*std::any_cast(&d.value)); } diff --git a/src/mlpack/bindings/cli/get_param.hpp b/src/mlpack/bindings/cli/get_param.hpp index a768a2902a..fe20f1d7dc 100644 --- a/src/mlpack/bindings/cli/get_param.hpp +++ b/src/mlpack/bindings/cli/get_param.hpp @@ -51,7 +51,7 @@ T& GetParam( // contains the filename. It's possible we could load empty matrices many // times, but I am not bothered by that---it shouldn't be something that // happens. - typedef std::tuple::type> TupleType; + using TupleType = std::tuple::type>; TupleType& tuple = *std::any_cast(&d.value); const std::string& value = std::get<0>(std::get<1>(tuple)); T& matrix = std::get<0>(tuple); @@ -85,7 +85,7 @@ T& GetParam( { // If this is an input parameter, we need to load both the matrix and the // dataset info. - typedef std::tuple> TupleType; + using TupleType = std::tuple>; TupleType* tuple = std::any_cast(&d.value); const std::string& value = std::get<0>(std::get<1>(*tuple)); T& t = std::get<0>(*tuple); @@ -115,7 +115,7 @@ T*& GetParam( { // If the model is an input model, we have to load it from file. 'value' // contains the filename. - typedef std::tuple TupleType; + using TupleType = std::tuple; TupleType* tuple = std::any_cast(&d.value); const std::string& value = std::get<1>(*tuple); if (d.input && !d.loaded) diff --git a/src/mlpack/bindings/cli/get_printable_param_impl.hpp b/src/mlpack/bindings/cli/get_printable_param_impl.hpp index 3bbd8989fc..38677ac676 100644 --- a/src/mlpack/bindings/cli/get_printable_param_impl.hpp +++ b/src/mlpack/bindings/cli/get_printable_param_impl.hpp @@ -77,7 +77,7 @@ std::string GetPrintableParam( std::tuple>>* /* junk */) { // Extract the string from the tuple that's being held. - typedef std::tuple::type> TupleType; + using TupleType = std::tuple::type>; const TupleType* tuple = std::any_cast(&data.value); std::ostringstream oss; @@ -105,7 +105,7 @@ std::string GetPrintableParam( const std::enable_if_t::value>*) { // Extract the string from the tuple that's being held. - typedef std::tuple::type> TupleType; + using TupleType = std::tuple::type>; const TupleType* tuple = std::any_cast(&data.value); std::ostringstream oss; diff --git a/src/mlpack/bindings/cli/get_raw_param.hpp b/src/mlpack/bindings/cli/get_raw_param.hpp index 5464b01d72..4c65c11ba4 100644 --- a/src/mlpack/bindings/cli/get_raw_param.hpp +++ b/src/mlpack/bindings/cli/get_raw_param.hpp @@ -48,7 +48,7 @@ T& GetRawParam( arma::mat>>>* = 0) { // Don't load the matrix. - typedef std::tuple> TupleType; + using TupleType = std::tuple>; T& value = std::get<0>(*std::any_cast(&d.value)); return value; } @@ -63,7 +63,7 @@ T*& GetRawParam( const std::enable_if_t::value>* = 0) { // Don't load the model. - typedef std::tuple TupleType; + using TupleType = std::tuple; T*& value = std::get<0>(*std::any_cast(&d.value)); return value; } diff --git a/src/mlpack/bindings/cli/in_place_copy.hpp b/src/mlpack/bindings/cli/in_place_copy.hpp index 2e8b2a5efc..fd31c25c8c 100644 --- a/src/mlpack/bindings/cli/in_place_copy.hpp +++ b/src/mlpack/bindings/cli/in_place_copy.hpp @@ -56,7 +56,7 @@ void InPlaceCopyInternal( = 0) { // Make the output filename the same as the input filename. - typedef std::tuple::type> TupleType; + using TupleType = std::tuple::type>; TupleType& tuple = *std::any_cast(&d.value); std::string& value = std::get<0>(std::get<1>(tuple)); @@ -78,7 +78,7 @@ void InPlaceCopyInternal( const std::enable_if_t::value>* = 0) { // Make the output filename the same as the input filename. - typedef std::tuple::type> TupleType; + using TupleType = std::tuple::type>; TupleType& tuple = *std::any_cast(&d.value); std::string& value = std::get<1>(tuple); diff --git a/src/mlpack/bindings/cli/output_param_impl.hpp b/src/mlpack/bindings/cli/output_param_impl.hpp index 0addc718b8..d05432a4fd 100644 --- a/src/mlpack/bindings/cli/output_param_impl.hpp +++ b/src/mlpack/bindings/cli/output_param_impl.hpp @@ -53,7 +53,7 @@ void OutputParamImpl( util::ParamData& data, const std::enable_if_t::value>*) { - typedef std::tuple> TupleType; + using TupleType = std::tuple>; const T& output = std::get<0>(*std::any_cast(&data.value)); const std::string& filename = std::get<0>(std::get<1>(*std::any_cast(&data.value))); @@ -77,7 +77,7 @@ void OutputParamImpl( // The const cast is necessary here because Serialize() can't ever be marked // const. In this case we can assume it though, since we will be saving and // not loading. - typedef std::tuple TupleType; + using TupleType = std::tuple; T*& output = const_cast(std::get<0>(*std::any_cast( &data.value))); const std::string& filename = @@ -95,7 +95,7 @@ void OutputParamImpl( std::tuple>>* /* junk */) { // Output the matrix with the mappings. - typedef std::tuple> TupleType; + using TupleType = std::tuple>; const T& tuple = std::get<0>(*std::any_cast(&data.value)); const std::string& filename = std::get<0>(std::get<1>(*std::any_cast(&data.value))); diff --git a/src/mlpack/bindings/cli/parameter_type.hpp b/src/mlpack/bindings/cli/parameter_type.hpp index 036240b375..15bb7a3a65 100644 --- a/src/mlpack/bindings/cli/parameter_type.hpp +++ b/src/mlpack/bindings/cli/parameter_type.hpp @@ -23,14 +23,14 @@ namespace cli { template struct ParameterTypeDeducer { - typedef T type; + using type = T; }; // If we have a serialize() function, then the type is a string. template struct ParameterTypeDeducer { - typedef std::string type; + using type = std::string; }; /** @@ -41,8 +41,8 @@ struct ParameterTypeDeducer template struct ParameterType { - typedef typename ParameterTypeDeducer::value, T>::type - type; + using type = + typename ParameterTypeDeducer::value, T>::type; }; /** @@ -53,7 +53,7 @@ struct ParameterType template struct ParameterType> { - typedef std::tuple type; + using type = std::tuple; }; /** @@ -65,7 +65,7 @@ struct ParameterType> template struct ParameterType> { - typedef std::tuple type; + using type = std::tuple; }; /** @@ -76,7 +76,7 @@ struct ParameterType> template struct ParameterType> { - typedef std::tuple type; + using type = std::tuple; }; /** @@ -86,7 +86,7 @@ template struct ParameterType, arma::Mat>> { - typedef std::tuple type; + using type = std::tuple; }; } // namespace cli diff --git a/src/mlpack/bindings/cli/set_param.hpp b/src/mlpack/bindings/cli/set_param.hpp index 73f493c660..964fd5a3e7 100644 --- a/src/mlpack/bindings/cli/set_param.hpp +++ b/src/mlpack/bindings/cli/set_param.hpp @@ -62,7 +62,7 @@ void SetParam( std::tuple>>* = 0) { // We're setting the string filename. - typedef std::tuple::type> TupleType; + using TupleType = std::tuple::type>; TupleType& tuple = *std::any_cast(&d.value); std::get<0>(std::get<1>(tuple)) = std::any_cast(value); } @@ -79,7 +79,7 @@ void SetParam( const std::enable_if_t::value>* = 0) { // We're setting the string filename. - typedef std::tuple::type> TupleType; + using TupleType = std::tuple::type>; TupleType& tuple = *std::any_cast(&d.value); std::get<1>(tuple) = std::any_cast(value); } diff --git a/src/mlpack/bindings/go/mlpack/capi/arma_util.cpp b/src/mlpack/bindings/go/mlpack/capi/arma_util.cpp index 81da118f50..0b0800ec19 100644 --- a/src/mlpack/bindings/go/mlpack/capi/arma_util.cpp +++ b/src/mlpack/bindings/go/mlpack/capi/arma_util.cpp @@ -377,7 +377,7 @@ void mlpackToArmaMatWithInfo(void* params, int mlpackArmaMatWithInfoElements(void* params, const char* identifier) { util::Params& p = *((util::Params*) params); - typedef std::tuple TupleType; + using TupleType = std::tuple; return std::get<1>(p.Get(identifier)).n_elem; } @@ -387,7 +387,7 @@ int mlpackArmaMatWithInfoElements(void* params, const char* identifier) int mlpackArmaMatWithInfoRows(void* params, const char* identifier) { util::Params& p = *((util::Params*) params); - typedef std::tuple TupleType; + using TupleType = std::tuple; return std::get<1>(p.Get(identifier)).n_rows; } @@ -397,7 +397,7 @@ int mlpackArmaMatWithInfoRows(void* params, const char* identifier) int mlpackArmaMatWithInfoCols(void* params, const char* identifier) { util::Params& p = *((util::Params*) params); - typedef std::tuple TupleType; + using TupleType = std::tuple; return std::get<1>(p.Get(identifier)).n_cols; } @@ -408,7 +408,7 @@ int mlpackArmaMatWithInfoCols(void* params, const char* identifier) void* mlpackArmaPtrMatWithInfoPtr(void* params, const char* identifier) { util::Params& p = *((util::Params*) params); - typedef std::tuple TupleType; + using TupleType = std::tuple; arma::mat& m = std::get<1>(p.Get(identifier)); if (m.is_empty()) { diff --git a/src/mlpack/bindings/go/print_go.cpp b/src/mlpack/bindings/go/print_go.cpp index d44756478d..19d4ee33a1 100644 --- a/src/mlpack/bindings/go/print_go.cpp +++ b/src/mlpack/bindings/go/print_go.cpp @@ -43,7 +43,7 @@ void PrintGo(util::Params& params, const std::string& bindingName) { std::map& parameters = params.Parameters(); - typedef std::map::iterator ParamIter; + using ParamIter = std::map::iterator; // Split into input and output parameters. Take two passes on the input // parameters, so that we get the required ones first. diff --git a/src/mlpack/bindings/go/tests/test_go_binding_main.cpp b/src/mlpack/bindings/go/tests/test_go_binding_main.cpp index 92738bf2e9..ef8f551798 100644 --- a/src/mlpack/bindings/go/tests/test_go_binding_main.cpp +++ b/src/mlpack/bindings/go/tests/test_go_binding_main.cpp @@ -191,7 +191,7 @@ void BINDING_FUNCTION(util::Params& params, util::Timers& /* timer */) // All numeric elements should be multiplied by 3. if (params.Has("matrix_and_info_in")) { - typedef tuple TupleType; + using TupleType = tuple; TupleType tuple = std::move(params.Get("matrix_and_info_in")); const data::DatasetInfo& di = std::get<0>(tuple); diff --git a/src/mlpack/bindings/julia/print_jl.cpp b/src/mlpack/bindings/julia/print_jl.cpp index 292b0850a5..623db29e54 100644 --- a/src/mlpack/bindings/julia/print_jl.cpp +++ b/src/mlpack/bindings/julia/print_jl.cpp @@ -34,7 +34,7 @@ void PrintJL(const string& bindingName, const BindingDetails& doc = p.Doc(); map& parameters = p.Parameters(); - typedef map::iterator ParamIter; + using ParamIter = map::iterator; // First, let's get a list of input and output options. We'll take two passes // so that the required input options are the first in the list. diff --git a/src/mlpack/bindings/julia/tests/test_julia_binding_main.cpp b/src/mlpack/bindings/julia/tests/test_julia_binding_main.cpp index 98e36074dc..04d5dc930a 100644 --- a/src/mlpack/bindings/julia/tests/test_julia_binding_main.cpp +++ b/src/mlpack/bindings/julia/tests/test_julia_binding_main.cpp @@ -193,7 +193,7 @@ void BINDING_FUNCTION(util::Params& params, util::Timers& /* timers */) // All numeric elements should be multiplied by 3. if (params.Has("matrix_and_info_in")) { - typedef tuple TupleType; + using TupleType = tuple; TupleType tuple = std::move(params.Get("matrix_and_info_in")); const data::DatasetInfo& di = std::get<0>(tuple); diff --git a/src/mlpack/bindings/python/mlpack/io_util.hpp b/src/mlpack/bindings/python/mlpack/io_util.hpp index 4b9f956419..df82de81dd 100644 --- a/src/mlpack/bindings/python/mlpack/io_util.hpp +++ b/src/mlpack/bindings/python/mlpack/io_util.hpp @@ -89,8 +89,8 @@ inline void SetParamWithInfo(util::Params& params, T& matrix, const bool* dims) { - typedef typename std::tuple TupleType; - typedef typename T::elem_type eT; + using TupleType = std::tuple; + using eT = typename T::elem_type; // The true type of the parameter is std::tuple. const size_t dimensions = matrix.n_rows; @@ -149,7 +149,7 @@ T& GetParamWithInfo(util::Params& params, const std::string& paramName) { // T will be the Armadillo type. - typedef std::tuple TupleType; + using TupleType = std::tuple; return std::get<1>(params.Get(paramName)); } diff --git a/src/mlpack/bindings/python/print_output_processing.hpp b/src/mlpack/bindings/python/print_output_processing.hpp index 01a1c13b0d..809e074a05 100644 --- a/src/mlpack/bindings/python/print_output_processing.hpp +++ b/src/mlpack/bindings/python/print_output_processing.hpp @@ -302,7 +302,7 @@ void PrintOutputProcessing(util::ParamData& d, const void* input, void* /* output */) { - typedef std::tuple> TupleType; + using TupleType = std::tuple>; TupleType* tuple = (TupleType*) input; PrintOutputProcessing>( diff --git a/src/mlpack/bindings/python/print_pyx.cpp b/src/mlpack/bindings/python/print_pyx.cpp index 06bdee2aee..b9e177f875 100644 --- a/src/mlpack/bindings/python/print_pyx.cpp +++ b/src/mlpack/bindings/python/print_pyx.cpp @@ -40,7 +40,7 @@ void PrintPYX(const util::BindingDetails& doc, util::Params params = IO::Parameters(bindingName); std::map& parameters = params.Parameters(); - typedef std::map::iterator ParamIter; + using ParamIter = std::map::iterator; // Split into input and output parameters. Take two passes on the input // parameters, so that we get the required ones first. @@ -258,7 +258,7 @@ void PrintPYX(const util::BindingDetails& doc, cout << " result = {}" << endl; cout << endl; - typedef std::tuple> TupleType; + using TupleType = std::tuple>; for (size_t i = 0; i < outputOptions.size(); ++i) { diff --git a/src/mlpack/bindings/python/tests/test_python_binding_main.cpp b/src/mlpack/bindings/python/tests/test_python_binding_main.cpp index 120bee7b94..59598eaf2e 100644 --- a/src/mlpack/bindings/python/tests/test_python_binding_main.cpp +++ b/src/mlpack/bindings/python/tests/test_python_binding_main.cpp @@ -235,7 +235,7 @@ void BINDING_FUNCTION(util::Params& params, util::Timers& /* timer */) // All numeric elements should be multiplied by 3. if (params.Has("matrix_and_info_in")) { - typedef tuple TupleType; + using TupleType = tuple; TupleType tuple = std::move(params.Get("matrix_and_info_in")); const data::DatasetInfo& di = std::get<0>(tuple); diff --git a/src/mlpack/bindings/tests/test_function_map.hpp b/src/mlpack/bindings/tests/test_function_map.hpp index 84d7f8e3a8..f449062b24 100644 --- a/src/mlpack/bindings/tests/test_function_map.hpp +++ b/src/mlpack/bindings/tests/test_function_map.hpp @@ -26,8 +26,8 @@ class TestFunctionMap { public: // Convenience typedef. - typedef std::map> FunctionMapType; + using FunctionMapType = std::map>; //! Get the instantiated TestFunctionMap object. static TestFunctionMap& GetSingleton(); diff --git a/src/mlpack/core/data/check_categorical_param.hpp b/src/mlpack/core/data/check_categorical_param.hpp index 0d8b9f4c75..e29a33f219 100644 --- a/src/mlpack/core/data/check_categorical_param.hpp +++ b/src/mlpack/core/data/check_categorical_param.hpp @@ -22,7 +22,7 @@ namespace data { inline void CheckCategoricalParam(util::Params& params, const std::string& paramName) { - typedef typename std::tuple TupleType; + using TupleType = std::tuple; arma::mat& matrix = std::get<1>(params.Get(paramName)); // This comes from Params::CheckInputMatrix(). diff --git a/src/mlpack/core/data/dataset_mapper.hpp b/src/mlpack/core/data/dataset_mapper.hpp index 893385e0cf..517572cdbe 100644 --- a/src/mlpack/core/data/dataset_mapper.hpp +++ b/src/mlpack/core/data/dataset_mapper.hpp @@ -170,8 +170,8 @@ class DatasetMapper std::vector types; // Forward mapping type. - using ForwardMapType = typename std::unordered_map; + using ForwardMapType = std::unordered_map; // Reverse mapping type. Multiple inputs may map to a single output, hence // the need for std::vector. diff --git a/src/mlpack/core/data/load_arff_impl.hpp b/src/mlpack/core/data/load_arff_impl.hpp index a1e45effee..adf45be507 100644 --- a/src/mlpack/core/data/load_arff_impl.hpp +++ b/src/mlpack/core/data/load_arff_impl.hpp @@ -160,8 +160,8 @@ void LoadARFF(const std::string& filename, } // Make sure all strings are mapped, if we have any. - typedef std::map>::const_iterator - IteratorType; + using IteratorType = + std::map>::const_iterator; for (IteratorType it = categoryStrings.begin(); it != categoryStrings.end(); ++it) { diff --git a/src/mlpack/core/data/map_policies/increment_policy.hpp b/src/mlpack/core/data/map_policies/increment_policy.hpp index 9f7773ac7b..1736b0be80 100644 --- a/src/mlpack/core/data/map_policies/increment_policy.hpp +++ b/src/mlpack/core/data/map_policies/increment_policy.hpp @@ -122,7 +122,7 @@ class IncrementPolicy if (numMappings == 0) types[dimension] = Datatype::categorical; - typedef typename std::pair PairType; + using PairType = std::pair; maps[dimension].first.insert(PairType(input, numMappings)); // Do we need to create the second map? diff --git a/src/mlpack/core/data/map_policies/missing_policy.hpp b/src/mlpack/core/data/map_policies/missing_policy.hpp index 4ce5c1b05c..30e2ed36fa 100644 --- a/src/mlpack/core/data/map_policies/missing_policy.hpp +++ b/src/mlpack/core/data/map_policies/missing_policy.hpp @@ -112,7 +112,7 @@ class MissingPolicy maps[dimension].first.count(string) == 0) { // This string does not exist yet. - typedef std::pair PairType; + using PairType = std::pair; maps[dimension].first.insert(PairType(string, value)); // Insert right mapping too. diff --git a/src/mlpack/core/distances/iou_distance.hpp b/src/mlpack/core/distances/iou_distance.hpp index 136a94fa30..619ea34848 100644 --- a/src/mlpack/core/distances/iou_distance.hpp +++ b/src/mlpack/core/distances/iou_distance.hpp @@ -66,7 +66,7 @@ class IoUDistance static typename VecTypeA::elem_type Evaluate(const VecTypeA& a, const VecTypeB& b) { - typedef typename VecTypeA::elem_type ElemType; + using ElemType = typename VecTypeA::elem_type; return (ElemType) (1.0 - IoU::Evaluate(a, b)); } diff --git a/src/mlpack/core/distances/lmetric.hpp b/src/mlpack/core/distances/lmetric.hpp index a15c24713f..315e1b8754 100644 --- a/src/mlpack/core/distances/lmetric.hpp +++ b/src/mlpack/core/distances/lmetric.hpp @@ -97,23 +97,23 @@ class LMetric /** * The Manhattan (L1) distance. */ -typedef LMetric<1, false> ManhattanDistance; +using ManhattanDistance = LMetric<1, false>; /** * The squared Euclidean (L2) distance. Note that this is not technically a * metric! But it can sometimes be used when distances are required. */ -typedef LMetric<2, false> SquaredEuclideanDistance; +using SquaredEuclideanDistance = LMetric<2, false>; /** * The Euclidean (L2) distance. */ -typedef LMetric<2, true> EuclideanDistance; +using EuclideanDistance = LMetric<2, true>; /** * The L-infinity distance. */ -typedef LMetric ChebyshevDistance; +using ChebyshevDistance = LMetric<2147483647, false>; } // namespace mlpack diff --git a/src/mlpack/core/distances/mahalanobis_distance.hpp b/src/mlpack/core/distances/mahalanobis_distance.hpp index 39f8eb413a..c04228355b 100644 --- a/src/mlpack/core/distances/mahalanobis_distance.hpp +++ b/src/mlpack/core/distances/mahalanobis_distance.hpp @@ -59,7 +59,7 @@ template class MahalanobisDistance { public: - typedef typename GetColType::type VecType; + using VecType = typename GetColType::type; /** * Initialize the Mahalanobis distance with the empty matrix as Q. diff --git a/src/mlpack/core/distributions/diagonal_gaussian_distribution.hpp b/src/mlpack/core/distributions/diagonal_gaussian_distribution.hpp index 0492dbbcb0..ec5d5100a2 100644 --- a/src/mlpack/core/distributions/diagonal_gaussian_distribution.hpp +++ b/src/mlpack/core/distributions/diagonal_gaussian_distribution.hpp @@ -22,8 +22,8 @@ class DiagonalGaussianDistribution { public: // Convenience typedefs. - typedef typename GetColType::type VecType; - typedef typename MatType::elem_type ElemType; + using VecType = typename GetColType::type; + using ElemType = typename MatType::elem_type; private: //! Mean of the distribution. diff --git a/src/mlpack/core/distributions/discrete_distribution.hpp b/src/mlpack/core/distributions/discrete_distribution.hpp index c309ece04d..a7e8971183 100644 --- a/src/mlpack/core/distributions/discrete_distribution.hpp +++ b/src/mlpack/core/distributions/discrete_distribution.hpp @@ -54,10 +54,10 @@ class DiscreteDistribution { public: // Convenience typedefs. - typedef typename GetColType::type VecType; - typedef typename MatType::elem_type ElemType; - typedef typename GetColType::type ObsVecType; - typedef typename ObsMatType::elem_type ObsType; + using VecType = typename GetColType::type; + using ElemType = typename MatType::elem_type; + using ObsVecType = typename GetColType::type; + using ObsType = typename ObsMatType::elem_type; /** * Default constructor, which creates a distribution that has no diff --git a/src/mlpack/core/distributions/gamma_distribution.hpp b/src/mlpack/core/distributions/gamma_distribution.hpp index f9364b3899..d007a1c720 100644 --- a/src/mlpack/core/distributions/gamma_distribution.hpp +++ b/src/mlpack/core/distributions/gamma_distribution.hpp @@ -54,8 +54,8 @@ class GammaDistribution { public: // Convenience typedefs. - typedef typename GetColType::type VecType; - typedef typename MatType::elem_type ElemType; + using VecType = typename GetColType::type; + using ElemType = typename MatType::elem_type; /** * Construct the Gamma distribution with the given number of dimensions diff --git a/src/mlpack/core/distributions/gaussian_distribution.hpp b/src/mlpack/core/distributions/gaussian_distribution.hpp index 775b021181..a3dbcc81c9 100644 --- a/src/mlpack/core/distributions/gaussian_distribution.hpp +++ b/src/mlpack/core/distributions/gaussian_distribution.hpp @@ -25,8 +25,8 @@ class GaussianDistribution { public: // Convenience typedefs for derived types of MatType. - typedef typename GetColType::type VecType; - typedef typename MatType::elem_type ElemType; + using VecType = typename GetColType::type; + using ElemType = typename MatType::elem_type; private: //! Mean of the distribution. diff --git a/src/mlpack/core/distributions/laplace_distribution.hpp b/src/mlpack/core/distributions/laplace_distribution.hpp index e77bc4a6d6..5d5fcc7e6b 100644 --- a/src/mlpack/core/distributions/laplace_distribution.hpp +++ b/src/mlpack/core/distributions/laplace_distribution.hpp @@ -52,8 +52,8 @@ class LaplaceDistribution { public: // Convenience typedefs. - typedef typename GetColType::type VecType; - typedef typename MatType::elem_type ElemType; + using VecType = typename GetColType::type; + using ElemType = typename MatType::elem_type; /** * Default constructor, which creates a Laplace distribution with zero diff --git a/src/mlpack/core/distributions/regression_distribution.hpp b/src/mlpack/core/distributions/regression_distribution.hpp index 163fb02743..1dbf027712 100644 --- a/src/mlpack/core/distributions/regression_distribution.hpp +++ b/src/mlpack/core/distributions/regression_distribution.hpp @@ -32,9 +32,9 @@ class RegressionDistribution { public: // Convenience typedefs. - typedef typename MatType::elem_type ElemType; - typedef typename GetColType::type VecType; - typedef typename GetRowType::type RowType; + using ElemType = typename MatType::elem_type; + using VecType = typename GetColType::type; + using RowType = typename GetRowType::type; private: //! Regression function for representing conditional mean. diff --git a/src/mlpack/core/kernels/cosine_similarity.hpp b/src/mlpack/core/kernels/cosine_similarity.hpp index d82db427cf..22fdce7354 100644 --- a/src/mlpack/core/kernels/cosine_similarity.hpp +++ b/src/mlpack/core/kernels/cosine_similarity.hpp @@ -58,7 +58,7 @@ class KernelTraits }; // This name is deprecated and can be removed in mlpack 5.0.0. -typedef CosineSimilarity CosineDistance; +using CosineDistance = CosineSimilarity; } // namespace mlpack diff --git a/src/mlpack/core/math/ccov_impl.hpp b/src/mlpack/core/math/ccov_impl.hpp index 5ea3d67212..b3b5e201b3 100644 --- a/src/mlpack/core/math/ccov_impl.hpp +++ b/src/mlpack/core/math/ccov_impl.hpp @@ -59,7 +59,7 @@ inline arma::Mat> ColumnCovariance( Log::Fatal << "ColumnCovariance(): normType must be 0 or 1" << std::endl; } - typedef typename std::complex eT; + using eT = std::complex; arma::Mat out; diff --git a/src/mlpack/core/math/log_add_impl.hpp b/src/mlpack/core/math/log_add_impl.hpp index e38ddba44a..b175cfc5a5 100644 --- a/src/mlpack/core/math/log_add_impl.hpp +++ b/src/mlpack/core/math/log_add_impl.hpp @@ -65,7 +65,7 @@ typename T::elem_type AccuLog(const T& x) if (maxVal == -std::numeric_limits::infinity()) return maxVal; - return maxVal + std::log(sum(exp(x - maxVal)));; + return maxVal + std::log(sum(exp(x - maxVal))); } /** diff --git a/src/mlpack/core/math/range.hpp b/src/mlpack/core/math/range.hpp index 6a44ab31a9..63450f0dc7 100644 --- a/src/mlpack/core/math/range.hpp +++ b/src/mlpack/core/math/range.hpp @@ -17,7 +17,7 @@ namespace mlpack { template class RangeType; -typedef RangeType Range; +using Range = RangeType; /** * Simple real-valued range. It contains an upper and lower bound. diff --git a/src/mlpack/core/metrics/bleu_impl.hpp b/src/mlpack/core/metrics/bleu_impl.hpp index 3f0cc20a78..a107f0d192 100644 --- a/src/mlpack/core/metrics/bleu_impl.hpp +++ b/src/mlpack/core/metrics/bleu_impl.hpp @@ -53,7 +53,7 @@ ElemType BLEU::Evaluate( { // WordVector is a string container type. // Also, TranslationCorpusType is an array of such containers. - typedef typename TranslationCorpusType::value_type WordVector; + using WordVector = typename TranslationCorpusType::value_type; // matchesByOrder: It catches how many times sequence of a particular order // is encountered in both reference corpus and translation corpus. diff --git a/src/mlpack/core/metrics/non_maximal_suppression_impl.hpp b/src/mlpack/core/metrics/non_maximal_suppression_impl.hpp index da40f0ecfc..61c698aed7 100644 --- a/src/mlpack/core/metrics/non_maximal_suppression_impl.hpp +++ b/src/mlpack/core/metrics/non_maximal_suppression_impl.hpp @@ -83,7 +83,7 @@ void NMS::Evaluate( sortedIndices); BoundingBoxesType x1 = boundingBoxes.submat(arma::uvec(1).fill(0), - sortedIndices);; + sortedIndices); BoundingBoxesType y2 = boundingBoxes.submat(arma::uvec(1).fill(3), sortedIndices); diff --git a/src/mlpack/core/tree/address.hpp b/src/mlpack/core/tree/address.hpp index e2e4250887..dbf9e7e4be 100644 --- a/src/mlpack/core/tree/address.hpp +++ b/src/mlpack/core/tree/address.hpp @@ -54,11 +54,11 @@ namespace mlpack { template void PointToAddress(AddressType& address, const VecType& point) { - typedef typename VecType::elem_type VecElemType; + using VecElemType = typename VecType::elem_type; // Check that the arguments are compatible. - typedef std::conditional_t AddressElemType; + using AddressElemType = + std::conditional_t; static_assert(std::is_same_v == true, "The vector element type does not " @@ -150,11 +150,11 @@ void PointToAddress(AddressType& address, const VecType& point) template void AddressToPoint(VecType& point, const AddressType& address) { - typedef typename VecType::elem_type VecElemType; + using VecElemType = typename VecType::elem_type; // Check that the arguments are compatible. - typedef std::conditional_t AddressElemType; + using AddressElemType = + std::conditional_t; static_assert(std::is_same_v == true, "The vector element type does not " diff --git a/src/mlpack/core/tree/ballbound.hpp b/src/mlpack/core/tree/ballbound.hpp index 023cc88f18..5c5cd99bef 100644 --- a/src/mlpack/core/tree/ballbound.hpp +++ b/src/mlpack/core/tree/ballbound.hpp @@ -33,7 +33,7 @@ class BallBound { public: //! A public version of the vector type. - typedef VecType Vec; + using Vec = VecType; private: //! The radius of the ball bound. diff --git a/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp b/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp index 065f795ddd..f3faf4acaf 100644 --- a/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp +++ b/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp @@ -55,11 +55,11 @@ class BinarySpaceTree { public: //! So other classes can use TreeType::Mat. - typedef MatType Mat; + using Mat = MatType; //! The type of element held in MatType. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; - typedef SplitType, MatType> Split; + using Split = SplitType, MatType>; private: //! The left child node. diff --git a/src/mlpack/core/tree/binary_space_tree/breadth_first_dual_tree_traverser.hpp b/src/mlpack/core/tree/binary_space_tree/breadth_first_dual_tree_traverser.hpp index 39766c7afe..99bb82813b 100644 --- a/src/mlpack/core/tree/binary_space_tree/breadth_first_dual_tree_traverser.hpp +++ b/src/mlpack/core/tree/binary_space_tree/breadth_first_dual_tree_traverser.hpp @@ -50,8 +50,8 @@ class BinarySpaceTree - QueueFrameType; + using QueueFrameType = + QueueFrame; /** * Traverse the two trees. This does not reset the number of prunes. diff --git a/src/mlpack/core/tree/binary_space_tree/rp_tree_max_split.hpp b/src/mlpack/core/tree/binary_space_tree/rp_tree_max_split.hpp index e8d46f14b8..0bffcdf76a 100644 --- a/src/mlpack/core/tree/binary_space_tree/rp_tree_max_split.hpp +++ b/src/mlpack/core/tree/binary_space_tree/rp_tree_max_split.hpp @@ -32,7 +32,7 @@ class RPTreeMaxSplit { public: //! The element type held by the matrix type. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; //! An information about the partition. struct SplitInfo { diff --git a/src/mlpack/core/tree/binary_space_tree/rp_tree_mean_split.hpp b/src/mlpack/core/tree/binary_space_tree/rp_tree_mean_split.hpp index c9834b46bc..5d1663937c 100644 --- a/src/mlpack/core/tree/binary_space_tree/rp_tree_mean_split.hpp +++ b/src/mlpack/core/tree/binary_space_tree/rp_tree_mean_split.hpp @@ -32,7 +32,7 @@ class RPTreeMeanSplit { public: //! The element type held by the matrix type. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; //! An information about the partition. struct SplitInfo { diff --git a/src/mlpack/core/tree/binary_space_tree/ub_tree_split.hpp b/src/mlpack/core/tree/binary_space_tree/ub_tree_split.hpp index 79e2ba818d..dd39d07bcd 100644 --- a/src/mlpack/core/tree/binary_space_tree/ub_tree_split.hpp +++ b/src/mlpack/core/tree/binary_space_tree/ub_tree_split.hpp @@ -29,10 +29,9 @@ class UBTreeSplit { public: //! The type of an address element. - typedef std::conditional_t< + using AddressElemType = std::conditional_t< sizeof(typename MatType::elem_type) * CHAR_BIT <= 32, - uint32_t, - uint64_t> AddressElemType; + uint32_t, uint64_t>; //! An information about the partition. struct SplitInfo diff --git a/src/mlpack/core/tree/binary_space_tree/vantage_point_split.hpp b/src/mlpack/core/tree/binary_space_tree/vantage_point_split.hpp index ebb4613ba3..4785a14a59 100644 --- a/src/mlpack/core/tree/binary_space_tree/vantage_point_split.hpp +++ b/src/mlpack/core/tree/binary_space_tree/vantage_point_split.hpp @@ -32,9 +32,9 @@ class VantagePointSplit { public: //! The matrix element type. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; //! The bounding shape type. - typedef typename BoundType::DistanceType DistanceType; + using DistanceType = typename BoundType::DistanceType; //! A struct that contains an information about the split. struct SplitInfo { diff --git a/src/mlpack/core/tree/cellbound.hpp b/src/mlpack/core/tree/cellbound.hpp index 21b31dbe9f..bfb4245fe5 100644 --- a/src/mlpack/core/tree/cellbound.hpp +++ b/src/mlpack/core/tree/cellbound.hpp @@ -76,9 +76,8 @@ class CellBound public: //! Depending on the precision of the tree element type, we may need to use //! uint32_t or uint64_t. - typedef std::conditional_t AddressElemType; + using AddressElemType = std::conditional_t; /** * Empty constructor; creates a bound of dimensionality 0. diff --git a/src/mlpack/core/tree/cosine_tree/cosine_tree.hpp b/src/mlpack/core/tree/cosine_tree/cosine_tree.hpp index cb5b52fe25..ef5effb365 100644 --- a/src/mlpack/core/tree/cosine_tree/cosine_tree.hpp +++ b/src/mlpack/core/tree/cosine_tree/cosine_tree.hpp @@ -32,7 +32,7 @@ template class CosineTree { public: - typedef typename GetDenseColType::type VecType; + using VecType = typename GetDenseColType::type; /** * CosineTree constructor for the root node of the tree. It initializes the diff --git a/src/mlpack/core/tree/cover_tree/cover_tree.hpp b/src/mlpack/core/tree/cover_tree/cover_tree.hpp index 13c6813a18..288aa856ce 100644 --- a/src/mlpack/core/tree/cover_tree/cover_tree.hpp +++ b/src/mlpack/core/tree/cover_tree/cover_tree.hpp @@ -99,9 +99,9 @@ class CoverTree { public: //! So that other classes can access the matrix type. - typedef MatType Mat; + using Mat = MatType; //! The type held by the matrix type. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; /** * Create the cover tree with the given dataset and given base. diff --git a/src/mlpack/core/tree/cover_tree/single_tree_traverser_impl.hpp b/src/mlpack/core/tree/cover_tree/single_tree_traverser_impl.hpp index 1db7d2676c..7881c4777c 100644 --- a/src/mlpack/core/tree/cover_tree/single_tree_traverser_impl.hpp +++ b/src/mlpack/core/tree/cover_tree/single_tree_traverser_impl.hpp @@ -72,8 +72,8 @@ SingleTreeTraverser::Traverse( { // This is a non-recursive implementation (which should be faster than a // recursive implementation). - typedef CoverTreeMapEntry MapEntryType; + using MapEntryType = CoverTreeMapEntry; // We will use this map as a priority queue. Each key represents the scale, // and then the vector is all the nodes in that scale which need to be diff --git a/src/mlpack/core/tree/hollow_ball_bound.hpp b/src/mlpack/core/tree/hollow_ball_bound.hpp index 2cad206b82..fe6d33ef9f 100644 --- a/src/mlpack/core/tree/hollow_ball_bound.hpp +++ b/src/mlpack/core/tree/hollow_ball_bound.hpp @@ -33,7 +33,7 @@ class HollowBallBound { public: //! A public version of the metric type. - typedef TDistanceType DistanceType; + using DistanceType = TDistanceType; private: //! The inner and the outer radii of the bound. diff --git a/src/mlpack/core/tree/octree/octree.hpp b/src/mlpack/core/tree/octree/octree.hpp index f3a78ba764..77f3fa9f1a 100644 --- a/src/mlpack/core/tree/octree/octree.hpp +++ b/src/mlpack/core/tree/octree/octree.hpp @@ -25,9 +25,9 @@ class Octree { public: //! So other classes can use TreeType::Mat. - typedef MatType Mat; + using Mat = MatType; //! The type of element held in MatType. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; //! A single-tree traverser; see single_tree_traverser.hpp. template diff --git a/src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value.hpp b/src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value.hpp index 62c1329b5f..bfb1efb8dc 100644 --- a/src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value.hpp +++ b/src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value.hpp @@ -30,9 +30,9 @@ class DiscreteHilbertValue public: //! Depending on the precision of the tree element type, we may need to use //! uint32_t or uint64_t. - typedef std::conditional_t HilbertElemType; + using HilbertElemType = + std::conditional_t; //! Default constructor. DiscreteHilbertValue(); diff --git a/src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value_impl.hpp b/src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value_impl.hpp index 78b0576392..fb860278bb 100644 --- a/src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/discrete_hilbert_value_impl.hpp @@ -152,7 +152,7 @@ DiscreteHilbertValue:: CalculateValue(const VecType& pt, typename std::enable_if_t::value>*) { - typedef typename VecType::elem_type VecElemType; + using VecElemType = typename VecType::elem_type; arma::Col res(pt.n_rows); // Calculate the number of bits for the exponent. const int numExpBits = std::ceil(std::log2( diff --git a/src/mlpack/core/tree/rectangle_tree/hilbert_r_tree_auxiliary_information.hpp b/src/mlpack/core/tree/rectangle_tree/hilbert_r_tree_auxiliary_information.hpp index 0a77cb1aa4..3bee353986 100644 --- a/src/mlpack/core/tree/rectangle_tree/hilbert_r_tree_auxiliary_information.hpp +++ b/src/mlpack/core/tree/rectangle_tree/hilbert_r_tree_auxiliary_information.hpp @@ -22,7 +22,7 @@ class HilbertRTreeAuxiliaryInformation { public: //! The element type held by the tree. - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; //! Default constructor HilbertRTreeAuxiliaryInformation(); diff --git a/src/mlpack/core/tree/rectangle_tree/minimal_coverage_sweep.hpp b/src/mlpack/core/tree/rectangle_tree/minimal_coverage_sweep.hpp index f70091020a..02875c45e2 100644 --- a/src/mlpack/core/tree/rectangle_tree/minimal_coverage_sweep.hpp +++ b/src/mlpack/core/tree/rectangle_tree/minimal_coverage_sweep.hpp @@ -33,7 +33,7 @@ class MinimalCoverageSweep template struct SweepCost { - typedef typename TreeType::ElemType type; + using type = typename TreeType::ElemType; }; /** diff --git a/src/mlpack/core/tree/rectangle_tree/minimal_coverage_sweep_impl.hpp b/src/mlpack/core/tree/rectangle_tree/minimal_coverage_sweep_impl.hpp index 04812f863f..dc1951e5d6 100644 --- a/src/mlpack/core/tree/rectangle_tree/minimal_coverage_sweep_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/minimal_coverage_sweep_impl.hpp @@ -24,8 +24,8 @@ SweepNonLeafNode(const size_t axis, const TreeType* node, typename TreeType::ElemType& axisCut) { - typedef typename TreeType::ElemType ElemType; - typedef HRectBound BoundType; + using ElemType = typename TreeType::ElemType; + using BoundType = HRectBound; std::vector> sorted(node->NumChildren()); @@ -88,8 +88,8 @@ SweepLeafNode(const size_t axis, const TreeType* node, typename TreeType::ElemType& axisCut) { - typedef typename TreeType::ElemType ElemType; - typedef HRectBound BoundType; + using ElemType = typename TreeType::ElemType; + using BoundType = HRectBound; std::vector> sorted(node->Count()); diff --git a/src/mlpack/core/tree/rectangle_tree/minimal_splits_number_sweep.hpp b/src/mlpack/core/tree/rectangle_tree/minimal_splits_number_sweep.hpp index b424547dd9..769cc1b8aa 100644 --- a/src/mlpack/core/tree/rectangle_tree/minimal_splits_number_sweep.hpp +++ b/src/mlpack/core/tree/rectangle_tree/minimal_splits_number_sweep.hpp @@ -34,7 +34,7 @@ class MinimalSplitsNumberSweep template struct SweepCost { - typedef size_t type; + using type = size_t; }; /** diff --git a/src/mlpack/core/tree/rectangle_tree/minimal_splits_number_sweep_impl.hpp b/src/mlpack/core/tree/rectangle_tree/minimal_splits_number_sweep_impl.hpp index 33ca7ba819..e6b00da5dc 100644 --- a/src/mlpack/core/tree/rectangle_tree/minimal_splits_number_sweep_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/minimal_splits_number_sweep_impl.hpp @@ -24,7 +24,7 @@ size_t MinimalSplitsNumberSweep::SweepNonLeafNode( const TreeType* node, typename TreeType::ElemType& axisCut) { - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; std::vector> sorted(node->NumChildren()); diff --git a/src/mlpack/core/tree/rectangle_tree/r_plus_plus_tree_auxiliary_information.hpp b/src/mlpack/core/tree/rectangle_tree/r_plus_plus_tree_auxiliary_information.hpp index 4fbd911622..acb5f6656f 100644 --- a/src/mlpack/core/tree/rectangle_tree/r_plus_plus_tree_auxiliary_information.hpp +++ b/src/mlpack/core/tree/rectangle_tree/r_plus_plus_tree_auxiliary_information.hpp @@ -24,9 +24,9 @@ class RPlusPlusTreeAuxiliaryInformation { public: //! The element type held by the tree. - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; //! The bound type held by the auxiliary information. - typedef HRectBound BoundType; + using BoundType = HRectBound; //! Construct the auxiliary information object. RPlusPlusTreeAuxiliaryInformation(); diff --git a/src/mlpack/core/tree/rectangle_tree/r_plus_plus_tree_auxiliary_information_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_plus_plus_tree_auxiliary_information_impl.hpp index 17a76d9f3f..b3aad521fc 100644 --- a/src/mlpack/core/tree/rectangle_tree/r_plus_plus_tree_auxiliary_information_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/r_plus_plus_tree_auxiliary_information_impl.hpp @@ -104,7 +104,7 @@ void RPlusPlusTreeAuxiliaryInformation::SplitAuxiliaryInfo( const size_t axis, const typename TreeType::ElemType cut) { - typedef HRectBound Bound; + using Bound = HRectBound; Bound& treeOneBound = treeOne->AuxiliaryInfo().OuterBound(); Bound& treeTwoBound = treeTwo->AuxiliaryInfo().OuterBound(); diff --git a/src/mlpack/core/tree/rectangle_tree/r_plus_tree_descent_heuristic_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_plus_tree_descent_heuristic_impl.hpp index bdd2441222..1a39c7952c 100644 --- a/src/mlpack/core/tree/rectangle_tree/r_plus_tree_descent_heuristic_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/r_plus_tree_descent_heuristic_impl.hpp @@ -22,7 +22,7 @@ template size_t RPlusTreeDescentHeuristic::ChooseDescentNode(TreeType* node, const size_t point) { - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; size_t bestIndex = 0; bool success = true; diff --git a/src/mlpack/core/tree/rectangle_tree/r_plus_tree_split.hpp b/src/mlpack/core/tree/rectangle_tree/r_plus_tree_split.hpp index dc66cd50b7..48ead5a993 100644 --- a/src/mlpack/core/tree/rectangle_tree/r_plus_tree_split.hpp +++ b/src/mlpack/core/tree/rectangle_tree/r_plus_tree_split.hpp @@ -31,7 +31,7 @@ template void RPlusTreeSplit:: SplitLeafNode(TreeType* tree, std::vector& relevels) { - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; if (tree->Count() == 1) { @@ -122,7 +122,7 @@ template bool RPlusTreeSplit:: SplitNonLeafNode(TreeType* tree, std::vector& relevels) { - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; // If we are splitting the root node, we need will do things differently so // that the constructor and other methods don't confuse the end user by giving // an address of another node. @@ -333,9 +333,8 @@ PartitionNode(const TreeType* node, size_t& minCutAxis, return false; // No partition required. // Define the type of the sweep cost. - typedef typename - SweepType::template SweepCost::type - SweepCostType; + using SweepCostType = typename + SweepType::template SweepCost::type; SweepCostType minCost = std::numeric_limits::max(); minCutAxis = node->Bound().Dim(); diff --git a/src/mlpack/core/tree/rectangle_tree/r_star_tree_descent_heuristic_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_star_tree_descent_heuristic_impl.hpp index 9612046302..92c20806ad 100644 --- a/src/mlpack/core/tree/rectangle_tree/r_star_tree_descent_heuristic_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/r_star_tree_descent_heuristic_impl.hpp @@ -23,7 +23,7 @@ inline size_t RStarTreeDescentHeuristic::ChooseDescentNode( const size_t point) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; bool tiedOne = false; std::vector originalScores(node->NumChildren()); @@ -164,7 +164,7 @@ inline size_t RStarTreeDescentHeuristic::ChooseDescentNode( const TreeType* insertedNode) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; std::vector scores(node->NumChildren()); std::vector vols(node->NumChildren()); diff --git a/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp index 8c9d43624e..dd7c8174a2 100644 --- a/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp @@ -28,7 +28,7 @@ size_t RStarTreeSplit::ReinsertPoints(TreeType* tree, std::vector& relevels) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; // Check if we need to reinsert. if (relevels[tree->TreeDepth() - 1]) @@ -83,8 +83,8 @@ void RStarTreeSplit::PickLeafSplit(TreeType* tree, size_t& bestIndex) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; - typedef HRectBound BoundType; + using ElemType = typename TreeType::ElemType; + using BoundType = HRectBound; bestAxis = 0; bestIndex = 0; @@ -176,7 +176,7 @@ template void RStarTreeSplit::SplitLeafNode(TreeType *tree, std::vector& relevels) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; // If there's no need to split, don't. if (tree->Count() <= tree->MaxLeafSize()) @@ -272,8 +272,8 @@ bool RStarTreeSplit::SplitNonLeafNode( std::vector& relevels) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; - typedef HRectBound BoundType; + using ElemType = typename TreeType::ElemType; + using BoundType = HRectBound; // Reinsertion isn't done for non-leaf nodes; the paper doesn't seem to make // it clear how to reinsert an entire node without reinserting each of the diff --git a/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic_impl.hpp index bf32712597..4460fa16e9 100644 --- a/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic_impl.hpp @@ -22,7 +22,7 @@ inline size_t RTreeDescentHeuristic::ChooseDescentNode(const TreeType* node, const size_t point) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; ElemType minScore = std::numeric_limits::max(); int bestIndex = 0; @@ -66,7 +66,7 @@ inline size_t RTreeDescentHeuristic::ChooseDescentNode( const TreeType* insertedNode) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; ElemType minScore = std::numeric_limits::max(); int bestIndex = 0; diff --git a/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp index 56db94d862..809885106b 100644 --- a/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp @@ -195,7 +195,7 @@ template void RTreeSplit::GetBoundSeeds(const TreeType *tree, int& iRet, int& jRet) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; ElemType worstPairScore = -1.0; for (size_t i = 0; i < tree->NumChildren(); ++i) @@ -230,7 +230,7 @@ void RTreeSplit::AssignPointDestNode(TreeType* oldTree, const int intJ) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; size_t end = oldTree->Count(); @@ -366,7 +366,7 @@ void RTreeSplit::AssignNodeDestNode(TreeType* oldTree, const int intJ) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; size_t end = oldTree->NumChildren(); assert(end > 1); // If this isn't true, the tree is really weird. diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp index 6d382b822a..abbfa5e71d 100644 --- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp +++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp @@ -58,11 +58,11 @@ class RectangleTree public: //! So other classes can use TreeType::Mat. - typedef MatType Mat; + using Mat = MatType; //! The element type held by the matrix type. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; //! The auxiliary information type held by the tree. - typedef AuxiliaryInformationType AuxiliaryInformation; + using AuxiliaryInformation = AuxiliaryInformationType; private: //! The max number of child nodes a non-leaf node can have. size_t maxNumChildren; diff --git a/src/mlpack/core/tree/rectangle_tree/x_tree_auxiliary_information.hpp b/src/mlpack/core/tree/rectangle_tree/x_tree_auxiliary_information.hpp index f7e017ca7e..953049a245 100644 --- a/src/mlpack/core/tree/rectangle_tree/x_tree_auxiliary_information.hpp +++ b/src/mlpack/core/tree/rectangle_tree/x_tree_auxiliary_information.hpp @@ -165,7 +165,7 @@ class XTreeAuxiliaryInformation * The X tree requires that the tree records it's "split history". To make * this easy, we use the following structure. */ - typedef struct SplitHistoryStruct + using SplitHistoryStruct = struct SplitHistoryStruct { int lastDimension; std::vector history; @@ -201,7 +201,7 @@ class XTreeAuxiliaryInformation ar(CEREAL_NVP(lastDimension)); ar(CEREAL_NVP(history)); } - } SplitHistoryStruct; + }; private: //! The max number of child nodes a non-leaf normal node can have. diff --git a/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp index 13281d27c4..eb3900c37c 100644 --- a/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp @@ -28,7 +28,7 @@ template void XTreeSplit::SplitLeafNode(TreeType *tree, std::vector& relevels) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; if (tree->Count() <= tree->MaxLeafSize()) return; @@ -123,8 +123,8 @@ template bool XTreeSplit::SplitNonLeafNode(TreeType *tree, std::vector& relevels) { // Convenience typedef. - typedef typename TreeType::ElemType ElemType; - typedef HRectBound BoundType; + using ElemType = typename TreeType::ElemType; + using BoundType = HRectBound; // The X tree paper doesn't explain how to handle the split history when // reinserting nodes and reinserting nodes seems to hurt the performance, so diff --git a/src/mlpack/core/tree/space_split/hyperplane.hpp b/src/mlpack/core/tree/space_split/hyperplane.hpp index 5e9a0eba33..3e80686e58 100644 --- a/src/mlpack/core/tree/space_split/hyperplane.hpp +++ b/src/mlpack/core/tree/space_split/hyperplane.hpp @@ -30,9 +30,9 @@ class HyperplaneBase { public: //! Useful typedef for the bound type. - typedef BoundT BoundType; + using BoundType = BoundT; //! Useful typedef for the projection vector type. - typedef ProjVectorT ProjVectorType; + using ProjVectorType = ProjVectorT; private: //! Projection vector. diff --git a/src/mlpack/core/tree/spill_tree/spill_tree.hpp b/src/mlpack/core/tree/spill_tree/spill_tree.hpp index de7a4eace8..052a75c8f3 100644 --- a/src/mlpack/core/tree/spill_tree/spill_tree.hpp +++ b/src/mlpack/core/tree/spill_tree/spill_tree.hpp @@ -73,11 +73,11 @@ class SpillTree { public: //! So other classes can use TreeType::Mat. - typedef MatType Mat; + using Mat = MatType; //! The type of element held in MatType. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; //! The bound type. - typedef typename HyperplaneType::BoundType BoundType; + using BoundType = typename HyperplaneType::BoundType; private: //! The left child node. diff --git a/src/mlpack/core/util/arma_traits.hpp b/src/mlpack/core/util/arma_traits.hpp index c476f75736..855209e633 100644 --- a/src/mlpack/core/util/arma_traits.hpp +++ b/src/mlpack/core/util/arma_traits.hpp @@ -122,19 +122,19 @@ struct IsVector > template struct GetRowType { - typedef arma::Row type; + using type = arma::Row; }; template struct GetRowType> { - typedef arma::Row type; + using type = arma::Row; }; template struct GetRowType> { - typedef arma::SpRow type; + using type = arma::SpRow; }; // Get the column vector type corresponding to a given MatType. @@ -142,25 +142,25 @@ struct GetRowType> template struct GetColType { - typedef arma::Col type; + using type = arma::Col; }; template struct GetUColType { - typedef arma::Col type; + using type = arma::Col; }; template struct GetColType> { - typedef arma::Col type; + using type = arma::Col; }; template struct GetColType> { - typedef arma::SpCol type; + using type = arma::SpCol; }; // Get the dense row vector type corresponding to a given MatType. @@ -168,13 +168,13 @@ struct GetColType> template struct GetDenseRowType { - typedef typename GetRowType::type type; + using type = typename GetRowType::type; }; template struct GetDenseRowType> { - typedef arma::Row type; + using type = arma::Row; }; // Get the dense column vector type corresponding to a given MatType. @@ -182,13 +182,13 @@ struct GetDenseRowType> template struct GetDenseColType { - typedef typename GetColType::type type; + using type = typename GetColType::type; }; template struct GetDenseColType> { - typedef arma::Col type; + using type = arma::Col; }; // Get the dense matrix type corresponding to a given MatType. @@ -196,19 +196,19 @@ struct GetDenseColType> template struct GetDenseMatType { - typedef arma::Mat type; + using type = arma::Mat; }; template struct GetUDenseMatType { - typedef arma::Mat type; + using type = arma::Mat; }; template struct GetDenseMatType> { - typedef arma::Mat type; + using type = arma::Mat; }; // Get the cube type corresponding to a given MatType. @@ -219,7 +219,7 @@ struct GetCubeType; template struct GetCubeType> { - typedef arma::Cube type; + using type = arma::Cube; }; // Get the sparse matrix type corresponding to a given MatType. @@ -227,13 +227,13 @@ struct GetCubeType> template struct GetSparseMatType { - typedef arma::SpMat type; + using type = arma::SpMat; }; template struct GetSparseMatType> { - typedef arma::SpMat type; + using type = arma::SpMat; }; // Get whether or not the given type is a base matrix type (e.g. not an diff --git a/src/mlpack/core/util/ens_traits.hpp b/src/mlpack/core/util/ens_traits.hpp index 36faa4dcc8..aeef1f911f 100644 --- a/src/mlpack/core/util/ens_traits.hpp +++ b/src/mlpack/core/util/ens_traits.hpp @@ -55,8 +55,8 @@ struct IsEnsOptimizerInternal { // If OptimizerType is a reference type, then forming the types below will // fail. So we need to strip the reference (and the const for good measure). - typedef std::remove_cv_t> - SafeOptimizerType; + using SafeOptimizerType = + std::remove_cv_t>; using OptimizeElemReturnForm = typename MatType::elem_type(SafeOptimizerType::*)(FunctionType&, diff --git a/src/mlpack/core/util/first_element_is_arma.hpp b/src/mlpack/core/util/first_element_is_arma.hpp index dd6d1fc11b..b306b18a2c 100644 --- a/src/mlpack/core/util/first_element_is_arma.hpp +++ b/src/mlpack/core/util/first_element_is_arma.hpp @@ -21,14 +21,14 @@ namespace mlpack { template struct First { - typedef void type; + using type = void; }; // This matches whenever CallbackTypes has one or more elements. template struct First { - typedef T type; + using type = T; }; // This utility template struct detects whether the first element in a diff --git a/src/mlpack/core/util/io.hpp b/src/mlpack/core/util/io.hpp index f15d6f067a..91598c3556 100644 --- a/src/mlpack/core/util/io.hpp +++ b/src/mlpack/core/util/io.hpp @@ -277,8 +277,8 @@ class IO std::map> parameters; //! Map of functions. Note that this is not specific to a binding, so we only //! have one. - typedef std::map> FunctionMapType; + using FunctionMapType = std::map>; FunctionMapType functionMap; //! Ensure only one thread can modify the docs map at a time. diff --git a/src/mlpack/core/util/params.hpp b/src/mlpack/core/util/params.hpp index 857e19c1d8..1f1fc9f31d 100644 --- a/src/mlpack/core/util/params.hpp +++ b/src/mlpack/core/util/params.hpp @@ -28,8 +28,8 @@ class Params { public: // Convenience typedef for function maps. - typedef std::map> FunctionMapType; + using FunctionMapType = std::map>; /** * Create a new Params class. In general this should only be called via diff --git a/src/mlpack/core/util/timers.hpp b/src/mlpack/core/util/timers.hpp index 86266fcef6..42d1fefd58 100644 --- a/src/mlpack/core/util/timers.hpp +++ b/src/mlpack/core/util/timers.hpp @@ -27,9 +27,9 @@ // uint64_t isn't defined on every windows. #if !defined(HAVE_UINT64_T) #if SIZEOF_UNSIGNED_LONG == 8 - typedef unsigned long uint64_t; + using uint64_t = unsigned long; #else - typedef unsigned long long uint64_t; + using uint64_t = unsigned long long; #endif // SIZEOF_UNSIGNED_LONG #endif // HAVE_UINT64_T #endif diff --git a/src/mlpack/core/util/timers_impl.hpp b/src/mlpack/core/util/timers_impl.hpp index 80d40e5df5..16de70c13f 100644 --- a/src/mlpack/core/util/timers_impl.hpp +++ b/src/mlpack/core/util/timers_impl.hpp @@ -110,7 +110,7 @@ inline std::string Timers::Print(const std::chrono::microseconds& totalDuration) // Also output convenient day/hr/min/sec. // The following line is a custom duration for a day. - typedef std::chrono::duration> days; + using days = std::chrono::duration>; days d = std::chrono::duration_cast(totalDuration); std::chrono::hours h = std::chrono::duration_cast( totalDuration % days(1)); diff --git a/src/mlpack/methods/adaboost/adaboost.hpp b/src/mlpack/methods/adaboost/adaboost.hpp index a4d8b79966..f68c984d1a 100644 --- a/src/mlpack/methods/adaboost/adaboost.hpp +++ b/src/mlpack/methods/adaboost/adaboost.hpp @@ -80,7 +80,7 @@ template, class AdaBoost { public: - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; /** * Create the AdaBoost object without training. Be sure to call Train() diff --git a/src/mlpack/methods/amf/amf.hpp b/src/mlpack/methods/amf/amf.hpp index e36166bcb0..25fd2dbf2f 100644 --- a/src/mlpack/methods/amf/amf.hpp +++ b/src/mlpack/methods/amf/amf.hpp @@ -129,9 +129,9 @@ class AMF UpdateRuleType update; }; // class AMF -typedef AMF, - NMFALSUpdate> NMFALSFactorizer; +using NMFALSFactorizer = AMF, + NMFALSUpdate>; //! Convenience typedefs. diff --git a/src/mlpack/methods/amf/update_rules/incremental_iterators.hpp b/src/mlpack/methods/amf/update_rules/incremental_iterators.hpp index 2bb56de093..3255cbf568 100644 --- a/src/mlpack/methods/amf/update_rules/incremental_iterators.hpp +++ b/src/mlpack/methods/amf/update_rules/incremental_iterators.hpp @@ -49,7 +49,7 @@ void IncrementVIter(const MatType& V, size_t& currentUserIndex, size_t& currentItemIndex) { - typedef typename MatType::elem_type eT; + using eT = typename MatType::elem_type; // For dense matrices, 0s may be represented, so increment until we find the // next nonzero value. diff --git a/src/mlpack/methods/ann/convolution_rules/fft_convolution.hpp b/src/mlpack/methods/ann/convolution_rules/fft_convolution.hpp index 5e2dfa4772..d0b56008e6 100644 --- a/src/mlpack/methods/ann/convolution_rules/fft_convolution.hpp +++ b/src/mlpack/methods/ann/convolution_rules/fft_convolution.hpp @@ -134,7 +134,7 @@ class FFTConvolution CubeType& output, const typename std::enable_if_t::value>* = 0) { - typedef typename GetDenseMatType::type MatType; + using MatType = typename GetDenseMatType::type; MatType convOutput; FFTConvolution::Convolution(input.slice(0), filter.slice(0), convOutput); diff --git a/src/mlpack/methods/ann/convolution_rules/naive_convolution.hpp b/src/mlpack/methods/ann/convolution_rules/naive_convolution.hpp index a323c7b38f..31227d093d 100644 --- a/src/mlpack/methods/ann/convolution_rules/naive_convolution.hpp +++ b/src/mlpack/methods/ann/convolution_rules/naive_convolution.hpp @@ -60,7 +60,7 @@ class NaiveConvolution const bool appending = false, const typename std::enable_if_t::value>* = 0) { - typedef typename InMatType::elem_type eT; + using eT = typename InMatType::elem_type; // Compute the output size. The filterRows and filterCols computation must // take into account the fact that dilation only adds rows or columns // *between* filter elements. So, e.g., a dilation of 2 on a kernel size of @@ -163,7 +163,7 @@ class NaiveConvolution const bool appending = false, const typename std::enable_if_t::value>* = 0) { - typedef typename GetDenseMatType::type MatType; + using MatType = typename GetDenseMatType::type; MatType convOutput; NaiveConvolution::Convolution(input.slice(0), filter.slice(0), convOutput, dW, dH, dilationW, dilationH, appending); diff --git a/src/mlpack/methods/ann/convolution_rules/svd_convolution.hpp b/src/mlpack/methods/ann/convolution_rules/svd_convolution.hpp index b8c00459ac..b1f9fe2022 100644 --- a/src/mlpack/methods/ann/convolution_rules/svd_convolution.hpp +++ b/src/mlpack/methods/ann/convolution_rules/svd_convolution.hpp @@ -56,7 +56,7 @@ class SVDConvolution MatType& output, const typename std::enable_if_t::value>* = 0) { - typedef typename GetColType::type ColType; + using ColType = typename GetColType::type; // Use the naive convolution in case the filter isn't two dimensional or the // filter is bigger than the input. if (filter.n_rows > input.n_rows || filter.n_cols > input.n_cols || @@ -122,7 +122,7 @@ class SVDConvolution CubeType& output, const typename std::enable_if_t::value>* = 0) { - typedef typename GetDenseMatType::type MatType; + using MatType = typename GetDenseMatType::type; MatType convOutput; SVDConvolution::Convolution(input.slice(0), filter.slice(0), convOutput); diff --git a/src/mlpack/methods/ann/init_rules/kathirvalavakumar_subavathi_init.hpp b/src/mlpack/methods/ann/init_rules/kathirvalavakumar_subavathi_init.hpp index 536af206e6..69bbecb18a 100644 --- a/src/mlpack/methods/ann/init_rules/kathirvalavakumar_subavathi_init.hpp +++ b/src/mlpack/methods/ann/init_rules/kathirvalavakumar_subavathi_init.hpp @@ -83,7 +83,7 @@ class KathirvalavakumarSubavathiInitialization template void Initialize(MatType& W, const size_t rows, const size_t cols) { - typedef typename GetRowType::type RowType; + using RowType = typename GetRowType::type; RowType b = s * sqrt(3 / (rows * dataSum)); const double theta = b.min(); RandomInitialization randomInit(-theta, theta); @@ -100,7 +100,7 @@ class KathirvalavakumarSubavathiInitialization void Initialize(MatType& W, const typename std::enable_if_t::value>* = 0) { - typedef typename GetRowType::type RowType; + using RowType = typename GetRowType::type; RowType b = s * sqrt(3 / (W.n_rows * dataSum)); const double theta = b.min(); RandomInitialization randomInit(-theta, theta); diff --git a/src/mlpack/methods/ann/init_rules/orthogonal_init.hpp b/src/mlpack/methods/ann/init_rules/orthogonal_init.hpp index a90b479e34..c3990f1025 100644 --- a/src/mlpack/methods/ann/init_rules/orthogonal_init.hpp +++ b/src/mlpack/methods/ann/init_rules/orthogonal_init.hpp @@ -42,7 +42,7 @@ class OrthogonalInitialization void Initialize(MatType& W, const size_t rows, const size_t cols) { MatType V; - typedef typename GetColType::type ColType; + using ColType = typename GetColType::type; ColType s; svd_econ(W, s, V, randu(rows, cols)); @@ -60,7 +60,7 @@ class OrthogonalInitialization const typename std::enable_if_t::value>* = 0) { MatType V; - typedef typename GetColType::type ColType; + using ColType = typename GetColType::type; ColType s; svd_econ(W, s, V, randu(W.n_rows, W.n_cols)); diff --git a/src/mlpack/methods/ann/layer/adaptive_max_pooling.hpp b/src/mlpack/methods/ann/layer/adaptive_max_pooling.hpp index 226d5004f0..52c993eb7f 100644 --- a/src/mlpack/methods/ann/layer/adaptive_max_pooling.hpp +++ b/src/mlpack/methods/ann/layer/adaptive_max_pooling.hpp @@ -129,7 +129,7 @@ class AdaptiveMaxPoolingType : public Layer // Convenience typedefs. // Standard Adaptive max pooling layer. -typedef AdaptiveMaxPoolingType AdaptiveMaxPooling; +using AdaptiveMaxPooling = AdaptiveMaxPoolingType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/adaptive_mean_pooling.hpp b/src/mlpack/methods/ann/layer/adaptive_mean_pooling.hpp index eb65c88415..44cd70f35a 100644 --- a/src/mlpack/methods/ann/layer/adaptive_mean_pooling.hpp +++ b/src/mlpack/methods/ann/layer/adaptive_mean_pooling.hpp @@ -130,7 +130,7 @@ class AdaptiveMeanPoolingType : public Layer // Convenience typedefs. // Standard Adaptive mean pooling layer. -typedef AdaptiveMeanPoolingType AdaptiveMeanPooling; +using AdaptiveMeanPooling = AdaptiveMeanPoolingType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/add.hpp b/src/mlpack/methods/ann/layer/add.hpp index 7d9158091b..0730a6b95e 100644 --- a/src/mlpack/methods/ann/layer/add.hpp +++ b/src/mlpack/methods/ann/layer/add.hpp @@ -111,7 +111,7 @@ class AddType : public Layer }; // class Add // Standard Add layer. -typedef AddType Add; +using Add = AddType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/add_merge.hpp b/src/mlpack/methods/ann/layer/add_merge.hpp index da07be9ed6..55749b5253 100644 --- a/src/mlpack/methods/ann/layer/add_merge.hpp +++ b/src/mlpack/methods/ann/layer/add_merge.hpp @@ -95,7 +95,7 @@ class AddMergeType : public MultiLayer void serialize(Archive& ar, const uint32_t /* version */); }; -typedef AddMergeType AddMerge; +using AddMerge = AddMergeType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/alpha_dropout.hpp b/src/mlpack/methods/ann/layer/alpha_dropout.hpp index 7b7831d033..a16b5426d0 100644 --- a/src/mlpack/methods/ann/layer/alpha_dropout.hpp +++ b/src/mlpack/methods/ann/layer/alpha_dropout.hpp @@ -147,7 +147,7 @@ class AlphaDropoutType : public Layer double b; }; // class AlphaDropoutType -typedef AlphaDropoutType AlphaDropout; +using AlphaDropout = AlphaDropoutType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/base_layer.hpp b/src/mlpack/methods/ann/layer/base_layer.hpp index 4ab5f6f01b..cfe3b0975a 100644 --- a/src/mlpack/methods/ann/layer/base_layer.hpp +++ b/src/mlpack/methods/ann/layer/base_layer.hpp @@ -131,7 +131,7 @@ class BaseLayer : public Layer /** * Standard Sigmoid-Layer using the logistic activation function. */ -typedef BaseLayer Sigmoid; +using Sigmoid = BaseLayer; template using SigmoidType = BaseLayer; @@ -139,7 +139,7 @@ using SigmoidType = BaseLayer; /** * Standard rectified linear unit non-linearity layer. */ -typedef BaseLayer ReLU; +using ReLU = BaseLayer; template using ReLUType = BaseLayer; @@ -147,7 +147,7 @@ using ReLUType = BaseLayer; /** * Standard hyperbolic tangent layer. */ -typedef BaseLayer TanH; +using TanH = BaseLayer; template using TanHType = BaseLayer; @@ -155,7 +155,7 @@ using TanHType = BaseLayer; /** * Standard Softplus-Layer using the Softplus activation function. */ -typedef BaseLayer SoftPlus; +using SoftPlus = BaseLayer; template using SoftPlusType = BaseLayer; @@ -163,7 +163,7 @@ using SoftPlusType = BaseLayer; /** * Standard HardSigmoid-Layer using the HardSigmoid activation function. */ -typedef BaseLayer HardSigmoid; +using HardSigmoid = BaseLayer; template using HardSigmoidType = BaseLayer; @@ -171,7 +171,7 @@ using HardSigmoidType = BaseLayer; /** * Standard Swish-Layer using the Swish activation function. */ -typedef BaseLayer Swish; +using Swish = BaseLayer; template using SwishType = BaseLayer; @@ -179,7 +179,7 @@ using SwishType = BaseLayer; /** * Standard Mish-Layer using the Mish activation function. */ -typedef BaseLayer Mish; +using Mish = BaseLayer; template using MishType = BaseLayer; @@ -187,7 +187,7 @@ using MishType = BaseLayer; /** * Standard LiSHT-Layer using the LiSHT activation function. */ -typedef BaseLayer LiSHT; +using LiSHT = BaseLayer; template using LiSHTType = BaseLayer; @@ -195,7 +195,7 @@ using LiSHTType = BaseLayer; /** * Standard GELU-Layer using the GELU activation function. */ -typedef BaseLayer GELU; +using GELU = BaseLayer; template using GELUType = BaseLayer; @@ -203,7 +203,7 @@ using GELUType = BaseLayer; /** * Standard Elliot-Layer using the Elliot activation function. */ -typedef BaseLayer Elliot; +using Elliot = BaseLayer; template using ElliotType = BaseLayer; @@ -211,7 +211,7 @@ using ElliotType = BaseLayer; /** * Standard ELiSH-Layer using the ELiSH activation function. */ -typedef BaseLayer Elish; +using Elish = BaseLayer; template using ElishType = BaseLayer; @@ -219,7 +219,7 @@ using ElishType = BaseLayer; /** * Standard Gaussian-Layer using the Gaussian activation function. */ -typedef BaseLayer Gaussian; +using Gaussian = BaseLayer; template using GaussianType = BaseLayer; @@ -227,7 +227,7 @@ using GaussianType = BaseLayer; /** * Standard HardSwish-Layer using the HardSwish activation function. */ -typedef BaseLayer HardSwish; +using HardSwish = BaseLayer; template using HardSwishType = BaseLayer; @@ -235,7 +235,7 @@ using HardSwishType = BaseLayer; /** * Standard TanhExp-Layer using the TanhExp activation function. */ -typedef BaseLayer TanhExp; +using TanhExp = BaseLayer; template using TanhExpType = BaseLayer; @@ -243,7 +243,7 @@ using TanhExpType = BaseLayer; /** * Standard SILU-Layer using the SILU activation function. */ -typedef BaseLayer SILU; +using SILU = BaseLayer; template using SILUType = BaseLayer; @@ -251,7 +251,7 @@ using SILUType = BaseLayer; /** * Standard Hyper Sinh layer. */ -typedef BaseLayer HyperSinh; +using HyperSinh = BaseLayer; template using HyperSinhType = BaseLayer; @@ -259,7 +259,7 @@ using HyperSinhType = BaseLayer; /** * Standard Bipolar Sigmoid layer. */ -typedef BaseLayer BipolarSigmoid; +using BipolarSigmoid = BaseLayer; template using BipolarSigmoidType = BaseLayer; diff --git a/src/mlpack/methods/ann/layer/batch_norm.hpp b/src/mlpack/methods/ann/layer/batch_norm.hpp index 1df2967aca..5fb1a3c50b 100644 --- a/src/mlpack/methods/ann/layer/batch_norm.hpp +++ b/src/mlpack/methods/ann/layer/batch_norm.hpp @@ -275,7 +275,7 @@ class BatchNormType : public Layer // Convenience typedefs. // Standard Adaptive max pooling layer. -typedef BatchNormType BatchNorm; +using BatchNorm = BatchNormType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/c_relu.hpp b/src/mlpack/methods/ann/layer/c_relu.hpp index d798fef5c9..66061ba77d 100644 --- a/src/mlpack/methods/ann/layer/c_relu.hpp +++ b/src/mlpack/methods/ann/layer/c_relu.hpp @@ -101,7 +101,7 @@ class CReLUType : public Layer // Convenience typedefs. // Standard CReLU layer. -typedef CReLUType CReLU; +using CReLU = CReLUType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/celu.hpp b/src/mlpack/methods/ann/layer/celu.hpp index 1df9ecd2bf..697e678514 100644 --- a/src/mlpack/methods/ann/layer/celu.hpp +++ b/src/mlpack/methods/ann/layer/celu.hpp @@ -131,7 +131,7 @@ class CELUType : public Layer // Convenience typedefs. // Standard CELU layer. -typedef CELUType CELU; +using CELU = CELUType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/concat.hpp b/src/mlpack/methods/ann/layer/concat.hpp index 9f44465404..12ceef776f 100644 --- a/src/mlpack/methods/ann/layer/concat.hpp +++ b/src/mlpack/methods/ann/layer/concat.hpp @@ -228,7 +228,7 @@ class ConcatType : public MultiLayer }; // class ConcatType. // Standard Concat layer. -typedef ConcatType Concat; +using Concat = ConcatType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/concatenate.hpp b/src/mlpack/methods/ann/layer/concatenate.hpp index de11e08945..37106e625f 100644 --- a/src/mlpack/methods/ann/layer/concatenate.hpp +++ b/src/mlpack/methods/ann/layer/concatenate.hpp @@ -99,7 +99,7 @@ class ConcatenateType : public Layer }; // class Concatenate // Standard Concatenate layer. -typedef ConcatenateType Concatenate; +using Concatenate = ConcatenateType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/convolution.hpp b/src/mlpack/methods/ann/layer/convolution.hpp index 087ab4e085..6dc0be26f2 100644 --- a/src/mlpack/methods/ann/layer/convolution.hpp +++ b/src/mlpack/methods/ann/layer/convolution.hpp @@ -73,7 +73,7 @@ template < class ConvolutionType : public Layer { public: - typedef typename GetCubeType::type CubeType; + using CubeType = typename GetCubeType::type; //! Create the ConvolutionType object. ConvolutionType(); @@ -397,12 +397,10 @@ class ConvolutionType : public Layer }; // class Convolution // Standard Convolution layer. -typedef ConvolutionType< - NaiveConvolution, - NaiveConvolution, - NaiveConvolution, - arma::mat -> Convolution; +using Convolution = ConvolutionType, + NaiveConvolution, + NaiveConvolution, + arma::mat>; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/dropconnect.hpp b/src/mlpack/methods/ann/layer/dropconnect.hpp index b14587632a..efbb37fa90 100644 --- a/src/mlpack/methods/ann/layer/dropconnect.hpp +++ b/src/mlpack/methods/ann/layer/dropconnect.hpp @@ -152,7 +152,7 @@ class DropConnectType : public Layer // Convenience typedefs. // Standard DropConnect layer. -typedef DropConnectType DropConnect; +using DropConnect = DropConnectType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/dropout.hpp b/src/mlpack/methods/ann/layer/dropout.hpp index ad18e8e452..1b79a489e0 100644 --- a/src/mlpack/methods/ann/layer/dropout.hpp +++ b/src/mlpack/methods/ann/layer/dropout.hpp @@ -120,7 +120,7 @@ class DropoutType : public Layer // Convenience typedefs. // Standard Dropout layer. -typedef DropoutType Dropout; +using Dropout = DropoutType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/elu.hpp b/src/mlpack/methods/ann/layer/elu.hpp index c446759c46..82c62763e8 100644 --- a/src/mlpack/methods/ann/layer/elu.hpp +++ b/src/mlpack/methods/ann/layer/elu.hpp @@ -198,10 +198,10 @@ class ELUType : public Layer // Convenience typedefs. // ELU layer. -typedef ELUType ELU; +using ELU = ELUType; // SELU layer. -typedef ELUType SELU; +using SELU = ELUType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/flexible_relu.hpp b/src/mlpack/methods/ann/layer/flexible_relu.hpp index 71efbdde58..984b92ba01 100644 --- a/src/mlpack/methods/ann/layer/flexible_relu.hpp +++ b/src/mlpack/methods/ann/layer/flexible_relu.hpp @@ -160,7 +160,7 @@ class FlexibleReLUType : public Layer // Convenience typedefs. // Standard flexible ReLU layer. -typedef FlexibleReLUType FlexibleReLU; +using FlexibleReLU = FlexibleReLUType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/ftswish.hpp b/src/mlpack/methods/ann/layer/ftswish.hpp index 49b5499473..d2182c75de 100644 --- a/src/mlpack/methods/ann/layer/ftswish.hpp +++ b/src/mlpack/methods/ann/layer/ftswish.hpp @@ -108,7 +108,7 @@ class FTSwishType : public Layer }; // class FTSwishType // Convenience typedefs. -typedef FTSwishType FTSwish; +using FTSwish = FTSwishType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/grouped_convolution.hpp b/src/mlpack/methods/ann/layer/grouped_convolution.hpp index dc62472c70..a092290f80 100644 --- a/src/mlpack/methods/ann/layer/grouped_convolution.hpp +++ b/src/mlpack/methods/ann/layer/grouped_convolution.hpp @@ -77,7 +77,7 @@ template < class GroupedConvolutionType : public Layer { public: - typedef typename GetCubeType::type CubeType; + using CubeType = typename GetCubeType::type; //! Create the GroupedConvolutionType object. GroupedConvolutionType(); @@ -417,12 +417,11 @@ class GroupedConvolutionType : public Layer }; // class Convolution // Standard Convolution layer. -typedef GroupedConvolutionType< +using GroupedConvolution = GroupedConvolutionType< NaiveConvolution, NaiveConvolution, NaiveConvolution, - arma::mat -> GroupedConvolution; + arma::mat>; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/hard_tanh.hpp b/src/mlpack/methods/ann/layer/hard_tanh.hpp index 462c58f8f1..18bdf734d1 100644 --- a/src/mlpack/methods/ann/layer/hard_tanh.hpp +++ b/src/mlpack/methods/ann/layer/hard_tanh.hpp @@ -127,7 +127,7 @@ class HardTanHType : public Layer // Convenience typedefs. // Standard HardTanH layer. -typedef HardTanHType HardTanH; +using HardTanH = HardTanHType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/identity.hpp b/src/mlpack/methods/ann/layer/identity.hpp index 732cd90697..6dd64e00c5 100644 --- a/src/mlpack/methods/ann/layer/identity.hpp +++ b/src/mlpack/methods/ann/layer/identity.hpp @@ -89,7 +89,7 @@ class IdentityType : public Layer // Convenience typedefs. -typedef IdentityType Identity; +using Identity = IdentityType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/layer_norm.hpp b/src/mlpack/methods/ann/layer/layer_norm.hpp index 7a391a3377..0e510d82b6 100644 --- a/src/mlpack/methods/ann/layer/layer_norm.hpp +++ b/src/mlpack/methods/ann/layer/layer_norm.hpp @@ -176,7 +176,7 @@ class LayerNormType : public Layer }; // class LayerNormType // Standard LayerNorm type -typedef LayerNormType LayerNorm; +using LayerNorm = LayerNormType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/leaky_relu.hpp b/src/mlpack/methods/ann/layer/leaky_relu.hpp index 6a18be2a74..b56702a32b 100644 --- a/src/mlpack/methods/ann/layer/leaky_relu.hpp +++ b/src/mlpack/methods/ann/layer/leaky_relu.hpp @@ -105,7 +105,7 @@ class LeakyReLUType : public Layer // Convenience typedefs. // Standard LeakyReLU layer. -typedef LeakyReLUType LeakyReLU; +using LeakyReLU = LeakyReLUType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/linear.hpp b/src/mlpack/methods/ann/layer/linear.hpp index 96b1e28a97..412b4a72e5 100644 --- a/src/mlpack/methods/ann/layer/linear.hpp +++ b/src/mlpack/methods/ann/layer/linear.hpp @@ -167,7 +167,7 @@ class LinearType : public Layer // Convenience typedefs. // Standard Linear layer using no regularization. -typedef LinearType Linear; +using Linear = LinearType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/linear3d.hpp b/src/mlpack/methods/ann/layer/linear3d.hpp index 6c20dc9618..6b27c07514 100644 --- a/src/mlpack/methods/ann/layer/linear3d.hpp +++ b/src/mlpack/methods/ann/layer/linear3d.hpp @@ -150,7 +150,7 @@ class Linear3DType : public Layer }; // class Linear // Standard Linear3D layer. -typedef Linear3DType Linear3D; +using Linear3D = Linear3DType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/linear3d_impl.hpp b/src/mlpack/methods/ann/layer/linear3d_impl.hpp index 6d2ba0bc59..afa6a640cc 100644 --- a/src/mlpack/methods/ann/layer/linear3d_impl.hpp +++ b/src/mlpack/methods/ann/layer/linear3d_impl.hpp @@ -98,7 +98,7 @@ template void Linear3DType::Forward( const MatType& input, MatType& output) { - typedef typename arma::Cube CubeType; + using CubeType = arma::Cube; const size_t nPoints = input.n_rows / this->inputDimensions[0]; const size_t batchSize = input.n_cols; @@ -123,7 +123,7 @@ void Linear3DType::Backward( const MatType& gy, MatType& g) { - typedef typename arma::Cube CubeType; + using CubeType = arma::Cube; if (gy.n_rows % outSize != 0) { @@ -151,7 +151,7 @@ void Linear3DType::Gradient( const MatType& error, MatType& gradient) { - typedef typename arma::Cube CubeType; + using CubeType = arma::Cube; if (error.n_rows % outSize != 0) Log::Fatal << "Propagated error matrix has invalid dimension!" << std::endl; diff --git a/src/mlpack/methods/ann/layer/linear_no_bias.hpp b/src/mlpack/methods/ann/layer/linear_no_bias.hpp index 15913a21db..cf4405e8e0 100644 --- a/src/mlpack/methods/ann/layer/linear_no_bias.hpp +++ b/src/mlpack/methods/ann/layer/linear_no_bias.hpp @@ -136,7 +136,7 @@ class LinearNoBiasType : public Layer // Convenience typedefs. // Standard Linear without bias layer using no regularization. -typedef LinearNoBiasType LinearNoBias; +using LinearNoBias = LinearNoBiasType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/log_softmax.hpp b/src/mlpack/methods/ann/layer/log_softmax.hpp index b1b4c475da..712604ea48 100644 --- a/src/mlpack/methods/ann/layer/log_softmax.hpp +++ b/src/mlpack/methods/ann/layer/log_softmax.hpp @@ -104,7 +104,7 @@ class LogSoftMaxType : public Layer // Convenience typedefs. // Standard Linear layer using no regularization. -typedef LogSoftMaxType LogSoftMax; +using LogSoftMax = LogSoftMaxType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/lstm.hpp b/src/mlpack/methods/ann/layer/lstm.hpp index 2df33e21ea..a56e501e4d 100644 --- a/src/mlpack/methods/ann/layer/lstm.hpp +++ b/src/mlpack/methods/ann/layer/lstm.hpp @@ -273,7 +273,7 @@ class LSTMType : public RecurrentLayer // Convenience typedefs. // Standard LSTM layer. -typedef LSTMType LSTM; +using LSTM = LSTMType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/max_pooling.hpp b/src/mlpack/methods/ann/layer/max_pooling.hpp index 2b63a9918f..87398bdb4d 100644 --- a/src/mlpack/methods/ann/layer/max_pooling.hpp +++ b/src/mlpack/methods/ann/layer/max_pooling.hpp @@ -308,7 +308,7 @@ class MaxPoolingType : public Layer }; // class MaxPoolingType // Standard MaxPooling layer. -typedef MaxPoolingType MaxPooling; +using MaxPooling = MaxPoolingType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/mean_pooling.hpp b/src/mlpack/methods/ann/layer/mean_pooling.hpp index e18265e56c..de159ec117 100644 --- a/src/mlpack/methods/ann/layer/mean_pooling.hpp +++ b/src/mlpack/methods/ann/layer/mean_pooling.hpp @@ -171,7 +171,7 @@ class MeanPoolingType : public Layer }; // class MeanPoolingType // Standard MeanPooling layer. -typedef MeanPoolingType MeanPooling; +using MeanPooling = MeanPoolingType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/multihead_attention.hpp b/src/mlpack/methods/ann/layer/multihead_attention.hpp index 85b8e6a664..006d5deadf 100644 --- a/src/mlpack/methods/ann/layer/multihead_attention.hpp +++ b/src/mlpack/methods/ann/layer/multihead_attention.hpp @@ -265,7 +265,7 @@ class MultiheadAttentionType : public Layer private: //! Element Type of the output. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; //! Target sequence length. size_t tgtSeqLen; @@ -343,7 +343,7 @@ class MultiheadAttentionType : public Layer }; // class MultiheadAttention // Standard MultiheadAttention layer using no regularization. -typedef MultiheadAttentionType MultiheadAttention; +using MultiheadAttention = MultiheadAttentionType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/multihead_attention_impl.hpp b/src/mlpack/methods/ann/layer/multihead_attention_impl.hpp index 7ea391fc46..8330e8f06c 100644 --- a/src/mlpack/methods/ann/layer/multihead_attention_impl.hpp +++ b/src/mlpack/methods/ann/layer/multihead_attention_impl.hpp @@ -73,7 +73,7 @@ template void MultiheadAttentionType:: Forward(const MatType& input, MatType& output) { - typedef typename arma::Cube CubeType; + using CubeType = arma::Cube; if (input.n_rows != embedDim * (selfAttention ? srcSeqLen : (tgtSeqLen + 2 * srcSeqLen))) @@ -187,7 +187,7 @@ Backward(const MatType& /* input */, const MatType& gy, MatType& g) { - typedef typename arma::Cube CubeType; + using CubeType = arma::Cube; if (gy.n_rows != tgtSeqLen * embedDim) { @@ -306,7 +306,7 @@ Gradient(const MatType& input, const MatType& error, MatType& gradient) { - typedef typename arma::Cube CubeType; + using CubeType = arma::Cube; if (input.n_rows != embedDim * (selfAttention ? srcSeqLen : (tgtSeqLen + 2 * srcSeqLen))) diff --git a/src/mlpack/methods/ann/layer/nearest_interpolation.hpp b/src/mlpack/methods/ann/layer/nearest_interpolation.hpp index bc9041a2fb..62d10d9448 100644 --- a/src/mlpack/methods/ann/layer/nearest_interpolation.hpp +++ b/src/mlpack/methods/ann/layer/nearest_interpolation.hpp @@ -102,7 +102,7 @@ class NearestInterpolationType : public Layer std::vector scaleFactors; }; // class NearestInterpolation -typedef NearestInterpolationType NearestInterpolation; +using NearestInterpolation = NearestInterpolationType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/noisylinear.hpp b/src/mlpack/methods/ann/layer/noisylinear.hpp index 70f819f84a..ad16dfc191 100644 --- a/src/mlpack/methods/ann/layer/noisylinear.hpp +++ b/src/mlpack/methods/ann/layer/noisylinear.hpp @@ -152,7 +152,7 @@ class NoisyLinearType : public Layer // Convenience typedefs. // Standard noisy linear layer. -typedef NoisyLinearType NoisyLinear; +using NoisyLinear = NoisyLinearType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/bicubic_interpolation.hpp b/src/mlpack/methods/ann/layer/not_adapted/bicubic_interpolation.hpp index 8daf91f89d..5010927bc4 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/bicubic_interpolation.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/bicubic_interpolation.hpp @@ -145,7 +145,7 @@ class BicubicInterpolation private: //! Element Type of the input. - typedef typename OutputDataType::elem_type ElemType; + using ElemType = typename OutputDataType::elem_type; //! Locally stored row size of the input. size_t inRowSize; diff --git a/src/mlpack/methods/ann/layer/not_adapted/bilinear_interpolation.hpp b/src/mlpack/methods/ann/layer/not_adapted/bilinear_interpolation.hpp index dcb182afc0..b520fdb0b3 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/bilinear_interpolation.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/bilinear_interpolation.hpp @@ -116,7 +116,7 @@ class BilinearInterpolationType : public Layer }; // class BilinearInterpolation // Standard BilinearInterpolation layer. -typedef BilinearInterpolationType BilinearInterpolation; +using BilinearInterpolation = BilinearInterpolationType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/constant.hpp b/src/mlpack/methods/ann/layer/not_adapted/constant.hpp index 8fd91f7af5..262f937d37 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/constant.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/constant.hpp @@ -103,7 +103,7 @@ class ConstantType : public Layer // Convenience typedefs. // Standard HardShrink layer. -typedef ConstantType Constant; +using Constant = ConstantType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/fast_lstm.hpp b/src/mlpack/methods/ann/layer/not_adapted/fast_lstm.hpp index da9b78356e..3c287795b7 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/fast_lstm.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/fast_lstm.hpp @@ -68,8 +68,8 @@ class FastLSTMType : public Layer { public: // Convenience typedefs. - typedef typename InputType::elem_type InputET; - typedef typename OutputType::elem_type OutputET; + using InputET = typename InputType::elem_type; + using OutputET = typename OutputType::elem_type; //! Create the FastLSTMType object. FastLSTMType(); @@ -305,7 +305,7 @@ class FastLSTMType : public Layer }; // class FastLSTMType. // Standard FastLSTM layer. -typedef FastLSTMType FastLSTM; +using FastLSTM = FastLSTMType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/glimpse.hpp b/src/mlpack/methods/ann/layer/not_adapted/glimpse.hpp index 01c75e37ee..3dd0ec96f6 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/glimpse.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/glimpse.hpp @@ -407,7 +407,7 @@ class GlimpseType : public Layer }; // class GlimpseType // Standard Glimpse layer. -typedef GlimpseType Glimpse; +using Glimpse = GlimpseType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/hardshrink.hpp b/src/mlpack/methods/ann/layer/not_adapted/hardshrink.hpp index 83e2d87907..da35f1b33c 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/hardshrink.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/hardshrink.hpp @@ -98,7 +98,7 @@ class HardShrinkType : public Layer // Convenience typedefs. // Standard HardShrink layer. -typedef HardShrinkType HardShrink; +using HardShrink = HardShrinkType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/highway.hpp b/src/mlpack/methods/ann/layer/not_adapted/highway.hpp index c525e9bfba..d529155202 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/highway.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/highway.hpp @@ -145,7 +145,7 @@ class HighwayType : public MultiLayer }; // class HighwayType // Standard Highway layer. -typedef HighwayType Highway; +using Highway = HighwayType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/join.hpp b/src/mlpack/methods/ann/layer/not_adapted/join.hpp index d6d8e126eb..e6383c42a4 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/join.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/join.hpp @@ -88,7 +88,7 @@ class JoinType : public Layer }; // class JoinType //Standard Join layer. -typedef JoinType Join; +using Join = JoinType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/lookup.hpp b/src/mlpack/methods/ann/layer/not_adapted/lookup.hpp index 4be7e26a7b..a9ad609572 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/lookup.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/lookup.hpp @@ -128,8 +128,8 @@ class LookupType : public Layer // Alias for using as embedding layer. // template // using Embedding = Lookup; -typedef LookupType Lookup; -typedef LookupType Embedding; +using Lookup = LookupType; +using Embedding = LookupType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/lookup_impl.hpp b/src/mlpack/methods/ann/layer/not_adapted/lookup_impl.hpp index abe892947e..0bbf14a705 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/lookup_impl.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/lookup_impl.hpp @@ -67,7 +67,7 @@ void LookupType::Gradient( const OutputType& error, OutputType& gradient) { - typedef typename arma::Cube CubeType; + using CubeType = arma::Cube; const size_t seqLength = input.n_rows; const size_t batchSize = input.n_cols; diff --git a/src/mlpack/methods/ann/layer/not_adapted/multiply_constant.hpp b/src/mlpack/methods/ann/layer/not_adapted/multiply_constant.hpp index f5f18c6310..27d2f5ccd9 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/multiply_constant.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/multiply_constant.hpp @@ -93,7 +93,7 @@ class MultiplyConstantType : public Layer // Convenience typedefs. // Standard MultiplyConstant layer. -typedef MultiplyConstantType MultiplyConstant; +using MultiplyConstant = MultiplyConstantType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/multiply_merge.hpp b/src/mlpack/methods/ann/layer/not_adapted/multiply_merge.hpp index 85ad8d81ee..613aee4e70 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/multiply_merge.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/multiply_merge.hpp @@ -125,7 +125,7 @@ class MultiplyMergeType : public MultiLayer }; // class MultiplyMergeType // Standard MultiplyMerge layer. -typedef MultiplyMergeType MultiplyMerge; +using MultiplyMerge = MultiplyMergeType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/positional_encoding.hpp b/src/mlpack/methods/ann/layer/not_adapted/positional_encoding.hpp index c7adea426f..3e1d44411d 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/positional_encoding.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/positional_encoding.hpp @@ -111,7 +111,7 @@ class PositionalEncodingType : public Layer }; // class PositionalEncodingTest // Standard PositionalEncoding layer. -typedef PositionalEncodingType PositionalEncoding; +using PositionalEncoding = PositionalEncodingType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/reinforce_normal.hpp b/src/mlpack/methods/ann/layer/not_adapted/reinforce_normal.hpp index b6e2081239..7d2e832c94 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/reinforce_normal.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/reinforce_normal.hpp @@ -95,7 +95,7 @@ class ReinforceNormalType : public Layer }; // class ReinforceNormalType. // Standard ReinforceNormal layer. -typedef ReinforceNormalType ReinforceNormal; +using ReinforceNormal = ReinforceNormalType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/reparametrization.hpp b/src/mlpack/methods/ann/layer/not_adapted/reparametrization.hpp index 1de576d0da..3ed69779f7 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/reparametrization.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/reparametrization.hpp @@ -190,7 +190,7 @@ class ReparametrizationType : public Layer }; // class ReparametrizationType // Standard Reparametrization layer. -typedef ReparametrizationType Reparametrization; +using Reparametrization = ReparametrizationType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/select.hpp b/src/mlpack/methods/ann/layer/not_adapted/select.hpp index f35f1465ad..e5cc670480 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/select.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/select.hpp @@ -107,7 +107,7 @@ class SelectType : public Layer }; // class SelectType // Standard Select layer. -typedef SelectType Select; +using Select = SelectType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/sequential.hpp b/src/mlpack/methods/ann/layer/not_adapted/sequential.hpp index 882eaf20da..bc1d10a275 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/sequential.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/sequential.hpp @@ -135,10 +135,10 @@ class SequentialType : public MultiLayer }; // class SequentialType // Standard Sequential layer. -typedef SequentialType Sequential; +using Sequential = SequentialType; // Standard Residual layer. -typedef SequentialType Residual; +using Residual = SequentialType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/softshrink.hpp b/src/mlpack/methods/ann/layer/not_adapted/softshrink.hpp index 1de26dea52..5ad2d64f46 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/softshrink.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/softshrink.hpp @@ -101,7 +101,7 @@ class SoftShrinkType : public Layer // Convenience typedefs. // Standard SoftShrink layer. -typedef SoftShrinkType SoftShrink; +using SoftShrink = SoftShrinkType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/spatial_dropout.hpp b/src/mlpack/methods/ann/layer/not_adapted/spatial_dropout.hpp index 599ad2a446..951ccaf38d 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/spatial_dropout.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/spatial_dropout.hpp @@ -126,7 +126,7 @@ class SpatialDropoutType : public Layer // Convenience typedefs. // Standard SpatialDropout layer. -typedef SpatialDropoutType SpatialDropout; +using SpatialDropout = SpatialDropoutType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/subview.hpp b/src/mlpack/methods/ann/layer/not_adapted/subview.hpp index 66019969f0..7ce67f49b8 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/subview.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/subview.hpp @@ -187,7 +187,7 @@ class SubviewType : public Layer }; // class SubviewType // Standard Subview layer. -typedef SubviewType Subview; +using Subview = SubviewType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/transposed_convolution.hpp b/src/mlpack/methods/ann/layer/not_adapted/transposed_convolution.hpp index 4ecebc3677..0947fa3b33 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/transposed_convolution.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/transposed_convolution.hpp @@ -455,13 +455,12 @@ class TransposedConvolutionType : public Layer }; // class TransposedConvolutionType // Standard TransposedConvolution -typedef TransposedConvolutionType< - NaiveConvolution, - NaiveConvolution, - NaiveConvolution, - arma::mat, - arma::mat -> TransposedConvolution; +using TransposedConvolution = TransposedConvolutionType< + NaiveConvolution, + NaiveConvolution, + NaiveConvolution, + arma::mat, + arma::mat>; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/transposed_convolution_impl.hpp b/src/mlpack/methods/ann/layer/not_adapted/transposed_convolution_impl.hpp index 02da6d7c2d..d67beb8454 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/transposed_convolution_impl.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/transposed_convolution_impl.hpp @@ -232,7 +232,7 @@ void TransposedConvolutionType< { inputPaddedTemp = arma::Cube( inputExpandedTemp.memptr(), inputExpandedTemp.n_rows, - inputExpandedTemp.n_cols, inputExpandedTemp.n_slices, false, false);; + inputExpandedTemp.n_cols, inputExpandedTemp.n_slices, false, false); } } else if (paddingForward.PadWLeft() != 0 || diff --git a/src/mlpack/methods/ann/layer/not_adapted/virtual_batch_norm.hpp b/src/mlpack/methods/ann/layer/not_adapted/virtual_batch_norm.hpp index 80acc49390..e137fd00f3 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/virtual_batch_norm.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/virtual_batch_norm.hpp @@ -174,7 +174,7 @@ class VirtualBatchNormType : public Layer }; // class VirtualBatchNormType // Standard VirtualBatchNorm layer. -typedef VirtualBatchNormType VirtualBatchNorm; +using VirtualBatchNorm = VirtualBatchNormType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/not_adapted/weight_norm.hpp b/src/mlpack/methods/ann/layer/not_adapted/weight_norm.hpp index 17de56d6eb..862595524c 100644 --- a/src/mlpack/methods/ann/layer/not_adapted/weight_norm.hpp +++ b/src/mlpack/methods/ann/layer/not_adapted/weight_norm.hpp @@ -170,7 +170,7 @@ class WeightNormType : public Layer }; // class WeightNormType. // Standard WeightNorm layer. -typedef WeightNormType WeightNorm; +using WeightNorm = WeightNormType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/padding.hpp b/src/mlpack/methods/ann/layer/padding.hpp index 0034cbe5de..1d9e4dfd89 100644 --- a/src/mlpack/methods/ann/layer/padding.hpp +++ b/src/mlpack/methods/ann/layer/padding.hpp @@ -127,7 +127,7 @@ class PaddingType : public Layer }; // class PaddingType // Standard Padding layer. -typedef PaddingType Padding; +using Padding = PaddingType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/parametric_relu.hpp b/src/mlpack/methods/ann/layer/parametric_relu.hpp index f8d6efd91c..b4b9f24678 100644 --- a/src/mlpack/methods/ann/layer/parametric_relu.hpp +++ b/src/mlpack/methods/ann/layer/parametric_relu.hpp @@ -145,7 +145,7 @@ class PReLUType : public Layer // Convenience typedefs. // Standard PReLU layer. -typedef PReLUType PReLU; +using PReLU = PReLUType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/radial_basis_function.hpp b/src/mlpack/methods/ann/layer/radial_basis_function.hpp index a0f278fd02..26f0f0e7f4 100644 --- a/src/mlpack/methods/ann/layer/radial_basis_function.hpp +++ b/src/mlpack/methods/ann/layer/radial_basis_function.hpp @@ -121,7 +121,7 @@ class RBFType : public Layer MatType distances; }; // class RBFType -typedef RBFType RBF; +using RBF = RBFType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/relu6.hpp b/src/mlpack/methods/ann/layer/relu6.hpp index cfd1af5301..e8784ce7d6 100644 --- a/src/mlpack/methods/ann/layer/relu6.hpp +++ b/src/mlpack/methods/ann/layer/relu6.hpp @@ -93,7 +93,7 @@ class ReLU6Type : public Layer // Convenience typedefs. // Standard ReLU6 layer. -typedef ReLU6Type ReLU6; +using ReLU6 = ReLU6Type; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/repeat.hpp b/src/mlpack/methods/ann/layer/repeat.hpp index bd0896b6c8..d136d207d6 100644 --- a/src/mlpack/methods/ann/layer/repeat.hpp +++ b/src/mlpack/methods/ann/layer/repeat.hpp @@ -34,8 +34,8 @@ class RepeatType : public Layer { public: //! Get Specific Col type, not only arma - typedef typename GetUColType::type UintCol; - typedef typename GetUDenseMatType::type UintMat; + using UintCol = typename GetUColType::type; + using UintMat = typename GetUDenseMatType::type; /** * Create the Repeat object. Multiples will be empty (e.g. 1s for all * dimensions), so this is the equivalent of an Identity Layer. @@ -147,7 +147,7 @@ class RepeatType : public Layer }; // class RepeatType. // Standard Repeat layer. -typedef RepeatType Repeat; +using Repeat = RepeatType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/softmax.hpp b/src/mlpack/methods/ann/layer/softmax.hpp index 3d92fc29c0..f7d3af133a 100644 --- a/src/mlpack/methods/ann/layer/softmax.hpp +++ b/src/mlpack/methods/ann/layer/softmax.hpp @@ -82,7 +82,7 @@ class SoftmaxType : public Layer }; // class SoftmaxType // Convenience typedef. -typedef SoftmaxType Softmax; +using Softmax = SoftmaxType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/layer/softmin.hpp b/src/mlpack/methods/ann/layer/softmin.hpp index 4a4e3ac240..6cf2b62126 100644 --- a/src/mlpack/methods/ann/layer/softmin.hpp +++ b/src/mlpack/methods/ann/layer/softmin.hpp @@ -81,7 +81,7 @@ class SoftminType : public Layer // Convenience typedefs. // Standard Softmin layer using no regularization. -typedef SoftminType Softmin; +using Softmin = SoftminType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/binary_cross_entropy_loss.hpp b/src/mlpack/methods/ann/loss_functions/binary_cross_entropy_loss.hpp index 5acb3c6c8c..caed04d2f9 100644 --- a/src/mlpack/methods/ann/loss_functions/binary_cross_entropy_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/binary_cross_entropy_loss.hpp @@ -89,12 +89,12 @@ class BCELossType }; // class BCELossType // Default typedef for typical `arma::mat` usage. -typedef BCELossType BCELoss; +using BCELoss = BCELossType; /** * Alias of BCELossType. */ -typedef BCELossType CrossEntropyError; +using CrossEntropyError = BCELossType; template using CrossEntropyErrorType = BCELossType; diff --git a/src/mlpack/methods/ann/loss_functions/binary_cross_entropy_loss_impl.hpp b/src/mlpack/methods/ann/loss_functions/binary_cross_entropy_loss_impl.hpp index f4abc23416..68ac6f1262 100644 --- a/src/mlpack/methods/ann/loss_functions/binary_cross_entropy_loss_impl.hpp +++ b/src/mlpack/methods/ann/loss_functions/binary_cross_entropy_loss_impl.hpp @@ -29,7 +29,7 @@ typename MatType::elem_type BCELossType::Forward( const MatType& prediction, const MatType& target) { - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; ElemType lossSum = -accu(target % log(prediction + eps) + (1. - target) % log(1. - prediction + eps)); diff --git a/src/mlpack/methods/ann/loss_functions/cosine_embedding_loss.hpp b/src/mlpack/methods/ann/loss_functions/cosine_embedding_loss.hpp index 63ae8c2e46..7575e58244 100644 --- a/src/mlpack/methods/ann/loss_functions/cosine_embedding_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/cosine_embedding_loss.hpp @@ -106,7 +106,7 @@ class CosineEmbeddingLossType }; // class CosineEmbeddingLossType // Default typedef for typical `arma::mat` usage. -typedef CosineEmbeddingLossType CosineEmbeddingLoss; +using CosineEmbeddingLoss = CosineEmbeddingLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/cosine_embedding_loss_impl.hpp b/src/mlpack/methods/ann/loss_functions/cosine_embedding_loss_impl.hpp index 2abc84b96e..231d0765af 100644 --- a/src/mlpack/methods/ann/loss_functions/cosine_embedding_loss_impl.hpp +++ b/src/mlpack/methods/ann/loss_functions/cosine_embedding_loss_impl.hpp @@ -30,7 +30,7 @@ typename MatType::elem_type CosineEmbeddingLossType::Forward( const MatType& prediction, const MatType& target) { - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; const size_t cols = prediction.n_cols; const size_t batchSize = prediction.n_elem / cols; @@ -67,7 +67,7 @@ void CosineEmbeddingLossType::Backward( const MatType& target, MatType& loss) { - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; const size_t cols = prediction.n_cols; const size_t batchSize = prediction.n_elem / cols; diff --git a/src/mlpack/methods/ann/loss_functions/dice_loss.hpp b/src/mlpack/methods/ann/loss_functions/dice_loss.hpp index 18036e5cdb..f77daf7625 100644 --- a/src/mlpack/methods/ann/loss_functions/dice_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/dice_loss.hpp @@ -90,7 +90,7 @@ class DiceLossType }; // class DiceLossType // Default typedef for typical `arma::mat` usage. -typedef DiceLossType DiceLoss; +using DiceLoss = DiceLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/earth_mover_distance.hpp b/src/mlpack/methods/ann/loss_functions/earth_mover_distance.hpp index 4d8b079c05..bdb5b2bd2f 100644 --- a/src/mlpack/methods/ann/loss_functions/earth_mover_distance.hpp +++ b/src/mlpack/methods/ann/loss_functions/earth_mover_distance.hpp @@ -78,7 +78,7 @@ class EarthMoverDistanceType }; // class EarthMoverDistanceType // Default typedef for typical `arma::mat` usage. -typedef EarthMoverDistanceType EarthMoverDistance; +using EarthMoverDistance = EarthMoverDistanceType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/empty_loss.hpp b/src/mlpack/methods/ann/loss_functions/empty_loss.hpp index 4a8aaa2a53..3367045c22 100644 --- a/src/mlpack/methods/ann/loss_functions/empty_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/empty_loss.hpp @@ -61,7 +61,7 @@ class EmptyLossType }; // class EmptyLossType // Default typedef for typical `arma::mat` usage. -typedef EmptyLossType EmptyLoss; +using EmptyLoss = EmptyLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/hinge_embedding_loss.hpp b/src/mlpack/methods/ann/loss_functions/hinge_embedding_loss.hpp index 67ab91baff..e81e557950 100644 --- a/src/mlpack/methods/ann/loss_functions/hinge_embedding_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/hinge_embedding_loss.hpp @@ -81,7 +81,7 @@ class HingeEmbeddingLossType }; // class HingeEmbeddingLossType // Default typedef for typical `arma::mat` usage. -typedef HingeEmbeddingLossType HingeEmbeddingLoss; +using HingeEmbeddingLoss = HingeEmbeddingLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/hinge_loss.hpp b/src/mlpack/methods/ann/loss_functions/hinge_loss.hpp index 622cdcc3f9..9b7b11576d 100644 --- a/src/mlpack/methods/ann/loss_functions/hinge_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/hinge_loss.hpp @@ -82,7 +82,7 @@ class HingeLossType }; // class HingeLossType // Default typedef for typical `arma::mat` usage. -typedef HingeLossType HingeLoss; +using HingeLoss = HingeLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/huber_loss.hpp b/src/mlpack/methods/ann/loss_functions/huber_loss.hpp index 45807d3c92..b8a1817f7c 100644 --- a/src/mlpack/methods/ann/loss_functions/huber_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/huber_loss.hpp @@ -91,7 +91,7 @@ class HuberLossType }; // class HuberLossType // Default typedef for typical `arma::mat` usage. -typedef HuberLossType HuberLoss; +using HuberLoss = HuberLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/huber_loss_impl.hpp b/src/mlpack/methods/ann/loss_functions/huber_loss_impl.hpp index 7ce26db895..720465bd6a 100644 --- a/src/mlpack/methods/ann/loss_functions/huber_loss_impl.hpp +++ b/src/mlpack/methods/ann/loss_functions/huber_loss_impl.hpp @@ -32,7 +32,7 @@ typename MatType::elem_type HuberLossType::Forward( const MatType& prediction, const MatType& target) { - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; ElemType lossSum = 0; for (size_t i = 0; i < prediction.n_elem; ++i) { @@ -53,7 +53,7 @@ void HuberLossType::Backward( const MatType& target, MatType& loss) { - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; loss.set_size(size(prediction)); for (size_t i = 0; i < loss.n_elem; ++i) diff --git a/src/mlpack/methods/ann/loss_functions/kl_divergence.hpp b/src/mlpack/methods/ann/loss_functions/kl_divergence.hpp index 2b2e429e27..fd3bca14db 100644 --- a/src/mlpack/methods/ann/loss_functions/kl_divergence.hpp +++ b/src/mlpack/methods/ann/loss_functions/kl_divergence.hpp @@ -91,7 +91,7 @@ class KLDivergenceType }; // class KLDivergenceType // Default typedef for typical `arma::mat` usage. -typedef KLDivergenceType KLDivergence; +using KLDivergence = KLDivergenceType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/l1_loss.hpp b/src/mlpack/methods/ann/loss_functions/l1_loss.hpp index a56b8a9978..d7efcef2ef 100644 --- a/src/mlpack/methods/ann/loss_functions/l1_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/l1_loss.hpp @@ -79,7 +79,7 @@ class L1LossType }; // class L1LossType // Default typedef for typical `arma::mat` usage. -typedef L1LossType L1Loss; +using L1Loss = L1LossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/log_cosh_loss.hpp b/src/mlpack/methods/ann/loss_functions/log_cosh_loss.hpp index 2fc628e801..3fef56629a 100644 --- a/src/mlpack/methods/ann/loss_functions/log_cosh_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/log_cosh_loss.hpp @@ -94,7 +94,7 @@ class LogCoshLossType }; // class LogCoshLossType // Default typedef for typical `arma::mat` usage. -typedef LogCoshLossType LogCoshLoss; +using LogCoshLoss = LogCoshLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/margin_ranking_loss.hpp b/src/mlpack/methods/ann/loss_functions/margin_ranking_loss.hpp index 04d40832e9..1fdea4a22f 100644 --- a/src/mlpack/methods/ann/loss_functions/margin_ranking_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/margin_ranking_loss.hpp @@ -91,7 +91,7 @@ class MarginRankingLossType }; // class MarginRankingLossType // Default typedef for typical `arma::mat` usage. -typedef MarginRankingLossType MarginRankingLoss; +using MarginRankingLoss = MarginRankingLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/mean_absolute_percentage_error.hpp b/src/mlpack/methods/ann/loss_functions/mean_absolute_percentage_error.hpp index 21408f9b08..432f08d167 100644 --- a/src/mlpack/methods/ann/loss_functions/mean_absolute_percentage_error.hpp +++ b/src/mlpack/methods/ann/loss_functions/mean_absolute_percentage_error.hpp @@ -78,7 +78,7 @@ class MeanAbsolutePercentageErrorType }; // class MeanAbsolutePercentageErrorType // Default typedef for typical `arma::mat` usage. -typedef MeanAbsolutePercentageErrorType MeanAbsolutePercentageError; +using MeanAbsolutePercentageError = MeanAbsolutePercentageErrorType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/mean_bias_error.hpp b/src/mlpack/methods/ann/loss_functions/mean_bias_error.hpp index a3adf4041c..1def4ea9f7 100644 --- a/src/mlpack/methods/ann/loss_functions/mean_bias_error.hpp +++ b/src/mlpack/methods/ann/loss_functions/mean_bias_error.hpp @@ -80,7 +80,7 @@ class MeanBiasErrorType }; // class MeanBiasErrorType // Default typedef for typical `arma::mat` usage. -typedef MeanBiasErrorType MeanBiasError; +using MeanBiasError = MeanBiasErrorType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/mean_squared_error.hpp b/src/mlpack/methods/ann/loss_functions/mean_squared_error.hpp index cfe2bfcc75..7b8a41fc69 100644 --- a/src/mlpack/methods/ann/loss_functions/mean_squared_error.hpp +++ b/src/mlpack/methods/ann/loss_functions/mean_squared_error.hpp @@ -78,7 +78,7 @@ class MeanSquaredErrorType }; // class MeanSquaredErrorType // Default typedef for typical `arma::mat` usage. -typedef MeanSquaredErrorType MeanSquaredError; +using MeanSquaredError = MeanSquaredErrorType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/mean_squared_logarithmic_error.hpp b/src/mlpack/methods/ann/loss_functions/mean_squared_logarithmic_error.hpp index 57fd036536..4c7a15b9bf 100644 --- a/src/mlpack/methods/ann/loss_functions/mean_squared_logarithmic_error.hpp +++ b/src/mlpack/methods/ann/loss_functions/mean_squared_logarithmic_error.hpp @@ -78,7 +78,8 @@ class MeanSquaredLogarithmicErrorType }; // class MeanSquaredLogarithmicErrorType // Default typedef for typical `arma::mat` usage. -typedef MeanSquaredLogarithmicErrorType MeanSquaredLogarithmicError; +using MeanSquaredLogarithmicError = + MeanSquaredLogarithmicErrorType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/multilabel_softmargin_loss.hpp b/src/mlpack/methods/ann/loss_functions/multilabel_softmargin_loss.hpp index 5240748793..6c33e2b73b 100644 --- a/src/mlpack/methods/ann/loss_functions/multilabel_softmargin_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/multilabel_softmargin_loss.hpp @@ -105,7 +105,7 @@ class MultiLabelSoftMarginLossType }; // class MultiLabelSoftMarginLossType // Default typedef for typical `arma::mat` usage. -typedef MultiLabelSoftMarginLossType MultiLabelSoftMarginLoss; +using MultiLabelSoftMarginLoss = MultiLabelSoftMarginLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/negative_log_likelihood.hpp b/src/mlpack/methods/ann/loss_functions/negative_log_likelihood.hpp index 0612d53805..533e713f44 100644 --- a/src/mlpack/methods/ann/loss_functions/negative_log_likelihood.hpp +++ b/src/mlpack/methods/ann/loss_functions/negative_log_likelihood.hpp @@ -85,7 +85,7 @@ class NegativeLogLikelihoodType }; // class NegativeLogLikelihoodType // Default typedef for typical `arma::mat` usage. -typedef NegativeLogLikelihoodType NegativeLogLikelihood; +using NegativeLogLikelihood = NegativeLogLikelihoodType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/negative_log_likelihood_impl.hpp b/src/mlpack/methods/ann/loss_functions/negative_log_likelihood_impl.hpp index b4f232cd37..70dc556b50 100644 --- a/src/mlpack/methods/ann/loss_functions/negative_log_likelihood_impl.hpp +++ b/src/mlpack/methods/ann/loss_functions/negative_log_likelihood_impl.hpp @@ -31,7 +31,7 @@ double NegativeLogLikelihoodType::Forward( const MatType& prediction, const MatType& target) { - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; ElemType lossSum = 0; for (size_t i = 0; i < prediction.n_cols; ++i) { diff --git a/src/mlpack/methods/ann/loss_functions/poisson_nll_loss.hpp b/src/mlpack/methods/ann/loss_functions/poisson_nll_loss.hpp index 42b968695a..9d4a268fa4 100644 --- a/src/mlpack/methods/ann/loss_functions/poisson_nll_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/poisson_nll_loss.hpp @@ -136,7 +136,7 @@ class PoissonNLLLossType }; // class PoissonNLLLossType // Default typedef for typical `arma::mat` usage. -typedef PoissonNLLLossType PoissonNLLLoss; +using PoissonNLLLoss = PoissonNLLLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/reconstruction_loss.hpp b/src/mlpack/methods/ann/loss_functions/reconstruction_loss.hpp index 7d05c7f369..fc40fbcd20 100644 --- a/src/mlpack/methods/ann/loss_functions/reconstruction_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/reconstruction_loss.hpp @@ -87,7 +87,7 @@ class ReconstructionLossType }; // class ReconstructionLossType // Default typedef for typical `arma::mat` usage. -typedef ReconstructionLossType ReconstructionLoss; +using ReconstructionLoss = ReconstructionLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/sigmoid_cross_entropy_error.hpp b/src/mlpack/methods/ann/loss_functions/sigmoid_cross_entropy_error.hpp index 45cc3340d3..7a9a6bae1d 100644 --- a/src/mlpack/methods/ann/loss_functions/sigmoid_cross_entropy_error.hpp +++ b/src/mlpack/methods/ann/loss_functions/sigmoid_cross_entropy_error.hpp @@ -98,7 +98,7 @@ class SigmoidCrossEntropyErrorType }; // class SigmoidCrossEntropyErrorType // Default typedef for typical `arma::mat` usage. -typedef SigmoidCrossEntropyErrorType SigmoidCrossEntropyError; +using SigmoidCrossEntropyError = SigmoidCrossEntropyErrorType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/sigmoid_cross_entropy_error_impl.hpp b/src/mlpack/methods/ann/loss_functions/sigmoid_cross_entropy_error_impl.hpp index 0fb7c805b2..a521eba3da 100644 --- a/src/mlpack/methods/ann/loss_functions/sigmoid_cross_entropy_error_impl.hpp +++ b/src/mlpack/methods/ann/loss_functions/sigmoid_cross_entropy_error_impl.hpp @@ -33,7 +33,7 @@ SigmoidCrossEntropyErrorType::Forward( const MatType& prediction, const MatType& target) { - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; ElemType maximum = 0; for (size_t i = 0; i < prediction.n_elem; ++i) { diff --git a/src/mlpack/methods/ann/loss_functions/soft_margin_loss.hpp b/src/mlpack/methods/ann/loss_functions/soft_margin_loss.hpp index 8f224ace9b..b191c2d0a6 100644 --- a/src/mlpack/methods/ann/loss_functions/soft_margin_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/soft_margin_loss.hpp @@ -85,7 +85,7 @@ class SoftMarginLossType }; // class SoftMarginLossType // Default typedef for typical `arma::mat` usage. -typedef SoftMarginLossType SoftMarginLoss; +using SoftMarginLoss = SoftMarginLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/triplet_margin_loss.hpp b/src/mlpack/methods/ann/loss_functions/triplet_margin_loss.hpp index 9ee1a45347..b6fa6fa3cc 100644 --- a/src/mlpack/methods/ann/loss_functions/triplet_margin_loss.hpp +++ b/src/mlpack/methods/ann/loss_functions/triplet_margin_loss.hpp @@ -89,7 +89,7 @@ class TripletMarginLossType }; // class TripletMarginLoss // Default typedef for typical `arma::mat` usage. -typedef TripletMarginLossType TripletMarginLoss; +using TripletMarginLoss = TripletMarginLossType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/loss_functions/vr_class_reward.hpp b/src/mlpack/methods/ann/loss_functions/vr_class_reward.hpp index 8487169c97..b109dc7210 100644 --- a/src/mlpack/methods/ann/loss_functions/vr_class_reward.hpp +++ b/src/mlpack/methods/ann/loss_functions/vr_class_reward.hpp @@ -112,7 +112,7 @@ class VRClassRewardType }; // class VRClassRewardType // Default typedef for typical `arma::mat` usage. -typedef VRClassRewardType VRClassReward; +using VRClassReward = VRClassRewardType; } // namespace mlpack diff --git a/src/mlpack/methods/ann/not_adapted/rbm/rbm.hpp b/src/mlpack/methods/ann/not_adapted/rbm/rbm.hpp index b5afe73bf9..4f64694527 100644 --- a/src/mlpack/methods/ann/not_adapted/rbm/rbm.hpp +++ b/src/mlpack/methods/ann/not_adapted/rbm/rbm.hpp @@ -38,7 +38,7 @@ class RBM { public: using NetworkType = RBM; - typedef typename DataType::elem_type ElemType; + using ElemType = typename DataType::elem_type; /** * Initialize all the parameters of the network using initializeRule. diff --git a/src/mlpack/methods/ann/regularizer/lregularizer.hpp b/src/mlpack/methods/ann/regularizer/lregularizer.hpp index 18aaf27ff5..3038feb611 100644 --- a/src/mlpack/methods/ann/regularizer/lregularizer.hpp +++ b/src/mlpack/methods/ann/regularizer/lregularizer.hpp @@ -58,12 +58,12 @@ class LRegularizer /** * The L1 Regularizer. */ -typedef LRegularizer<1> L1Regularizer; +using L1Regularizer = LRegularizer<1>; /** * The L2 Regularizer. */ -typedef LRegularizer<2> L2Regularizer; +using L2Regularizer = LRegularizer<2>; } // namespace mlpack diff --git a/src/mlpack/methods/approx_kfn/drusilla_select_impl.hpp b/src/mlpack/methods/approx_kfn/drusilla_select_impl.hpp index d536e3ceda..f66d701893 100644 --- a/src/mlpack/methods/approx_kfn/drusilla_select_impl.hpp +++ b/src/mlpack/methods/approx_kfn/drusilla_select_impl.hpp @@ -119,7 +119,7 @@ void DrusillaSelect::Train( } // Find the top m elements using a priority queue. - typedef std::pair Candidate; + using Candidate = std::pair; struct CandidateCmp { bool operator()(const Candidate& c1, const Candidate& c2) diff --git a/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression.hpp b/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression.hpp index 06459fbd1f..db6f12e95b 100644 --- a/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression.hpp +++ b/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression.hpp @@ -99,9 +99,9 @@ template class BayesianLinearRegression { public: - typedef typename ModelMatType::elem_type ElemType; - typedef typename GetDenseColType::type DenseVecType; - typedef typename GetDenseRowType::type DenseRowType; + using ElemType = typename ModelMatType::elem_type; + using DenseVecType = typename GetDenseColType::type; + using DenseRowType = typename GetDenseRowType::type; /** * Set the parameters of Bayesian Ridge regression object. The regularization diff --git a/src/mlpack/methods/cf/cf.hpp b/src/mlpack/methods/cf/cf.hpp index 6efb558d12..9a12d9efc4 100644 --- a/src/mlpack/methods/cf/cf.hpp +++ b/src/mlpack/methods/cf/cf.hpp @@ -272,7 +272,7 @@ class CFType NormalizationType normalization; //! Candidate represents a possible recommendation (value, item). - typedef std::pair Candidate; + using Candidate = std::pair; //! Compare two candidates based on the value. struct CandidateCmp { @@ -283,7 +283,7 @@ class CFType }; }; // class CFType -typedef CFType<> CF; +using CF = CFType<>; } // namespace mlpack diff --git a/src/mlpack/methods/cf/cf_impl.hpp b/src/mlpack/methods/cf/cf_impl.hpp index a0dce6e6e5..91a584d543 100644 --- a/src/mlpack/methods/cf/cf_impl.hpp +++ b/src/mlpack/methods/cf/cf_impl.hpp @@ -227,8 +227,8 @@ GetRecommendations(const size_t numRecs, // Default candidate: the smallest possible value and invalid item number. const Candidate def = std::make_pair(-DBL_MAX, cleanedData.n_rows); std::vector vect(numRecs, def); - typedef std::priority_queue, CandidateCmp> - CandidateList; + using CandidateList = + std::priority_queue, CandidateCmp>; CandidateList pqueue(CandidateCmp(), std::move(vect)); // Look through the ratings column corresponding to the current user. diff --git a/src/mlpack/methods/cf/cf_model.hpp b/src/mlpack/methods/cf/cf_model.hpp index dde86162ae..dea4a74941 100644 --- a/src/mlpack/methods/cf/cf_model.hpp +++ b/src/mlpack/methods/cf/cf_model.hpp @@ -87,7 +87,7 @@ template class CFWrapper : public CFWrapperBase { protected: - typedef CFType CFModelType; + using CFModelType = CFType; public: //! Create the CFWrapper object, using default parameters to initialize the diff --git a/src/mlpack/methods/cf/svd_wrapper.hpp b/src/mlpack/methods/cf/svd_wrapper.hpp index 6a70f1702d..3bc3a1cc43 100644 --- a/src/mlpack/methods/cf/svd_wrapper.hpp +++ b/src/mlpack/methods/cf/svd_wrapper.hpp @@ -81,7 +81,7 @@ class SVDWrapper }; // class SVDWrapper //! add simple typedefs -typedef SVDWrapper ArmaSVDFactorizer; +using ArmaSVDFactorizer = SVDWrapper; } // namespace mlpack diff --git a/src/mlpack/methods/dbscan/dbscan.hpp b/src/mlpack/methods/dbscan/dbscan.hpp index 3666f1c278..c019da3f56 100644 --- a/src/mlpack/methods/dbscan/dbscan.hpp +++ b/src/mlpack/methods/dbscan/dbscan.hpp @@ -52,9 +52,9 @@ class DBSCAN { public: //! Easy access to the MatType. - typedef typename RangeSearchType::Mat MatType; + using MatType = typename RangeSearchType::Mat; //! Easy access to Element Type of the matrix. - typedef typename RangeSearchType::Mat::elem_type ElemType; + using ElemType = typename RangeSearchType::Mat::elem_type; /** * Construct the DBSCAN object with the given parameters. The batchMode * parameter should be set to false in the case where RAM issues will be diff --git a/src/mlpack/methods/decision_tree/decision_tree.hpp b/src/mlpack/methods/decision_tree/decision_tree.hpp index 5ed4cbd9bd..3f263d76cc 100644 --- a/src/mlpack/methods/decision_tree/decision_tree.hpp +++ b/src/mlpack/methods/decision_tree/decision_tree.hpp @@ -39,11 +39,11 @@ class DecisionTree : { public: //! Allow access to the numeric split type. - typedef NumericSplitType NumericSplit; + using NumericSplit = NumericSplitType; //! Allow access to the categorical split type. - typedef CategoricalSplitType CategoricalSplit; + using CategoricalSplit = CategoricalSplitType; //! Allow access to the dimension selection type. - typedef DimensionSelectionType DimensionSelection; + using DimensionSelection = DimensionSelectionType; /** * Construct the decision tree on the given data and labels, where the data @@ -507,10 +507,9 @@ class DecisionTree : //! Note that this class will also hold the members of the NumericSplit and //! CategoricalSplit AuxiliarySplitInfo classes, since it inherits from them. //! We'll define some convenience typedefs here. - typedef typename NumericSplit::AuxiliarySplitInfo - NumericAuxiliarySplitInfo; - typedef typename CategoricalSplit::AuxiliarySplitInfo - CategoricalAuxiliarySplitInfo; + using NumericAuxiliarySplitInfo = typename NumericSplit::AuxiliarySplitInfo; + using CategoricalAuxiliarySplitInfo = + typename CategoricalSplit::AuxiliarySplitInfo; /** * Calculate the class probabilities of the given labels. @@ -596,11 +595,11 @@ using DecisionStump = DecisionTree ID3DecisionStump; +using ID3DecisionStump = DecisionTree; } // namespace mlpack // Include implementation. diff --git a/src/mlpack/methods/decision_tree/decision_tree_main.cpp b/src/mlpack/methods/decision_tree/decision_tree_main.cpp index 20b785510a..b2ceec705c 100644 --- a/src/mlpack/methods/decision_tree/decision_tree_main.cpp +++ b/src/mlpack/methods/decision_tree/decision_tree_main.cpp @@ -151,7 +151,7 @@ PARAM_MODEL_OUT(DecisionTreeModel, "output_model", "Output for trained decision" " tree.", "M"); // Convenience typedef. -typedef tuple TupleType; +using TupleType = tuple; void BINDING_FUNCTION(util::Params& params, util::Timers& /* timers */) { diff --git a/src/mlpack/methods/decision_tree/decision_tree_regressor.hpp b/src/mlpack/methods/decision_tree/decision_tree_regressor.hpp index b0f4a61241..b5eb341fe7 100644 --- a/src/mlpack/methods/decision_tree/decision_tree_regressor.hpp +++ b/src/mlpack/methods/decision_tree/decision_tree_regressor.hpp @@ -39,11 +39,11 @@ class DecisionTreeRegressor : { public: //! Allow access to the numeric split type. - typedef NumericSplitType NumericSplit; + using NumericSplit = NumericSplitType; //! Allow access to the categorical split type. - typedef CategoricalSplitType CategoricalSplit; + using CategoricalSplit = CategoricalSplitType; //! Allow access to the dimension selection type. - typedef DimensionSelectionType DimensionSelection; + using DimensionSelection = DimensionSelectionType; /** * Construct a decision tree without training it. It will be a leaf node. @@ -455,10 +455,9 @@ class DecisionTreeRegressor : //! Note that this class will also hold the members of the NumericSplit and //! CategoricalSplit AuxiliarySplitInfo classes, since it inherits from them. //! We'll define some convenience typedefs here. - typedef typename NumericSplit::AuxiliarySplitInfo - NumericAuxiliarySplitInfo; - typedef typename CategoricalSplit::AuxiliarySplitInfo - CategoricalAuxiliarySplitInfo; + using NumericAuxiliarySplitInfo = typename NumericSplit::AuxiliarySplitInfo; + using CategoricalAuxiliarySplitInfo = + typename CategoricalSplit::AuxiliarySplitInfo; /** * Corresponding to the public Train() method, this method is designed for diff --git a/src/mlpack/methods/decision_tree/decision_tree_regressor_impl.hpp b/src/mlpack/methods/decision_tree/decision_tree_regressor_impl.hpp index 73b226c89b..53f500ea22 100644 --- a/src/mlpack/methods/decision_tree/decision_tree_regressor_impl.hpp +++ b/src/mlpack/methods/decision_tree/decision_tree_regressor_impl.hpp @@ -939,7 +939,7 @@ DecisionTreeRegressorPredict(point); } @@ -958,7 +958,7 @@ void DecisionTreeRegressor::Predict(const MatType& data, PredVecType& predictions) const { - typedef typename PredVecType::elem_type ElemType; + using ElemType = typename PredVecType::elem_type; predictions.set_size(data.n_cols); // If the tree's root is leaf. diff --git a/src/mlpack/methods/decision_tree/fitness_functions/mse_gain.hpp b/src/mlpack/methods/decision_tree/fitness_functions/mse_gain.hpp index 77687d2cd1..2335d9bba8 100644 --- a/src/mlpack/methods/decision_tree/fitness_functions/mse_gain.hpp +++ b/src/mlpack/methods/decision_tree/fitness_functions/mse_gain.hpp @@ -151,8 +151,8 @@ class MSEGain const WeightVecType& weights, const size_t minimum) { - typedef typename ResponsesType::elem_type RType; - typedef typename WeightVecType::elem_type WType; + using RType = typename ResponsesType::elem_type; + using WType = typename WeightVecType::elem_type; // Initializing data members to cache statistics. leftMean = 0.0; @@ -230,8 +230,8 @@ class MSEGain const WeightVecType& weights, const size_t index) { - typedef typename ResponsesType::elem_type RType; - typedef typename WeightVecType::elem_type WType; + using RType = typename ResponsesType::elem_type; + using WType = typename WeightVecType::elem_type; if (UseWeights) { diff --git a/src/mlpack/methods/decision_tree/splits/best_binary_categorical_split.hpp b/src/mlpack/methods/decision_tree/splits/best_binary_categorical_split.hpp index 4cd59b9003..b214e9773e 100644 --- a/src/mlpack/methods/decision_tree/splits/best_binary_categorical_split.hpp +++ b/src/mlpack/methods/decision_tree/splits/best_binary_categorical_split.hpp @@ -65,10 +65,10 @@ class BestBinaryCategoricalSplit // No extra info needed for split. class AuxiliarySplitInfo { }; // Allow access to the numeric split type. - typedef BestBinaryNumericSplit NumericSplit; + using NumericSplit = BestBinaryNumericSplit; // For calls to the numeric splitter. - typedef typename BestBinaryNumericSplit - ::AuxiliarySplitInfo NumericAux; + using NumericAux = + typename BestBinaryNumericSplit::AuxiliarySplitInfo; /** * Check if we can split a node. If we can split a node in a way that diff --git a/src/mlpack/methods/decision_tree/splits/best_binary_numeric_split_impl.hpp b/src/mlpack/methods/decision_tree/splits/best_binary_numeric_split_impl.hpp index 4687506a16..faae1f5f91 100644 --- a/src/mlpack/methods/decision_tree/splits/best_binary_numeric_split_impl.hpp +++ b/src/mlpack/methods/decision_tree/splits/best_binary_numeric_split_impl.hpp @@ -221,8 +221,8 @@ BestBinaryNumericSplit::SplitIfBetter( AuxiliarySplitInfo& /* aux */, FitnessFunction& fitnessFunction) { - typedef typename ResponsesType::elem_type RType; - typedef typename WeightVecType::elem_type WType; + using RType = typename ResponsesType::elem_type; + using WType = typename WeightVecType::elem_type; // First sanity check: if we don't have enough points, we can't split. if (data.n_elem < (minimumLeafSize * 2)) @@ -377,8 +377,8 @@ BestBinaryNumericSplit::SplitIfBetter( AuxiliarySplitInfo& /* aux */, FitnessFunction& fitnessFunction) { - typedef typename ResponsesType::elem_type RType; - typedef typename WeightVecType::elem_type WType; + using RType = typename ResponsesType::elem_type; + using WType = typename WeightVecType::elem_type; // First sanity check: if we don't have enough points, we can't split. if (data.n_elem < (minimumLeafSize * 2)) diff --git a/src/mlpack/methods/decision_tree/utils.hpp b/src/mlpack/methods/decision_tree/utils.hpp index 83ad18307f..db60e5897b 100644 --- a/src/mlpack/methods/decision_tree/utils.hpp +++ b/src/mlpack/methods/decision_tree/utils.hpp @@ -25,8 +25,8 @@ inline void WeightedSum(const VecType& values, double& accWeights, double& weightedMean) { - typedef typename VecType::elem_type VType; - typedef typename WeightVecType::elem_type WType; + using VType = typename VecType::elem_type; + using WType = typename WeightVecType::elem_type; WType totalWeights[4] = { 0.0, 0.0, 0.0, 0.0 }; VType weightedSum[4] = { 0.0, 0.0, 0.0, 0.0 }; diff --git a/src/mlpack/methods/det/dt_utils.hpp b/src/mlpack/methods/det/dt_utils.hpp index 8e5a76748c..2f851aae10 100644 --- a/src/mlpack/methods/det/dt_utils.hpp +++ b/src/mlpack/methods/det/dt_utils.hpp @@ -132,8 +132,8 @@ class PathCacher size_t NumNodes() const { return pathCache.size(); } protected: - typedef std::list> PathType; - typedef std::vector> PathCacheType; + using PathType = std::list>; + using PathCacheType = std::vector>; PathType path; PathFormat format; diff --git a/src/mlpack/methods/det/dtree.hpp b/src/mlpack/methods/det/dtree.hpp index 09eb0fc6e9..f3e6f817e3 100644 --- a/src/mlpack/methods/det/dtree.hpp +++ b/src/mlpack/methods/det/dtree.hpp @@ -46,11 +46,11 @@ class DTree { public: //! The actual, underlying type we're working with. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; //! The type of vector we are using. - typedef typename GetColType::type VecType; + using VecType = typename GetColType::type; //! The statistic type we are holding. - typedef typename arma::Col StatType; + using StatType = arma::Col; /** * Create an empty density estimation tree. diff --git a/src/mlpack/methods/det/dtree_impl.hpp b/src/mlpack/methods/det/dtree_impl.hpp index 78239a60de..9eadec082d 100644 --- a/src/mlpack/methods/det/dtree_impl.hpp +++ b/src/mlpack/methods/det/dtree_impl.hpp @@ -32,7 +32,7 @@ void ExtractSplits(std::vector>& splitVec, static_assert(std::is_same_v, "The ElemType does not correspond to the matrix's element type."); - typedef std::pair SplitItem; + using SplitItem = std::pair; const typename MatType::row_type dimVec = arma::sort(data(dim, arma::span(start, end - 1))); @@ -61,7 +61,7 @@ void ExtractSplits(std::vector>& splitVec, const size_t end, const size_t minLeafSize) { - typedef std::pair SplitItem; + using SplitItem = std::pair; arma::rowvec dimVec = data(dim, arma::span(start, end - 1)); // We sort these, in-place (it's a copy of the data, anyways). @@ -92,7 +92,7 @@ void ExtractSplits(std::vector>& splitVec, // It's common sense, but we also use it in a check later. Log::Assert(minLeafSize > 0); - typedef std::pair SplitItem; + using SplitItem = std::pair; const size_t n_elem = end - start; // Construct a vector of values. @@ -434,7 +434,7 @@ bool DTree::FindSplit(const MatType& data, double& rightError, const size_t minLeafSize) const { - typedef std::pair SplitItem; + using SplitItem = std::pair; // Ensure the dimensionality of the data is the same as the dimensionality of // the bounding rectangle. diff --git a/src/mlpack/methods/emst/dtb.hpp b/src/mlpack/methods/emst/dtb.hpp index 1cefa02875..da92cca2ee 100644 --- a/src/mlpack/methods/emst/dtb.hpp +++ b/src/mlpack/methods/emst/dtb.hpp @@ -80,7 +80,7 @@ class DualTreeBoruvka { public: //! Convenience typedef. - typedef TreeType Tree; + using Tree = TreeType; private: //! Permutations of points during tree building. diff --git a/src/mlpack/methods/emst/dtb_impl.hpp b/src/mlpack/methods/emst/dtb_impl.hpp index 7c40c9fb30..c05f9849ff 100644 --- a/src/mlpack/methods/emst/dtb_impl.hpp +++ b/src/mlpack/methods/emst/dtb_impl.hpp @@ -98,7 +98,7 @@ void DualTreeBoruvka::ComputeMST( { totalDist = 0; // Reset distance. - typedef DTBRules RuleType; + using RuleType = DTBRules; RuleType rules(data, connections, neighborsDistances, neighborsInComponent, neighborsOutComponent, distance); while (edges.size() < (data.n_cols - 1)) diff --git a/src/mlpack/methods/emst/dtb_rules.hpp b/src/mlpack/methods/emst/dtb_rules.hpp index c0564059be..524a3d924e 100644 --- a/src/mlpack/methods/emst/dtb_rules.hpp +++ b/src/mlpack/methods/emst/dtb_rules.hpp @@ -81,7 +81,7 @@ class DTBRules TreeType& referenceNode, const double oldScore) const; - typedef typename mlpack::TraversalInfo TraversalInfoType; + using TraversalInfoType = mlpack::TraversalInfo; const TraversalInfoType& TraversalInfo() const { return traversalInfo; } TraversalInfoType& TraversalInfo() { return traversalInfo; } diff --git a/src/mlpack/methods/fastmks/fastmks.hpp b/src/mlpack/methods/fastmks/fastmks.hpp index 300b75a289..f0937f9c73 100644 --- a/src/mlpack/methods/fastmks/fastmks.hpp +++ b/src/mlpack/methods/fastmks/fastmks.hpp @@ -61,7 +61,7 @@ class FastMKS { public: //! Convenience typedef. - typedef TreeType, FastMKSStat, MatType> Tree; + using Tree = TreeType, FastMKSStat, MatType>; /** * Create the FastMKS object with an empty reference set and default kernel. @@ -332,7 +332,7 @@ class FastMKS IPMetric distance; //! Candidate represents a possible candidate point (value, index). - typedef std::pair Candidate; + using Candidate = std::pair; //! Compare two candidates based on the value. struct CandidateCmp { @@ -343,8 +343,8 @@ class FastMKS }; //! Use a priority queue to represent the list of candidate points. - typedef std::priority_queue, - CandidateCmp> CandidateList; + using CandidateList = std::priority_queue, + CandidateCmp>; }; } // namespace mlpack diff --git a/src/mlpack/methods/fastmks/fastmks_impl.hpp b/src/mlpack/methods/fastmks/fastmks_impl.hpp index 6acd1014e0..7395a45610 100644 --- a/src/mlpack/methods/fastmks/fastmks_impl.hpp +++ b/src/mlpack/methods/fastmks/fastmks_impl.hpp @@ -472,7 +472,7 @@ void FastMKS::Search( { // Create rules object (this will store the results). This constructor // precalculates each self-kernel value. - typedef FastMKSRules RuleType; + using RuleType = FastMKSRules; RuleType rules(*referenceSet, querySet, k, distance.Kernel()); typename Tree::template SingleTreeTraverser traverser(rules); @@ -533,7 +533,7 @@ void FastMKS::Search( indices.set_size(k, queryTree->Dataset().n_cols); kernels.set_size(k, queryTree->Dataset().n_cols); - typedef FastMKSRules RuleType; + using RuleType = FastMKSRules; RuleType rules(*referenceSet, queryTree->Dataset(), k, distance.Kernel()); typename Tree::template DualTreeTraverser traverser(rules); @@ -602,7 +602,7 @@ void FastMKS::Search( { // Create rules object (this will store the results). This constructor // precalculates each self-kernel value. - typedef FastMKSRules RuleType; + using RuleType = FastMKSRules; RuleType rules(*referenceSet, *referenceSet, k, distance.Kernel()); typename Tree::template SingleTreeTraverser traverser(rules); diff --git a/src/mlpack/methods/fastmks/fastmks_rules.hpp b/src/mlpack/methods/fastmks/fastmks_rules.hpp index 706f7f4645..42c6e956c7 100644 --- a/src/mlpack/methods/fastmks/fastmks_rules.hpp +++ b/src/mlpack/methods/fastmks/fastmks_rules.hpp @@ -118,7 +118,7 @@ class FastMKSRules //! Modify the number of times Score() was called. size_t& Scores() { return scores; } - typedef typename mlpack::TraversalInfo TraversalInfoType; + using TraversalInfoType = mlpack::TraversalInfo; const TraversalInfoType& TraversalInfo() const { return traversalInfo; } TraversalInfoType& TraversalInfo() { return traversalInfo; } @@ -134,7 +134,7 @@ class FastMKSRules const typename TreeType::Mat& querySet; //! Candidate represents a possible candidate point (value, index). - typedef std::pair Candidate; + using Candidate = std::pair; //! Compare two candidates based on the value. struct CandidateCmp { diff --git a/src/mlpack/methods/fastmks/fastmks_rules_impl.hpp b/src/mlpack/methods/fastmks/fastmks_rules_impl.hpp index 30ac4ebbbc..4b9c506301 100644 --- a/src/mlpack/methods/fastmks/fastmks_rules_impl.hpp +++ b/src/mlpack/methods/fastmks/fastmks_rules_impl.hpp @@ -476,7 +476,7 @@ double FastMKSRules::CalculateBound(TreeType& queryNode) // where p_j^*(p_q) is the j'th kernel candidate for query point p_q and // k_j^*(p_q) is K(p_q, p_j^*(p_q)). double worstPointCandidateKernel = DBL_MAX; - typedef std::vector::const_iterator iter; + using iter = std::vector::const_iterator; for (iter it = candidatesPoints.begin(); it != candidatesPoints.end(); ++it) { const double candidateKernel = it->first - queryDescendantDistance * diff --git a/src/mlpack/methods/gmm/gmm_train_main.cpp b/src/mlpack/methods/gmm/gmm_train_main.cpp index 10cebd70a2..3cca718926 100644 --- a/src/mlpack/methods/gmm/gmm_train_main.cpp +++ b/src/mlpack/methods/gmm/gmm_train_main.cpp @@ -228,7 +228,7 @@ void BINDING_FUNCTION(util::Params& params, util::Timers& timers) const int samplings = params.Get("samplings"); const double percentage = params.Get("percentage"); - typedef KMeans KMeansType; + using KMeansType = KMeans; KMeansType k(kmeansMaxIterations, SquaredEuclideanDistance(), RefinedStart(samplings, percentage)); diff --git a/src/mlpack/methods/gmm/positive_definite_constraint.hpp b/src/mlpack/methods/gmm/positive_definite_constraint.hpp index 29d1e12f67..1353134502 100644 --- a/src/mlpack/methods/gmm/positive_definite_constraint.hpp +++ b/src/mlpack/methods/gmm/positive_definite_constraint.hpp @@ -37,8 +37,8 @@ class PositiveDefiniteConstraint MatType& covariance, const std::enable_if_t::value>* /* junk */ = 0) { - typedef typename MatType::elem_type ElemType; - typedef typename GetColType::type VecType; + using ElemType = typename MatType::elem_type; + using VecType = typename GetColType::type; // What we want to do is make sure that the matrix is positive definite and // that the condition number isn't too large. We also need to ensure that @@ -83,7 +83,7 @@ class PositiveDefiniteConstraint VecType& diagCovariance, const std::enable_if_t::value>* /* junk */ = 0) { - typedef typename VecType::elem_type ElemType; + using ElemType = typename VecType::elem_type; // If the matrix is not positive definite or if the condition number is // large, we must project it back onto the cone of positive definite diff --git a/src/mlpack/methods/hoeffding_trees/binary_numeric_split.hpp b/src/mlpack/methods/hoeffding_trees/binary_numeric_split.hpp index 71b75142ad..79a2733f81 100644 --- a/src/mlpack/methods/hoeffding_trees/binary_numeric_split.hpp +++ b/src/mlpack/methods/hoeffding_trees/binary_numeric_split.hpp @@ -47,7 +47,7 @@ class BinaryNumericSplit { public: //! The splitting information required by the BinaryNumericSplit. - typedef BinaryNumericSplitInfo SplitInfo; + using SplitInfo = BinaryNumericSplitInfo; /** * Create the BinaryNumericSplit object with the given number of classes. diff --git a/src/mlpack/methods/hoeffding_trees/hoeffding_categorical_split.hpp b/src/mlpack/methods/hoeffding_trees/hoeffding_categorical_split.hpp index f11d83c84f..4005140871 100644 --- a/src/mlpack/methods/hoeffding_trees/hoeffding_categorical_split.hpp +++ b/src/mlpack/methods/hoeffding_trees/hoeffding_categorical_split.hpp @@ -44,7 +44,7 @@ class HoeffdingCategoricalSplit { public: //! The type of split information required by the HoeffdingCategoricalSplit. - typedef CategoricalSplitInfo SplitInfo; + using SplitInfo = CategoricalSplitInfo; /** * Create the HoeffdingCategoricalSplit given a number of categories for this diff --git a/src/mlpack/methods/hoeffding_trees/hoeffding_numeric_split.hpp b/src/mlpack/methods/hoeffding_trees/hoeffding_numeric_split.hpp index 17c6d36f2b..cfe57c90b8 100644 --- a/src/mlpack/methods/hoeffding_trees/hoeffding_numeric_split.hpp +++ b/src/mlpack/methods/hoeffding_trees/hoeffding_numeric_split.hpp @@ -53,7 +53,7 @@ class HoeffdingNumericSplit { public: //! The splitting information type required by the HoeffdingNumericSplit. - typedef NumericSplitInfo SplitInfo; + using SplitInfo = NumericSplitInfo; /** * Create the HoeffdingNumericSplit class, and specify some basic parameters diff --git a/src/mlpack/methods/hoeffding_trees/hoeffding_tree.hpp b/src/mlpack/methods/hoeffding_trees/hoeffding_tree.hpp index 5b873235c8..b2143d9e17 100644 --- a/src/mlpack/methods/hoeffding_trees/hoeffding_tree.hpp +++ b/src/mlpack/methods/hoeffding_trees/hoeffding_tree.hpp @@ -68,9 +68,9 @@ class HoeffdingTree { public: //! Allow access to the numeric split type. - typedef NumericSplitType NumericSplit; + using NumericSplit = NumericSplitType; //! Allow access to the categorical split type. - typedef CategoricalSplitType CategoricalSplit; + using CategoricalSplit = CategoricalSplitType; /** * Construct a Hoeffding tree with no data and no information. Be sure to diff --git a/src/mlpack/methods/hoeffding_trees/hoeffding_tree_main.cpp b/src/mlpack/methods/hoeffding_trees/hoeffding_tree_main.cpp index deb192586f..6ded521931 100644 --- a/src/mlpack/methods/hoeffding_trees/hoeffding_tree_main.cpp +++ b/src/mlpack/methods/hoeffding_trees/hoeffding_tree_main.cpp @@ -133,7 +133,7 @@ PARAM_INT_IN("observations_before_binning", "If the 'domingos' split strategy " "performed.", "o", 100); // Convenience typedef. -typedef tuple TupleType; +using TupleType = tuple; void BINDING_FUNCTION(util::Params& params, util::Timers& timers) { diff --git a/src/mlpack/methods/hoeffding_trees/hoeffding_tree_model.hpp b/src/mlpack/methods/hoeffding_trees/hoeffding_tree_model.hpp index ac8f62fdae..c69e4b4f37 100644 --- a/src/mlpack/methods/hoeffding_trees/hoeffding_tree_model.hpp +++ b/src/mlpack/methods/hoeffding_trees/hoeffding_tree_model.hpp @@ -37,17 +37,17 @@ class HoeffdingTreeModel }; //! Convenience typedef for GINI_HOEFFDING tree type. - typedef HoeffdingTree GiniHoeffdingTreeType; + using GiniHoeffdingTreeType = HoeffdingTree; //! Convenience typedef for GINI_BINARY tree type. - typedef HoeffdingTree GiniBinaryTreeType; + using GiniBinaryTreeType = HoeffdingTree; //! Convenience typedef for INFO_HOEFFDING tree type. - typedef HoeffdingTree InfoHoeffdingTreeType; + using InfoHoeffdingTreeType = HoeffdingTree; //! Convenience typedef for INFO_BINARY tree type. - typedef HoeffdingTree InfoBinaryTreeType; + using InfoBinaryTreeType = HoeffdingTree; /** * Construct the Hoeffding tree model, but don't initialize any tree. diff --git a/src/mlpack/methods/hoeffding_trees/typedef.hpp b/src/mlpack/methods/hoeffding_trees/typedef.hpp index 20dab2471a..614123cc49 100644 --- a/src/mlpack/methods/hoeffding_trees/typedef.hpp +++ b/src/mlpack/methods/hoeffding_trees/typedef.hpp @@ -17,7 +17,7 @@ namespace mlpack { -typedef StreamingDecisionTree> HoeffdingTreeType; +using HoeffdingTreeType = StreamingDecisionTree>; } // namespace mlpack diff --git a/src/mlpack/methods/kde/kde.hpp b/src/mlpack/methods/kde/kde.hpp index 9b13f9e767..8c4e519a97 100644 --- a/src/mlpack/methods/kde/kde.hpp +++ b/src/mlpack/methods/kde/kde.hpp @@ -85,7 +85,7 @@ class KDE { public: //! Convenience typedef. - typedef TreeType Tree; + using Tree = TreeType; /** * Initialize KDE object using custom instantiated Metric and Kernel objects. diff --git a/src/mlpack/methods/kde/kde_impl.hpp b/src/mlpack/methods/kde/kde_impl.hpp index 6e5fe10fed..de89f41a71 100644 --- a/src/mlpack/methods/kde/kde_impl.hpp +++ b/src/mlpack/methods/kde/kde_impl.hpp @@ -413,7 +413,7 @@ Evaluate(MatType querySet, arma::vec& estimations) } // Evaluate. - typedef KDERules RuleType; + using RuleType = KDERules; RuleType rules = RuleType(referenceTree->Dataset(), querySet, estimations, @@ -506,7 +506,7 @@ Evaluate(Tree* queryTree, } // Evaluate. - typedef KDERules RuleType; + using RuleType = KDERules; RuleType rules = RuleType(referenceTree->Dataset(), queryTree->Dataset(), estimations, @@ -570,7 +570,7 @@ Evaluate(arma::vec& estimations) } // Evaluate. - typedef KDERules RuleType; + using RuleType = KDERules; RuleType rules = RuleType(referenceTree->Dataset(), referenceTree->Dataset(), estimations, diff --git a/src/mlpack/methods/kde/kde_model.hpp b/src/mlpack/methods/kde/kde_model.hpp index e520405f14..b2987ec883 100644 --- a/src/mlpack/methods/kde/kde_model.hpp +++ b/src/mlpack/methods/kde/kde_model.hpp @@ -212,7 +212,7 @@ class KDEWrapper : public KDEWrapperBase } protected: - typedef KDE KDEType; + using KDEType = KDE; //! The instantiated KDE object that we are wrapping. KDEType kde; diff --git a/src/mlpack/methods/kde/kde_rules.hpp b/src/mlpack/methods/kde/kde_rules.hpp index 1a77894c40..8b2bc7e412 100644 --- a/src/mlpack/methods/kde/kde_rules.hpp +++ b/src/mlpack/methods/kde/kde_rules.hpp @@ -78,7 +78,7 @@ class KDERules TreeType& referenceNode, const double oldScore) const; - typedef typename mlpack::TraversalInfo TraversalInfoType; + using TraversalInfoType = mlpack::TraversalInfo; //! Get traversal information. const TraversalInfoType& TraversalInfo() const { return traversalInfo; } @@ -210,7 +210,7 @@ class KDECleanRules TreeType& /* referenceNode*/ , const double oldScore) const { return oldScore; } - typedef typename mlpack::TraversalInfo TraversalInfoType; + using TraversalInfoType = mlpack::TraversalInfo; //! Get traversal information. const TraversalInfoType& TraversalInfo() const { return traversalInfo; } diff --git a/src/mlpack/methods/kmeans/dual_tree_kmeans.hpp b/src/mlpack/methods/kmeans/dual_tree_kmeans.hpp index 5897ff1b04..abafe87a43 100644 --- a/src/mlpack/methods/kmeans/dual_tree_kmeans.hpp +++ b/src/mlpack/methods/kmeans/dual_tree_kmeans.hpp @@ -41,7 +41,7 @@ class DualTreeKMeans { public: //! Convenience typedef. - typedef TreeType Tree; + using Tree = TreeType; template::Iterate( // We won't use the KNN class here because we have our own set of rules. lastIterationCentroids = centroids; - typedef DualTreeKMeansRules RuleType; + using RuleType = DualTreeKMeansRules; RuleType rules(nns.ReferenceTree().Dataset(), dataset, assignments, upperBounds, lowerBounds, distance, prunedPoints, oldFromNewCentroids, visited); diff --git a/src/mlpack/methods/kmeans/dual_tree_kmeans_rules.hpp b/src/mlpack/methods/kmeans/dual_tree_kmeans_rules.hpp index 47080c0396..0d8f2583e4 100644 --- a/src/mlpack/methods/kmeans/dual_tree_kmeans_rules.hpp +++ b/src/mlpack/methods/kmeans/dual_tree_kmeans_rules.hpp @@ -43,7 +43,7 @@ class DualTreeKMeansRules TreeType& referenceNode, const double oldScore); - typedef typename mlpack::TraversalInfo TraversalInfoType; + using TraversalInfoType = mlpack::TraversalInfo; TraversalInfoType& TraversalInfo() { return traversalInfo; } const TraversalInfoType& TraversalInfo() const { return traversalInfo; } diff --git a/src/mlpack/methods/kmeans/pelleg_moore_kmeans.hpp b/src/mlpack/methods/kmeans/pelleg_moore_kmeans.hpp index e7e4f9e444..baee13f960 100644 --- a/src/mlpack/methods/kmeans/pelleg_moore_kmeans.hpp +++ b/src/mlpack/methods/kmeans/pelleg_moore_kmeans.hpp @@ -69,7 +69,7 @@ class PellegMooreKMeans size_t& DistanceCalculations() { return distanceCalculations; } //! Convenience typedef for the tree. - typedef KDTree TreeType; + using TreeType = KDTree; private: //! The original dataset reference. diff --git a/src/mlpack/methods/kmeans/pelleg_moore_kmeans_impl.hpp b/src/mlpack/methods/kmeans/pelleg_moore_kmeans_impl.hpp index b28fc214cd..a88fbc7319 100644 --- a/src/mlpack/methods/kmeans/pelleg_moore_kmeans_impl.hpp +++ b/src/mlpack/methods/kmeans/pelleg_moore_kmeans_impl.hpp @@ -49,7 +49,7 @@ double PellegMooreKMeans::Iterate( counts.zeros(centroids.n_cols); // Create rules object. - typedef PellegMooreKMeansRules RulesType; + using RulesType = PellegMooreKMeansRules; RulesType rules(dataset, centroids, newCentroids, counts, distance); // Use single-tree traverser. diff --git a/src/mlpack/methods/lars/lars.hpp b/src/mlpack/methods/lars/lars.hpp index 0700b686f5..d5106c909e 100644 --- a/src/mlpack/methods/lars/lars.hpp +++ b/src/mlpack/methods/lars/lars.hpp @@ -86,9 +86,9 @@ template class LARS { public: - typedef typename GetColType::type ModelColType; - typedef typename GetDenseMatType::type DenseMatType; - typedef typename ModelMatType::elem_type ElemType; + using ModelColType = typename GetColType::type; + using DenseMatType = typename GetDenseMatType::type; + using ElemType = typename ModelMatType::elem_type; /** * Set the parameters to LARS. Both lambda1 and lambda2 default to 0. diff --git a/src/mlpack/methods/linear_regression/linear_regression.hpp b/src/mlpack/methods/linear_regression/linear_regression.hpp index d36c855d7d..b8425d6463 100644 --- a/src/mlpack/methods/linear_regression/linear_regression.hpp +++ b/src/mlpack/methods/linear_regression/linear_regression.hpp @@ -30,8 +30,8 @@ template class LinearRegression { public: - typedef typename GetColType::type ModelColType; - typedef typename ModelMatType::elem_type ElemType; + using ModelColType = typename GetColType::type; + using ElemType = typename ModelMatType::elem_type; /** * Creates the model. diff --git a/src/mlpack/methods/linear_svm/linear_svm.hpp b/src/mlpack/methods/linear_svm/linear_svm.hpp index dd680da97b..3ecfbb1c21 100644 --- a/src/mlpack/methods/linear_svm/linear_svm.hpp +++ b/src/mlpack/methods/linear_svm/linear_svm.hpp @@ -79,9 +79,9 @@ template class LinearSVM { public: - typedef typename ModelMatType::elem_type ElemType; - typedef typename GetDenseMatType::type DenseMatType; - typedef typename GetDenseColType::type DenseColType; + using ElemType = typename ModelMatType::elem_type; + using DenseMatType = typename GetDenseMatType::type; + using DenseColType = typename GetDenseColType::type; /** * Initialize the Linear SVM without performing training. Default diff --git a/src/mlpack/methods/linear_svm/linear_svm_function.hpp b/src/mlpack/methods/linear_svm/linear_svm_function.hpp index 20ef0cc24b..909e9412f9 100644 --- a/src/mlpack/methods/linear_svm/linear_svm_function.hpp +++ b/src/mlpack/methods/linear_svm/linear_svm_function.hpp @@ -27,11 +27,11 @@ template class LinearSVMFunction { public: - typedef typename ParametersType::elem_type ElemType; - typedef typename GetDenseMatType::type DenseMatType; - typedef typename GetSparseMatType::type SparseMatType; - typedef typename GetDenseColType::type DenseColType; - typedef typename GetDenseRowType::type DenseRowType; + using ElemType = typename ParametersType::elem_type; + using DenseMatType = typename GetDenseMatType::type; + using SparseMatType = typename GetSparseMatType::type; + using DenseColType = typename GetDenseColType::type; + using DenseRowType = typename GetDenseRowType::type; /** * Construct the Linear SVM objective function with given parameters. diff --git a/src/mlpack/methods/lmnn/constraints.hpp b/src/mlpack/methods/lmnn/constraints.hpp index 7704d239fe..ad632214f3 100644 --- a/src/mlpack/methods/lmnn/constraints.hpp +++ b/src/mlpack/methods/lmnn/constraints.hpp @@ -34,18 +34,18 @@ class Constraints { public: //! Convenience typedef. - typedef NeighborSearch KNN; + using KNN = NeighborSearch; // Convenience typedef for element type of data. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; // Convenience typedef for column vector of data. - typedef typename GetColType::type VecType; + using VecType = typename GetColType::type; // Convenience typedef for cube of data. - typedef typename GetCubeType::type CubeType; + using CubeType = typename GetCubeType::type; // Convenience typedef for dense matrix of indices. - typedef typename GetUDenseMatType::type UMatType; + using UMatType = typename GetUDenseMatType::type; // Convenience typedef for dense vector of indices. - typedef typename GetColType::type UVecType; + using UVecType = typename GetColType::type; /** * Constructor for creating a Constraints instance. diff --git a/src/mlpack/methods/lmnn/constraints_impl.hpp b/src/mlpack/methods/lmnn/constraints_impl.hpp index 74014f061e..c99a4cfeda 100644 --- a/src/mlpack/methods/lmnn/constraints_impl.hpp +++ b/src/mlpack/methods/lmnn/constraints_impl.hpp @@ -402,7 +402,7 @@ void Constraints::Triplets( UMatType impostors(k, dataset.n_cols); Impostors(impostors, dataset, labels, norms); - UMatType targetNeighbors(k, dataset.n_cols);; + UMatType targetNeighbors(k, dataset.n_cols); TargetNeighbors(targetNeighbors, dataset, labels, norms); outputMatrix = UMatType(3, k * k * N); diff --git a/src/mlpack/methods/lmnn/lmnn_function.hpp b/src/mlpack/methods/lmnn/lmnn_function.hpp index e64b8ae0d0..07107b3b6f 100644 --- a/src/mlpack/methods/lmnn/lmnn_function.hpp +++ b/src/mlpack/methods/lmnn/lmnn_function.hpp @@ -47,15 +47,15 @@ template::type VecType; + using VecType = typename GetColType::type; // Convenience typedef for cube of data. - typedef typename GetCubeType::type CubeType; + using CubeType = typename GetCubeType::type; // Convenience typedef for dense matrix of indices. - typedef typename GetUDenseMatType::type UMatType; + using UMatType = typename GetUDenseMatType::type; // Convenience typedef for dense vector of indices. - typedef typename GetColType::type UVecType; + using UVecType = typename GetColType::type; public: /** diff --git a/src/mlpack/methods/local_coordinate_coding/lcc.hpp b/src/mlpack/methods/local_coordinate_coding/lcc.hpp index 11b96d53b3..f464a5db7d 100644 --- a/src/mlpack/methods/local_coordinate_coding/lcc.hpp +++ b/src/mlpack/methods/local_coordinate_coding/lcc.hpp @@ -79,8 +79,8 @@ template class LocalCoordinateCoding { public: - typedef typename GetColType::type ColType; - typedef typename GetRowType::type RowType; + using ColType = typename GetColType::type; + using RowType = typename GetRowType::type; /** * Set the parameters to LocalCoordinateCoding, and train the dictionary. diff --git a/src/mlpack/methods/logistic_regression/logistic_regression.hpp b/src/mlpack/methods/logistic_regression/logistic_regression.hpp index 6dd06dbd00..1879468327 100644 --- a/src/mlpack/methods/logistic_regression/logistic_regression.hpp +++ b/src/mlpack/methods/logistic_regression/logistic_regression.hpp @@ -37,9 +37,9 @@ template class LogisticRegression { public: - typedef typename MatType::elem_type ElemType; - typedef typename GetDenseRowType::type RowType; - typedef typename GetDenseColType::type ColType; + using ElemType = typename MatType::elem_type; + using RowType = typename GetDenseRowType::type; + using ColType = typename GetDenseColType::type; /** * Construct the LogisticRegression class without performing any training. diff --git a/src/mlpack/methods/logistic_regression/logistic_regression_function_impl.hpp b/src/mlpack/methods/logistic_regression/logistic_regression_function_impl.hpp index 1489bc820c..cd0fe75fb0 100644 --- a/src/mlpack/methods/logistic_regression/logistic_regression_function_impl.hpp +++ b/src/mlpack/methods/logistic_regression/logistic_regression_function_impl.hpp @@ -77,7 +77,7 @@ LogisticRegressionFunction::Evaluate( // f(w) = sum(y log(sig(w'x)) + (1 - y) log(sig(1 - w'x))). // We want to minimize this function. L2-regularization is just lambda // multiplied by the squared l2-norm of the parameters then divided by two. - typedef typename CoordinatesType::elem_type ElemType; + using ElemType = typename CoordinatesType::elem_type; // Specifying these here makes the code below a little bit cleaner, and avoids // accidentally casting an entire expression to `double`, e.g., by the use of @@ -123,7 +123,7 @@ LogisticRegressionFunction::Evaluate( const size_t begin, const size_t batchSize) const { - typedef typename CoordinatesType::elem_type ElemType; + using ElemType = typename CoordinatesType::elem_type; // Specifying these here makes the code below a little bit cleaner, and avoids // accidentally casting an entire expression to `double`, e.g., by the use of @@ -159,7 +159,7 @@ void LogisticRegressionFunction::Gradient( const CoordinatesType& parameters, GradType& gradient) const { - typedef typename CoordinatesType::elem_type ElemType; + using ElemType = typename CoordinatesType::elem_type; // Regularization term. GradType regularization; @@ -189,7 +189,7 @@ void LogisticRegressionFunction::Gradient( GradType& gradient, const size_t batchSize) const { - typedef typename CoordinatesType::elem_type ElemType; + using ElemType = typename CoordinatesType::elem_type; // Regularization term. GradType regularization; @@ -226,7 +226,7 @@ void LogisticRegressionFunction::PartialGradient( const size_t j, GradType& gradient) const { - typedef typename CoordinatesType::elem_type ElemType; + using ElemType = typename CoordinatesType::elem_type; // Specifying this here makes the code below a little bit cleaner, and avoids // accidentally casting an entire expression to `double`, e.g., by the use of @@ -256,7 +256,7 @@ LogisticRegressionFunction::EvaluateWithGradient( const CoordinatesType& parameters, GradType& gradient) const { - typedef typename CoordinatesType::elem_type ElemType; + using ElemType = typename CoordinatesType::elem_type; // Specifying these here makes the code below a little bit cleaner, and avoids // accidentally casting an entire expression to `double`, e.g., by the use of @@ -299,7 +299,7 @@ LogisticRegressionFunction::EvaluateWithGradient( GradType& gradient, const size_t batchSize) const { - typedef typename CoordinatesType::elem_type ElemType; + using ElemType = typename CoordinatesType::elem_type; // Specifying these here makes the code below a little bit cleaner, and avoids // accidentally casting an entire expression to `double`, e.g., by the use of diff --git a/src/mlpack/methods/lsh/lsh_search.hpp b/src/mlpack/methods/lsh/lsh_search.hpp index f8f7a2d37b..6be0b2e06a 100644 --- a/src/mlpack/methods/lsh/lsh_search.hpp +++ b/src/mlpack/methods/lsh/lsh_search.hpp @@ -462,7 +462,7 @@ class LSHSearch size_t distanceEvaluations; //! Candidate represents a possible candidate neighbor (distance, index). - typedef std::pair Candidate; + using Candidate = std::pair; //! Compare two candidates based on the distance. struct CandidateCmp { @@ -473,8 +473,8 @@ class LSHSearch }; //! Use a priority queue to represent the list of candidate neighbors. - typedef std::priority_queue, CandidateCmp> - CandidateList; + using CandidateList = std::priority_queue, + CandidateCmp>; }; // class LSHSearch } // namespace mlpack diff --git a/src/mlpack/methods/mean_shift/mean_shift_impl.hpp b/src/mlpack/methods/mean_shift/mean_shift_impl.hpp index 9c8faa7154..f2888339bb 100644 --- a/src/mlpack/methods/mean_shift/mean_shift_impl.hpp +++ b/src/mlpack/methods/mean_shift/mean_shift_impl.hpp @@ -94,8 +94,8 @@ void MeanShift::GenSeeds(const MatType& data, const int minFreq, CentroidsType& seeds) { - typedef typename GetColType::type VecType; - typedef typename GetColType::type CentroidVecType; + using VecType = typename GetColType::type; + using CentroidVecType = typename GetColType::type; std::map > allSeeds; for (size_t i = 0; i < data.n_cols; ++i) { @@ -138,7 +138,7 @@ MeanShift::CalculateCentroid( const std::vector& distances, VecType& centroid) { - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; ElemType sumWeight = 0; for (size_t i = 0; i < neighbors.size(); ++i) @@ -189,8 +189,8 @@ inline void MeanShift::Cluster( bool useSeeds) { // Convenience typedefs. - typedef typename MatType::elem_type ElemType; - typedef typename GetColType::type VecType; + using ElemType = typename MatType::elem_type; + using VecType = typename GetColType::type; if (radius <= 0) { diff --git a/src/mlpack/methods/naive_bayes/naive_bayes_classifier.hpp b/src/mlpack/methods/naive_bayes/naive_bayes_classifier.hpp index c11887aa04..d92d248d2f 100644 --- a/src/mlpack/methods/naive_bayes/naive_bayes_classifier.hpp +++ b/src/mlpack/methods/naive_bayes/naive_bayes_classifier.hpp @@ -58,7 +58,7 @@ class NaiveBayesClassifier { public: // Convenience typedef. - typedef typename ModelMatType::elem_type ElemType; + using ElemType = typename ModelMatType::elem_type; /** * Initializes the classifier as per the input and then trains it by diff --git a/src/mlpack/methods/nca/nca_softmax_error_function.hpp b/src/mlpack/methods/nca/nca_softmax_error_function.hpp index 88237d88b3..babfbc7f6c 100644 --- a/src/mlpack/methods/nca/nca_softmax_error_function.hpp +++ b/src/mlpack/methods/nca/nca_softmax_error_function.hpp @@ -47,9 +47,9 @@ class SoftmaxErrorFunction { public: // Convenience typedef for element type of data. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; // Convenience typedef for column vector of data. - typedef typename GetColType::type VecType; + using VecType = typename GetColType::type; /** * Initialize with the given kernel; useful when the kernel has some state to diff --git a/src/mlpack/methods/neighbor_search/kfn_main.cpp b/src/mlpack/methods/neighbor_search/kfn_main.cpp index 65fdb6e870..d14a109a0f 100644 --- a/src/mlpack/methods/neighbor_search/kfn_main.cpp +++ b/src/mlpack/methods/neighbor_search/kfn_main.cpp @@ -26,7 +26,7 @@ using namespace mlpack; using namespace mlpack::util; // Convenience typedef. -typedef NSModel KFNModel; +using KFNModel = NSModel; // Program Name. BINDING_USER_NAME("k-Furthest-Neighbors Search"); diff --git a/src/mlpack/methods/neighbor_search/knn_main.cpp b/src/mlpack/methods/neighbor_search/knn_main.cpp index 06e7912ee6..72f463ff38 100644 --- a/src/mlpack/methods/neighbor_search/knn_main.cpp +++ b/src/mlpack/methods/neighbor_search/knn_main.cpp @@ -26,7 +26,7 @@ using namespace mlpack; using namespace mlpack::util; // Convenience typedef. -typedef NSModel KNNModel; +using KNNModel = NSModel; // Program Name. BINDING_USER_NAME("k-Nearest-Neighbors Search"); diff --git a/src/mlpack/methods/neighbor_search/neighbor_search.hpp b/src/mlpack/methods/neighbor_search/neighbor_search.hpp index d2470b1b19..357dd90efd 100644 --- a/src/mlpack/methods/neighbor_search/neighbor_search.hpp +++ b/src/mlpack/methods/neighbor_search/neighbor_search.hpp @@ -81,9 +81,9 @@ class NeighborSearch { public: //! Convenience typedef. - typedef TreeType, MatType> Tree; + using Tree = TreeType, MatType>; //! The type of element held in MatType. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; /** * Initialize the NeighborSearch object, passing a reference dataset (this is diff --git a/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp b/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp index f20807731f..a104b16607 100644 --- a/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp +++ b/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp @@ -411,7 +411,7 @@ DualTreeTraversalType, SingleTreeTraversalType>::Search( neighborPtr->set_size(k, querySet.n_cols); distancePtr->set_size(k, querySet.n_cols); - typedef NeighborSearchRules RuleType; + using RuleType = NeighborSearchRules; switch (searchMode) { @@ -610,7 +610,7 @@ DualTreeTraversalType, SingleTreeTraversalType>::Search( distances.set_size(k, querySet.n_cols); // Create the helper object for the traversal. - typedef NeighborSearchRules RuleType; + using RuleType = NeighborSearchRules; RuleType rules(*referenceSet, querySet, k, distance, epsilon, sameSet); // Create the traverser. @@ -693,7 +693,7 @@ DualTreeTraversalType, SingleTreeTraversalType>::Search( distancePtr->set_size(k, referenceSet->n_cols); // Create the helper object for the traversal. - typedef NeighborSearchRules RuleType; + using RuleType = NeighborSearchRules; RuleType rules(*referenceSet, *referenceSet, k, distance, epsilon, true /* don't return the same point as nearest neighbor */); diff --git a/src/mlpack/methods/neighbor_search/neighbor_search_rules.hpp b/src/mlpack/methods/neighbor_search/neighbor_search_rules.hpp index 057515ca7a..1dbb2d2b94 100644 --- a/src/mlpack/methods/neighbor_search/neighbor_search_rules.hpp +++ b/src/mlpack/methods/neighbor_search/neighbor_search_rules.hpp @@ -35,7 +35,7 @@ class NeighborSearchRules { public: //! The type of element held in MatType. - typedef typename TreeType::Mat::elem_type ElemType; + using ElemType = typename TreeType::Mat::elem_type; /** * Construct the NeighborSearchRules object. This is usually done from within @@ -155,7 +155,7 @@ class NeighborSearchRules size_t& Scores() { return scores; } //! Convenience typedef. - typedef typename mlpack::TraversalInfo TraversalInfoType; + using TraversalInfoType = mlpack::TraversalInfo; //! Get the traversal info. const TraversalInfoType& TraversalInfo() const { return traversalInfo; } @@ -174,7 +174,7 @@ class NeighborSearchRules const typename TreeType::Mat& querySet; //! Candidate represents a possible candidate neighbor (distance, index). - typedef std::pair Candidate; + using Candidate = std::pair; //! Compare two candidates based on the distance. struct CandidateCmp { @@ -185,8 +185,8 @@ class NeighborSearchRules }; //! Use a priority queue to represent the list of candidate neighbors. - typedef std::priority_queue, CandidateCmp> - CandidateList; + using CandidateList = std::priority_queue, + CandidateCmp>; //! Set of candidate neighbors for each point. std::vector candidates; diff --git a/src/mlpack/methods/neighbor_search/ns_model.hpp b/src/mlpack/methods/neighbor_search/ns_model.hpp index cf5e9338c5..b01059d9e7 100644 --- a/src/mlpack/methods/neighbor_search/ns_model.hpp +++ b/src/mlpack/methods/neighbor_search/ns_model.hpp @@ -164,12 +164,12 @@ class NSWrapper : public NSWrapperBase protected: // Convenience typedef for the neighbor search type held by this class. - typedef NeighborSearch NSType; + using NSType = NeighborSearch; //! The instantiated NeighborSearch object that we are wrapping. NSType ns; diff --git a/src/mlpack/methods/neighbor_search/typedef.hpp b/src/mlpack/methods/neighbor_search/typedef.hpp index c66db6b026..5ed8b7ed3e 100644 --- a/src/mlpack/methods/neighbor_search/typedef.hpp +++ b/src/mlpack/methods/neighbor_search/typedef.hpp @@ -28,13 +28,13 @@ namespace mlpack { * The KNN class is the k-nearest-neighbors method. It returns L2 distances * (Euclidean distances) for each of the k nearest neighbors. */ -typedef NeighborSearch KNN; +using KNN = NeighborSearch; /** * The KFN class is the k-furthest-neighbors method. It returns L2 distances * (Euclidean distances) for each of the k furthest neighbors. */ -typedef NeighborSearch KFN; +using KFN = NeighborSearch; /** * The DefeatistKNN class is the k-nearest-neighbors method considering @@ -63,7 +63,7 @@ using DefeatistKNN = NeighborSearch< * search on SPTree. It returns L2 distances (Euclidean distances) for each of * the k nearest neighbors found. */ -typedef DefeatistKNN SpillKNN; +using SpillKNN = DefeatistKNN; } // namespace mlpack diff --git a/src/mlpack/methods/pca/pca_impl.hpp b/src/mlpack/methods/pca/pca_impl.hpp index d4d4784036..bb511ba6ac 100644 --- a/src/mlpack/methods/pca/pca_impl.hpp +++ b/src/mlpack/methods/pca/pca_impl.hpp @@ -111,7 +111,7 @@ void PCA::Apply(const MatType& data, // It's possible a user didn't pass in a matrix but instead an expression, but // we need a type that we can store. - typedef typename GetDenseColType::type BaseColType; + using BaseColType = typename GetDenseColType::type; OutMatType eigvec; BaseColType eigVal; @@ -152,8 +152,8 @@ double PCA::Apply(const MatType& data, throw std::invalid_argument(oss.str()); } - typedef typename GetDenseMatType::type BaseMatType; - typedef typename GetDenseColType::type BaseColType; + using BaseMatType = typename GetDenseMatType::type; + using BaseColType = typename GetDenseColType::type; BaseMatType eigvec; BaseColType eigVal; @@ -231,8 +231,8 @@ double PCA::Apply(const MatType& data, throw std::invalid_argument(oss.str()); } - typedef typename GetDenseMatType::type BaseMatType; - typedef typename GetDenseColType::type BaseColType; + using BaseMatType = typename GetDenseMatType::type; + using BaseColType = typename GetDenseColType::type; BaseMatType eigvec; BaseColType eigVal; diff --git a/src/mlpack/methods/perceptron/perceptron.hpp b/src/mlpack/methods/perceptron/perceptron.hpp index dccc250975..6ef6954e5f 100644 --- a/src/mlpack/methods/perceptron/perceptron.hpp +++ b/src/mlpack/methods/perceptron/perceptron.hpp @@ -35,7 +35,7 @@ class Perceptron { public: //! The element type used in the Perceptron. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; /** * Constructor: create the perceptron with the given number of classes and diff --git a/src/mlpack/methods/radical/radical_impl.hpp b/src/mlpack/methods/radical/radical_impl.hpp index 3fbc67b3d2..6926919c99 100644 --- a/src/mlpack/methods/radical/radical_impl.hpp +++ b/src/mlpack/methods/radical/radical_impl.hpp @@ -45,7 +45,7 @@ inline typename VecType::elem_type Radical::Vasicek( VecType& z, const size_t m) const { - typedef typename VecType::elem_type ElemType; + using ElemType = typename VecType::elem_type; z = sort(z); @@ -75,8 +75,8 @@ inline typename MatType::elem_type Radical::Apply2D(const MatType& matX, MatType& candidate, util::Timers& timers) { - typedef typename GetColType::type VecType; - typedef typename MatType::elem_type ElemType; + using VecType = typename GetColType::type; + using ElemType = typename MatType::elem_type; timers.Start("radical_copy_and_perturb"); CopyAndPerturb(perturbed, matX); @@ -123,7 +123,7 @@ inline void Radical::Apply(const MatType& matXT, MatType& matW, util::Timers& timers) { - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; // matX is nPoints by nDims (although less intuitive than columns being // points, and although this is the transpose of the ICA literature, this @@ -232,7 +232,7 @@ inline void WhitenFeatureMajorMatrix(const MatType& matX, MatType& matXWhitened, MatType& matWhitening) { - typedef typename GetColType::type VecType; + using VecType = typename GetColType::type; MatType matU, matV; VecType s; diff --git a/src/mlpack/methods/random_forest/random_forest.hpp b/src/mlpack/methods/random_forest/random_forest.hpp index 9d3e79e01f..293be71644 100644 --- a/src/mlpack/methods/random_forest/random_forest.hpp +++ b/src/mlpack/methods/random_forest/random_forest.hpp @@ -43,8 +43,8 @@ class RandomForest { public: //! Allow access to the underlying decision tree type. - typedef DecisionTree DecisionTreeType; + using DecisionTreeType = DecisionTree; /** * Construct the random forest without any training or specifying the number diff --git a/src/mlpack/methods/range_search/range_search.hpp b/src/mlpack/methods/range_search/range_search.hpp index 11203091c0..28bb46b37f 100644 --- a/src/mlpack/methods/range_search/range_search.hpp +++ b/src/mlpack/methods/range_search/range_search.hpp @@ -45,11 +45,11 @@ class RangeSearch { public: //! Convenience typedef. - typedef TreeType Tree; + using Tree = TreeType; //! The type of Matrix. - typedef MatType Mat; + using Mat = MatType; //! The type of element held in MatType. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; /** * Initialize the RangeSearch object with a given reference dataset (this is diff --git a/src/mlpack/methods/range_search/range_search_impl.hpp b/src/mlpack/methods/range_search/range_search_impl.hpp index cbc2929660..849788bad5 100644 --- a/src/mlpack/methods/range_search/range_search_impl.hpp +++ b/src/mlpack/methods/range_search/range_search_impl.hpp @@ -332,7 +332,7 @@ void RangeSearch::Search( distancePtr->resize(querySet.n_cols); // Create the helper object for the traversal. - typedef RangeSearchRules RuleType; + using RuleType = RangeSearchRules; // Reset counts. baseCases = 0; @@ -486,7 +486,7 @@ void RangeSearch::Search( distances.resize(querySet.n_cols); // Create the helper object for the traversal. - typedef RangeSearchRules RuleType; + using RuleType = RangeSearchRules; RuleType rules(*referenceSet, queryTree->Dataset(), range, *neighborPtr, distances, distance); @@ -549,7 +549,7 @@ void RangeSearch::Search( distancePtr->resize(referenceSet->n_cols); // Create the helper object for the traversal. - typedef RangeSearchRules RuleType; + using RuleType = RangeSearchRules; RuleType rules(*referenceSet, *referenceSet, range, *neighborPtr, *distancePtr, distance, true /* don't return the query in the results */); diff --git a/src/mlpack/methods/range_search/range_search_rules.hpp b/src/mlpack/methods/range_search/range_search_rules.hpp index 5777cd7487..e910e744c2 100644 --- a/src/mlpack/methods/range_search/range_search_rules.hpp +++ b/src/mlpack/methods/range_search/range_search_rules.hpp @@ -28,9 +28,9 @@ class RangeSearchRules { public: //! Easy access to MatType. - typedef typename TreeType::Mat MatType; + using MatType = typename TreeType::Mat; //! The type of element held in MatType. - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; /** * Construct the RangeSearchRules object. This is usually done from within @@ -111,7 +111,7 @@ class RangeSearchRules TreeType& referenceNode, const ElemType oldScore) const; - typedef typename mlpack::TraversalInfo TraversalInfoType; + using TraversalInfoType = mlpack::TraversalInfo; const TraversalInfoType& TraversalInfo() const { return traversalInfo; } TraversalInfoType& TraversalInfo() { return traversalInfo; } diff --git a/src/mlpack/methods/range_search/rs_model.hpp b/src/mlpack/methods/range_search/rs_model.hpp index 4753c80668..40865cc553 100644 --- a/src/mlpack/methods/range_search/rs_model.hpp +++ b/src/mlpack/methods/range_search/rs_model.hpp @@ -145,7 +145,7 @@ class RSWrapper : public RSWrapperBase } protected: - typedef RangeSearch RSType; + using RSType = RangeSearch; //! The instantiated RangeSearch object that we are wrapping. RSType rs; diff --git a/src/mlpack/methods/rann/ra_model.hpp b/src/mlpack/methods/rann/ra_model.hpp index 9e31c04176..651e44bf92 100644 --- a/src/mlpack/methods/rann/ra_model.hpp +++ b/src/mlpack/methods/rann/ra_model.hpp @@ -193,10 +193,10 @@ class RAWrapper : public RAWrapperBase } protected: - typedef RASearch RAType; + using RAType = RASearch; //! The instantiated RASearch object that we are wrapping. RAType ra; diff --git a/src/mlpack/methods/rann/ra_search.hpp b/src/mlpack/methods/rann/ra_search.hpp index 2bed1d61a8..8039a7cb3d 100644 --- a/src/mlpack/methods/rann/ra_search.hpp +++ b/src/mlpack/methods/rann/ra_search.hpp @@ -74,7 +74,7 @@ class RASearch { public: //! Convenience typedef. - typedef TreeType, MatType> Tree; + using Tree = TreeType, MatType>; /** * Initialize the RASearch object, passing both a reference dataset (this is diff --git a/src/mlpack/methods/rann/ra_search_impl.hpp b/src/mlpack/methods/rann/ra_search_impl.hpp index e766808a91..f6810c068a 100644 --- a/src/mlpack/methods/rann/ra_search_impl.hpp +++ b/src/mlpack/methods/rann/ra_search_impl.hpp @@ -260,7 +260,7 @@ Search(const MatType& querySet, neighborPtr->set_size(k, querySet.n_cols); distancePtr->set_size(k, querySet.n_cols); - typedef RASearchRules RuleType; + using RuleType = RASearchRules; if (naive) { @@ -424,7 +424,7 @@ void RASearch::Search( distances.set_size(k, querySet.n_cols); // Create the helper object for the tree traversal. - typedef RASearchRules RuleType; + using RuleType = RASearchRules; RuleType rules(*referenceSet, queryTree->Dataset(), k, distance, tau, alpha, naive, sampleAtLeaves, firstLeafExact, singleSampleLimit, false); @@ -476,7 +476,7 @@ void RASearch::Search( distancePtr->set_size(k, referenceSet->n_cols); // Create the helper object for the tree traversal. - typedef RASearchRules RuleType; + using RuleType = RASearchRules; RuleType rules(*referenceSet, *referenceSet, k, distance, tau, alpha, naive, sampleAtLeaves, firstLeafExact, singleSampleLimit, true /* same sets */); diff --git a/src/mlpack/methods/rann/ra_search_rules.hpp b/src/mlpack/methods/rann/ra_search_rules.hpp index da203b0c91..a4dc948ca1 100644 --- a/src/mlpack/methods/rann/ra_search_rules.hpp +++ b/src/mlpack/methods/rann/ra_search_rules.hpp @@ -235,7 +235,7 @@ class RASearchRules return sum(numSamplesMade); } - typedef typename mlpack::TraversalInfo TraversalInfoType; + using TraversalInfoType = mlpack::TraversalInfo; const TraversalInfoType& TraversalInfo() const { return traversalInfo; } TraversalInfoType& TraversalInfo() { return traversalInfo; } @@ -253,7 +253,7 @@ class RASearchRules const arma::mat& querySet; //! Candidate represents a possible candidate neighbor (distance, index). - typedef std::pair Candidate; + using Candidate = std::pair; //! Compare two candidates based on the distance. struct CandidateCmp { @@ -264,8 +264,8 @@ class RASearchRules }; //! Use a priority queue to represent the list of candidate neighbors. - typedef std::priority_queue, CandidateCmp> - CandidateList; + using CandidateList = std::priority_queue, + CandidateCmp>; //! Set of candidate neighbors for each point. std::vector candidates; diff --git a/src/mlpack/methods/rann/ra_typedef.hpp b/src/mlpack/methods/rann/ra_typedef.hpp index f432837b33..118b8d3e61 100644 --- a/src/mlpack/methods/rann/ra_typedef.hpp +++ b/src/mlpack/methods/rann/ra_typedef.hpp @@ -32,7 +32,7 @@ namespace mlpack { * while the search can be performed multiple times with different approximation * levels. */ -typedef RASearch<> KRANN; +using KRANN = RASearch<>; /** * The KRAFN class is the k-rank-approximate-farthest-neighbors method. It @@ -43,7 +43,7 @@ typedef RASearch<> KRANN; * while the search can be performed multiple times with different approximation * levels. */ -typedef RASearch KRAFN; +using KRAFN = RASearch; } // namespace mlpack diff --git a/src/mlpack/methods/softmax_regression/softmax_regression.hpp b/src/mlpack/methods/softmax_regression/softmax_regression.hpp index 838bace925..1a1855e77e 100644 --- a/src/mlpack/methods/softmax_regression/softmax_regression.hpp +++ b/src/mlpack/methods/softmax_regression/softmax_regression.hpp @@ -58,10 +58,10 @@ template class SoftmaxRegression { public: - typedef typename MatType::elem_type ElemType; - typedef typename GetDenseMatType::type DenseMatType; - typedef typename GetDenseRowType::type DenseRowType; - typedef typename GetDenseColType::type DenseColType; + using ElemType = typename MatType::elem_type; + using DenseMatType = typename GetDenseMatType::type; + using DenseRowType = typename GetDenseRowType::type; + using DenseColType = typename GetDenseColType::type; /** * Initialize the SoftmaxRegression without performing training. Default diff --git a/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp b/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp index 070cc413e7..c889ac81c8 100644 --- a/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp +++ b/src/mlpack/methods/softmax_regression/softmax_regression_function.hpp @@ -22,9 +22,9 @@ template class SoftmaxRegressionFunction { public: - typedef typename MatType::elem_type ElemType; - typedef typename GetDenseMatType::type DenseMatType; - typedef typename GetSparseMatType::type SpMatType; + using ElemType = typename MatType::elem_type; + using DenseMatType = typename GetDenseMatType::type; + using SpMatType = typename GetSparseMatType::type; /** * Construct the Softmax Regression objective function with the given diff --git a/src/mlpack/methods/sparse_coding/sparse_coding.hpp b/src/mlpack/methods/sparse_coding/sparse_coding.hpp index ba22c17798..723a7fa261 100644 --- a/src/mlpack/methods/sparse_coding/sparse_coding.hpp +++ b/src/mlpack/methods/sparse_coding/sparse_coding.hpp @@ -115,8 +115,8 @@ template class SparseCoding { public: - typedef typename GetColType::type ColType; - typedef typename GetRowType::type RowType; + using ColType = typename GetColType::type; + using RowType = typename GetRowType::type; /** * Set the parameters to SparseCoding. lambda2 defaults to 0. This diff --git a/src/mlpack/tests/adaboost_test.cpp b/src/mlpack/tests/adaboost_test.cpp index 785333e865..5d6c456731 100644 --- a/src/mlpack/tests/adaboost_test.cpp +++ b/src/mlpack/tests/adaboost_test.cpp @@ -26,8 +26,8 @@ using namespace mlpack; */ TEMPLATE_TEST_CASE("HammingLossBoundIris", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; @@ -47,8 +47,8 @@ TEMPLATE_TEST_CASE("HammingLossBoundIris", "[AdaBoostTest]", mat, fmat) // Define parameters for AdaBoost. size_t iterations = 100; eT tolerance = 2e-10; - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; AdaBoost a; eT ztProduct = a.Train(inputData, labels.row(0), numClasses, iterations, tolerance, perceptronIter); @@ -71,8 +71,8 @@ TEMPLATE_TEST_CASE("HammingLossBoundIris", "[AdaBoostTest]", mat, fmat) */ TEMPLATE_TEST_CASE("WeakLearnerErrorIris", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("iris.csv", inputData)) @@ -89,8 +89,8 @@ TEMPLATE_TEST_CASE("WeakLearnerErrorIris", "[AdaBoostTest]", mat, fmat) int perceptronIter = 400; Row perceptronPrediction(labels.n_cols); - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; PerceptronType p(inputData, labels.row(0), numClasses, perceptronIter); p.Classify(inputData, perceptronPrediction); @@ -120,8 +120,8 @@ TEMPLATE_TEST_CASE("WeakLearnerErrorIris", "[AdaBoostTest]", mat, fmat) TEMPLATE_TEST_CASE("HammingLossBoundVertebralColumn", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("vc2.csv", inputData)) @@ -136,8 +136,8 @@ TEMPLATE_TEST_CASE("HammingLossBoundVertebralColumn", "[AdaBoostTest]", mat, // Define your own weak learner, perceptron in this case. // Run the perceptron for perceptronIter iterations. size_t perceptronIter = 800; - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; PerceptronType p(inputData, labels.row(0), numClasses, perceptronIter); // Define parameters for AdaBoost. @@ -166,8 +166,8 @@ TEMPLATE_TEST_CASE("HammingLossBoundVertebralColumn", "[AdaBoostTest]", mat, TEMPLATE_TEST_CASE("WeakLearnerErrorVertebralColumn", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("vc2.csv", inputData)) @@ -184,8 +184,8 @@ TEMPLATE_TEST_CASE("WeakLearnerErrorVertebralColumn", "[AdaBoostTest]", mat, size_t perceptronIter = 800; Row perceptronPrediction(labels.n_cols); - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; PerceptronType p(inputData, labels.row(0), numClasses, perceptronIter); p.Classify(inputData, perceptronPrediction); @@ -215,8 +215,8 @@ TEMPLATE_TEST_CASE("WeakLearnerErrorVertebralColumn", "[AdaBoostTest]", mat, TEMPLATE_TEST_CASE("HammingLossBoundNonLinearSepData", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("train_nonlinsep.txt", inputData)) @@ -231,8 +231,8 @@ TEMPLATE_TEST_CASE("HammingLossBoundNonLinearSepData", "[AdaBoostTest]", mat, // Define your own weak learner, perceptron in this case. // Run the perceptron for perceptronIter iterations. size_t perceptronIter = 800; - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; PerceptronType p(inputData, labels.row(0), numClasses, perceptronIter); // Define parameters for AdaBoost. @@ -261,8 +261,8 @@ TEMPLATE_TEST_CASE("HammingLossBoundNonLinearSepData", "[AdaBoostTest]", mat, TEMPLATE_TEST_CASE("WeakLearnerErrorNonLinearSepData", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("train_nonlinsep.txt", inputData)) @@ -279,8 +279,8 @@ TEMPLATE_TEST_CASE("WeakLearnerErrorNonLinearSepData", "[AdaBoostTest]", mat, size_t perceptronIter = 800; Row perceptronPrediction(labels.n_cols); - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; PerceptronType p(inputData, labels.row(0), numClasses, perceptronIter); p.Classify(inputData, perceptronPrediction); @@ -309,8 +309,8 @@ TEMPLATE_TEST_CASE("WeakLearnerErrorNonLinearSepData", "[AdaBoostTest]", mat, */ TEMPLATE_TEST_CASE("HammingLossIris_DS", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("iris.csv", inputData)) @@ -351,8 +351,8 @@ TEMPLATE_TEST_CASE("HammingLossIris_DS", "[AdaBoostTest]", mat, fmat) */ TEMPLATE_TEST_CASE("WeakLearnerErrorIris_DS", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("iris.csv", inputData)) @@ -402,8 +402,8 @@ TEMPLATE_TEST_CASE("WeakLearnerErrorIris_DS", "[AdaBoostTest]", mat, fmat) TEMPLATE_TEST_CASE("HammingLossBoundVertebralColumn_DS", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("vc2.csv", inputData)) @@ -448,8 +448,8 @@ TEMPLATE_TEST_CASE("HammingLossBoundVertebralColumn_DS", "[AdaBoostTest]", mat, TEMPLATE_TEST_CASE("WeakLearnerErrorVertebralColumn_DS", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("vc2.csv", inputData)) @@ -494,8 +494,8 @@ TEMPLATE_TEST_CASE("WeakLearnerErrorVertebralColumn_DS", "[AdaBoostTest]", mat, TEMPLATE_TEST_CASE("HammingLossBoundNonLinearSepData_DS", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("train_nonlinsep.txt", inputData)) @@ -540,8 +540,8 @@ TEMPLATE_TEST_CASE("HammingLossBoundNonLinearSepData_DS", "[AdaBoostTest]", mat, TEMPLATE_TEST_CASE("WeakLearnerErrorNonLinearSepData_DS", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("train_nonlinsep.txt", inputData)) @@ -587,8 +587,8 @@ TEMPLATE_TEST_CASE("WeakLearnerErrorNonLinearSepData_DS", "[AdaBoostTest]", mat, */ TEMPLATE_TEST_CASE("ClassifyTest_VERTEBRALCOL", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("vc2.csv", inputData)) @@ -614,8 +614,8 @@ TEMPLATE_TEST_CASE("ClassifyTest_VERTEBRALCOL", "[AdaBoostTest]", mat, fmat) const size_t numClasses = max(labels.row(0)) + 1; Row perceptronPrediction(labels.n_cols); - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; PerceptronType p(inputData, labels.row(0), numClasses, perceptronIter); p.Classify(inputData, perceptronPrediction); @@ -661,8 +661,8 @@ TEMPLATE_TEST_CASE("ClassifyTest_VERTEBRALCOL", "[AdaBoostTest]", mat, fmat) */ TEMPLATE_TEST_CASE("ClassifyTest_NONLINSEP", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("train_nonlinsep.txt", inputData)) @@ -732,8 +732,8 @@ TEMPLATE_TEST_CASE("ClassifyTest_NONLINSEP", "[AdaBoostTest]", mat, fmat) */ TEMPLATE_TEST_CASE("ClassifyTest_IRIS", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; MatType inputData; if (!data::Load("iris_train.csv", inputData)) @@ -748,8 +748,8 @@ TEMPLATE_TEST_CASE("ClassifyTest_IRIS", "[AdaBoostTest]", mat, fmat) // Run the perceptron for perceptronIter iterations. size_t perceptronIter = 800; - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; PerceptronType p(inputData, labels.row(0), numClasses, perceptronIter); // Define parameters for AdaBoost. @@ -803,8 +803,8 @@ TEMPLATE_TEST_CASE("ClassifyTest_IRIS", "[AdaBoostTest]", mat, fmat) */ TEMPLATE_TEST_CASE("TrainTest", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; // First train on the iris dataset. MatType inputData; @@ -818,8 +818,8 @@ TEMPLATE_TEST_CASE("TrainTest", "[AdaBoostTest]", mat, fmat) const size_t numClasses = max(labels.row(0)) + 1; size_t perceptronIter = 800; - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; PerceptronType p(inputData, labels.row(0), numClasses, perceptronIter); // Now train AdaBoost. @@ -862,7 +862,7 @@ TEMPLATE_TEST_CASE("TrainTest", "[AdaBoostTest]", mat, fmat) TEMPLATE_TEST_CASE("PerceptronSerializationTest", "[AdaBoostTest]", fmat, mat) { - typedef TestType MatType; + using MatType = TestType; // Build an AdaBoost object. MatType data = randu(10, 500); @@ -872,8 +872,8 @@ TEMPLATE_TEST_CASE("PerceptronSerializationTest", "[AdaBoostTest]", fmat, mat) for (size_t i = 250; i < 500; ++i) labels[i] = 1; - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; AdaBoost ab(data, labels, 2, 50, 1e-10, 800); // Now create another dataset to train with. @@ -919,7 +919,7 @@ TEMPLATE_TEST_CASE("PerceptronSerializationTest", "[AdaBoostTest]", fmat, mat) TEMPLATE_TEST_CASE("ID3DecisionStumpSerializationTest", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; + using MatType = TestType; // Build an AdaBoost object. MatType data = randu(10, 500); @@ -970,7 +970,7 @@ TEMPLATE_TEST_CASE("ID3DecisionStumpSerializationTest", "[AdaBoostTest]", mat, TEMPLATE_TEST_CASE("AdaBoostSinglePointClassify", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; + using MatType = TestType; // Create random data. MatType data = randu(10, 100); @@ -978,8 +978,8 @@ TEMPLATE_TEST_CASE("AdaBoostSinglePointClassify", "[AdaBoostTest]", mat, fmat) Row labels = randi>(100, distr_param(0, 3)); // Train a model. - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; AdaBoost ab(data, labels, 4); // Ensure that we can get single-point classifications. @@ -994,8 +994,8 @@ TEMPLATE_TEST_CASE("AdaBoostSinglePointClassify", "[AdaBoostTest]", mat, fmat) TEMPLATE_TEST_CASE("AdaBoostSinglePointClassifyWithProbs", "[AdaBoostTest]", mat, fmat) { - typedef TestType MatType; - typedef typename MatType::elem_type eT; + using MatType = TestType; + using eT = typename MatType::elem_type; // Create random data. MatType data = randu(10, 100); @@ -1003,8 +1003,8 @@ TEMPLATE_TEST_CASE("AdaBoostSinglePointClassifyWithProbs", "[AdaBoostTest]", Row labels = randi>(100, distr_param(0, 3)); // Train a model. - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; AdaBoost ab(data, labels, 4); // Ensure that we can get single-point classifications. @@ -1023,7 +1023,7 @@ TEMPLATE_TEST_CASE("AdaBoostSinglePointClassifyWithProbs", "[AdaBoostTest]", // hyperparameters. TEMPLATE_TEST_CASE("AdaBoostParamsConstructor", "[AdaBoostTest]", fmat, mat) { - typedef TestType MatType; + using MatType = TestType; MatType inputData; if (!data::Load("iris.csv", inputData)) @@ -1038,8 +1038,8 @@ TEMPLATE_TEST_CASE("AdaBoostParamsConstructor", "[AdaBoostTest]", fmat, mat) // Create two AdaBoost models. One does not allow the perceptron to train for // more than one iteration, and therefore should get less accuracy than the // one we let train in full. - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; AdaBoost a1(inputData, labels, numClasses, 2, 1e-6, 1 /* perceptron max iterations */); @@ -1061,15 +1061,15 @@ TEMPLATE_TEST_CASE("AdaBoostParamsConstructor", "[AdaBoostTest]", fmat, mat) // Ensure that all Train() overloads work correctly. TEMPLATE_TEST_CASE("AdaBoostTrainOverloads", "[AdaBoostTest]", fmat, mat) { - typedef TestType MatType; + using MatType = TestType; // Create random data. MatType data = randu(10, 100); // Create random labels. Row labels = randi>(100, distr_param(0, 3)); - typedef Perceptron - PerceptronType; + using PerceptronType = + Perceptron; AdaBoost a1, a2, a3, a4; a1.MaxIterations() = 65; a1.Tolerance() = 2e-4; diff --git a/src/mlpack/tests/aknn_test.cpp b/src/mlpack/tests/aknn_test.cpp index c1791f109d..b4b640d3b9 100644 --- a/src/mlpack/tests/aknn_test.cpp +++ b/src/mlpack/tests/aknn_test.cpp @@ -292,8 +292,8 @@ TEST_CASE("AKNNSparseKNNKDTreeTest", "[AKNNTest]") arma::mat denseQuery(queryDataset); arma::mat denseReference(referenceDataset); - typedef NeighborSearch SparseKNN; + using SparseKNN = NeighborSearch; SparseKNN aknn(referenceDataset, DUAL_TREE_MODE, 0.05); arma::mat distancesSparse; @@ -316,7 +316,7 @@ TEST_CASE("AKNNSparseKNNKDTreeTest", "[AKNNTest]") */ TEST_CASE("AKNNModelTest", "[AKNNTest]") { - typedef NSModel KNNModel; + using KNNModel = NSModel; util::Timers timers; arma::mat queryData = arma::randu(10, 50); @@ -404,7 +404,7 @@ TEST_CASE("AKNNModelTest", "[AKNNTest]") */ TEST_CASE("AKNNModelMonochromaticTest", "[AKNNTest]") { - typedef NSModel KNNModel; + using KNNModel = NSModel; util::Timers timers; arma::mat referenceData = arma::randu(10, 200); diff --git a/src/mlpack/tests/ann/layer/repeat.cpp b/src/mlpack/tests/ann/layer/repeat.cpp index 2d29acf920..a3e0823250 100644 --- a/src/mlpack/tests/ann/layer/repeat.cpp +++ b/src/mlpack/tests/ann/layer/repeat.cpp @@ -24,7 +24,7 @@ using namespace mlpack; */ TEMPLATE_TEST_CASE("RepeatTestCaseI0", "[ANNLayerTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; // Input will be 4 x 3. MatType input(4, 3, arma::fill::randn); @@ -66,7 +66,7 @@ TEMPLATE_TEST_CASE("RepeatTestCaseI0", "[ANNLayerTest]", arma::mat, arma::fmat) */ TEMPLATE_TEST_CASE("RepeatTestCaseI1", "[ANNLayerTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; // Input will be 4 x 3. MatType input(4, 3, arma::fill::randn); @@ -108,7 +108,7 @@ TEMPLATE_TEST_CASE("RepeatTestCaseI1", "[ANNLayerTest]", arma::mat, arma::fmat) */ TEMPLATE_TEST_CASE("RepeatTestCaseI2", "[ANNLayerTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; // Input will be 4 x 3. MatType input(4, 3, arma::fill::randn); @@ -156,7 +156,7 @@ TEMPLATE_TEST_CASE("RepeatTestCaseI2", "[ANNLayerTest]", arma::mat, arma::fmat) */ TEMPLATE_TEST_CASE("RepeatTestCaseB1", "[ANNLayerTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; // Input will be 4 x 3. MatType input(4, 3, arma::fill::randn); @@ -195,7 +195,7 @@ TEMPLATE_TEST_CASE("RepeatTestCaseB1", "[ANNLayerTest]", arma::mat, arma::fmat) */ TEMPLATE_TEST_CASE("RepeatTestCaseB2", "[ANNLayerTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; // Input will be 4 x 3. MatType input(4, 3, arma::fill::randn); @@ -234,7 +234,7 @@ TEMPLATE_TEST_CASE("RepeatTestCaseB2", "[ANNLayerTest]", arma::mat, arma::fmat) */ TEMPLATE_TEST_CASE("RepeatTestCaseB3", "[ANNLayerTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; // Input will be 4 x 3. MatType input(4, 3, arma::fill::randn); @@ -288,7 +288,7 @@ template <> struct GradientBound TEMPLATE_TEST_CASE("GradientRepeatTest", "[ANNLayerTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; struct GradientFunction { GradientFunction(std::vector multiples, bool interleave) : diff --git a/src/mlpack/tests/bayesian_linear_regression_test.cpp b/src/mlpack/tests/bayesian_linear_regression_test.cpp index 4b07e2097f..42608b1677 100644 --- a/src/mlpack/tests/bayesian_linear_regression_test.cpp +++ b/src/mlpack/tests/bayesian_linear_regression_test.cpp @@ -211,7 +211,7 @@ TEST_CASE("EqualtoRidge", "[BayesianLinearRegressionTest]") TEMPLATE_TEST_CASE("BayesianLinearRegressionConstructorVariantTest", "[BayesianLinearRegressionTest]", arma::mat) { - typedef TestType MatType; + using MatType = TestType; MatType matX; arma::Row y; @@ -278,7 +278,7 @@ TEMPLATE_TEST_CASE("BayesianLinearRegressionConstructorVariantTest", TEMPLATE_TEST_CASE("BayesianLinearRegressionTrainVariantTest", "[BayesianLinearRegressionTest]", arma::mat) { - typedef TestType MatType; + using MatType = TestType; MatType matX; arma::Row y; diff --git a/src/mlpack/tests/cli_binding_test.cpp b/src/mlpack/tests/cli_binding_test.cpp index 47c7f28f27..c3c92cf7f7 100644 --- a/src/mlpack/tests/cli_binding_test.cpp +++ b/src/mlpack/tests/cli_binding_test.cpp @@ -111,7 +111,7 @@ TEST_CASE("GetParamLoadedMatTest", "[CLIOptionTest]") // Create value. string filename = "hello.csv"; arma::mat m(5, 5, arma::fill::ones); - typedef std::tuple TupleType; + using TupleType = std::tuple; TupleType testTuple{filename, 0, 0}; tuple tuple = make_tuple(m, testTuple); d.value = tuple; @@ -137,7 +137,7 @@ TEST_CASE("GetParamUnloadedMatTest", "[CLIOptionTest]") arma::mat test(5, 5, arma::fill::ones); data::Save("test.csv", test); arma::mat m; - typedef tuple TupleType; + using TupleType = tuple; TupleType testTuple{filename, 0, 0}; tuple tuple = make_tuple(m, testTuple); d.value = tuple; @@ -165,7 +165,7 @@ TEST_CASE("GetParamUmatTest", "[CLIOptionTest]") // Create value. string filename = "hello.csv"; arma::Mat m(5, 5, arma::fill::ones); - typedef tuple TupleType; + using TupleType = tuple; TupleType testTuple{filename, 0, 0}; tuple, TupleType> tuple = make_tuple(m, testTuple); d.value = tuple; @@ -192,7 +192,7 @@ TEST_CASE("GetParamUnloadedUmatTest", "[CLIOptionTest]") arma::Mat test(5, 5, arma::fill::ones); data::Save("test.csv", test); arma::Mat m; - typedef tuple TupleType; + using TupleType = tuple; TupleType testTuple{filename, 0, 0}; tuple, TupleType> tuple = make_tuple(m, testTuple); d.value = tuple; @@ -236,7 +236,7 @@ TEST_CASE("GetParamDatasetInfoMatTest", "[CLIOptionTest]") data::DatasetInfo dd; arma::mat m; - typedef tuple TupleType; + using TupleType = tuple; TupleType testTuple{filename, 0, 0}; tuple tuple1 = make_tuple(dd, m); tuple tuple2 = make_tuple(tuple1, testTuple); @@ -313,7 +313,7 @@ TEST_CASE("RawParamMatTest", "[CLIOptionTest]") // Create value. string filename = "hello.csv"; arma::mat m(5, 5, arma::fill::ones); - typedef tuple TupleType; + using TupleType = tuple; TupleType testTuple{filename, 0, 0}; tuple tuple = make_tuple(m, testTuple); d.value = tuple; @@ -363,7 +363,7 @@ TEST_CASE("GetRawParamDatasetInfoTest", "[CLIOptionTest]") // Create tuples. data::DatasetInfo dd(3); arma::mat m(3, 3, arma::fill::randu); - typedef tuple TupleType; + using TupleType = tuple; TupleType testTuple{filename, 0, 0}; tuple tuple1 = make_tuple(dd, m); tuple tuple2 = make_tuple(tuple1, testTuple); @@ -392,7 +392,7 @@ TEST_CASE("OutputParamMatTest", "[CLIOptionTest]") // Create value. string filename = "test.csv"; arma::mat m(3, 3, arma::fill::randu); - typedef tuple TupleType; + using TupleType = tuple; TupleType testTuple{filename, 0, 0}; tuple t = make_tuple(m, testTuple); @@ -420,7 +420,7 @@ TEST_CASE("OutputParamUmatTest", "[CLIOptionTest]") // Create value. string filename = "test.csv"; arma::Mat m(3, 3, arma::fill::randu); - typedef tuple TupleType; + using TupleType = tuple; TupleType testTuple{filename, 0, 0}; tuple, TupleType> t = make_tuple(m, testTuple); @@ -513,7 +513,7 @@ TEST_CASE("SetParamMatrixTest", "[CLIOptionTest]") // Create initial value. string filename = "hello.csv"; arma::mat m(5, 5, arma::fill::randu); - typedef tuple TupleType; + using TupleType = tuple; TupleType testTuple{filename, 0, 0}; d.value = make_tuple(m, testTuple); @@ -565,7 +565,7 @@ TEST_CASE("SetParamDatasetInfoMatTest", "[CLIOptionTest]") string filename = "test.csv"; arma::mat m(3, 3, arma::fill::randu); DatasetInfo di(3); - typedef tuple TupleType; + using TupleType = tuple; TupleType testTuple{filename, 0, 0}; tuple t1 = make_tuple(di, m); tuple, TupleType> t2 = make_tuple(t1, @@ -608,7 +608,7 @@ TEST_CASE("GetAllocatedMemoryNonModelTest", "[CLIOptionTest]") // Also test with a matrix type. arma::mat test(10, 10, arma::fill::ones); string filename = "test.csv"; - typedef tuple TupleType; + using TupleType = tuple; TupleType testTuple{filename, 0, 0}; tuple t = make_tuple(test, testTuple); d.value = t; @@ -656,7 +656,7 @@ TEST_CASE("DeleteAllocatedMemoryNonModelTest", "[CLIOptionTest]") arma::mat test(10, 10, arma::fill::ones); string filename = "test.csv"; - typedef tuple TupleType; + using TupleType = tuple; TupleType testTuple{filename, 0, 0}; tuple t = make_tuple(test, testTuple); d.value = t; diff --git a/src/mlpack/tests/decision_tree_regressor_test.cpp b/src/mlpack/tests/decision_tree_regressor_test.cpp index 9f9c35f1c0..6e0d59f736 100644 --- a/src/mlpack/tests/decision_tree_regressor_test.cpp +++ b/src/mlpack/tests/decision_tree_regressor_test.cpp @@ -1194,7 +1194,7 @@ TEST_CASE("CategoricalMADGainWeightedBuildTest", "[DecisionTreeRegressorTest]") TEMPLATE_TEST_CASE("SimpleGeneralizationTest_", "[DecisionTreeRegressorTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Allow three trials. bool success = false; diff --git a/src/mlpack/tests/distance_test.cpp b/src/mlpack/tests/distance_test.cpp index af118da468..9ba0537bb1 100644 --- a/src/mlpack/tests/distance_test.cpp +++ b/src/mlpack/tests/distance_test.cpp @@ -108,7 +108,7 @@ TEST_CASE("LMetricZerosTest", "[DistanceTest]") */ TEMPLATE_TEST_CASE("MDUnsetCovarianceTest", "[DistanceTest]", float, double) { - typedef TestType eT; + using eT = TestType; MahalanobisDistance> md; md.Q() = arma::eye>(4, 4); @@ -125,7 +125,7 @@ TEMPLATE_TEST_CASE("MDUnsetCovarianceTest", "[DistanceTest]", float, double) */ TEMPLATE_TEST_CASE("MDRootUnsetCovarianceTest", "[DistanceTest]", float, double) { - typedef TestType eT; + using eT = TestType; MahalanobisDistance> md; md.Q() = arma::eye>(4, 4); @@ -142,7 +142,7 @@ TEMPLATE_TEST_CASE("MDRootUnsetCovarianceTest", "[DistanceTest]", float, double) */ TEMPLATE_TEST_CASE("MDEyeCovarianceTest", "[DistanceTest]", float, double) { - typedef TestType eT; + using eT = TestType; MahalanobisDistance> md(4); arma::Col a = "1.0 2.0 2.0 3.0"; @@ -158,7 +158,7 @@ TEMPLATE_TEST_CASE("MDEyeCovarianceTest", "[DistanceTest]", float, double) */ TEMPLATE_TEST_CASE("MDRootEyeCovarianceTest", "[DistanceTest]", float, double) { - typedef TestType eT; + using eT = TestType; MahalanobisDistance> md(4); arma::Col a = "1.0 2.0 2.5 5.0"; @@ -173,7 +173,7 @@ TEMPLATE_TEST_CASE("MDRootEyeCovarianceTest", "[DistanceTest]", float, double) */ TEMPLATE_TEST_CASE("MDDiagonalCovarianceTest", "[DistanceTest]", float, double) { - typedef TestType eT; + using eT = TestType; arma::Mat q = arma::eye>(5, 5); q(0, 0) = 2.0; @@ -195,7 +195,7 @@ TEMPLATE_TEST_CASE("MDDiagonalCovarianceTest", "[DistanceTest]", float, double) */ TEMPLATE_TEST_CASE("MDFullCovarianceTest", "[DistanceTest]", float, double) { - typedef TestType eT; + using eT = TestType; arma::Mat q = "1.0 2.0 3.0 4.0;" "0.5 0.6 0.7 0.1;" diff --git a/src/mlpack/tests/distribution_test.cpp b/src/mlpack/tests/distribution_test.cpp index b1325d557c..cf33b42481 100644 --- a/src/mlpack/tests/distribution_test.cpp +++ b/src/mlpack/tests/distribution_test.cpp @@ -36,10 +36,10 @@ TEMPLATE_TEST_CASE("DiscreteDistributionConstructorTest", "[DistributionTest]", (std::pair), (std::pair)) { - typedef typename TestType::first_type ElemType; - typedef typename TestType::second_type ObsElemType; - typedef typename arma::Mat MatType; - typedef typename arma::Mat ObsMatType; + using ElemType = typename TestType::first_type; + using ObsElemType = typename TestType::second_type; + using MatType = arma::Mat; + using ObsMatType = arma::Mat; DiscreteDistribution d(5); @@ -61,10 +61,10 @@ TEMPLATE_TEST_CASE("DiscreteDistributionProbabilityTest", "[DistributionTest]", (std::pair), (std::pair)) { - typedef typename TestType::first_type ElemType; - typedef typename TestType::second_type ObsElemType; - typedef typename arma::Mat MatType; - typedef typename arma::Mat ObsMatType; + using ElemType = typename TestType::first_type; + using ObsElemType = typename TestType::second_type; + using MatType = arma::Mat; + using ObsMatType = arma::Mat; DiscreteDistribution d(5); @@ -87,11 +87,11 @@ TEMPLATE_TEST_CASE("DiscreteDistributionRandomTest", "[DistributionTest]", (std::pair), (std::pair)) { - typedef typename TestType::first_type ElemType; - typedef typename TestType::second_type ObsElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; - typedef typename arma::Mat ObsMatType; + using ElemType = typename TestType::first_type; + using ObsElemType = typename TestType::second_type; + using VecType = arma::Col; + using MatType = arma::Mat; + using ObsMatType = arma::Mat; DiscreteDistribution d(arma::Col("3")); @@ -123,10 +123,10 @@ TEMPLATE_TEST_CASE("DiscreteDistributionTrainTest", "[DistributionTest]", (std::pair), (std::pair)) { - typedef typename TestType::first_type ElemType; - typedef typename TestType::second_type ObsElemType; - typedef typename arma::Mat MatType; - typedef typename arma::Mat ObsMatType; + using ElemType = typename TestType::first_type; + using ObsElemType = typename TestType::second_type; + using MatType = arma::Mat; + using ObsMatType = arma::Mat; DiscreteDistribution d(4); @@ -150,11 +150,11 @@ TEMPLATE_TEST_CASE("DiscreteDistributionTrainProbTest", "[DistributionTest]", (std::pair), (std::pair)) { - typedef typename TestType::first_type ElemType; - typedef typename TestType::second_type ObsElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; - typedef typename arma::Mat ObsMatType; + using ElemType = typename TestType::first_type; + using ObsElemType = typename TestType::second_type; + using VecType = arma::Col; + using MatType = arma::Mat; + using ObsMatType = arma::Mat; DiscreteDistribution d(3); @@ -179,10 +179,10 @@ TEMPLATE_TEST_CASE("MultiDiscreteDistributionTrainProbTest", (std::pair), (std::pair)) { - typedef typename TestType::first_type ElemType; - typedef typename TestType::second_type ObsElemType; - typedef typename arma::Mat MatType; - typedef typename arma::Mat ObsMatType; + using ElemType = typename TestType::first_type; + using ObsElemType = typename TestType::second_type; + using MatType = arma::Mat; + using ObsMatType = arma::Mat; DiscreteDistribution d("10 10 10"); @@ -208,10 +208,10 @@ TEMPLATE_TEST_CASE("MultiDiscreteDistributionConstructorTest", (std::pair), (std::pair)) { - typedef typename TestType::first_type ElemType; - typedef typename TestType::second_type ObsElemType; - typedef typename arma::Mat MatType; - typedef typename arma::Mat ObsMatType; + using ElemType = typename TestType::first_type; + using ObsElemType = typename TestType::second_type; + using MatType = arma::Mat; + using ObsMatType = arma::Mat; DiscreteDistribution d("4 4 4 4"); @@ -231,11 +231,11 @@ TEMPLATE_TEST_CASE("MultiDiscreteDistributionTrainTest", "[DistributionTest]", (std::pair), (std::pair)) { - typedef typename TestType::first_type ElemType; - typedef typename TestType::second_type ObsElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; - typedef typename arma::Mat ObsMatType; + using ElemType = typename TestType::first_type; + using ObsElemType = typename TestType::second_type; + using VecType = arma::Col; + using MatType = arma::Mat; + using ObsMatType = arma::Mat; std::vector pro; pro.push_back(VecType("0.1, 0.3, 0.6")); @@ -261,11 +261,11 @@ TEMPLATE_TEST_CASE("MultiDiscreteDistributionTrainProTest", (std::pair), (std::pair)) { - typedef typename TestType::first_type ElemType; - typedef typename TestType::second_type ObsElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; - typedef typename arma::Mat ObsMatType; + using ElemType = typename TestType::first_type; + using ObsElemType = typename TestType::second_type; + using VecType = arma::Col; + using MatType = arma::Mat; + using ObsMatType = arma::Mat; DiscreteDistribution d("5 5 5"); @@ -293,11 +293,11 @@ TEMPLATE_TEST_CASE("DiscreteLogProbabilityTest", "[DistributionTest]", (std::pair), (std::pair)) { - typedef typename TestType::first_type ElemType; - typedef typename TestType::second_type ObsElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; - typedef typename arma::Mat ObsMatType; + using ElemType = typename TestType::first_type; + using ObsElemType = typename TestType::second_type; + using VecType = arma::Col; + using MatType = arma::Mat; + using ObsMatType = arma::Mat; // Same case as before. DiscreteDistribution d("5 5"); @@ -326,11 +326,11 @@ TEMPLATE_TEST_CASE("DiscreteProbabilityTest", "[DistributionTest]", (std::pair), (std::pair)) { - typedef typename TestType::first_type ElemType; - typedef typename TestType::second_type ObsElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; - typedef typename arma::Mat ObsMatType; + using ElemType = typename TestType::first_type; + using ObsElemType = typename TestType::second_type; + using VecType = arma::Col; + using MatType = arma::Mat; + using ObsMatType = arma::Mat; // Same case as before. DiscreteDistribution d("5 5"); @@ -358,7 +358,7 @@ TEMPLATE_TEST_CASE("DiscreteProbabilityTest", "[DistributionTest]", TEMPLATE_TEST_CASE("GaussianDistributionEmptyConstructor", "[DistributionTest]", float, double) { - typedef typename arma::Mat MatType; + using MatType = arma::Mat; GaussianDistribution d; @@ -373,7 +373,7 @@ TEMPLATE_TEST_CASE("GaussianDistributionEmptyConstructor", "[DistributionTest]", TEMPLATE_TEST_CASE("GaussianDistributionDimensionalityConstructor", "[DistributionTest]", float, double) { - typedef typename arma::Mat MatType; + using MatType = arma::Mat; GaussianDistribution d(4); @@ -389,9 +389,9 @@ TEMPLATE_TEST_CASE("GaussianDistributionDimensionalityConstructor", TEMPLATE_TEST_CASE("GaussianDistributionDistributionConstructor", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; VecType mean(3); MatType covariance(3, 3); @@ -417,9 +417,9 @@ TEMPLATE_TEST_CASE("GaussianDistributionDistributionConstructor", TEMPLATE_TEST_CASE("GaussianDistributionProbabilityTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; VecType mean("5 6 3 3 2"); MatType cov("6 1 1 1 2;" @@ -450,9 +450,9 @@ TEMPLATE_TEST_CASE("GaussianDistributionProbabilityTest", "[DistributionTest]", TEMPLATE_TEST_CASE("GaussianUnivariateProbabilityTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-7; @@ -496,9 +496,9 @@ TEMPLATE_TEST_CASE("GaussianUnivariateProbabilityTest", "[DistributionTest]", TEMPLATE_TEST_CASE("GaussianMultivariateProbabilityTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-7; @@ -569,9 +569,9 @@ TEMPLATE_TEST_CASE("GaussianMultivariateProbabilityTest", "[DistributionTest]", TEMPLATE_TEST_CASE("GaussianMultipointMultivariateProbabilityTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; // Same case as before. VecType mean = "5 6 3 3 2"; @@ -607,9 +607,9 @@ TEMPLATE_TEST_CASE("GaussianMultipointMultivariateProbabilityTest", TEMPLATE_TEST_CASE("GaussianDistributionRandomTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 0.3 : 0.125; @@ -644,9 +644,9 @@ TEMPLATE_TEST_CASE("GaussianDistributionRandomTest", "[DistributionTest]", TEMPLATE_TEST_CASE("GaussianDistributionTrainTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 1e-3 : 1e-5; @@ -691,9 +691,9 @@ TEMPLATE_TEST_CASE("GaussianDistributionTrainTest", "[DistributionTest]", float, TEMPLATE_TEST_CASE("GaussianDistributionTrainWithProbabilitiesTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 0.25 : 0.1; @@ -735,9 +735,9 @@ TEMPLATE_TEST_CASE("GaussianDistributionTrainWithProbabilitiesTest", TEMPLATE_TEST_CASE("GaussianDistributionWithProbabilties1Test", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol1 = (std::is_same_v) ? 1e-10 : 1e-17; const ElemType tol2 = (std::is_same_v) ? 1e-2 : 1e-4; @@ -779,9 +779,9 @@ TEMPLATE_TEST_CASE("GaussianDistributionWithProbabilties1Test", TEMPLATE_TEST_CASE("GaussianDistributionTrainWithTwoDistProbabilitiesTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; VecType mean1 = ("5.0"); VecType cov1 = ("4.0"); @@ -836,8 +836,8 @@ TEMPLATE_TEST_CASE("GaussianDistributionTrainWithTwoDistProbabilitiesTest", TEMPLATE_TEST_CASE("GammaDistributionTrainTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using MatType = arma::Mat; // Create a gamma distribution random generator. ElemType alphaReal = 5.3; @@ -887,9 +887,9 @@ TEMPLATE_TEST_CASE("GammaDistributionTrainTest", "[DistributionTest]", float, TEMPLATE_TEST_CASE("GammaDistributionTrainWithProbabilitiesTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 0.03 : 0.015; @@ -938,9 +938,9 @@ TEMPLATE_TEST_CASE("GammaDistributionTrainWithProbabilitiesTest", TEMPLATE_TEST_CASE("GammaDistributionTrainAllProbabilities1Test", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; ElemType alphaReal = 5.4; ElemType betaReal = 6.7; @@ -982,9 +982,9 @@ TEMPLATE_TEST_CASE("GammaDistributionTrainAllProbabilities1Test", TEMPLATE_TEST_CASE("GammaDistributionTrainTwoDistProbabilities1Test", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 0.25 : 0.075; @@ -1042,8 +1042,8 @@ TEMPLATE_TEST_CASE("GammaDistributionTrainTwoDistProbabilities1Test", TEMPLATE_TEST_CASE("GammaDistributionFittingTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using MatType = arma::Mat; // Offset from the actual alpha/beta. 10% is quite a relaxed tolerance since // the random points we generate are few (for test speed) and might be fitted @@ -1103,8 +1103,8 @@ TEMPLATE_TEST_CASE("GammaDistributionFittingTest", "[DistributionTest]", float, TEMPLATE_TEST_CASE("GammaDistributionTrainConstructorTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using MatType = arma::Mat; const MatType data = arma::randu(10, 500); @@ -1126,9 +1126,9 @@ TEMPLATE_TEST_CASE("GammaDistributionTrainConstructorTest", TEMPLATE_TEST_CASE("GammaDistributionTrainStatisticsTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const MatType data = arma::randu(1, 500); @@ -1153,9 +1153,9 @@ TEMPLATE_TEST_CASE("GammaDistributionTrainStatisticsTest", "[DistributionTest]", TEMPLATE_TEST_CASE("GammaDistributionRandomTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const VecType a("2.0 2.5 3.0"), b("0.4 0.6 1.3"); const size_t numPoints = 4000; @@ -1179,9 +1179,9 @@ TEMPLATE_TEST_CASE("GammaDistributionRandomTest", "[DistributionTest]", float, TEMPLATE_TEST_CASE("GammaDistributionProbabilityTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; // Train two 1-dimensional distributions. const VecType a1("2.0"), b1("0.9"), a2("3.1"), b2("1.4"); @@ -1220,9 +1220,9 @@ TEMPLATE_TEST_CASE("GammaDistributionProbabilityTest", "[DistributionTest]", TEMPLATE_TEST_CASE("GammaDistributionLogProbabilityTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; // Train two 1-dimensional distributions. const VecType a1("2.0"), b1("0.9"), a2("3.1"), b2("1.4"); @@ -1268,12 +1268,12 @@ TEMPLATE_TEST_CASE("DiscreteDistributionTest", "[DistributionTest]", (std::pair), (std::pair)) { - typedef typename TestType::first_type ElemType; - typedef typename TestType::second_type ObsElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; - typedef typename arma::Col ObsVecType; - typedef typename arma::Mat ObsMatType; + using ElemType = typename TestType::first_type; + using ObsElemType = typename TestType::second_type; + using VecType = arma::Col; + using MatType = arma::Mat; + using ObsVecType = arma::Col; + using ObsMatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-8; @@ -1373,9 +1373,9 @@ TEST_CASE("GaussianDistributionTest", "[DistributionTest]") TEMPLATE_TEST_CASE("LaplaceDistributionTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef arma::Col VecType; - typedef arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; VecType mean(20); mean.randu(); @@ -1398,9 +1398,9 @@ TEMPLATE_TEST_CASE("LaplaceDistributionTest", "[DistributionTest]", float, TEMPLATE_TEST_CASE("LaplaceDistributionProbabilityTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef arma::Col VecType; - typedef arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; LaplaceDistribution l(VecType("0.0"), 1.0); @@ -1428,9 +1428,9 @@ TEMPLATE_TEST_CASE("LaplaceDistributionProbabilityTest", "[DistributionTest]", TEMPLATE_TEST_CASE("LaplaceDistributionLogProbabilityTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef arma::Col VecType; - typedef arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; LaplaceDistribution l(VecType("0.0"), 1.0); @@ -1513,7 +1513,7 @@ TEST_CASE("RegressionDistributionTest", "[DistributionTest]") TEMPLATE_TEST_CASE("DiagonalGaussianDistributionEmptyConstructor", "[DistributionTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; DiagonalGaussianDistribution> d; @@ -1528,7 +1528,7 @@ TEMPLATE_TEST_CASE("DiagonalGaussianDistributionEmptyConstructor", TEMPLATE_TEST_CASE("DiagonalGaussianDistributionDimensionalityConstructor", "[DistributionTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; DiagonalGaussianDistribution> d(4); @@ -1543,9 +1543,9 @@ TEMPLATE_TEST_CASE("DiagonalGaussianDistributionDimensionalityConstructor", TEMPLATE_TEST_CASE("DiagonalGaussianDistributionConstructor", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; VecType mean = arma::randu(3); VecType covariance = arma::randu(3); @@ -1567,9 +1567,9 @@ TEMPLATE_TEST_CASE("DiagonalGaussianDistributionConstructor", TEMPLATE_TEST_CASE("DiagonalGaussianDistributionProbabilityTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; VecType mean("2 5 3 4 1"); VecType cov("3 1 5 3 2"); @@ -1596,9 +1596,9 @@ TEMPLATE_TEST_CASE("DiagonalGaussianDistributionProbabilityTest", TEMPLATE_TEST_CASE("DiagonalGaussianUnivariateProbabilityTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-7; @@ -1636,9 +1636,9 @@ TEMPLATE_TEST_CASE("DiagonalGaussianUnivariateProbabilityTest", TEMPLATE_TEST_CASE("DiagonalGaussianMultivariateProbabilityTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-7; @@ -1671,9 +1671,9 @@ TEMPLATE_TEST_CASE("DiagonalGaussianMultivariateProbabilityTest", TEMPLATE_TEST_CASE("DiagonalGaussianMultipointMultivariateProbabilityTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; VecType mean = "2 5 3 7 2"; VecType cov("9 2 1 4 8"); @@ -1702,9 +1702,9 @@ TEMPLATE_TEST_CASE("DiagonalGaussianMultipointMultivariateProbabilityTest", TEMPLATE_TEST_CASE("DiagonalGaussianDistributionRandomTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 0.2 : 0.1; @@ -1735,9 +1735,9 @@ TEMPLATE_TEST_CASE("DiagonalGaussianDistributionRandomTest", TEMPLATE_TEST_CASE("DiagonalGaussianDistributionTrainTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 1e-3 : 1e-5; @@ -1774,9 +1774,9 @@ TEMPLATE_TEST_CASE("DiagonalGaussianDistributionTrainTest", TEMPLATE_TEST_CASE("DiagonalGaussianUnbiasedEstimatorTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-7; @@ -1812,9 +1812,9 @@ TEMPLATE_TEST_CASE("DiagonalGaussianUnbiasedEstimatorTest", TEMPLATE_TEST_CASE("DiagonalGaussianWeightedParametersReductionTest", "[DistributionTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; const ElemType tol = (std::is_same_v) ? 1e-4 : 1e-7; diff --git a/src/mlpack/tests/emst_test.cpp b/src/mlpack/tests/emst_test.cpp index 0a4c6ae8d3..c5a8e43b81 100644 --- a/src/mlpack/tests/emst_test.cpp +++ b/src/mlpack/tests/emst_test.cpp @@ -41,7 +41,7 @@ TEST_CASE("EMSTExhaustiveSyntheticTest", "[EMSTTest]") arma::mat results; // Build the tree by hand to get a leaf size of 1. - typedef KDTree TreeType; + using TreeType = KDTree; std::vector oldFromNew; std::vector newFromOld; TreeType tree(data, oldFromNew, newFromOld, 1); diff --git a/src/mlpack/tests/hoeffding_tree_test.cpp b/src/mlpack/tests/hoeffding_tree_test.cpp index bd3205bc37..1b962201d4 100644 --- a/src/mlpack/tests/hoeffding_tree_test.cpp +++ b/src/mlpack/tests/hoeffding_tree_test.cpp @@ -548,8 +548,8 @@ TEST_CASE("HoeffdingTreeSimpleDatasetTest", "[HoeffdingTreeTest]") // Now train two streaming decision trees; one on the whole dataset, and one // on streaming data. - typedef HoeffdingTree TreeType; + using TreeType = HoeffdingTree; TreeType batchTree(dataset, info, labels, 3, false); TreeType streamTree(info, 3); for (size_t i = 0; i < 9000; ++i) @@ -594,7 +594,7 @@ TEST_CASE("NumDescendantsTest1", "[HoeffdingTreeTest]") } // Now train streaming decision tree; - typedef HoeffdingTree TreeType; + using TreeType = HoeffdingTree; TreeType streamTree(info, 3); for (size_t i = 0; i < 500; ++i) streamTree.Train(dataset.col(i), labels[i]); @@ -643,8 +643,8 @@ TEST_CASE("NumDescendantsTest2", "[HoeffdingTreeTest]") // Now train the streaming decision tree. This should split because splitting // on dimension 2 gives a perfect split. - typedef HoeffdingTree TreeType; + using TreeType = HoeffdingTree; TreeType batchTree(dataset, info, labels, 3, false); REQUIRE(batchTree.NumDescendants() == 3); @@ -836,7 +836,7 @@ TEST_CASE("NumericHoeffdingTreeTest", "[HoeffdingTreeTest]") // Now train two streaming decision trees; one on the whole dataset, and one // on streaming data. - typedef HoeffdingTree TreeType; + using TreeType = HoeffdingTree; TreeType batchTree(dataset, info, labels, 3, false); TreeType streamTree(info, 3); for (size_t i = 0; i < 9000; ++i) @@ -905,7 +905,7 @@ TEST_CASE("BinaryNumericHoeffdingTreeTest", "[HoeffdingTreeTest]") // Now train two streaming decision trees; one on the whole dataset, and one // on streaming data. - typedef HoeffdingTree TreeType; + using TreeType = HoeffdingTree; TreeType batchTree(dataset, info, labels, 3, false); TreeType streamTree(info, 3); for (size_t i = 0; i < 9000; ++i) diff --git a/src/mlpack/tests/io_test.cpp b/src/mlpack/tests/io_test.cpp index 617b713055..4d7c11f5b0 100644 --- a/src/mlpack/tests/io_test.cpp +++ b/src/mlpack/tests/io_test.cpp @@ -1084,7 +1084,7 @@ TEST_CASE("MatrixAndDatasetInfoTest", "[IOTest]") f.close(); // Add options. - typedef tuple TupleType; + using TupleType = tuple; #define BINDING_NAME MatrixAndDatasetInfoTest PARAM_MATRIX_AND_INFO_IN("dataset", "Test dataset", "d"); #undef BINDING_NAME diff --git a/src/mlpack/tests/kde_test.cpp b/src/mlpack/tests/kde_test.cpp index 69aaf11b6b..a866e27690 100644 --- a/src/mlpack/tests/kde_test.cpp +++ b/src/mlpack/tests/kde_test.cpp @@ -100,7 +100,7 @@ TEST_CASE("KDETreeAsArguments", "[KDETest]") kernel); // Get dual-tree results. - typedef KDTree Tree; + using Tree = KDTree; std::vector oldFromNewQueries, oldFromNewReferences; Tree* queryTree = new Tree(query, oldFromNewQueries, 2); Tree* referenceTree = new Tree(reference, oldFromNewReferences, 2); @@ -295,7 +295,7 @@ TEST_CASE("BallTreeGaussianKDETest", "[KDETest]") kernel); // BallTree KDE. - typedef BallTree Tree; + using Tree = BallTree; std::vector oldFromNewQueries, oldFromNewReferences; Tree* queryTree = new Tree(query, oldFromNewQueries, 2); Tree* referenceTree = new Tree(reference, oldFromNewReferences, 2); @@ -467,7 +467,7 @@ TEST_CASE("DuplicatedReferenceSampleKDETest", "[KDETest]") kernel); // Dual-tree KDE. - typedef KDTree Tree; + using Tree = KDTree; std::vector oldFromNewQueries, oldFromNewReferences; Tree* queryTree = new Tree(query, oldFromNewQueries, 2); Tree* referenceTree = new Tree(reference, oldFromNewReferences, 2); @@ -502,7 +502,7 @@ TEST_CASE("DuplicatedQuerySampleKDETest", "[KDETest]") query.col(2) = query.col(3); // Dual-tree KDE. - typedef KDTree Tree; + using Tree = KDTree; std::vector oldFromNewQueries, oldFromNewReferences; Tree* queryTree = new Tree(query, oldFromNewQueries, 2); Tree* referenceTree = new Tree(reference, oldFromNewReferences, 2); @@ -611,7 +611,7 @@ TEST_CASE("EmptyReferenceTest", "[KDETest]") // When training using a tree. std::vector oldFromNewReferences; - typedef KDTree Tree; + using Tree = KDTree; Tree* referenceTree = new Tree(reference, oldFromNewReferences, 2); REQUIRE_THROWS_AS( kde.Train(referenceTree, &oldFromNewReferences), std::invalid_argument); @@ -644,7 +644,7 @@ TEST_CASE("EvaluationMatchDimensionsTest", "[KDETest]") std::invalid_argument); // When evaluating using a query tree. - typedef KDTree Tree; + using Tree = KDTree; std::vector oldFromNewQueries; Tree* queryTree = new Tree(query, oldFromNewQueries, 3); REQUIRE_THROWS_AS(kde.Evaluate(queryTree, oldFromNewQueries, estimations), @@ -679,7 +679,7 @@ TEST_CASE("EmptyQuerySetTest", "[KDETest]") REQUIRE_NOTHROW(kde.Evaluate(query, estimations)); // When evaluating using a query tree. - typedef KDTree Tree; + using Tree = KDTree; std::vector oldFromNewQueries; Tree* queryTree = new Tree(query, oldFromNewQueries, 3); REQUIRE_NOTHROW( @@ -718,7 +718,7 @@ TEST_CASE("KDESerializationTest", "[KDETest]") kde.Train(reference); // Get estimations to compare. - arma::mat query = arma::randu(4, 100);; + arma::mat query = arma::randu(4, 100); arma::vec estimations = arma::vec(query.n_cols); kde.Evaluate(query, estimations); @@ -802,7 +802,7 @@ TEST_CASE("CopyConstructor", "[KDETest]") const double kernelBandwidth = 1.5; const double relError = 0.05; - typedef KDE KDEType; + using KDEType = KDE; // KDE. KDEType kde(relError, 0, GaussianKernel(kernelBandwidth)); @@ -838,8 +838,7 @@ TEST_CASE("MoveConstructor", "[KDETest]") const double kernelBandwidth = 1.2; const double relError = 0.05; - typedef KDE - KDEType; + using KDEType = KDE; // KDE. KDEType kde(relError, 0, EpanechnikovKernel(kernelBandwidth)); diff --git a/src/mlpack/tests/kfn_test.cpp b/src/mlpack/tests/kfn_test.cpp index 7bb0063404..b217a6b39c 100644 --- a/src/mlpack/tests/kfn_test.cpp +++ b/src/mlpack/tests/kfn_test.cpp @@ -39,8 +39,8 @@ TEST_CASE("KFNExhaustiveSyntheticTest", "[KFNTest]") data[9] = 0.90; data[10] = 1.00; - typedef BinarySpaceTree, arma::mat> TreeType; + using TreeType = BinarySpaceTree, arma::mat>; // We will loop through three times, one for each method of performing the // calculation. We'll always use 10 neighbors, so set that parameter. @@ -470,8 +470,8 @@ TEST_CASE("KFNDualCoverTreeTest", "[KFNTest]") arma::mat kdDistances; tree.Search(dataset, 5, kdNeighbors, kdDistances); - typedef CoverTree, NeighborSearchStat, - arma::mat, FirstPointIsRoot> TreeType; + using TreeType = CoverTree, + NeighborSearchStat, arma::mat, FirstPointIsRoot>; TreeType referenceTree(dataset); @@ -500,8 +500,8 @@ TEST_CASE("KFNSingleBallTreeTest", "[KFNTest]") arma::mat data; data.randu(75, 1000); // 75 dimensional, 1000 points. - typedef BallTree, - arma::mat> TreeType; + using TreeType = BallTree, arma::mat>; TreeType tree(data); KFN naive(tree.Dataset(), NAIVE_MODE); diff --git a/src/mlpack/tests/knn_test.cpp b/src/mlpack/tests/knn_test.cpp index b238fa6309..300f546ad2 100644 --- a/src/mlpack/tests/knn_test.cpp +++ b/src/mlpack/tests/knn_test.cpp @@ -363,8 +363,8 @@ TEST_CASE("KNNExhaustiveSyntheticTest", "[KNNTest]") data[9] = 0.90; data[10] = 1.00; - typedef KDTree, - arma::mat> TreeType; + using TreeType = KDTree, arma::mat>; // We will loop through three times, one for each method of performing the // calculation. @@ -864,8 +864,8 @@ TEST_CASE("KNNSingleBallTreeTest", "[KNNTest]") arma::mat data; data.randu(50, 300); // 50 dimensional, 300 points. - typedef BallTree, - arma::mat> TreeType; + using TreeType = BallTree, arma::mat>; TreeType tree(data); KNN naive(tree.Dataset(), NAIVE_MODE); @@ -1030,8 +1030,8 @@ TEST_CASE("SparseKNNKDTreeTest", "[KNNTest]") arma::mat denseQuery(queryDataset); arma::mat denseReference(referenceDataset); - typedef NeighborSearch SparseKNN; + using SparseKNN = NeighborSearch; SparseKNN a(referenceDataset); KNN naive(denseReference, NAIVE_MODE); @@ -1058,8 +1058,8 @@ TEST_CASE("SparseKNNKDTreeTest", "[KNNTest]") /* TEST_CASE("SparseKNNCoverTreeTest", "[KNNTest]") { - typedef CoverTree, FirstPointIsRoot, - NeighborSearchStat, arma::sp_mat> SparseCoverTree; + using SparseCoverTree = CoverTree, FirstPointIsRoot, + NeighborSearchStat, arma::sp_mat>; // The dimensionality of these datasets must be high so that the probability // of a completely empty point is very low. In this case, with dimensionality @@ -1072,8 +1072,8 @@ TEST_CASE("SparseKNNCoverTreeTest", "[KNNTest]") arma::mat denseQuery(queryDataset); arma::mat denseReference(referenceDataset); - typedef NeighborSearch SparseKNN; + using SparseKNN = NeighborSearch; arma::mat sparseDistances; arma::Mat sparseNeighbors; @@ -1098,7 +1098,7 @@ TEST_CASE("KNNModelTest", "[KNNTest]") { // Ensure that we can build an NSModel and get correct // results. - typedef NSModel KNNModel; + using KNNModel = NSModel; util::Timers timers; arma::mat queryData = arma::randu(10, 50); @@ -1190,7 +1190,7 @@ TEST_CASE("KNNModelMonochromaticTest", "[KNNTest]") { // Ensure that we can build an NSModel and get correct // results, in the case where the reference set is the same as the query set. - typedef NSModel KNNModel; + using KNNModel = NSModel; util::Timers timers; arma::mat referenceData = arma::randu(10, 200); @@ -1357,8 +1357,8 @@ TEST_CASE("KNNCopyConstructorAndOperatorTest", "[KNNTest]") TEST_CASE("KNNCopyConstructorAndOperatorRTreeTest", "[KNNTest]") { arma::mat dataset = arma::randu(5, 500); - typedef NeighborSearch NeighborSearchType; + using NeighborSearchType = NeighborSearch; NeighborSearchType knn(std::move(dataset)); // Copy constructor and operator. @@ -1385,8 +1385,8 @@ TEST_CASE("KNNCopyConstructorAndOperatorRTreeTest", "[KNNTest]") TEST_CASE("KNNCopyConstructorAndOperatorCoverTreeTest", "[KNNTest]") { arma::mat dataset = arma::randu(5, 500); - typedef NeighborSearch NeighborSearchType; + using NeighborSearchType = NeighborSearch; NeighborSearchType knn(std::move(dataset)); // Copy constructor and operator. @@ -1413,8 +1413,8 @@ TEST_CASE("KNNCopyConstructorAndOperatorCoverTreeTest", "[KNNTest]") TEST_CASE("KNNCopyConstructorAndOperatorBinarySpaceTreeTest", "[KNNTest]") { arma::mat dataset = arma::randu(5, 500); - typedef NeighborSearch NeighborSearchType; + using NeighborSearchType = NeighborSearch; NeighborSearchType knn(std::move(dataset)); // Copy constructor and operator. @@ -1441,8 +1441,8 @@ TEST_CASE("KNNCopyConstructorAndOperatorBinarySpaceTreeTest", "[KNNTest]") TEST_CASE("KNNCopyConstructorAndOperatorSpillTreeTest", "[KNNTest]") { arma::mat dataset = arma::randu(5, 500); - typedef NeighborSearch NeighborSearchType; + using NeighborSearchType = NeighborSearch; NeighborSearchType knn(std::move(dataset)); // Copy constructor and operator. @@ -1469,8 +1469,8 @@ TEST_CASE("KNNCopyConstructorAndOperatorSpillTreeTest", "[KNNTest]") TEST_CASE("KNNCopyConstructorAndOperatorOctreeTest", "[KNNTest]") { arma::mat dataset = arma::randu(5, 500); - typedef NeighborSearch NeighborSearchType; + using NeighborSearchType = NeighborSearch; NeighborSearchType knn(std::move(dataset)); // Copy constructor and operator. @@ -1522,8 +1522,8 @@ TEST_CASE("KNNMoveConstructorTest", "[KNNTest]") TEST_CASE("KNNMoveConstructorRTreeTest", "[KNNTest]") { arma::mat dataset = arma::randu(5, 500); - typedef NeighborSearch NeighborSearchType; + using NeighborSearchType = NeighborSearch; NeighborSearchType* knn = new NeighborSearchType(std::move(dataset)); // Get predictions. @@ -1556,8 +1556,8 @@ TEST_CASE("KNNMoveConstructorRTreeTest", "[KNNTest]") TEST_CASE("KNNMoveConstructorBinarySpaceTreeTest", "[KNNTest]") { arma::mat dataset = arma::randu(5, 500); - typedef NeighborSearch NeighborSearchType; + using NeighborSearchType = NeighborSearch; NeighborSearchType* knn = new NeighborSearchType(std::move(dataset)); // Get predictions. @@ -1589,8 +1589,8 @@ TEST_CASE("KNNMoveConstructorBinarySpaceTreeTest", "[KNNTest]") TEST_CASE("KNNMoveConstructorOctreeTest", "[KNNTest]") { arma::mat dataset = arma::randu(5, 500); - typedef NeighborSearch NeighborSearchType; + using NeighborSearchType = NeighborSearch; NeighborSearchType* knn = new NeighborSearchType(std::move(dataset)); // Get predictions. @@ -1622,8 +1622,8 @@ TEST_CASE("KNNMoveConstructorOctreeTest", "[KNNTest]") TEST_CASE("KNNMoveConstructorCoverTreeTest", "[KNNTest]") { arma::mat dataset = arma::randu(5, 500); - typedef NeighborSearch NeighborSearchType; + using NeighborSearchType = NeighborSearch; NeighborSearchType* knn = new NeighborSearchType(std::move(dataset)); // Get predictions. @@ -1655,8 +1655,8 @@ TEST_CASE("KNNMoveConstructorCoverTreeTest", "[KNNTest]") TEST_CASE("KNNMoveConstructorSpillTreeTest", "[KNNTest]") { arma::mat dataset = arma::randu(5, 500); - typedef NeighborSearch NeighborSearchType; + using NeighborSearchType = NeighborSearch; NeighborSearchType* knn = new NeighborSearchType(std::move(dataset)); // Get predictions. diff --git a/src/mlpack/tests/krann_search_test.cpp b/src/mlpack/tests/krann_search_test.cpp index 851cb190c7..487bbe01fd 100644 --- a/src/mlpack/tests/krann_search_test.cpp +++ b/src/mlpack/tests/krann_search_test.cpp @@ -170,8 +170,8 @@ TEST_CASE("DualTreeSearch", "[KRANNTest]") size_t expectedRankErrorUB = 10; // Build query tree by hand. - typedef KDTree, - arma::mat> TreeType; + using TreeType = KDTree, + arma::mat>; std::vector oldFromNewQueries; TreeType queryTree(queryData, oldFromNewQueries); @@ -286,8 +286,8 @@ TEST_CASE("SingleCoverTreeTest", "[KRANNTest]") arma::Mat neighbors; arma::mat distances; - typedef RASearch RACoverTreeSearch; + using RACoverTreeSearch = RASearch; RACoverTreeSearch tssRann(refData, false, true, 1.0, 0.95, false, false, 5); @@ -350,10 +350,10 @@ TEST_CASE("DualCoverTreeTest", "[KRANNTest]") arma::Mat neighbors; arma::mat distances; - typedef StandardCoverTree, - arma::mat> TreeType; - typedef RASearch RACoverTreeSearch; + using TreeType = StandardCoverTree, arma::mat>; + using RACoverTreeSearch = RASearch; TreeType refTree(refData); TreeType queryTree(queryData); @@ -421,10 +421,10 @@ TEST_CASE("SingleBallTreeTest", "[KRANNTest]") arma::Mat neighbors; arma::mat distances; - typedef BinarySpaceTree, RAQueryStat > - TreeType; - typedef RASearch - RABallTreeSearch; + using TreeType = BinarySpaceTree, + RAQueryStat>; + using RABallTreeSearch = RASearch; RABallTreeSearch tssRann(refData, queryData, false, true); @@ -484,10 +484,10 @@ TEST_CASE("DualBallTreeTest", "[KRANNTest]") arma::Mat neighbors; arma::mat distances; - typedef BinarySpaceTree, RAQueryStat > - TreeType; - typedef RASearch - RABallTreeSearch; + using TreeType = BinarySpaceTree, + RAQueryStat>; + using RABallTreeSearch = RASearch; TreeType refTree(refData); TreeType queryTree(queryData); diff --git a/src/mlpack/tests/lars_test.cpp b/src/mlpack/tests/lars_test.cpp index 95220bccff..28cfd20cf3 100644 --- a/src/mlpack/tests/lars_test.cpp +++ b/src/mlpack/tests/lars_test.cpp @@ -62,7 +62,7 @@ template void LassoTest(size_t nPoints, size_t nDims, bool elasticNet, bool useCholesky, bool fitIntercept, bool normalizeData) { - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; MatType X; arma::Row y; @@ -610,8 +610,8 @@ TEST_CASE("LARSTrainReturnCorrelation", "[LARSTest]") */ TEMPLATE_TEST_CASE("LARSTestComputeError", "[LARSTest]", arma::fmat, arma::mat) { - typedef TestType MatType; - typedef typename MatType::elem_type ElemType; + using MatType = TestType; + using ElemType = typename MatType::elem_type; MatType X; MatType Y; @@ -943,8 +943,8 @@ TEST_CASE("LARSTestKKT", "[LARSTest]") TEMPLATE_TEST_CASE("LARSConstructorVariantTest", "[LARSTest]", arma::fmat, arma::mat) { - typedef TestType MatType; - typedef typename MatType::elem_type ElemType; + using MatType = TestType; + using ElemType = typename MatType::elem_type; // The results of the training are not all that important here; the more // important thing is just that all the overloads compile properly. We do @@ -1090,8 +1090,8 @@ TEMPLATE_TEST_CASE("LARSConstructorVariantTest", "[LARSTest]", arma::fmat, // Check that all variants of Train() appear to work. TEMPLATE_TEST_CASE("LARSTrainVariantTest", "[LARSTest]", arma::fmat, arma::mat) { - typedef TestType MatType; - typedef typename MatType::elem_type ElemType; + using MatType = TestType; + using ElemType = typename MatType::elem_type; // The results of the training are not all that important here; the more // important thing is just that all the overloads compile properly. We do @@ -1223,8 +1223,8 @@ TEMPLATE_TEST_CASE("LARSTrainVariantTest", "[LARSTest]", arma::fmat, arma::mat) // Ensure that SelectBeta() works correctly. TEMPLATE_TEST_CASE("LARSSelectBetaTest", "[LARSTest]", arma::fmat, arma::mat) { - typedef TestType MatType; - typedef typename MatType::elem_type ElemType; + using MatType = TestType; + using ElemType = typename MatType::elem_type; const ElemType tol = (std::is_same_v) ? 1e-5 : 5e-3; @@ -1299,7 +1299,7 @@ TEST_CASE("LARSSelectBetaInvalidLambda1Test", "[LARSTest]") // Test that we can train a sparse model on dense data. TEMPLATE_TEST_CASE("LARSSparseModelDenseData", "[LARSTest]", float, double) { - typedef TestType eT; + using eT = TestType; // 1k-dimensional data. arma::Mat data(1000, 500, arma::fill::randu); diff --git a/src/mlpack/tests/linear_regression_test.cpp b/src/mlpack/tests/linear_regression_test.cpp index 1706babe80..4ec9b7c2bf 100644 --- a/src/mlpack/tests/linear_regression_test.cpp +++ b/src/mlpack/tests/linear_regression_test.cpp @@ -24,9 +24,9 @@ using namespace mlpack; TEMPLATE_TEST_CASE("LinearRegressionTestCase", "[LinearRegressionTest]", arma::fmat, arma::mat) { - typedef TestType MatType; - typedef arma::Row RowType; - typedef arma::Col ColType; + using MatType = TestType; + using RowType = arma::Row; + using ColType = arma::Col; // Predictors and points are 10x3 matrices. MatType predictors(3, 10); @@ -77,8 +77,8 @@ TEMPLATE_TEST_CASE("LinearRegressionTestCase", "[LinearRegressionTest]", TEMPLATE_TEST_CASE("ComputeErrorTest", "[LinearRegressionTest]", arma::fmat, arma::mat) { - typedef TestType MatType; - typedef arma::Row RowType; + using MatType = TestType; + using RowType = arma::Row; MatType predictors; predictors = { { 0, 1, 2, 4, 8, 16 }, @@ -281,8 +281,8 @@ TEST_CASE("LinearRegressionTrainReturnObjective", "[LinearRegressionTest]") TEMPLATE_TEST_CASE("LinearRegressionAllTrainVersionsTest", "[LinearRegressionTest]", arma::fmat, arma::mat) { - typedef TestType MatType; - typedef arma::Row RowType; + using MatType = TestType; + using RowType = arma::Row; // The data doesn't really matter for this test; mostly we want to make sure // that all the Train() variants work properly. @@ -341,8 +341,8 @@ TEMPLATE_TEST_CASE("LinearRegressionAllTrainVersionsTest", TEMPLATE_TEST_CASE("LinearRegressionSinglePointPredictTest", "[LinearRegressionTest]", arma::fmat, arma::mat) { - typedef TestType MatType; - typedef arma::Row RowType; + using MatType = TestType; + using RowType = arma::Row; MatType predictors; predictors = { { 0, 1, 2, 4, 8, 16 }, diff --git a/src/mlpack/tests/linear_svm_test.cpp b/src/mlpack/tests/linear_svm_test.cpp index beaf7907f4..a32fd54114 100644 --- a/src/mlpack/tests/linear_svm_test.cpp +++ b/src/mlpack/tests/linear_svm_test.cpp @@ -875,9 +875,9 @@ TEST_CASE("LinearSVMParallelSGDTwoClasses", "[LinearSVMTest]") */ TEMPLATE_TEST_CASE("LinearSVMSparseLBFGSTest", "[LinearSVMTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::SpMat SparseMatType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using SparseMatType = arma::SpMat; + using MatType = arma::Mat; // Create a random dataset. SparseMatType dataset; @@ -908,9 +908,9 @@ TEMPLATE_TEST_CASE("LinearSVMSparseLBFGSTest", "[LinearSVMTest]", float, double) TEMPLATE_TEST_CASE("LinearSVMLBFGSMultipleClasses", "[LinearSVMTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Mat MatType; - typedef typename arma::Col VecType; + using ElemType = TestType; + using MatType = arma::Mat; + using VecType = arma::Col; const size_t points = 1000; const size_t inputSize = 5; @@ -1015,9 +1015,9 @@ TEMPLATE_TEST_CASE("LinearSVMLBFGSMultipleClasses", "[LinearSVMTest]", float, TEMPLATE_TEST_CASE("LinearSVMClassifySinglePointTest", "[LinearSVMTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Mat MatType; - typedef typename arma::Col VecType; + using ElemType = TestType; + using MatType = arma::Mat; + using VecType = arma::Col; const size_t points = 500; const size_t inputSize = 5; @@ -1229,7 +1229,7 @@ TEST_CASE("LinearSVMCallbackTest", "[LinearSVMTest]") TEMPLATE_TEST_CASE("LinearSVMConstructorVariantTest", "[LinearSVMTest]", arma::fmat, arma::mat) { - typedef TestType MatType; + using MatType = TestType; // Create some random data. The results here do not matter all that much; // this is more of a test that all constructor variants successfully compile @@ -1327,7 +1327,7 @@ TEMPLATE_TEST_CASE("LinearSVMConstructorVariantTest", "[LinearSVMTest]", TEMPLATE_TEST_CASE("LinearSVMTrainVariantTest", "[LinearSVMTest]", arma::fmat, arma::mat) { - typedef TestType MatType; + using MatType = TestType; // Create some random data. The results here do not matter all that much; // this is more of a test that all constructor variants successfully compile diff --git a/src/mlpack/tests/lmnn_test.cpp b/src/mlpack/tests/lmnn_test.cpp index 5192483972..6e93907981 100644 --- a/src/mlpack/tests/lmnn_test.cpp +++ b/src/mlpack/tests/lmnn_test.cpp @@ -32,7 +32,7 @@ using namespace ens; */ TEMPLATE_TEST_CASE("LMNNTargetNeighborsTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -67,7 +67,7 @@ TEMPLATE_TEST_CASE("LMNNTargetNeighborsTest", "[LMNNTest]", float, double) */ TEMPLATE_TEST_CASE("LMNNImpostorsTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -107,7 +107,7 @@ TEMPLATE_TEST_CASE("LMNNImpostorsTest", "[LMNNTest]", float, double) */ TEMPLATE_TEST_CASE("LMNNInitialPointTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Cheap fake dataset. arma::Mat dataset = arma::randu>(5, 5); @@ -136,7 +136,7 @@ TEMPLATE_TEST_CASE("LMNNInitialPointTest", "[LMNNTest]", float, double) */ TEMPLATE_TEST_CASE("LMNNInitialEvaluationTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -157,7 +157,7 @@ TEMPLATE_TEST_CASE("LMNNInitialEvaluationTest", "[LMNNTest]", float, double) */ TEMPLATE_TEST_CASE("LMNNInitialGradientTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -185,7 +185,7 @@ TEMPLATE_TEST_CASE("LMNNInitialGradientTest", "[LMNNTest]", float, double) TEMPLATE_TEST_CASE("LMNNInitialEvaluateWithGradientTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -215,7 +215,7 @@ TEMPLATE_TEST_CASE("LMNNInitialEvaluateWithGradientTest", "[LMNNTest]", float, */ TEMPLATE_TEST_CASE("LMNNSeparableObjectiveTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -240,7 +240,7 @@ TEMPLATE_TEST_CASE("LMNNSeparableObjectiveTest", "[LMNNTest]", float, double) */ TEMPLATE_TEST_CASE("LMNNSeparableGradientTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -304,7 +304,7 @@ TEMPLATE_TEST_CASE("LMNNSeparableGradientTest", "[LMNNTest]", float, double) TEMPLATE_TEST_CASE("LMNNSeparableEvaluateWithGradientTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -377,7 +377,7 @@ TEMPLATE_TEST_CASE("LMNNSeparableEvaluateWithGradientTest", "[LMNNTest]", float, // Check that final objective value using SGD optimizer is optimal. TEMPLATE_TEST_CASE("LMNNSGDSimpleDatasetTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -402,7 +402,7 @@ TEMPLATE_TEST_CASE("LMNNSGDSimpleDatasetTest", "[LMNNTest]", float, double) // Check that final objective value using L-BFGS optimizer is optimal. TEMPLATE_TEST_CASE("LMNNLBFGSSimpleDatasetTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -430,7 +430,7 @@ double KnnAccuracy(const MatType& dataset, const LabelsType& labels, const size_t k) { - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; LabelsType uniqueLabels = arma::unique(labels); @@ -468,7 +468,7 @@ double KnnAccuracy(const MatType& dataset, // simple dataset. TEMPLATE_TEST_CASE("LMNNAccuracyTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -498,7 +498,7 @@ TEMPLATE_TEST_CASE("LMNNAccuracyTest", "[LMNNTest]", float, double) // three tries. TEMPLATE_TEST_CASE("LMNNLowRankAccuracyLBFGSTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; bool success = false; for (size_t trial = 0; trial < 3; ++trial) @@ -558,7 +558,7 @@ TEMPLATE_TEST_CASE("LMNNLowRankAccuracyLBFGSTest", "[LMNNTest]", float, double) // three tries. TEMPLATE_TEST_CASE("LMNNLowRankAccuracyTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; bool success = false; for (size_t trial = 0; trial < 3; ++trial) @@ -679,7 +679,7 @@ double CheckGradient(FunctionType& function, MatType& coordinates, const typename MatType::elem_type eps = 1e-7) { - typedef typename MatType::elem_type ElemType; + using ElemType = typename MatType::elem_type; // Get gradients for the current parameters. MatType orgGradient, gradient, estGradient; @@ -714,7 +714,7 @@ double CheckGradient(FunctionType& function, TEMPLATE_TEST_CASE("LMNNFunctionGradientTest", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -733,7 +733,7 @@ TEMPLATE_TEST_CASE("LMNNFunctionGradientTest", "[LMNNTest]", float, double) TEMPLATE_TEST_CASE("LMNNFunctionGradientTest2", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; // Useful but simple dataset with six points and two classes. arma::Mat dataset = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -752,7 +752,7 @@ TEMPLATE_TEST_CASE("LMNNFunctionGradientTest2", "[LMNNTest]", float, double) TEMPLATE_TEST_CASE("LMNNFunctionGradientTest3", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; arma::Mat dataset; arma::Row labels; @@ -774,7 +774,7 @@ TEMPLATE_TEST_CASE("LMNNFunctionGradientTest3", "[LMNNTest]", float, double) TEMPLATE_TEST_CASE("LMNNFunctionGradientTest4", "[LMNNTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; arma::Mat dataset; arma::Row labels; diff --git a/src/mlpack/tests/local_coordinate_coding_test.cpp b/src/mlpack/tests/local_coordinate_coding_test.cpp index 6809a11bf8..c78f711955 100644 --- a/src/mlpack/tests/local_coordinate_coding_test.cpp +++ b/src/mlpack/tests/local_coordinate_coding_test.cpp @@ -49,8 +49,8 @@ void VerifyCorrectness(const MatType& beta, TEMPLATE_TEST_CASE("LocalCoordinateCodingTestCodingStep", "[LocalCoordinateCodingTest]", arma::mat, arma::fmat) { - typedef TestType MatType; - typedef arma::Col VecType; + using MatType = TestType; + using VecType = arma::Col; double lambda1 = 0.1; uword nAtoms = 10; @@ -90,7 +90,7 @@ TEMPLATE_TEST_CASE("LocalCoordinateCodingTestCodingStep", TEMPLATE_TEST_CASE("LocalCoordinateCodingTestDictionaryStep", "[LocalCoordinateCodingTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; const double tol = 0.1; @@ -130,7 +130,7 @@ TEMPLATE_TEST_CASE("LocalCoordinateCodingTestDictionaryStep", TEMPLATE_TEST_CASE("LocalCoordinateCodingSerializationTest", "[LocalCoordinateCodingTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; MatType X = randu(100, 100); size_t nAtoms = 10; @@ -183,7 +183,7 @@ TEMPLATE_TEST_CASE("LocalCoordinateCodingSerializationTest", TEMPLATE_TEST_CASE("LocalCoordinateCodingTrainReturnObjective", "[LocalCoordinateCodingTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; double lambda1 = 0.1; uword nAtoms = 10; diff --git a/src/mlpack/tests/logistic_regression_test.cpp b/src/mlpack/tests/logistic_regression_test.cpp index 2b1006ce7c..079e8da0d9 100644 --- a/src/mlpack/tests/logistic_regression_test.cpp +++ b/src/mlpack/tests/logistic_regression_test.cpp @@ -1107,7 +1107,7 @@ TEST_CASE("IncrementalTraining", "[LogisticRegressionTest]") TEMPLATE_TEST_CASE("LogisticRegressionAllConstructorsTest", "[LogisticRegressionTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; // Create random data. MatType data(50, 1000, arma::fill::randu); @@ -1170,7 +1170,7 @@ TEMPLATE_TEST_CASE("LogisticRegressionAllConstructorsTest", TEMPLATE_TEST_CASE("LogisticRegressionAllTrainTest", "[LogisticRegressionTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; // Create random data. MatType data(50, 1000, arma::fill::randu); diff --git a/src/mlpack/tests/mean_shift_test.cpp b/src/mlpack/tests/mean_shift_test.cpp index 678adaa725..b0dee3bc6a 100644 --- a/src/mlpack/tests/mean_shift_test.cpp +++ b/src/mlpack/tests/mean_shift_test.cpp @@ -58,7 +58,7 @@ MatType GetMeanShiftData() */ TEMPLATE_TEST_CASE("MeanShiftSimpleTest", "[MeanShiftTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; MeanShift<> meanShift; @@ -95,7 +95,7 @@ TEMPLATE_TEST_CASE("MeanShiftSimpleTest", "[MeanShiftTest]", float, double) TEMPLATE_TEST_CASE("MeanShiftSimpleCentroidsOnlyTest", "[MeanShiftTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; MeanShift<> meanShift; @@ -110,8 +110,8 @@ TEMPLATE_TEST_CASE("MeanShiftSimpleCentroidsOnlyTest", "[MeanShiftTest]", float, // recovers those four centers. TEMPLATE_TEST_CASE("GaussianClustering", "[MeanShiftTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using MatType = arma::Mat; GaussianDistribution g1("0.0 0.0 0.0", arma::eye(3, 3)); GaussianDistribution g2("5.0 5.0 5.0", 2 * arma::eye(3, 3)); @@ -188,8 +188,8 @@ TEMPLATE_TEST_CASE("GaussianClustering", "[MeanShiftTest]", float, double) TEMPLATE_TEST_CASE("GaussianClusteringCentroidsOnly", "[MeanShiftTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using MatType = arma::Mat; GaussianDistribution g1("0.0 0.0 0.0", arma::eye(3, 3)); GaussianDistribution g2("5.0 5.0 5.0", 2 * arma::eye(3, 3)); diff --git a/src/mlpack/tests/metric_test.cpp b/src/mlpack/tests/metric_test.cpp index d1b5d39647..2ab6069b67 100644 --- a/src/mlpack/tests/metric_test.cpp +++ b/src/mlpack/tests/metric_test.cpp @@ -224,7 +224,7 @@ TEST_CASE("NMSMetricTest", "[MetricTest]") */ TEST_CASE("BLEUScoreTest", "[MetricTest]") { - typedef typename std::vector WordVector; + using WordVector = std::vector; std::vector> referenceCorpus = {{{"this", "is", "my", "house"}, {"this", "is", "my", "car"}, diff --git a/src/mlpack/tests/nbc_test.cpp b/src/mlpack/tests/nbc_test.cpp index 626594f266..f32d57721a 100644 --- a/src/mlpack/tests/nbc_test.cpp +++ b/src/mlpack/tests/nbc_test.cpp @@ -443,7 +443,7 @@ TEST_CASE("NBCResetTest", "[NBCTest]") */ TEMPLATE_TEST_CASE("NBCIncrementalTest", "[NBCTest]", arma::fmat, arma::mat) { - typedef TestType MatType; + using MatType = TestType; const char* trainFilename = "trainSet.csv"; @@ -478,7 +478,7 @@ TEMPLATE_TEST_CASE("NBCIncrementalTest", "[NBCTest]", arma::fmat, arma::mat) */ TEMPLATE_TEST_CASE("NBCModelMatTypeTest", "[NBCTest]", float, double) { - typedef TestType ElemType; + using ElemType = TestType; NaiveBayesClassifier> nbc; diff --git a/src/mlpack/tests/nca_test.cpp b/src/mlpack/tests/nca_test.cpp index 09024d67ec..e5b72919cc 100644 --- a/src/mlpack/tests/nca_test.cpp +++ b/src/mlpack/tests/nca_test.cpp @@ -28,7 +28,7 @@ using namespace ens; */ TEMPLATE_TEST_CASE("SoftmaxInitialPoint", "[NCATest]", float, double) { - typedef TestType eT; + using eT = TestType; // Cheap fake dataset. arma::Mat data; @@ -61,7 +61,7 @@ TEMPLATE_TEST_CASE("SoftmaxInitialPoint", "[NCATest]", float, double) */ TEMPLATE_TEST_CASE("SoftmaxInitialEvaluation", "[NCATest]", float, double) { - typedef TestType eT; + using eT = TestType; // Useful but simple dataset with six points and two classes. arma::Mat data = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -85,7 +85,7 @@ TEMPLATE_TEST_CASE("SoftmaxInitialEvaluation", "[NCATest]", float, double) */ TEMPLATE_TEST_CASE("SoftmaxInitialGradient", "[NCATest]", float, double) { - typedef TestType eT; + using eT = TestType; // Useful but simple dataset with six points and two classes. arma::Mat data = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -117,7 +117,7 @@ TEMPLATE_TEST_CASE("SoftmaxInitialGradient", "[NCATest]", float, double) */ TEMPLATE_TEST_CASE("SoftmaxOptimalEvaluation", "[NCATest]", float, double) { - typedef TestType eT; + using eT = TestType; // Simple optimal dataset. arma::Mat data = " 500 500 -500 -500;" @@ -140,7 +140,7 @@ TEMPLATE_TEST_CASE("SoftmaxOptimalEvaluation", "[NCATest]", float, double) */ TEMPLATE_TEST_CASE("SoftmaxOptimalGradient", "[NCATest]", float, double) { - typedef TestType eT; + using eT = TestType; // Simple optimal dataset. arma::Mat data = " 500 500 -500 -500;" @@ -164,7 +164,7 @@ TEMPLATE_TEST_CASE("SoftmaxOptimalGradient", "[NCATest]", float, double) */ TEMPLATE_TEST_CASE("SoftmaxSeparableObjective", "[NCATest]", float, double) { - typedef TestType eT; + using eT = TestType; // Useful but simple dataset with six points and two classes. arma::Mat data = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -192,7 +192,7 @@ TEMPLATE_TEST_CASE("SoftmaxSeparableObjective", "[NCATest]", float, double) TEMPLATE_TEST_CASE("OptimalSoftmaxSeparableObjective", "[NCATest]", float, double) { - typedef TestType eT; + using eT = TestType; // Simple optimal dataset. arma::Mat data = " 500 500 -500 -500;" @@ -217,7 +217,7 @@ TEMPLATE_TEST_CASE("OptimalSoftmaxSeparableObjective", "[NCATest]", float, */ TEMPLATE_TEST_CASE("SoftmaxSeparableGradient", "[NCATest]", float, double) { - typedef TestType eT; + using eT = TestType; // Useful but simple dataset with six points and two classes. arma::Mat data = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -283,7 +283,7 @@ TEMPLATE_TEST_CASE("SoftmaxSeparableGradient", "[NCATest]", float, double) */ TEMPLATE_TEST_CASE("NCASGDSimpleDataset", "[NCATest]", float, double) { - typedef TestType eT; + using eT = TestType; // Useful but simple dataset with six points and two classes. arma::Mat data = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" @@ -321,7 +321,7 @@ TEMPLATE_TEST_CASE("NCASGDSimpleDataset", "[NCATest]", float, double) TEMPLATE_TEST_CASE("NCALBFGSSimpleDataset", "[NCATest]", float, double) { - typedef TestType eT; + using eT = TestType; // Useful but simple dataset with six points and two classes. arma::Mat data = "-0.1 -0.1 -0.1 0.1 0.1 0.1;" diff --git a/src/mlpack/tests/nmf_test.cpp b/src/mlpack/tests/nmf_test.cpp index 0ca3a90463..1f00d74c60 100644 --- a/src/mlpack/tests/nmf_test.cpp +++ b/src/mlpack/tests/nmf_test.cpp @@ -307,7 +307,7 @@ TEST_CASE("NonNegNMFALSTest", "[NMFTest]") */ TEMPLATE_TEST_CASE("NoInitializationTest", "[NMFTest]", float, double) { - typedef TestType eT; + using eT = TestType; arma::Mat W, H; W.randu(100, 5); diff --git a/src/mlpack/tests/pca_test.cpp b/src/mlpack/tests/pca_test.cpp index 2878913e2c..d8c820a3a7 100644 --- a/src/mlpack/tests/pca_test.cpp +++ b/src/mlpack/tests/pca_test.cpp @@ -337,7 +337,7 @@ TEST_CASE("PCAScalingTest", "[PCATest]") TEMPLATE_TEST_CASE("PCASubviewTest", "[PCATest]", ExactSVDPolicy, RandomizedSVDPCAPolicy, RandomizedBlockKrylovSVDPolicy, QUICSVDPolicy) { - typedef TestType DecompositionPolicy; + using DecompositionPolicy = TestType; // Generate an artifical dataset in 10 dimensions. arma::mat data(3, 5000); @@ -384,7 +384,7 @@ TEMPLATE_TEST_CASE("PCASubviewTest", "[PCATest]", ExactSVDPolicy, TEMPLATE_TEST_CASE("PCAExpressionTest", "[PCATest]", ExactSVDPolicy, RandomizedSVDPCAPolicy, RandomizedBlockKrylovSVDPolicy, QUICSVDPolicy) { - typedef TestType DecompositionPolicy; + using DecompositionPolicy = TestType; // Generate an artifical dataset in 10 dimensions. arma::mat data(3, 5000); @@ -431,7 +431,7 @@ TEMPLATE_TEST_CASE("PCAExpressionTest", "[PCATest]", ExactSVDPolicy, TEMPLATE_TEST_CASE("PCAFloatTest", "[PCATest]", ExactSVDPolicy, RandomizedSVDPCAPolicy, RandomizedBlockKrylovSVDPolicy, QUICSVDPolicy) { - typedef TestType DecompositionPolicy; + using DecompositionPolicy = TestType; // Generate an artifical dataset in 10 dimensions. arma::fmat data(3, 5000); @@ -475,8 +475,8 @@ TEMPLATE_TEST_CASE("PCAFloatTest", "[PCATest]", ExactSVDPolicy, */ TEMPLATE_TEST_CASE("PCASparseToDenseTest", "[PCATest]", float, double) { - typedef arma::Mat MatType; - typedef arma::SpMat SpMatType; + using MatType = arma::Mat; + using SpMatType = arma::SpMat; SpMatType dataset; dataset.sprandu(1000, 50000, 0.01); diff --git a/src/mlpack/tests/perceptron_test.cpp b/src/mlpack/tests/perceptron_test.cpp index 1aa15c90e1..328a6cf9b4 100644 --- a/src/mlpack/tests/perceptron_test.cpp +++ b/src/mlpack/tests/perceptron_test.cpp @@ -221,7 +221,7 @@ TEST_CASE("TwoPoints", "[PerceptronTest]") TEMPLATE_TEST_CASE("NonLinearlySeparableDataset", "[PerceptronTest]", float, double) { - typedef TestType eT; + using eT = TestType; Mat trainData; trainData = { { 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8 }, diff --git a/src/mlpack/tests/radical_test.cpp b/src/mlpack/tests/radical_test.cpp index b821c1d976..92a4cc1292 100644 --- a/src/mlpack/tests/radical_test.cpp +++ b/src/mlpack/tests/radical_test.cpp @@ -18,9 +18,9 @@ using namespace std; TEMPLATE_TEST_CASE("Radical_Test_Radical3D", "[RadicalTest]", float, double) { - typedef TestType ElemType; - typedef typename arma::Col VecType; - typedef typename arma::Mat MatType; + using ElemType = TestType; + using VecType = arma::Col; + using MatType = arma::Mat; MatType matX; if (!data::Load("data_3d_mixed.txt", matX)) diff --git a/src/mlpack/tests/range_search_test.cpp b/src/mlpack/tests/range_search_test.cpp index 1335ae5d9b..9e48434b94 100644 --- a/src/mlpack/tests/range_search_test.cpp +++ b/src/mlpack/tests/range_search_test.cpp @@ -71,7 +71,7 @@ TEST_CASE("ExhaustiveSyntheticTest", "[RangeSearchTest]") data[9] = 0.90; data[10] = 1.00; - typedef KDTree TreeType; + using TreeType = KDTree; // We will loop through three times, one for each method of performing the // calculation. @@ -1126,7 +1126,7 @@ TEST_CASE("RangeSearchTrainTest", "[RangeSearchTest]") TEST_CASE("TrainTreeTest", "[RangeSearchTest]") { // Avoid mappings by using the cover tree. - typedef RangeSearch RSType; + using RSType = RangeSearch; RSType empty; arma::mat dataset = arma::randu(5, 100); diff --git a/src/mlpack/tests/rectangle_tree_test.cpp b/src/mlpack/tests/rectangle_tree_test.cpp index 221aed25b6..f1a35ab798 100644 --- a/src/mlpack/tests/rectangle_tree_test.cpp +++ b/src/mlpack/tests/rectangle_tree_test.cpp @@ -42,8 +42,8 @@ TEST_CASE("RectangleTreeConstructionCountTest", "[RectangleTreeTraitsTest]") arma::mat dataset; dataset.randu(3, 1000); // 1000 points in 3 dimensions. - typedef RTree, - arma::mat> TreeType; + using TreeType = RTree, arma::mat>; TreeType tree(dataset, 20, 6, 5, 2, 0); TreeType tree2 = tree; @@ -90,8 +90,8 @@ TEST_CASE("RectangleTreeConstructionRepeatTest", "[RectangleTreeTraitsTest]") arma::mat dataset; dataset.randu(8, 1000); // 1000 points in 8 dimensions. - typedef RTree, - arma::mat> TreeType; + using TreeType = RTree, arma::mat>; TreeType tree(dataset, 20, 6, 5, 2, 0); @@ -218,8 +218,8 @@ TEST_CASE("RectangleTreeContainmentTest", "[RectangleTreeTraitsTest]") arma::mat dataset; dataset.randu(8, 1000); // 1000 points in 8 dimensions. - typedef RTree, - arma::mat> TreeType; + using TreeType = RTree, arma::mat>; TreeType tree(dataset, 20, 6, 5, 2, 0); CheckContainment(tree); @@ -263,8 +263,8 @@ TEST_CASE("CheckMinAndMaxFills", "[RectangleTreeTraitsTest]") arma::mat dataset; dataset.randu(8, 1000); // 1000 points in 8 dimensions. - typedef RTree, - arma::mat> TreeType; + using TreeType = RTree, arma::mat>; TreeType tree(dataset, 20, 6, 5, 2, 0); CheckFills(tree); @@ -353,8 +353,8 @@ TEST_CASE("TreeBalance", "[RectangleTreeTraitsTest]") arma::mat dataset; dataset.randu(8, 1000); // 1000 points in 8 dimensions. - typedef RTree, - arma::mat> TreeType; + using TreeType = RTree, arma::mat>; TreeType tree(dataset, 20, 6, 5, 2, 0); @@ -376,8 +376,8 @@ TEST_CASE("PointDeletion", "[RectangleTreeTraitsTest]") const int numIter = 50; - typedef RTree, - arma::mat> TreeType; + using TreeType = RTree, arma::mat>; TreeType tree(dataset, 20, 6, 5, 2, 0); for (int i = 0; i < numIter; ++i) @@ -449,8 +449,8 @@ TEST_CASE("PointDynamicAdd", "[RectangleTreeTraitsTest]") arma::mat dataset; dataset.randu(8, 1000); // 1000 points in 8 dimensions. - typedef RTree, - arma::mat> TreeType; + using TreeType = RTree, arma::mat>; TreeType tree(dataset, 20, 6, 5, 2, 0); // Add numIter new points to the dataset. The tree copies the dataset, so we @@ -529,8 +529,8 @@ TEST_CASE("SingleTreeTraverserTest", "[RectangleTreeTraitsTest]") arma::Mat neighbors2; arma::mat distances2; - typedef RStarTree, - arma::mat> TreeType; + using TreeType = RStarTree, arma::mat>; TreeType rTree(dataset, 20, 6, 5, 2, 0); REQUIRE(rTree.NumDescendants() == 1000); @@ -572,8 +572,8 @@ TEST_CASE("XTreeTraverserTest", "[RectangleTreeTraitsTest]") arma::Mat neighbors2; arma::mat distances2; - typedef XTree, - arma::mat> TreeType; + using TreeType = XTree, arma::mat>; TreeType xTree(dataset, 20, 6, 5, 2, 0); REQUIRE(xTree.NumDescendants() == numP); @@ -613,8 +613,8 @@ TEST_CASE("HilbertRTreeTraverserTest", "[RectangleTreeTraitsTest]") arma::Mat neighbors2; arma::mat distances2; - typedef HilbertRTree, arma::mat> TreeType; + using TreeType = HilbertRTree, arma::mat>; TreeType hilbertRTree(dataset, 20, 6, 5, 2, 0); REQUIRE(hilbertRTree.NumDescendants() == numP); @@ -684,8 +684,8 @@ TEST_CASE("HilbertRTreeOrderingTest", "[RectangleTreeTraitsTest]") arma::mat dataset; dataset.randu(8, 1000); // 1000 points in 8 dimensions. - typedef HilbertRTree, arma::mat> TreeType; + using TreeType = HilbertRTree, arma::mat>; TreeType hilbertRTree(dataset, 20, 6, 5, 2, 0); CheckHilbertOrdering(hilbertRTree); @@ -694,9 +694,8 @@ TEST_CASE("HilbertRTreeOrderingTest", "[RectangleTreeTraitsTest]") template void CheckDiscreteHilbertValueSync(const TreeType& tree) { - typedef DiscreteHilbertValue - HilbertValue; - typedef typename HilbertValue::HilbertElemType HilbertElemType; + using HilbertValue = DiscreteHilbertValue; + using HilbertElemType = typename HilbertValue::HilbertElemType; if (tree.IsLeaf()) { @@ -725,8 +724,8 @@ TEST_CASE("DiscreteHilbertValueSyncTest", "[RectangleTreeTraitsTest]") arma::mat dataset; dataset.randu(8, 1000); // 1000 points in 8 dimensions. - typedef HilbertRTree, arma::mat> TreeType; + using TreeType = HilbertRTree, arma::mat>; TreeType hilbertRTree(dataset, 20, 6, 5, 2, 0); CheckDiscreteHilbertValueSync(hilbertRTree); @@ -856,8 +855,7 @@ TEST_CASE("DiscreteHilbertValueTest", "[RectangleTreeTraitsTest]") template void CheckHilbertValue(const TreeType& tree) { - typedef DiscreteHilbertValue - HilbertValue; + using HilbertValue = DiscreteHilbertValue; const HilbertValue& value = tree.AuxiliaryInfo().HilbertValue(); @@ -892,8 +890,8 @@ void CheckHilbertValue(const TreeType& tree) TEST_CASE("HilbertRTeeCopyConstructorTest", "[RectangleTreeTraitsTest]") { - typedef HilbertRTree, arma::mat> TreeType; + using TreeType = HilbertRTree, arma::mat>; arma::mat dataset; dataset.randu(8, 1000); // 1000 points in 8 dimensions. @@ -912,8 +910,8 @@ TEST_CASE("HilbertRTeeCopyConstructorTest", "[RectangleTreeTraitsTest]") TEST_CASE("HilbertRTeeMoveConstructorTest", "[RectangleTreeTraitsTest]") { - typedef HilbertRTree, arma::mat> TreeType; + using TreeType = HilbertRTree, arma::mat>; arma::mat dataset; dataset.randu(8, 1000); // 1000 points in 8 dimensions. @@ -965,8 +963,8 @@ TEST_CASE("RPlusTreeOverlapTest", "[RectangleTreeTraitsTest]") arma::mat dataset; dataset.randu(8, 1000); // 1000 points in 8 dimensions. - typedef RPlusTree, arma::mat> TreeType; + using TreeType = RPlusTree, arma::mat>; TreeType rPlusTree(dataset, 20, 6, 5, 2, 0); CheckOverlap(rPlusTree); @@ -993,8 +991,8 @@ TEST_CASE("RPlusTreeTraverserTest", "[RectangleTreeTraitsTest]") arma::Mat neighbors2; arma::mat distances2; - typedef RPlusTree, - arma::mat > TreeType; + using TreeType = RPlusTree, arma::mat>; TreeType rPlusTree(dataset, 20, 6, 5, 2, 0); REQUIRE(rPlusTree.NumDescendants() == numP); @@ -1026,7 +1024,7 @@ TEST_CASE("RPlusTreeTraverserTest", "[RectangleTreeTraitsTest]") template void CheckRPlusPlusTreeBound(const TreeType& tree) { - typedef HRectBound Bound; + using Bound = HRectBound; bool success = true; @@ -1082,8 +1080,8 @@ TEST_CASE("RPlusPlusTreeBoundTest", "[RectangleTreeTraitsTest]") dataset.randu(8, 1000); // 1000 points in 8 dimensions. // Check the MinimalCoverageSweep. - typedef RPlusPlusTree, arma::mat> TreeType; + using TreeType = RPlusPlusTree, arma::mat>; TreeType rPlusPlusTree(dataset, 20, 6, 5, 2, 0); CheckRPlusPlusTreeBound(rPlusPlusTree); @@ -1096,11 +1094,10 @@ TEST_CASE("RPlusPlusTreeBoundTest", "[RectangleTreeTraitsTest]") REQUIRE((int) rPlusPlusTree.TreeDepth() == GetMinLevel(rPlusPlusTree)); // Check the MinimalSplitsNumberSweep. - typedef RectangleTree, arma::mat, RPlusTreeSplit, - RPlusPlusTreeDescentHeuristic, RPlusPlusTreeAuxiliaryInformation> - RPlusPlusTreeMinimalSplits; + RPlusPlusTreeDescentHeuristic, RPlusPlusTreeAuxiliaryInformation>; RPlusPlusTreeMinimalSplits rPlusPlusTree2(dataset, 20, 6, 5, 2, 0); @@ -1122,8 +1119,8 @@ TEST_CASE("RPlusPlusTreeTraverserTest", "[RectangleTreeTraitsTest]") arma::Mat neighbors2; arma::mat distances2; - typedef RPlusPlusTree, arma::mat > TreeType; + using TreeType = RPlusPlusTree, arma::mat>; TreeType rPlusPlusTree(dataset, 20, 6, 5, 2, 0); REQUIRE(rPlusPlusTree.NumDescendants() == numP); @@ -1169,8 +1166,8 @@ TEST_CASE("RTreeSplitTest", "[RectangleTreeTraitsTest]") "0.1 0.5;" "0.3 0.7;")); - typedef RTree, - arma::mat> TreeType; + using TreeType = RTree, arma::mat>; TreeType rTree(data, 5, 2, 2, 1, 0); // There's technically no reason they have to be in a certain order, so we @@ -1264,8 +1261,8 @@ TEST_CASE("RStarTreeSplitTest", "[RectangleTreeTraitsTest]") "0.1 0.5;" "0.3 0.7;")); - typedef RStarTree, - arma::mat> TreeType; + using TreeType = RStarTree, arma::mat>; TreeType rTree(data, 5, 2, 2, 1, 0); @@ -1345,7 +1342,7 @@ TEST_CASE("RStarTreeSplitTest", "[RectangleTreeTraitsTest]") TEST_CASE("RectangleTreeMoveDatasetTest", "[RectangleTreeTraitsTest]") { arma::mat dataset = arma::randu(3, 1000); - typedef RTree TreeType; + using TreeType = RTree; TreeType tree(std::move(dataset)); diff --git a/src/mlpack/tests/serialization_test.cpp b/src/mlpack/tests/serialization_test.cpp index d12235f9b5..81d1736d60 100644 --- a/src/mlpack/tests/serialization_test.cpp +++ b/src/mlpack/tests/serialization_test.cpp @@ -299,7 +299,7 @@ TEST_CASE("BinarySpaceTreeTest", "[SerializationTest]") { arma::mat data; data.randu(3, 100); - typedef KDTree TreeType; + using TreeType = KDTree; TreeType tree(data); TreeType* xmlTree; @@ -319,7 +319,7 @@ TEST_CASE("BinarySpaceTreeOverwriteTest", "[SerializationTest]") { arma::mat data; data.randu(3, 100); - typedef KDTree TreeType; + using TreeType = KDTree; TreeType tree(data); arma::mat otherData; @@ -337,8 +337,8 @@ TEST_CASE("CoverTreeTest", "[SerializationTest]") { arma::mat data; data.randu(3, 100); - typedef StandardCoverTree - TreeType; + using TreeType = + StandardCoverTree; TreeType tree(data); TreeType* xmlTree; @@ -392,8 +392,8 @@ TEST_CASE("CoverTreeOverwriteTest", "[SerializationTest]") { arma::mat data; data.randu(3, 100); - typedef StandardCoverTree - TreeType; + using TreeType = + StandardCoverTree; TreeType tree(data); arma::mat otherData; @@ -445,7 +445,7 @@ TEST_CASE("RectangleTreeTest", "[SerializationTest]") { arma::mat data; data.randu(3, 1000); - typedef RTree TreeType; + using TreeType = RTree; TreeType tree(data); TreeType* xmlTree; @@ -500,7 +500,7 @@ TEST_CASE("RectangleTreeOverwriteTest", "[SerializationTest]") { arma::mat data; data.randu(3, 1000); - typedef RTree TreeType; + using TreeType = RTree; TreeType tree(data); arma::mat otherData; @@ -648,7 +648,7 @@ TEST_CASE("SoftmaxRegressionTest", "[SerializationTest]") TEST_CASE("DETTest", "[SerializationTest]") { - typedef DTree DTreeX; + using DTreeX = DTree; // Create a density estimation tree on a random dataset. arma::mat dataset = arma::randu(25, 5000); diff --git a/src/mlpack/tests/softmax_regression_test.cpp b/src/mlpack/tests/softmax_regression_test.cpp index 4b88a8fc83..a962f237a7 100644 --- a/src/mlpack/tests/softmax_regression_test.cpp +++ b/src/mlpack/tests/softmax_regression_test.cpp @@ -223,7 +223,7 @@ TEST_CASE("SoftmaxRegressionTwoClasses", "[SoftmaxRegressionTest]") TEMPLATE_TEST_CASE("SoftmaxRegressionFitIntercept", "[SoftmaxRegressionTest]", arma::fmat, arma::mat) { - typedef TestType MatType; + using MatType = TestType; // Generate a two-Gaussian dataset, // which can't be separated without adding the intercept term. @@ -272,8 +272,8 @@ TEMPLATE_TEST_CASE("SoftmaxRegressionFitIntercept", "[SoftmaxRegressionTest]", TEMPLATE_TEST_CASE("SoftmaxRegressionMultipleClasses", "[SoftmaxRegressionTest]", arma::fmat, arma::mat) { - typedef TestType MatType; - typedef typename GetColType::type VecType; + using MatType = TestType; + using VecType = typename GetColType::type; const size_t points = 5000; const size_t inputSize = 5; @@ -729,7 +729,7 @@ TEST_CASE("SoftmaxImmediateTrainTest", "[SoftmaxRegressionTest]") TEMPLATE_TEST_CASE("SoftmaxRegressionConstructorVariantTest", "[SoftmaxRegressionTest]", arma::fmat, arma::mat) { - typedef TestType MatType; + using MatType = TestType; // Create random data. MatType data(50, 1000, arma::fill::randu); @@ -809,7 +809,7 @@ TEMPLATE_TEST_CASE("SoftmaxRegressionConstructorVariantTest", TEMPLATE_TEST_CASE("SoftmaxRegressionTrainVariantTest", "[SoftmaxRegressionTest]", arma::fmat, arma::mat) { - typedef TestType MatType; + using MatType = TestType; // Create random data. MatType data(50, 1000, arma::fill::randu); diff --git a/src/mlpack/tests/sort_policy_test.cpp b/src/mlpack/tests/sort_policy_test.cpp index 0f33a3beb1..66411170de 100644 --- a/src/mlpack/tests/sort_policy_test.cpp +++ b/src/mlpack/tests/sort_policy_test.cpp @@ -62,7 +62,7 @@ TEST_CASE("NnsNodeToNodeDistance", "[SortPolicyTest]") // Well, there's no easy way to make HRectBounds the way we want, so we have // to make them and then expand the region to include new points. arma::mat dataset("1"); - typedef KDTree TreeType; + using TreeType = KDTree; TreeType nodeOne(dataset); arma::vec utility(1); utility[0] = 0; @@ -118,7 +118,7 @@ TEST_CASE("NnsPointToNodeDistance", "[SortPolicyTest]") utility[0] = 0; arma::mat dataset("1"); - typedef KDTree TreeType; + using TreeType = KDTree; TreeType node(dataset); node.Bound() = HRectBound(1); node.Bound() |= utility; @@ -191,7 +191,7 @@ TEST_CASE("FnsNodeToNodeDistance", "[SortPolicyTest]") utility[0] = 0; arma::mat dataset("1"); - typedef KDTree TreeType; + using TreeType = KDTree; TreeType nodeOne(dataset); nodeOne.Bound() = HRectBound(1); nodeOne.Bound() |= utility; @@ -243,7 +243,7 @@ TEST_CASE("FnsPointToNodeDistance", "[SortPolicyTest]") utility[0] = 0; arma::mat dataset("1"); - typedef KDTree TreeType; + using TreeType = KDTree; TreeType node(dataset); node.Bound() = HRectBound(1); node.Bound() |= utility; diff --git a/src/mlpack/tests/sparse_coding_test.cpp b/src/mlpack/tests/sparse_coding_test.cpp index 0a732cf2a5..03c31fb4f7 100644 --- a/src/mlpack/tests/sparse_coding_test.cpp +++ b/src/mlpack/tests/sparse_coding_test.cpp @@ -50,8 +50,8 @@ void SCVerifyCorrectness(const VecType& beta, TEMPLATE_TEST_CASE("SparseCodingTestCodingStepLasso", "[SparseCodingTest]", arma::mat, arma::fmat) { - typedef TestType MatType; - typedef arma::Col VecType; + using MatType = TestType; + using VecType = arma::Col; double lambda1 = 0.1; uword nAtoms = 25; @@ -84,8 +84,8 @@ TEMPLATE_TEST_CASE("SparseCodingTestCodingStepLasso", "[SparseCodingTest]", TEMPLATE_TEST_CASE("SparseCodingTestCodingStepElasticNet", "[SparseCodingTest]", arma::mat, arma::fmat) { - typedef TestType MatType; - typedef arma::Col VecType; + using MatType = TestType; + using VecType = arma::Col; double lambda1 = 0.1; double lambda2 = 0.2; @@ -120,7 +120,7 @@ TEMPLATE_TEST_CASE("SparseCodingTestCodingStepElasticNet", "[SparseCodingTest]", TEMPLATE_TEST_CASE("SparseCodingTestDictionaryStep", "[SparseCodingTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; const double tol = std::is_same_v ? 0.01 : 1e-6; @@ -153,7 +153,7 @@ TEMPLATE_TEST_CASE("SparseCodingTestDictionaryStep", "[SparseCodingTest]", TEMPLATE_TEST_CASE("SerializationTest", "[SparseCodingTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; MatType X = randu(100, 100); size_t nAtoms = 25; @@ -213,7 +213,7 @@ TEMPLATE_TEST_CASE("SerializationTest", "[SparseCodingTest]", arma::mat, TEMPLATE_TEST_CASE("SparseCodingTrainReturnObjective", "[SparseCodingTest]", arma::mat, arma::fmat) { - typedef TestType MatType; + using MatType = TestType; const double tol = std::is_same_v ? 0.01 : 1e-6; diff --git a/src/mlpack/tests/spill_tree_test.cpp b/src/mlpack/tests/spill_tree_test.cpp index 7075932a6c..e2b1a560fa 100644 --- a/src/mlpack/tests/spill_tree_test.cpp +++ b/src/mlpack/tests/spill_tree_test.cpp @@ -27,7 +27,7 @@ TEST_CASE("SpillTreeConstructionCountTest", "[SpillTreeTest]") arma::mat dataset; dataset.randu(3, 1000); // 1000 points in 3 dimensions. - typedef SPTree TreeType; + using TreeType = SPTree; // When overlapping buffer is 0, there shouldn't be repeated points. TreeType tree1(dataset, 0); @@ -79,7 +79,7 @@ TEST_CASE("SpillTreeConstructionParentTest", "[SpillTreeTest]") arma::mat dataset; dataset.randu(3, 1000); // 1000 points in 3 dimensions. - typedef SPTree TreeType; + using TreeType = SPTree; TreeType tree(dataset, 0.5); @@ -204,11 +204,11 @@ void SpillTreeHyperplaneTestAux() */ TEST_CASE("SpillTreeHyperplaneTest", "[SpillTreeTest]") { - typedef SPTree SpillType1; - typedef NonOrtSPTree SpillType2; - typedef MeanSPTree SpillType3; - typedef NonOrtMeanSPTree - SpillType4; + using SpillType1 = SPTree; + using SpillType2 = NonOrtSPTree; + using SpillType3 = MeanSPTree; + using SpillType4 = + NonOrtMeanSPTree; SpillTreeHyperplaneTestAux(); SpillTreeHyperplaneTestAux(); @@ -222,7 +222,7 @@ TEST_CASE("SpillTreeHyperplaneTest", "[SpillTreeTest]") TEST_CASE("SpillTreeMoveConstructorTest", "[SpillTreeTest]") { arma::mat dataset = arma::randu(3, 1000); - typedef SPTree TreeType; + using TreeType = SPTree; TreeType tree(dataset); @@ -257,7 +257,7 @@ TEST_CASE("SpillTreeMoveConstructorTest", "[SpillTreeTest]") TEST_CASE("SpillTreeCopyConstructorTest", "[SpillTreeTest]") { arma::mat dataset = arma::randu(3, 1000); - typedef SPTree TreeType; + using TreeType = SPTree; TreeType* tree = new TreeType(dataset); @@ -293,7 +293,7 @@ TEST_CASE("SpillTreeCopyConstructorTest", "[SpillTreeTest]") TEST_CASE("SpillTreeMoveDatasetTest", "[SpillTreeTest]") { arma::mat dataset = arma::randu(3, 1000); - typedef SPTree TreeType; + using TreeType = SPTree; TreeType tree(std::move(dataset)); diff --git a/src/mlpack/tests/svd_batch_test.cpp b/src/mlpack/tests/svd_batch_test.cpp index 379d78b64e..2bcc9003bd 100644 --- a/src/mlpack/tests/svd_batch_test.cpp +++ b/src/mlpack/tests/svd_batch_test.cpp @@ -24,7 +24,7 @@ using namespace arma; TEMPLATE_TEST_CASE("SVDBatchConvergenceElementTest", "[SVDBatchTest]", float, double) { - typedef TestType eT; + using eT = TestType; SpMat data; data.sprandn(100, 100, 0.2); @@ -67,7 +67,7 @@ class SpecificRandomInitialization */ TEMPLATE_TEST_CASE("SVDBatchMomentumTest", "[SVDBatchTest]", float, double) { - typedef TestType eT; + using eT = TestType; Mat dataset; if (!data::Load("GroupLensSmall.csv", dataset)) @@ -121,7 +121,7 @@ TEMPLATE_TEST_CASE("SVDBatchMomentumTest", "[SVDBatchTest]", float, double) TEMPLATE_TEST_CASE("SVDBatchRegularizationTest", "[SVDBatchTest]", float, double) { - typedef TestType eT; + using eT = TestType; Mat dataset; if (!data::Load("GroupLensSmall.csv", dataset)) diff --git a/src/mlpack/tests/svd_incremental_test.cpp b/src/mlpack/tests/svd_incremental_test.cpp index 1a78ec95ad..9fa6ffe458 100644 --- a/src/mlpack/tests/svd_incremental_test.cpp +++ b/src/mlpack/tests/svd_incremental_test.cpp @@ -25,7 +25,7 @@ using namespace arma; TEMPLATE_TEST_CASE("SVDIncompleteIncrementalConvergenceTest", "[SVDIncrementalTest]", float, double) { - typedef TestType eT; + using eT = TestType; SpMat data; data.sprandn(100, 100, 0.2); @@ -53,7 +53,7 @@ TEMPLATE_TEST_CASE("SVDIncompleteIncrementalConvergenceTest", TEMPLATE_TEST_CASE("SVDCompleteIncrementalConvergenceTest", "[SVDIncrementalTest]", float, double) { - typedef TestType eT; + using eT = TestType; SpMat data; data.sprandn(100, 100, 0.2); @@ -101,7 +101,7 @@ class SpecificRandomInitialization TEMPLATE_TEST_CASE("SVDIncompleteIncrementalRegularizationTest", "[SVDIncrementalTest]", float, double) { - typedef TestType eT; + using eT = TestType; Mat dataset; if (!data::Load("GroupLensSmall.csv", dataset)) diff --git a/src/mlpack/tests/tree_test.cpp b/src/mlpack/tests/tree_test.cpp index 7f38097f97..bb4e5a55f9 100644 --- a/src/mlpack/tests/tree_test.cpp +++ b/src/mlpack/tests/tree_test.cpp @@ -1130,7 +1130,7 @@ TEST_CASE("FurthestPointDistanceTest", "[TreeTest]") arma::mat dataset; dataset.randu(5, 100); - typedef KDTree TreeType; + using TreeType = KDTree; TreeType tree(dataset); // Now, check each node. @@ -1176,7 +1176,7 @@ TEST_CASE("ParentDistanceTest", "[TreeTest]") arma::mat dataset; dataset.randu(5, 500); - typedef KDTree TreeType; + using TreeType = KDTree; TreeType tree(dataset); // The root's parent distance should be 0 (although maybe it doesn't actually @@ -1222,7 +1222,7 @@ TEST_CASE("ParentDistanceTestWithMapping", "[TreeTest]") dataset.randu(5, 500); std::vector oldFromNew; - typedef KDTree TreeType; + using TreeType = KDTree; TreeType tree(dataset, oldFromNew); // The root's parent distance should be 0 (although maybe it doesn't actually @@ -1286,7 +1286,7 @@ void GenerateVectorOfTree(TreeType* node, */ TEST_CASE("KdTreeTest", "[TreeTest]") { - typedef KDTree TreeType; + using TreeType = KDTree; size_t maxRuns = 10; // Ten total tests. size_t pointIncrements = 1000; // Range is from 2000 points to 11000. @@ -1355,7 +1355,7 @@ TEST_CASE("KdTreeTest", "[TreeTest]") TEST_CASE("MaxRPTreeTest", "[TreeTest]") { - typedef MaxRPTree TreeType; + using TreeType = MaxRPTree; size_t maxRuns = 10; // Ten total tests. size_t pointIncrements = 1000; // Range is from 2000 points to 11000. @@ -1398,7 +1398,7 @@ TEST_CASE("MaxRPTreeTest", "[TreeTest]") template bool CheckHyperplaneSplit(const TreeType& tree) { - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; const typename TreeType::Mat& dataset = tree.Dataset(); arma::Mat mat(dataset.n_rows + 1, @@ -1487,7 +1487,7 @@ void CheckMaxRPTreeSplit(const TreeType& tree) TEST_CASE("MaxRPTreeSplitTest", "[TreeTest]") { - typedef MaxRPTree TreeType; + using TreeType = MaxRPTree; arma::mat dataset; dataset.randu(8, 1000); TreeType root(dataset); @@ -1497,7 +1497,7 @@ TEST_CASE("MaxRPTreeSplitTest", "[TreeTest]") TEST_CASE("RPTreeTest", "[TreeTest]") { - typedef RPTree TreeType; + using TreeType = RPTree; size_t maxRuns = 10; // Ten total tests. size_t pointIncrements = 1000; // Range is from 2000 points to 11000. @@ -1540,7 +1540,7 @@ TEST_CASE("RPTreeTest", "[TreeTest]") template void CheckRPTreeSplit(const TreeType& tree) { - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; if (tree.IsLeaf()) return; @@ -1575,7 +1575,7 @@ void CheckRPTreeSplit(const TreeType& tree) TEST_CASE("RPTreeSplitTest", "[TreeTest]") { - typedef RPTree TreeType; + using TreeType = RPTree; arma::mat dataset; dataset.randu(8, 1000); TreeType root(dataset); @@ -1611,7 +1611,7 @@ bool CheckPointBounds(TreeType& node) */ TEST_CASE("BallTreeTest", "[TreeTest]") { - typedef BallTree TreeType; + using TreeType = BallTree; size_t maxRuns = 10; // Ten total tests. size_t pointIncrements = 1000; // Range is from 2000 points to 11000. @@ -1690,8 +1690,8 @@ void GenerateVectorOfTree(TreeType* node, */ TEST_CASE("ExhaustiveSparseKDTreeTest", "[TreeTest]") { - typedef KDTree> - TreeType; + using TreeType = + KDTree>; size_t maxRuns = 2; // Two total tests. size_t pointIncrements = 200; // Range is from 200 points to 400. @@ -1859,8 +1859,8 @@ TEST_CASE("SimpleCoverTreeConstructionTest", "[TreeTest]") "2.0 1.0;")); // The root point will be the first point, (0, 0). - typedef StandardCoverTree - TreeType; + using TreeType = StandardCoverTree; TreeType tree(data); // Expansion constant of 2.0. // The furthest point from the root will be (-5, -5), with a distance of @@ -1897,8 +1897,8 @@ TEST_CASE("CoverTreeConstructionTest", "[TreeTest]") // 50-dimensional, 1000 point. dataset.randu(50, 1000); - typedef StandardCoverTree - TreeType; + using TreeType = + StandardCoverTree; TreeType tree(dataset); // Ensure each leaf is only created once. @@ -1929,8 +1929,8 @@ TEST_CASE("SparseCoverTreeConstructionTest", "[TreeTest]") // 50-dimensional, 1000 point. dataset.sprandu(50, 1000, 0.3); - typedef StandardCoverTree - TreeType; + using TreeType = + StandardCoverTree; TreeType tree(dataset); // Ensure each leaf is only created once. @@ -1960,8 +1960,8 @@ TEST_CASE("CoverTreeManualConstructorTest", "[TreeTest]") arma::mat dataset; dataset.zeros(10, 10); - typedef StandardCoverTree - TreeType; + using TreeType = + StandardCoverTree; TreeType node(dataset, 1.3, 3, 2, NULL, 1.5, 2.75); REQUIRE(&node.Dataset() == &dataset); @@ -1982,8 +1982,8 @@ TEST_CASE("CoverTreeAlternateMetricTest", "[TreeTest]") // 5-dimensional, 300-point dataset. dataset.randu(5, 300); - typedef StandardCoverTree - TreeType; + using TreeType = + StandardCoverTree; TreeType tree(dataset); // Ensure each leaf is only created once. @@ -2012,8 +2012,8 @@ TEST_CASE("CoverTreeCopyConstructor", "[TreeTest]") { arma::mat dataset; dataset.randu(10, 10); // dataset is irrelevant. - typedef StandardCoverTree - TreeType; + using TreeType = + StandardCoverTree; TreeType c(dataset, 1.3, 0, 5, NULL, 1.45, 5.2); // Random parameters. c.Children().push_back(new TreeType(dataset, 1.3, 1, 4, &c, 1.3, 2.45)); c.Children().push_back(new TreeType(dataset, 1.5, 2, 3, &c, 1.2, 5.67)); @@ -2070,8 +2070,8 @@ TEST_CASE("CoverTreeCopyConstructor", "[TreeTest]") TEST_CASE("CoverTreeMoveDatasetTest", "[TreeTest]") { arma::mat dataset = arma::randu(3, 1000); - typedef StandardCoverTree - TreeType; + using TreeType = + StandardCoverTree; TreeType t(std::move(dataset)); @@ -2094,7 +2094,7 @@ TEST_CASE("CoverTreeMoveDatasetTest", "[TreeTest]") TEST_CASE("BinarySpaceTreeCopyConstructor", "[TreeTest]") { arma::mat data("1"); - typedef KDTree TreeType; + using TreeType = KDTree; TreeType b(data); b.Begin() = 10; b.Count() = 50; diff --git a/src/mlpack/tests/tree_traits_test.cpp b/src/mlpack/tests/tree_traits_test.cpp index bbf98113f6..8c3c8bfbf2 100644 --- a/src/mlpack/tests/tree_traits_test.cpp +++ b/src/mlpack/tests/tree_traits_test.cpp @@ -44,7 +44,7 @@ TEST_CASE("DefaultsTraitsTest", "[TreeTraitsTest]") // Test the binary space tree traits. TEST_CASE("BinarySpaceTreeTraitsTest", "[TreeTraitsTest]") { - typedef BinarySpaceTree> TreeType; + using TreeType = BinarySpaceTree>; // Children are non-overlapping. bool b = TreeTraits::HasOverlappingChildren; diff --git a/src/mlpack/tests/ub_tree_test.cpp b/src/mlpack/tests/ub_tree_test.cpp index baf811019d..b43a644552 100644 --- a/src/mlpack/tests/ub_tree_test.cpp +++ b/src/mlpack/tests/ub_tree_test.cpp @@ -18,10 +18,9 @@ using namespace mlpack; TEST_CASE("AddressTest", "[UBTreeTest]") { - typedef double ElemType; - typedef std::conditional_t AddressElemType; + using ElemType = double; + using AddressElemType = std::conditional_t; arma::Mat dataset(8, 1000); dataset.randu(); @@ -43,10 +42,9 @@ TEST_CASE("AddressTest", "[UBTreeTest]") template void CheckSplit(const TreeType& tree) { - typedef typename TreeType::ElemType ElemType; - typedef std::conditional_t AddressElemType; + using ElemType = typename TreeType::ElemType; + using AddressElemType = std::conditional_t; if (tree.IsLeaf()) return; @@ -86,7 +84,7 @@ void CheckSplit(const TreeType& tree) TEST_CASE("UBTreeSplitTest", "[UBTreeTest]") { - typedef UBTree TreeType; + using TreeType = UBTree; arma::mat dataset(8, 1000); dataset.randu(); @@ -98,7 +96,7 @@ TEST_CASE("UBTreeSplitTest", "[UBTreeTest]") template void CheckBound(const TreeType& tree) { - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; for (size_t i = 0; i < tree.NumDescendants(); ++i) { arma::Col point = tree.Dataset().col(tree.Descendant(i)); @@ -139,7 +137,7 @@ void CheckBound(const TreeType& tree) TEST_CASE("UBTreeBoundTest", "[UBTreeTest]") { - typedef UBTree TreeType; + using TreeType = UBTree; arma::mat dataset(8, 1000); dataset.randu(); @@ -152,7 +150,7 @@ TEST_CASE("UBTreeBoundTest", "[UBTreeTest]") template void CheckDistance(TreeType& tree, TreeType* node = NULL) { - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; if (node == NULL) { node = &tree; @@ -239,7 +237,7 @@ void CheckDistance(TreeType& tree, TreeType* node = NULL) TEST_CASE("UBTreeDistanceTest", "[UBTreeTest]") { - typedef UBTree TreeType; + using TreeType = UBTree; arma::mat dataset(8, 200); dataset.randu(); @@ -251,7 +249,7 @@ TEST_CASE("UBTreeDistanceTest", "[UBTreeTest]") TEST_CASE("UBTreeTest", "[UBTreeTest]") { - typedef UBTree TreeType; + using TreeType = UBTree; size_t maxRuns = 10; // Ten total tests. size_t pointIncrements = 1000; // Range is from 2000 points to 11000. diff --git a/src/mlpack/tests/vantage_point_tree_test.cpp b/src/mlpack/tests/vantage_point_tree_test.cpp index 4dde750504..fe7e8a0008 100644 --- a/src/mlpack/tests/vantage_point_tree_test.cpp +++ b/src/mlpack/tests/vantage_point_tree_test.cpp @@ -18,7 +18,7 @@ using namespace mlpack; TEST_CASE("VPTreeTraitsTest", "[VantagePointTreeTest]") { - typedef VPTree TreeType; + using TreeType = VPTree; bool b = TreeTraits::HasOverlappingChildren; REQUIRE(b == true); @@ -124,7 +124,7 @@ TEST_CASE("HollowBallBoundTest", "[VantagePointTreeTest]") template void CheckBound(TreeType& tree) { - typedef typename TreeType::ElemType ElemType; + using ElemType = typename TreeType::ElemType; if (tree.IsLeaf()) { // Ensure that the bound contains all descendant points. @@ -168,7 +168,7 @@ void CheckBound(TreeType& tree) TEST_CASE("VPTreeBoundTest", "[VantagePointTreeTest]") { - typedef VPTree TreeType; + using TreeType = VPTree; arma::mat dataset(8, 1000); dataset.randu(); @@ -179,7 +179,7 @@ TEST_CASE("VPTreeBoundTest", "[VantagePointTreeTest]") TEST_CASE("VPTreeTest", "[VantagePointTreeTest]") { - typedef VPTree TreeType; + using TreeType = VPTree; size_t maxRuns = 10; // Ten total tests. size_t pointIncrements = 1000; // Range is from 2000 points to 11000. From db14293137192c68cb01c0dc929719e595c23f68 Mon Sep 17 00:00:00 2001 From: Martin Lambertsen Date: Fri, 25 Oct 2024 11:11:20 +0200 Subject: [PATCH 15/25] Fix review findings --- src/mlpack/bindings/cli/delete_allocated_memory.hpp | 2 +- src/mlpack/bindings/cli/get_allocated_memory.hpp | 2 +- src/mlpack/bindings/cli/get_param.hpp | 2 +- src/mlpack/bindings/cli/get_raw_param.hpp | 2 +- src/mlpack/bindings/cli/output_param_impl.hpp | 2 +- src/mlpack/bindings/python/tests/test_python_binding.py | 4 ++-- .../string_encoding_policies/tf_idf_encoding_policy.hpp | 4 ++-- .../tree/rectangle_tree/x_tree_auxiliary_information.hpp | 2 +- .../ann/activation_functions/bipolar_sigmoid_function.hpp | 2 +- .../bayesian_linear_regression_impl.hpp | 2 +- .../splits/best_binary_categorical_split_impl.hpp | 2 +- src/mlpack/methods/lsh/lsh_search_impl.hpp | 2 +- src/mlpack/tests/ann/recurrent_network_test.cpp | 2 +- src/mlpack/tests/det_test.cpp | 4 ++-- src/mlpack/tests/linear_svm_test.cpp | 4 ++-- .../tests/main_tests/bayesian_linear_regression_test.cpp | 6 +++--- src/mlpack/tests/main_tests/cf_test.cpp | 2 +- src/mlpack/tests/main_tests/hmm_train_test.cpp | 2 +- src/mlpack/tests/main_tests/preprocess_split_test.cpp | 6 +++--- src/mlpack/tests/random_test.cpp | 2 +- src/mlpack/tests/softmax_regression_test.cpp | 2 +- 21 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/mlpack/bindings/cli/delete_allocated_memory.hpp b/src/mlpack/bindings/cli/delete_allocated_memory.hpp index 910fc7636c..628fbe9f61 100644 --- a/src/mlpack/bindings/cli/delete_allocated_memory.hpp +++ b/src/mlpack/bindings/cli/delete_allocated_memory.hpp @@ -42,7 +42,7 @@ void DeleteAllocatedMemoryImpl( const std::enable_if_t::value>* = 0) { // Delete the allocated memory (hopefully we actually own it). - using TupleType = std::tuple; + using TupleType = std::tuple; delete std::get<0>(*std::any_cast(&d.value)); } diff --git a/src/mlpack/bindings/cli/get_allocated_memory.hpp b/src/mlpack/bindings/cli/get_allocated_memory.hpp index 56e3492b65..39db794529 100644 --- a/src/mlpack/bindings/cli/get_allocated_memory.hpp +++ b/src/mlpack/bindings/cli/get_allocated_memory.hpp @@ -44,7 +44,7 @@ void* GetAllocatedMemory( { // Here we have a model, which is a tuple, and we need the address of the // memory. - using TupleType = std::tuple; + using TupleType = std::tuple; return std::get<0>(*std::any_cast(&d.value)); } diff --git a/src/mlpack/bindings/cli/get_param.hpp b/src/mlpack/bindings/cli/get_param.hpp index fe20f1d7dc..b777b9377a 100644 --- a/src/mlpack/bindings/cli/get_param.hpp +++ b/src/mlpack/bindings/cli/get_param.hpp @@ -115,7 +115,7 @@ T*& GetParam( { // If the model is an input model, we have to load it from file. 'value' // contains the filename. - using TupleType = std::tuple; + using TupleType = std::tuple; TupleType* tuple = std::any_cast(&d.value); const std::string& value = std::get<1>(*tuple); if (d.input && !d.loaded) diff --git a/src/mlpack/bindings/cli/get_raw_param.hpp b/src/mlpack/bindings/cli/get_raw_param.hpp index 4c65c11ba4..189c3b3e29 100644 --- a/src/mlpack/bindings/cli/get_raw_param.hpp +++ b/src/mlpack/bindings/cli/get_raw_param.hpp @@ -63,7 +63,7 @@ T*& GetRawParam( const std::enable_if_t::value>* = 0) { // Don't load the model. - using TupleType = std::tuple; + using TupleType = std::tuple; T*& value = std::get<0>(*std::any_cast(&d.value)); return value; } diff --git a/src/mlpack/bindings/cli/output_param_impl.hpp b/src/mlpack/bindings/cli/output_param_impl.hpp index d05432a4fd..1f3e167392 100644 --- a/src/mlpack/bindings/cli/output_param_impl.hpp +++ b/src/mlpack/bindings/cli/output_param_impl.hpp @@ -77,7 +77,7 @@ void OutputParamImpl( // The const cast is necessary here because Serialize() can't ever be marked // const. In this case we can assume it though, since we will be saving and // not loading. - using TupleType = std::tuple; + using TupleType = std::tuple; T*& output = const_cast(std::get<0>(*std::any_cast( &data.value))); const std::string& filename = diff --git a/src/mlpack/bindings/python/tests/test_python_binding.py b/src/mlpack/bindings/python/tests/test_python_binding.py index bfa21810d1..75f6259057 100644 --- a/src/mlpack/bindings/python/tests/test_python_binding.py +++ b/src/mlpack/bindings/python/tests/test_python_binding.py @@ -293,7 +293,7 @@ class TestPythonBinding(unittest.TestCase): """ Test a Pandas Series input paramter """ - x = pd.Series(np.random.rand(100)) + x = pd.Series(np.random.rand(100)) z = copy.deepcopy(x) output = test_python_binding(string_in='hello', @@ -313,7 +313,7 @@ class TestPythonBinding(unittest.TestCase): """ Test a Pandas Series input paramter """ - x = pd.Series(np.random.rand(100)) + x = pd.Series(np.random.rand(100)) output = test_python_binding(string_in='hello', int_in=12, diff --git a/src/mlpack/core/data/string_encoding_policies/tf_idf_encoding_policy.hpp b/src/mlpack/core/data/string_encoding_policies/tf_idf_encoding_policy.hpp index 8f6d2b6242..da3534a06c 100644 --- a/src/mlpack/core/data/string_encoding_policies/tf_idf_encoding_policy.hpp +++ b/src/mlpack/core/data/string_encoding_policies/tf_idf_encoding_policy.hpp @@ -158,7 +158,7 @@ class TfIdfEncodingPolicy InverseDocumentFrequency( output.n_cols, numContainingStrings[value]); - output(value - 1, line) = tf * idf; + output(value - 1, line) = tf * idf; } /** @@ -188,7 +188,7 @@ class TfIdfEncodingPolicy const ElemType idf = InverseDocumentFrequency( output.size(), numContainingStrings[value]); - output[line][value - 1] = tf * idf; + output[line][value - 1] = tf * idf; } /* diff --git a/src/mlpack/core/tree/rectangle_tree/x_tree_auxiliary_information.hpp b/src/mlpack/core/tree/rectangle_tree/x_tree_auxiliary_information.hpp index 953049a245..1d0d858a45 100644 --- a/src/mlpack/core/tree/rectangle_tree/x_tree_auxiliary_information.hpp +++ b/src/mlpack/core/tree/rectangle_tree/x_tree_auxiliary_information.hpp @@ -165,7 +165,7 @@ class XTreeAuxiliaryInformation * The X tree requires that the tree records it's "split history". To make * this easy, we use the following structure. */ - using SplitHistoryStruct = struct SplitHistoryStruct + struct SplitHistoryStruct { int lastDimension; std::vector history; diff --git a/src/mlpack/methods/ann/activation_functions/bipolar_sigmoid_function.hpp b/src/mlpack/methods/ann/activation_functions/bipolar_sigmoid_function.hpp index d960a711ba..080744f167 100644 --- a/src/mlpack/methods/ann/activation_functions/bipolar_sigmoid_function.hpp +++ b/src/mlpack/methods/ann/activation_functions/bipolar_sigmoid_function.hpp @@ -75,7 +75,7 @@ class BipolarSigmoidFunction const OutputVecType& y, DerivVecType& dy) { - dy = (1.0 - pow(y, 2)) / 2.0; + dy = (1.0 - pow(y, 2)) / 2.0; } }; // class BipolarSigmoidFunction diff --git a/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression_impl.hpp b/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression_impl.hpp index e293e825e5..f278ada551 100644 --- a/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression_impl.hpp +++ b/src/mlpack/methods/bayesian_linear_regression/bayesian_linear_regression_impl.hpp @@ -121,7 +121,7 @@ BayesianLinearRegression::Train( // Initialize the hyperparameters and begin with an infinitely broad prior. alpha = ((ElemType) 1e-6); - beta = ((ElemType) 1 / (var(t, 1) * 0.1)); + beta = ((ElemType) 1 / (var(t, 1) * 0.1)); unsigned short i = 0; ElemType crit = ((ElemType) 1.0); diff --git a/src/mlpack/methods/decision_tree/splits/best_binary_categorical_split_impl.hpp b/src/mlpack/methods/decision_tree/splits/best_binary_categorical_split_impl.hpp index 1e078c5600..2a81dddecc 100644 --- a/src/mlpack/methods/decision_tree/splits/best_binary_categorical_split_impl.hpp +++ b/src/mlpack/methods/decision_tree/splits/best_binary_categorical_split_impl.hpp @@ -180,7 +180,7 @@ double BestBinaryCategoricalSplit::SplitIfBetter( } for (size_t i = 0; i < numCategories; ++i) { - categoryResponse[i] = categoryCounts[i] == 0 ? 0 : + categoryResponse[i] = categoryCounts[i] == 0 ? 0 : categoryResponse[i] / categoryCounts[i]; } diff --git a/src/mlpack/methods/lsh/lsh_search_impl.hpp b/src/mlpack/methods/lsh/lsh_search_impl.hpp index c45a9eebc2..23157393fd 100644 --- a/src/mlpack/methods/lsh/lsh_search_impl.hpp +++ b/src/mlpack/methods/lsh/lsh_search_impl.hpp @@ -834,7 +834,7 @@ void LSHSearch::ReturnIndicesFromTable( { for (size_t p = 0; p < T + 1; ++p) { - const size_t hashInd = hashMat(p, i); // Find the query's bucket. + const size_t hashInd = hashMat(p, i); // Find the query's bucket. const size_t tableRow = bucketRowInHashTable[hashInd]; if (tableRow < secondHashSize) diff --git a/src/mlpack/tests/ann/recurrent_network_test.cpp b/src/mlpack/tests/ann/recurrent_network_test.cpp index fc150ab516..960b0d9462 100644 --- a/src/mlpack/tests/ann/recurrent_network_test.cpp +++ b/src/mlpack/tests/ann/recurrent_network_test.cpp @@ -34,7 +34,7 @@ void GenerateNoisySines(arma::cube& data, const size_t sequences, const double noise = 0.3) { - arma::colvec x = arma::linspace(0, points - 1, points) / + arma::colvec x = arma::linspace(0, points - 1, points) / points * 20.0; arma::colvec y1 = arma::sin(x + randu() * 3.0); arma::colvec y2 = arma::sin(x / 2.0 + randu() * 3.0); diff --git a/src/mlpack/tests/det_test.cpp b/src/mlpack/tests/det_test.cpp index 941f9190e8..d60bc0e2e6 100644 --- a/src/mlpack/tests/det_test.cpp +++ b/src/mlpack/tests/det_test.cpp @@ -267,7 +267,7 @@ TEST_CASE("TestGrow", "[DETTest]") rootError = -log(4.0) - log(7.0) - log(7.0); lError = 2 * log(2.0 / 5.0) - (log(7.0) + log(4.0) + log(4.5)); - rError = 2 * log(3.0 / 5.0) - (log(7.0) + log(4.0) + log(2.5)); + rError = 2 * log(3.0 / 5.0) - (log(7.0) + log(4.0) + log(2.5)); rlError = 2 * log(1.0 / 5.0) - (log(0.5) + log(4.0) + log(2.5)); rrError = 2 * log(2.0 / 5.0) - (log(6.5) + log(4.0) + log(2.5)); @@ -396,7 +396,7 @@ TEST_CASE("TestVariableImportance", "[DETTest]") rootError = -1.0 * exp(-log(4.0) - log(7.0) - log(7.0)); lError = -1.0 * exp(2 * log(2.0 / 5.0) - (log(7.0) + log(4.0) + log(4.5))); - rError = -1.0 * exp(2 * log(3.0 / 5.0) - (log(7.0) + log(4.0) + log(2.5))); + rError = -1.0 * exp(2 * log(3.0 / 5.0) - (log(7.0) + log(4.0) + log(2.5))); rlError = -1.0 * exp(2 * log(1.0 / 5.0) - (log(0.5) + log(4.0) + log(2.5))); rrError = -1.0 * exp(2 * log(2.0 / 5.0) - (log(6.5) + log(4.0) + log(2.5))); diff --git a/src/mlpack/tests/linear_svm_test.cpp b/src/mlpack/tests/linear_svm_test.cpp index a32fd54114..e567e95c6e 100644 --- a/src/mlpack/tests/linear_svm_test.cpp +++ b/src/mlpack/tests/linear_svm_test.cpp @@ -575,7 +575,7 @@ TEST_CASE("LinearSVMLBFGSTwoClasses", "[LinearSVMTest]") for (size_t i = 0; i < points / 2; ++i) { data.col(i) = g1.Random(); - labels(i) = 0; + labels(i) = 0; } for (size_t i = points / 2; i < points; ++i) { @@ -844,7 +844,7 @@ TEST_CASE("LinearSVMParallelSGDTwoClasses", "[LinearSVMTest]") for (size_t i = 0; i < points / 2; ++i) { data.col(i) = g1.Random(); - labels(i) = 0; + labels(i) = 0; } for (size_t i = points / 2; i < points; ++i) { diff --git a/src/mlpack/tests/main_tests/bayesian_linear_regression_test.cpp b/src/mlpack/tests/main_tests/bayesian_linear_regression_test.cpp index ed5b690852..b4137929c7 100644 --- a/src/mlpack/tests/main_tests/bayesian_linear_regression_test.cpp +++ b/src/mlpack/tests/main_tests/bayesian_linear_regression_test.cpp @@ -33,7 +33,7 @@ TEST_CASE_METHOD(BRTestFixture, int n = 50, m = 4; arma::mat matX = arma::randu(m, n); arma::rowvec omega = arma::randu(m); - arma::rowvec y = omega * matX; + arma::rowvec y = omega * matX; SetInputParam("input", std::move(matX)); SetInputParam("responses", std::move(y)); @@ -59,7 +59,7 @@ TEST_CASE_METHOD(BRTestFixture, arma::mat matX = arma::randu(m, n); arma::mat matXtest = arma::randu(m, 2 * n); const arma::rowvec omega = arma::randu(m); - arma::rowvec y = omega * matX; + arma::rowvec y = omega * matX; BayesianLinearRegression<> model; model.Train(matX, y); @@ -99,7 +99,7 @@ TEST_CASE_METHOD(BRTestFixture, arma::mat matX = arma::randu(m, n); arma::mat matXtest = arma::randu(m, 2 * n); const arma::rowvec omega = arma::randu(m); - arma::rowvec y = omega * matX; + arma::rowvec y = omega * matX; BayesianLinearRegression<> model; model.Train(matX, y); diff --git a/src/mlpack/tests/main_tests/cf_test.cpp b/src/mlpack/tests/main_tests/cf_test.cpp index e6d5e50163..bca867878d 100644 --- a/src/mlpack/tests/main_tests/cf_test.cpp +++ b/src/mlpack/tests/main_tests/cf_test.cpp @@ -352,7 +352,7 @@ TEST_CASE_METHOD(CFTestFixture, "CFMaxIterationsTest", FixedRandomSeed(); RUN_BINDING(); - outputModel = params.Get("output_model"); + outputModel = params.Get("output_model"); // By default, the main program use NMFPolicy. CFType& cf = dynamic_castTransition()*100, diff --git a/src/mlpack/tests/main_tests/preprocess_split_test.cpp b/src/mlpack/tests/main_tests/preprocess_split_test.cpp index 05eb4c7995..291412042a 100644 --- a/src/mlpack/tests/main_tests/preprocess_split_test.cpp +++ b/src/mlpack/tests/main_tests/preprocess_split_test.cpp @@ -310,9 +310,9 @@ TEST_CASE_METHOD( * * The vc2 dataset labels file contains 40 0s, 100 1s, and 67 2s. * Considering a test ratio of 0.3, - * Number of 0s in the test set lables = 12 ( floor(40 * 0.3) = floor(12) ). - * Number of 1s in the test set labels = 30 ( floor(100 * 0.3) = floor(30) ). - * Number of 2s in the test set labels = 20 ( floor(67 * 0.3) = floor(20.1) ). + * Number of 0s in the test set lables = 12 ( floor(40 * 0.3) = floor(12) ). + * Number of 1s in the test set labels = 30 ( floor(100 * 0.3) = floor(30) ). + * Number of 2s in the test set labels = 20 ( floor(67 * 0.3) = floor(20.1) ). * Total points in the test set = 62 ( 12 + 30 + 20 ). */ TEST_CASE_METHOD( diff --git a/src/mlpack/tests/random_test.cpp b/src/mlpack/tests/random_test.cpp index c3a576e06a..e0f90fdc1b 100644 --- a/src/mlpack/tests/random_test.cpp +++ b/src/mlpack/tests/random_test.cpp @@ -77,7 +77,7 @@ TEST_CASE("WeightedRandomTest", "[RandomTest]") for (std::vector weightSet : weights) { DiscreteDistribution<> d(1); - d.Probabilities(0) = arma::vec(weightSet); + d.Probabilities(0) = arma::vec(weightSet); std::vector count(weightSet.size(), 0); for (size_t iter = 0; iter < iterations; ++iter) { diff --git a/src/mlpack/tests/softmax_regression_test.cpp b/src/mlpack/tests/softmax_regression_test.cpp index a962f237a7..78984d9127 100644 --- a/src/mlpack/tests/softmax_regression_test.cpp +++ b/src/mlpack/tests/softmax_regression_test.cpp @@ -207,7 +207,7 @@ TEST_CASE("SoftmaxRegressionTwoClasses", "[SoftmaxRegressionTest]") for (size_t i = 0; i < points / 2; ++i) { data.col(i) = g1.Random(); - labels(i) = 0; + labels(i) = 0; } for (size_t i = points / 2; i < points; ++i) { From 855a22f2677d0826846f1bd40cdd06428749c36b Mon Sep 17 00:00:00 2001 From: Martin Lambertsen Date: Fri, 25 Oct 2024 11:20:47 +0200 Subject: [PATCH 16/25] Modernize typedefs in docs --- doc/developer/elemtype.md | 2 +- doc/developer/trees.md | 2 +- doc/tutorials/fastmks.md | 7 ++++--- doc/tutorials/neighbor_search.md | 2 +- doc/user/core/trees/ball_tree.md | 6 +++--- doc/user/core/trees/binary_space_tree.md | 20 ++++++++++---------- doc/user/core/trees/kdtree.md | 6 +++--- doc/user/core/trees/mean_split_ball_tree.md | 6 +++--- doc/user/core/trees/mean_split_kdtree.md | 6 +++--- doc/user/core/trees/vptree.md | 6 +++--- doc/user/matrices.md | 4 ++-- doc/user/methods/adaboost.md | 6 +++--- doc/user/methods/amf.md | 5 +++-- 13 files changed, 40 insertions(+), 38 deletions(-) diff --git a/doc/developer/elemtype.md b/doc/developer/elemtype.md index a758414197..21d370af61 100644 --- a/doc/developer/elemtype.md +++ b/doc/developer/elemtype.md @@ -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 diff --git a/doc/developer/trees.md b/doc/developer/trees.md index bd9b0de1b2..04917e2c0c 100644 --- a/doc/developer/trees.md +++ b/doc/developer/trees.md @@ -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 //// diff --git a/doc/tutorials/fastmks.md b/doc/tutorials/fastmks.md index 21a0d4afb8..16351003c8 100644 --- a/doc/tutorials/fastmks.md +++ b/doc/tutorials/fastmks.md @@ -386,8 +386,9 @@ IPMetric 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, FirstPointIsRoot, FastMKSStat> - TreeType; // Convenience typedef. +// Convenience typedef. +using TreeType = + CoverTree, 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 TreeType; +using TreeType = CustomTree; // The FastMKS constructor will create the tree. FastMKS f(data); diff --git a/doc/tutorials/neighbor_search.md b/doc/tutorials/neighbor_search.md index b0a64d1516..dea0675e53 100644 --- a/doc/tutorials/neighbor_search.md +++ b/doc/tutorials/neighbor_search.md @@ -213,7 +213,7 @@ The `KNN` class is, specifically, a typedef of the more extensible distance. ```c++ -typedef NeighborSearch KNN; +using KNN = NeighborSearch; ``` Using the `KNN` class is particularly simple; first, the object must be diff --git a/doc/user/core/trees/ball_tree.md b/doc/user/core/trees/ball_tree.md index fdca730b6c..536343cfcc 100644 --- a/doc/user/core/trees/ball_tree.md +++ b/doc/user/core/trees/ball_tree.md @@ -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 TreeType; +using TreeType = mlpack::BallTree; TreeType tree; mlpack::data::Load("tree.bin", "tree", tree); diff --git a/doc/user/core/trees/binary_space_tree.md b/doc/user/core/trees/binary_space_tree.md index c6ce2d08ea..c804d9ca3b 100644 --- a/doc/user/core/trees/binary_space_tree.md +++ b/doc/user/core/trees/binary_space_tree.md @@ -1850,11 +1850,11 @@ arma::mat dataset; mlpack::data::Load("corel-histogram.csv", dataset, true); // Convenience typedef for the tree type. -typedef mlpack::BinarySpaceTree TreeType; +using TreeType = mlpack::BinarySpaceTree; // 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 TreeType; +using TreeType = mlpack::BinarySpaceTree; TreeType tree; mlpack::data::Load("tree.bin", "tree", tree); diff --git a/doc/user/core/trees/kdtree.md b/doc/user/core/trees/kdtree.md index 84c997dde9..8b4ac468f4 100644 --- a/doc/user/core/trees/kdtree.md +++ b/doc/user/core/trees/kdtree.md @@ -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 TreeType; +using TreeType = mlpack::KDTree; TreeType tree; mlpack::data::Load("tree.bin", "tree", tree); diff --git a/doc/user/core/trees/mean_split_ball_tree.md b/doc/user/core/trees/mean_split_ball_tree.md index d7ad1055b2..03c1923338 100644 --- a/doc/user/core/trees/mean_split_ball_tree.md +++ b/doc/user/core/trees/mean_split_ball_tree.md @@ -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 TreeType; +using TreeType = mlpack::MeanSplitBallTree; TreeType tree; mlpack::data::Load("tree.bin", "tree", tree); diff --git a/doc/user/core/trees/mean_split_kdtree.md b/doc/user/core/trees/mean_split_kdtree.md index d49912a90a..8197d73e50 100644 --- a/doc/user/core/trees/mean_split_kdtree.md +++ b/doc/user/core/trees/mean_split_kdtree.md @@ -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 TreeType; +using TreeType = mlpack::MeanSplitKDTree; TreeType tree; mlpack::data::Load("tree.bin", "tree", tree); diff --git a/doc/user/core/trees/vptree.md b/doc/user/core/trees/vptree.md index b0b916651d..0e12a03f9b 100644 --- a/doc/user/core/trees/vptree.md +++ b/doc/user/core/trees/vptree.md @@ -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 TreeType; +using TreeType = mlpack::VPTree; TreeType tree; mlpack::data::Load("tree.bin", "tree", tree); diff --git a/doc/user/matrices.md b/doc/user/matrices.md index 840f91e8b2..4da53ad7a2 100644 --- a/doc/user/matrices.md +++ b/doc/user/matrices.md @@ -256,10 +256,10 @@ arma::Row 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 ab(dataset, labels, 5); // Create test data (500 points). diff --git a/doc/user/methods/adaboost.md b/doc/user/methods/adaboost.md index 302e893db7..b7fb991b3f 100644 --- a/doc/user/methods/adaboost.md +++ b/doc/user/methods/adaboost.md @@ -418,9 +418,9 @@ arma::Row labels = // Train in the constructor, using floating-point data. // The weak learner type is now a floating-point Perceptron. -typedef mlpack::Perceptron PerceptronType; +using PerceptronType = mlpack::Perceptron; mlpack::AdaBoost ab(dataset, labels, 5); // Create test data (500 points). diff --git a/doc/user/methods/amf.md b/doc/user/methods/amf.md index 821f201dcd..d593e875fd 100644 --- a/doc/user/methods/amf.md +++ b/doc/user/methods/amf.md @@ -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::RandomAMFInitialization> InitType; +using InitType = + mlpack::MergeInitialization, + mlpack::RandomAMFInitialization>; InitType init(initW, initH); // Create an AMF object with the custom initialization. From 05d75967ed74e222f5e0ca60bcc81939027d33c7 Mon Sep 17 00:00:00 2001 From: Martin Lambertsen Date: Fri, 25 Oct 2024 11:24:20 +0200 Subject: [PATCH 17/25] Fix uninitialized variable warning The warning was detected during build of the tests on Linux with gcc 13.2. --- .../amf/update_rules/svd_incomplete_incremental_learning.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mlpack/methods/amf/update_rules/svd_incomplete_incremental_learning.hpp b/src/mlpack/methods/amf/update_rules/svd_incomplete_incremental_learning.hpp index ecc125e3db..d54cc6a0ad 100644 --- a/src/mlpack/methods/amf/update_rules/svd_incomplete_incremental_learning.hpp +++ b/src/mlpack/methods/amf/update_rules/svd_incomplete_incremental_learning.hpp @@ -54,7 +54,7 @@ class SVDIncompleteIncrementalLearning SVDIncompleteIncrementalLearning(double u = 0.001, double kw = 0, double kh = 0) - : u(u), kw(kw), kh(kh), currentUserIndex(0) + : u(u), kw(kw), kh(kh), currentUserIndex(0), currentItemIndex(0) { // Nothing to do. } From 017c39f1b268d04f7ad5e5418a26c2490d18a33f Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Fri, 25 Oct 2024 08:57:24 -0400 Subject: [PATCH 18/25] Use using instead of typedef for clarity. --- doc/user/core/trees/rp_tree.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/user/core/trees/rp_tree.md b/doc/user/core/trees/rp_tree.md index 032c90b253..da2ad2fac7 100644 --- a/doc/user/core/trees/rp_tree.md +++ b/doc/user/core/trees/rp_tree.md @@ -559,9 +559,9 @@ find the number of leaf nodes with fewer than 10 points. // above). // This convenient typedef saves us a long type name! -typedef mlpack::RPTree TreeType; +using TreeType = mlpack::RPTree; TreeType tree; mlpack::data::Load("tree.bin", "tree", tree); From 51d600e98e472e2ee1acdf75f55531707cfd8a1e Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Mon, 28 Oct 2024 17:50:05 -0400 Subject: [PATCH 19/25] Fix path to match the CMAKE_SYSROOT path. --- doc/embedded/crosscompile_armv7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/embedded/crosscompile_armv7.md b/doc/embedded/crosscompile_armv7.md index e319be741f..64b648b778 100644 --- a/doc/embedded/crosscompile_armv7.md +++ b/doc/embedded/crosscompile_armv7.md @@ -115,7 +115,7 @@ cmake \ -DBOARD_NAME="RPI2" \ -DCMAKE_CROSSCOMPILE=ON \ -DCMAKE_TOOLCHAIN_FILE=../board/crosscompile-toolchain.cmake \ - -DTOOLCHAIN_PREFIX=/path/to/bootlin/toolchain/armv7-eabihf--glibc--stable-2023.08-1/bin/arm-buildroot-linux-gnueabihf- \ + -DTOOLCHAIN_PREFIX=/path/to/bootlin/toolchain/armv7-eabihf--glibc--stable-2024.02-1/bin/arm-buildroot-linux-gnueabihf- \ -DCMAKE_SYSROOT=/path/to/bootlin/toolchain/armv7-eabihf--glibc--stable-2024.02-1/arm-buildroot-linux-gnueabihf/sysroot \ ../ ``` From 189f2b6ab6b5a38ce6f77716955d79110552c103 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Tue, 29 Oct 2024 09:15:26 -0400 Subject: [PATCH 20/25] Fix name of option. --- doc/embedded/crosscompile_armv7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/embedded/crosscompile_armv7.md b/doc/embedded/crosscompile_armv7.md index 64b648b778..9451bc1cbc 100644 --- a/doc/embedded/crosscompile_armv7.md +++ b/doc/embedded/crosscompile_armv7.md @@ -113,7 +113,7 @@ cross-compilation toolchain. cmake \ -DBUILD_TESTS=ON \ -DBOARD_NAME="RPI2" \ - -DCMAKE_CROSSCOMPILE=ON \ + -DCMAKE_CROSSCOMPILING=ON \ -DCMAKE_TOOLCHAIN_FILE=../board/crosscompile-toolchain.cmake \ -DTOOLCHAIN_PREFIX=/path/to/bootlin/toolchain/armv7-eabihf--glibc--stable-2024.02-1/bin/arm-buildroot-linux-gnueabihf- \ -DCMAKE_SYSROOT=/path/to/bootlin/toolchain/armv7-eabihf--glibc--stable-2024.02-1/arm-buildroot-linux-gnueabihf/sysroot \ From c0943e4ea4a1eeb7dc69a17dfe2cd6ecdb7364ee Mon Sep 17 00:00:00 2001 From: Omar Shrit Date: Sat, 2 Nov 2024 16:21:07 +0100 Subject: [PATCH 21/25] Move Board directory to the CMake Signed-off-by: Omar Shrit --- CMake/ConfigureCrossCompile.cmake | 4 ++-- {board => CMake}/crosscompile-toolchain.cmake | 0 {board => CMake}/flags-config.cmake | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename {board => CMake}/crosscompile-toolchain.cmake (100%) rename {board => CMake}/flags-config.cmake (100%) diff --git a/CMake/ConfigureCrossCompile.cmake b/CMake/ConfigureCrossCompile.cmake index 0a39b829ed..525b6495ae 100644 --- a/CMake/ConfigureCrossCompile.cmake +++ b/CMake/ConfigureCrossCompile.cmake @@ -5,10 +5,10 @@ # available on your system in order to find the BLAS library. If OpenBLAS will # be compiled, the OPENBLAS_TARGET variable must be set. This can be done # by, e.g., setting BOARD_NAME (which will set OPENBLAS_TARGET in -# `board/flags-config.cmake`). +# `flags-config.cmake`). if (CMAKE_CROSSCOMPILING) - include(board/flags-config.cmake) + include(flags-config.cmake) if (NOT CMAKE_SYSROOT AND (NOT TOOLCHAIN_PREFIX)) message(FATAL_ERROR "Neither CMAKE_SYSROOT nor TOOLCHAIN_PREFIX are set; please set both of them and try again.") elseif(NOT CMAKE_SYSROOT) diff --git a/board/crosscompile-toolchain.cmake b/CMake/crosscompile-toolchain.cmake similarity index 100% rename from board/crosscompile-toolchain.cmake rename to CMake/crosscompile-toolchain.cmake diff --git a/board/flags-config.cmake b/CMake/flags-config.cmake similarity index 100% rename from board/flags-config.cmake rename to CMake/flags-config.cmake From 169dab01de5fbf3a489d2cf22ae25d3e3a279cae Mon Sep 17 00:00:00 2001 From: Omar Shrit Date: Sat, 2 Nov 2024 16:29:03 +0100 Subject: [PATCH 22/25] Modify the files accordingly Signed-off-by: Omar Shrit --- CMake/ConfigureCrossCompile.cmake | 2 +- CMake/crosscompile-toolchain.cmake | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMake/ConfigureCrossCompile.cmake b/CMake/ConfigureCrossCompile.cmake index 525b6495ae..8c39509252 100644 --- a/CMake/ConfigureCrossCompile.cmake +++ b/CMake/ConfigureCrossCompile.cmake @@ -8,7 +8,7 @@ # `flags-config.cmake`). if (CMAKE_CROSSCOMPILING) - include(flags-config.cmake) + include(CMake/flags-config.cmake) if (NOT CMAKE_SYSROOT AND (NOT TOOLCHAIN_PREFIX)) message(FATAL_ERROR "Neither CMAKE_SYSROOT nor TOOLCHAIN_PREFIX are set; please set both of them and try again.") elseif(NOT CMAKE_SYSROOT) diff --git a/CMake/crosscompile-toolchain.cmake b/CMake/crosscompile-toolchain.cmake index 2b586e1113..20e72c3e73 100644 --- a/CMake/crosscompile-toolchain.cmake +++ b/CMake/crosscompile-toolchain.cmake @@ -1,14 +1,14 @@ -## This file handles cross-compilation configurations for aarch64, -## known as arm64. The objective of this file is to find and assign -## cross-compiler and the entire toolchain. +## This file handles cross-compilation configurations for any architecture. +## The objective of this file is to find and assign cross-compiler and the +## entire toolchain. ## ## This configuration works best with the buildroot toolchain. When using this ## file, be sure to set the TOOLCHAIN_PREFIX and CMAKE_SYSROOT variables, ## preferably via the CMake configuration command (e.g. `-DCMAKE_SYSROOT=<...>`). ## -## Currently, we recommend using buildroot toolchain for -## cross-compilation. Here is the link to download the toolchains: -## https://toolchains.bootlin.com/ +## You can use any toochain to produce the cross compiled binaries. However, +## we recommend using buildroot toolchain for cross-compilation. Here is the +## link to download the toolchains: https://toolchains.bootlin.com/ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSROOT) From e381293eba5b957e8273aea6572527dac26d1371 Mon Sep 17 00:00:00 2001 From: Omar Shrit Date: Sat, 2 Nov 2024 16:30:56 +0100 Subject: [PATCH 23/25] fix the docs to match the new modification Signed-off-by: Omar Shrit --- doc/embedded/crosscompile_armv7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/embedded/crosscompile_armv7.md b/doc/embedded/crosscompile_armv7.md index 9451bc1cbc..c0c78f233e 100644 --- a/doc/embedded/crosscompile_armv7.md +++ b/doc/embedded/crosscompile_armv7.md @@ -114,7 +114,7 @@ cmake \ -DBUILD_TESTS=ON \ -DBOARD_NAME="RPI2" \ -DCMAKE_CROSSCOMPILING=ON \ - -DCMAKE_TOOLCHAIN_FILE=../board/crosscompile-toolchain.cmake \ + -DCMAKE_TOOLCHAIN_FILE=../CMake/crosscompile-toolchain.cmake \ -DTOOLCHAIN_PREFIX=/path/to/bootlin/toolchain/armv7-eabihf--glibc--stable-2024.02-1/bin/arm-buildroot-linux-gnueabihf- \ -DCMAKE_SYSROOT=/path/to/bootlin/toolchain/armv7-eabihf--glibc--stable-2024.02-1/arm-buildroot-linux-gnueabihf/sysroot \ ../ From f9514a66b0c1c8aff8fd3b2052c81e2368ce3f64 Mon Sep 17 00:00:00 2001 From: Omar Shrit Date: Tue, 5 Nov 2024 13:07:44 +0100 Subject: [PATCH 24/25] Fix the flags for cortexA72 Signed-off-by: Omar Shrit --- CMake/ConfigureCrossCompile.cmake | 2 +- CMake/{flags-config.cmake => crosscompile-arch-config.cmake} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename CMake/{flags-config.cmake => crosscompile-arch-config.cmake} (97%) diff --git a/CMake/ConfigureCrossCompile.cmake b/CMake/ConfigureCrossCompile.cmake index 8c39509252..d9711ab18c 100644 --- a/CMake/ConfigureCrossCompile.cmake +++ b/CMake/ConfigureCrossCompile.cmake @@ -8,7 +8,7 @@ # `flags-config.cmake`). if (CMAKE_CROSSCOMPILING) - include(CMake/flags-config.cmake) + include(CMake/crosscompile-arch-config.cmake) if (NOT CMAKE_SYSROOT AND (NOT TOOLCHAIN_PREFIX)) message(FATAL_ERROR "Neither CMAKE_SYSROOT nor TOOLCHAIN_PREFIX are set; please set both of them and try again.") elseif(NOT CMAKE_SYSROOT) diff --git a/CMake/flags-config.cmake b/CMake/crosscompile-arch-config.cmake similarity index 97% rename from CMake/flags-config.cmake rename to CMake/crosscompile-arch-config.cmake index 5999ab86ac..aa1fad449e 100644 --- a/CMake/flags-config.cmake +++ b/CMake/crosscompile-arch-config.cmake @@ -56,7 +56,7 @@ elseif(BOARD MATCHES "RPI3" OR BOARD MATCHES "CORTEXA53") set(OPENBLAS_TARGET "CORTEXA53") set(OPENBLAS_BINARY "64") elseif(BOARD MATCHES "RPI4" OR BOARD MATCHES "CORTEXA72") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=cortex-a72 -ftree-vectorize") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8.2-a+crypto+fp16+rcpc+dotprod -asynchronous-unwind-tables") set(OPENBLAS_TARGET "CORTEXA72") set(OPENBLAS_BINARY "64") elseif(BOARD MATCHES "JETSONAGX" OR BOARD MATCHES "CORTEXA76") From fcfbf804f608e2c7bb0ee66bb508475d1e35453b Mon Sep 17 00:00:00 2001 From: Omar Shrit Date: Tue, 5 Nov 2024 22:04:04 +0100 Subject: [PATCH 25/25] Update CMake/crosscompile-arch-config.cmake Co-authored-by: Ryan Curtin --- CMake/crosscompile-arch-config.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/crosscompile-arch-config.cmake b/CMake/crosscompile-arch-config.cmake index aa1fad449e..73e3c49edd 100644 --- a/CMake/crosscompile-arch-config.cmake +++ b/CMake/crosscompile-arch-config.cmake @@ -56,7 +56,7 @@ elseif(BOARD MATCHES "RPI3" OR BOARD MATCHES "CORTEXA53") set(OPENBLAS_TARGET "CORTEXA53") set(OPENBLAS_BINARY "64") elseif(BOARD MATCHES "RPI4" OR BOARD MATCHES "CORTEXA72") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8.2-a+crypto+fp16+rcpc+dotprod -asynchronous-unwind-tables") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8.2-a+crypto+fp16+rcpc+dotprod -fasynchronous-unwind-tables") set(OPENBLAS_TARGET "CORTEXA72") set(OPENBLAS_BINARY "64") elseif(BOARD MATCHES "JETSONAGX" OR BOARD MATCHES "CORTEXA76")