Merge remote-tracking branch 'origin/master' into doc-rp-trees
This commit is contained in:
@@ -13,6 +13,8 @@ _????-??-??_
|
||||
|
||||
* Fix compilation if only including `mlpack/methods/kde/kde_model.hpp` (#3800).
|
||||
|
||||
* Fix serialization and `MinDistance()` bugs with `HollowBallBound` (#3808).
|
||||
|
||||
## mlpack 4.5.0
|
||||
|
||||
_2024-09-17_
|
||||
|
||||
@@ -222,7 +222,7 @@ class ExampleTree
|
||||
template<typename Archive>
|
||||
ExampleTree(
|
||||
Archive& ar,
|
||||
const typename std::enable_if_c<typename Archive::is_loading>::type* = 0);
|
||||
const std::enable_if_t<typename Archive::is_loading>* = 0);
|
||||
|
||||
// Release any resources held by the tree.
|
||||
~ExampleTree();
|
||||
@@ -476,7 +476,7 @@ archive:
|
||||
template<typename Archive>
|
||||
ExampleTree(
|
||||
Archive& ar,
|
||||
const typename std::enable_if_c<typename Archive::is_loading>::type* = 0);
|
||||
const std::enable_if_t<typename Archive::is_loading>* = 0);
|
||||
```
|
||||
|
||||
This has implications on how the tree must be stored. In this case, the dataset
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 71 KiB |
@@ -96,6 +96,11 @@ when the sidebar is built for each page.
|
||||
<code>MeanSplitBallTree</code>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="LINKROOTuser/core/trees/vptree.html">
|
||||
<code>VPTree</code>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="LINKROOTuser/core/trees/rp_tree.html">
|
||||
<code>RPTree</code>
|
||||
|
||||
@@ -413,7 +413,7 @@ class uses a hyperrectangle bound. An example `HRectBound` is shown below; the
|
||||
bound is the smallest rectangle that encloses all of the points.
|
||||
|
||||
<center>
|
||||
<img src="../../../img/hrectbound.png" width="50%" alt="hyperrectangle bound enclosing points">
|
||||
<img src="../../../img/hrectbound.png" width="450" alt="hyperrectangle bound enclosing points">
|
||||
</center>
|
||||
|
||||
mlpack supplies several drop-in `BoundType` classes, and it is also possible to
|
||||
@@ -423,6 +423,8 @@ write a custom `BoundType` for use with `BinarySpaceTree`:
|
||||
points in the smallest possible hyperrectangle
|
||||
* [`BallBound`](#ballbound): ball bound, encloses the descendant points in the
|
||||
ball with the smallest possible radius
|
||||
* [`HollowBallBound`](#hollowballbound): hollow ball bound, equivalent to a
|
||||
ball bound with a ball subtracted from it.
|
||||
* [Custom `BoundType`s](#custom-boundtypes): implement a fully custom
|
||||
`BoundType`
|
||||
|
||||
@@ -577,7 +579,7 @@ operations with data points or other bounds.
|
||||
|
||||
Once an `HRectBound` has been successfully created and set to the desired
|
||||
bounding hyperrectangle, there are a number of functions that can bound the
|
||||
distance between a `HRectBound` and other objects.
|
||||
distance between an `HRectBound` and other objects.
|
||||
|
||||
* `b.Contains(point)`
|
||||
* `b.Contains(bound)`
|
||||
@@ -776,7 +778,7 @@ std::cout << "Distance between Manhattan distance HRectBound and "
|
||||
// point.
|
||||
arma::fmat floatData(3, 25, arma::fill::randu);
|
||||
mlpack::HRectBound<mlpack::ChebyshevDistance, float> cb;
|
||||
cb |= floatData; // This will set the bound to [2.0, 3.0] in every dimension.
|
||||
cb |= floatData;
|
||||
// Note the use of arma::fvec to represent a point, since ElemType is float.
|
||||
const mlpack::RangeType<float> r3 = cb.RangeDistance(arma::fvec("1.5 1.5 4.0"));
|
||||
std::cout << "Distance between Chebyshev distance HRectBound and "
|
||||
@@ -840,8 +842,8 @@ Different constructor forms can be used to specify different template parameters
|
||||
any points at all).
|
||||
|
||||
***Note***: these constructors provide an empty bound; be sure to
|
||||
[grow](#growing-and-shrinking-the-bound) the bound or
|
||||
[directly modify the bound](#accessing-and-modifying-properties-of-the-bound)
|
||||
[grow](#growing-the-bound) the bound or
|
||||
[directly modify the bound](#accessing-and-modifying-properties-of-the-bound-1)
|
||||
before using it!
|
||||
|
||||
---
|
||||
@@ -1078,6 +1080,368 @@ std::cout << "Distance between Chebyshev distance BallBound and "
|
||||
|
||||
---
|
||||
|
||||
### `HollowBallBound`
|
||||
|
||||
The `HollowBallBound` class represents a bounding shape that is an
|
||||
arbitrary-dimensional ball bound with another smaller ball subtracted from its
|
||||
inside. A `HollowBallBound` consists of a center point, an outer radius, and a
|
||||
secondary center point and inner radius. An example `HollowBallBound` is shown
|
||||
below in two dimensions; shaded area represents area held within the bound.
|
||||
|
||||
<center>
|
||||
<img src="../../../img/hollowballbound.png" width="350" alt="hollow ball bound">
|
||||
</center>
|
||||
|
||||
`HollowBallBound` is used directly by the [`VPTree`](vptree.md) class.
|
||||
|
||||
---
|
||||
|
||||
#### Constructors
|
||||
|
||||
`HollowBallBound` allows configurable behavior via its two template parameters:
|
||||
|
||||
```
|
||||
HollowBallBound<DistanceType, ElemType>
|
||||
```
|
||||
|
||||
Different constructor forms can be used to specify different template parameters
|
||||
(and thus different bound behavior).
|
||||
|
||||
* `b = HollowBallBound(dimensionality)`
|
||||
- Construct a `HollowBallBound` with the given `dimensionality`.
|
||||
- The bound will be empty with invalid centers and radii (e.g., `b` will not
|
||||
contain any points at all).
|
||||
- The bound will use the [Euclidean distance](../distances.md#lmetric) for
|
||||
distance computation, and will expect data to have elements with type
|
||||
`double`.
|
||||
|
||||
* `b = HollowBallBound<DistanceType, ElemType>(dimensionality)`
|
||||
- Construct a `HollowBallBound` with the given `dimensionality` that will use
|
||||
the given `DistanceType` class to compute distances, and expect data to
|
||||
have elements with type `ElemType`.
|
||||
- `ElemType` should generally be `double` or `float`.
|
||||
|
||||
***Note***: these constructors provide an empty bound; be sure to
|
||||
[grow](#growing-the-bound-1) the bound or
|
||||
[directly modify the bound](#accessing-and-modifying-properties-of-the-bound-2)
|
||||
before using it!
|
||||
|
||||
---
|
||||
|
||||
* `b = HollowBallBound(innerRadius, outerRadius, center)`
|
||||
- Construct a `HollowBallBound` with the given `innerRadius` for the inner
|
||||
ball, `outerRadius` for the outer ball, and `center`.
|
||||
- Both the inner and outer ball are centered at `center`.
|
||||
- `innerRadius` and `outerRadius` should have type `double`.
|
||||
- `center` should have type `arma::vec`.
|
||||
- The bound will use the [Euclidean distance](../distances.md#lmetric) for
|
||||
distance computation, and will expect data to have elements with type
|
||||
`double`.
|
||||
|
||||
* `b = HollowBallBound<DistanceType, ElemType>(innerRadius, outerRadius, center)`
|
||||
- Construct a `HollowBallBound` with the given `innerRadius` for the inner
|
||||
ball, `outerRadius` for the outer ball, and `center`.
|
||||
- Both the inner and outer ball are centered at `center`.
|
||||
- `innerRadius` and `outerRadius` should have type `ElemType`.
|
||||
- `center` should be a vector with element type `ElemType` (e.g.
|
||||
`arma::Col<ElemType>`).
|
||||
- The bound will use the given `DistanceType` class to compute distances, and
|
||||
expect data to have elements with type `ElemType`.
|
||||
|
||||
---
|
||||
|
||||
#### Accessing and modifying properties of the bound
|
||||
|
||||
The individual bounds associated with each dimension of a `HollowBallBound` can
|
||||
be accessed and modified.
|
||||
|
||||
* `b.Dim()` will return a `size_t` indicating the dimensionality of the bound.
|
||||
|
||||
* `b.Center()` returns an `arma::vec&` containing the center of the outer ball.
|
||||
Its elements can be directly modified.
|
||||
|
||||
* `b.HollowCenter()` returns an `arma::vec&` containing the center of the inner
|
||||
ball. Its elements can be directly modified.
|
||||
- It is possible that `b.HollowCenter()` is outside of the outer ball!
|
||||
|
||||
* `b.OuterRadius()` will return a `double` that is the radius of the outer
|
||||
ball.
|
||||
- `b.OuterRadius() = r` will set the radius of the outer ball to `r`.
|
||||
|
||||
* `b.InnerRadius()` will return a `double` that is the radius of the inner
|
||||
ball.
|
||||
- `b.InnerRadius() = r` will set the radius of the inner ball to `r`.
|
||||
- It is possible that `b.InnerRadius() > b.OuterRadius()`, and this implies
|
||||
that the hollow center is outside the outer ball (otherwise the bound is
|
||||
empty).
|
||||
|
||||
* `b[dim]` will return a [`Range`](../math.md#range) object representing the
|
||||
extents of the bound in dimension `dim`.
|
||||
- The range is defined as
|
||||
`[b.Center()[dim] - b.OuterRadius(), b.Center()[dim] + b.OuterRadius()]`.
|
||||
- ***Note:*** this returns the maximum extents of the bound and does not
|
||||
consider the inner (hollow) ball.
|
||||
|
||||
* `b.Diameter()` returns the diameter of the ball. This is always equal to
|
||||
`2 * b.OuterRadius()`.
|
||||
|
||||
* `b.MinWidth()` returns the minimum width of the bound in any dimension as a
|
||||
`double`. This is always equal to `b.Diameter()`.
|
||||
|
||||
* `b.Distance()` returns either a
|
||||
[`EuclideanDistance`](../distances.md#lmetric) distance metric object, or a
|
||||
`DistanceType` if a custom `DistanceType` has been specified in the
|
||||
constructor.
|
||||
|
||||
* `b.Center(center)` will store the center of the `HollowBallBound` in the
|
||||
vector `center`. `center` should be of type `arma::vec`.
|
||||
|
||||
* `b.MinWidth()` returns the minimum width of the bound in any dimension as a
|
||||
`double`. This value is cached and no computation is performed when calling
|
||||
`b.MinWidth()`. If the bound is empty, `0` is returned.
|
||||
|
||||
* `b.Distance()` returns either a
|
||||
[`EuclideanDistance`](../distances.md#lmetric) distance metric object, or a
|
||||
`DistanceType` if a custom `DistanceType` has been specified in the
|
||||
constructor.
|
||||
|
||||
* `b.Center(center)` will compute the center of the `HollowBallBound` (e.g. the
|
||||
vector with elements equal to the midpoint of `b` in each dimension) and
|
||||
store it in the vector `center`. `center` should be of type `arma::vec`.
|
||||
|
||||
* `b.Volume()` computes the volume of the hyperrectangle specified by `b`. The
|
||||
volume is returned as a `double`.
|
||||
|
||||
* `b.Diameter()` computes the longest diagonal of the hyperrectangle specified
|
||||
by `b`.
|
||||
|
||||
* A `HollowBallBound` can be serialized with
|
||||
[`data::Save()` and `data::Load()`](../../load_save.md#mlpack-objects).
|
||||
|
||||
***Note:*** if a custom `ElemType` was specified in the constructor, then:
|
||||
|
||||
* `b[dim]` will return a `RangeType<ElemType>`;
|
||||
* `b.OuterRadius()`, `b.InnerRadius()`, `b.MinWidth()`, and `b.Diameter()` will
|
||||
return `ElemType`;
|
||||
* `b.Center()` and `b.HollowCenter()` will return `arma::Col<ElemType>&`; and
|
||||
* `b.Center(center)` expects `center` to be of type `arma::Col<ElemType>`.
|
||||
|
||||
---
|
||||
|
||||
#### Growing the bound
|
||||
|
||||
The `HollowBallBound` uses the logical `|=` to grow the bound to include points
|
||||
or other bounds.
|
||||
|
||||
* `b |= data` expands `b` so the outer ball includes all of the data points in
|
||||
`data`, shrinking the inner ball as necessary. `data` should be a
|
||||
[column-major `arma::mat`](../../matrices.md#representing-data-in-mlpack).
|
||||
The expansion operation is minimal, so `b` is not expanded any more than
|
||||
necessary.
|
||||
- The bound is grown using [Jack Ritter's bounding sphere
|
||||
algorithm](https://en.wikipedia.org/wiki/Bounding_sphere#Ritter's_bounding_sphere),
|
||||
which may move the center of the bound as it iteratively adds points to the
|
||||
bound. (The hollow center is not moved.)
|
||||
- If the bound is empty, the centers are initialized to the first point of
|
||||
`data`.
|
||||
- If the bound is not empty, then `data` is expected to have dimensionality
|
||||
that matches `b.Dim()`.
|
||||
|
||||
* `b |= bound` expands `b` to include all of the volume included in `bound`.
|
||||
The center points will not be modified.
|
||||
- The outer ball's radius will be expanded to include the outer balls of both
|
||||
`b` and `bound`.
|
||||
- The inner (hollow) ball's radius will be shrunk to be the intersection of
|
||||
the inner balls of `b` and `bound`. (This may result in `b.InnerRadius()`
|
||||
being 0.)
|
||||
|
||||
***Notes:***
|
||||
|
||||
- The growth operation does not grow the inner (hollow) ball. Properties
|
||||
related to the inner ball should be set manually with `b.HollowCenter()` and
|
||||
`b.InnerRadius()`.
|
||||
|
||||
- If a custom `ElemType` was specified, then any `data` argument should be a
|
||||
matrix with that `ElemType` (e.g. `arma::Mat<ElemType>`).
|
||||
|
||||
---
|
||||
|
||||
#### Bounding distances to other objects
|
||||
|
||||
Once a `HollowBallBound` has been successfully created and set to the desired
|
||||
bounding balls, there are a number of functions that can bound the
|
||||
distance between a `HollowBallBound` and other objects.
|
||||
|
||||
* `b.Contains(point)`
|
||||
* `b.Contains(bound)`
|
||||
- Return a `bool` indicating whether or not `b` contains the given `point`
|
||||
(an `arma::vec`) or another `bound` (an `HRectBound`).
|
||||
- When passing another `bound`, `true` will be returned if `bound` even
|
||||
partially overlaps with `b`.
|
||||
|
||||
* `b.MinDistance(point)`
|
||||
* `b.MinDistance(bound)`
|
||||
- Return a `double` whose value is the minimum possible distance between `b`
|
||||
and either a `point` (an `arma::vec`) or another `bound` (a
|
||||
`HollowBallBound`).
|
||||
- The minimum distance between `b` and another point or bound is the length
|
||||
of the shortest possible line that can connect the other point or bound to
|
||||
`b`.
|
||||
- If `point` or `bound` are contained in `b`, then the returned distance is
|
||||
0.
|
||||
|
||||
* `b.MaxDistance(point)`
|
||||
* `b.MaxDistance(bound)`
|
||||
- Return a `double` whose value is the maximum possible distance between `b`
|
||||
and either a `point` (an `arma::vec`) or another `bound` (a
|
||||
`HollowBallBound`).
|
||||
- The maximum distance between `b` and a given `point` is the furthest
|
||||
possible distance between `point` and any possible point falling within the
|
||||
bounding hyperrectangle of `b`.
|
||||
- The maximum distance between `b` and another `bound` is the furthest
|
||||
possible distance between any possible point falling within the bounding
|
||||
hyperrectangle of `b`, and any possible point falling within the bounding
|
||||
hyperrectangle of `bound`.
|
||||
- Note that this definition means that even if `b.Contains(point)` or
|
||||
`b.Contains(bound)` is `true`, the maximum distance may be greater than
|
||||
`0`.
|
||||
|
||||
* `b.RangeDistance(point)`
|
||||
* `b.RangeDistance(bound)`
|
||||
- Compute the minimum and maximum distance between `b` and `point` or
|
||||
`bound`, returning the result as a [`Range`](../math.md#range) object.
|
||||
- This is more efficient than calling `b.MinDistance()` and
|
||||
`b.MaxDistance()`.
|
||||
|
||||
***Note:*** if a custom `DistanceType` and `ElemType` were specified in the
|
||||
constructor, then all distances will be computed with respect to the specified
|
||||
`DistanceType` and all return values will either be `ElemType` or
|
||||
[`RangeType<ElemType>`](../math.md#range) (except for `Contains()`, which will
|
||||
still return a `bool`).
|
||||
|
||||
---
|
||||
|
||||
#### Example usage
|
||||
|
||||
```c++
|
||||
// Create a hollow ball bound in 3 dimensions whose outer ball is the unit ball
|
||||
// and whose inner ball is the ball with radius 0.5 centered at the origin.
|
||||
// The bounding range for all three dimensions is [0.0, 1.0].
|
||||
mlpack::HollowBallBound b(0.5, 1.0, arma::vec(3));
|
||||
|
||||
std::cout << "Hollow unit ball bound created manually:" << std::endl;
|
||||
std::cout << " - Center: " << b.Center().t();
|
||||
std::cout << " - Outer radius: " << b.OuterRadius() << "." << std::endl;
|
||||
std::cout << " - Hollow center: " << b.HollowCenter().t();
|
||||
std::cout << " - Inner radius: " << b.InnerRadius() << "." << std::endl;
|
||||
for (size_t i = 0; i < 3; ++i)
|
||||
{
|
||||
std::cout << " - Dimension " << i << " extents: [" << b[i].Lo() << ", "
|
||||
<< b[i].Hi() << "]." << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// Create a small dataset of 5 points.
|
||||
arma::mat dataset(3, 5);
|
||||
dataset.col(0) = arma::vec("2.0 2.0 2.0");
|
||||
dataset.col(1) = arma::vec("2.5 2.5 2.5");
|
||||
dataset.col(2) = arma::vec("3.0 2.0 3.0");
|
||||
dataset.col(3) = arma::vec("2.0 3.0 2.0");
|
||||
dataset.col(4) = arma::vec("3.0 3.0 3.0");
|
||||
|
||||
// If we simply build a HollowBallBound to enclose those points, the hollow part
|
||||
// of the ball is unmodified and remains empty.
|
||||
mlpack::HollowBallBound b2(3);
|
||||
b2 |= dataset;
|
||||
std::cout << "Hollow ball bound on points with only `operator|=()`:"
|
||||
<< std::endl;
|
||||
std::cout << " - Center: " << b2.Center().t();
|
||||
std::cout << " - Outer radius: " << b2.OuterRadius() << "." << std::endl;
|
||||
std::cout << " - Hollow center: " << b2.HollowCenter().t();
|
||||
std::cout << " - Inner radius: " << b2.InnerRadius() << "." << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
// On the other hand, if we initialize a HollowBallBound to a non-empty bound,
|
||||
// then `operator|=()` will shrink the hollow ball as necessary.
|
||||
//
|
||||
// We initialize this ball bound to a "slice" with radii [3.6, 3.7].
|
||||
mlpack::HollowBallBound b3(3.6, 3.7, arma::vec(3));
|
||||
b3 |= dataset;
|
||||
std::cout << "Hollow ball bound on points with pre-initialization and "
|
||||
<< "`operator|=()`:" << std::endl;
|
||||
std::cout << " - Center: " << b3.Center().t();
|
||||
std::cout << " - Outer radius: " << b3.OuterRadius() << "." << std::endl;
|
||||
std::cout << " - Hollow center: " << b3.HollowCenter().t();
|
||||
std::cout << " - Inner radius: " << b3.InnerRadius() << "." << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
// Manually create a hollow ball bound whose hollow center is different than the
|
||||
// outer ball's center.
|
||||
mlpack::HollowBallBound b4(3);
|
||||
b4.OuterRadius() = 3.0;
|
||||
b4.InnerRadius() = 1.5;
|
||||
b4.Center() = arma::vec(3);
|
||||
b4.HollowCenter() = arma::vec("1.0 1.0 1.0");
|
||||
|
||||
// Compute the minimum distance between a point inside the hollow unit ball's
|
||||
// outer ball.
|
||||
const double d1 = b.MinDistance(arma::vec("0.9 0.9 0.9"));
|
||||
std::cout << "Minimum distance between hollow unit ball bound and [0.9, 0.9, "
|
||||
<< "0.9]: " << d1 << "." << std::endl;
|
||||
|
||||
// Compute the minimum distance between a point inside the hollow unit ball's
|
||||
// inner ball (so the point is not contained in the bound---it is within the
|
||||
// hollow section).
|
||||
const double d2 = b.MinDistance(arma::vec("0.0 0.0 0.0"));
|
||||
std::cout << "Minimum distance between hollow unit ball bound and [0.0, 0.0, "
|
||||
<< "0.0]: " << d2 << "." << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
// Use Contains(). In this case, the 'else' will be taken.
|
||||
if (b.Contains(arma::vec("1.5 1.5 1.5")))
|
||||
{
|
||||
std::cout << "Hollow unit ball bound contains [1.5, 1.5, 1.5]." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Hollow unit ball bound does not contain [1.5, 1.5, 1.5]."
|
||||
<< std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// Compute the maximum distance between a point inside the unit ball and the
|
||||
// unit hollow ball bound.
|
||||
const double d3 = b4.MaxDistance(arma::vec("0.1 0.1 0.1"));
|
||||
std::cout << "Maximum distance between hollow unit ball bound and [0.1, 0.1, "
|
||||
<< "0.1]: " << d3 << "." << std::endl;
|
||||
|
||||
// Compute the minimum and maximum distances between the hollow unit ball bound
|
||||
// and the bound built on data points.
|
||||
const mlpack::Range r = b.RangeDistance(b3);
|
||||
std::cout << "Distances between hollow unit ball bound and second hollow "
|
||||
<< "dataset bound: [" << r.Lo() << ", " << r.Hi() << "]." << std::endl;
|
||||
|
||||
// Create a bound using the Manhattan (L1) distance and compute the minimum and
|
||||
// maximum distance to a point.
|
||||
mlpack::HollowBallBound<mlpack::ManhattanDistance> mb(2.0, 5.0, arma::vec(3));
|
||||
const mlpack::Range r2 = mb.RangeDistance(arma::vec("1.5 1.5 4.0"));
|
||||
std::cout << "Distance between Manhattan distance HollowBallBound and "
|
||||
<< "[1.5, 1.5, 4.0]: [" << r2.Lo() << ", " << r2.Hi() << "]." << std::endl;
|
||||
|
||||
// Create a bound using the Chebyshev (L-inf) distance, using random 32-bit
|
||||
// floating point elements, and compute the minimum and maximum distance to a
|
||||
// point.
|
||||
arma::fmat floatData(3, 25, arma::fill::randu);
|
||||
mlpack::HollowBallBound<mlpack::ChebyshevDistance, float> cb;
|
||||
cb |= floatData;
|
||||
// Note the use of arma::fvec to represent a point, since ElemType is float.
|
||||
const mlpack::RangeType<float> r3 = cb.RangeDistance(arma::fvec("1.5 1.5 4.0"));
|
||||
std::cout << "Distance between Chebyshev distance HollowBallBound and "
|
||||
<< "[1.5, 1.5, 4.0]: [" << r3.Lo() << ", " << r3.Hi() << "]." << std::endl;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Custom `BoundType`s
|
||||
|
||||
The `BinarySpaceTree` class allows an arbitrary `BoundType` template parameter
|
||||
@@ -1261,6 +1625,8 @@ 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
|
||||
* [`VantagePointSplit`](#vantagepointsplit): split by selecting a 'vantage
|
||||
point' and then split points into 'near' and 'far' sets
|
||||
* [`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
|
||||
@@ -1314,6 +1680,51 @@ task*.
|
||||
For implementation details, see
|
||||
[the source code](/src/mlpack/core/tree/binary_space_tree/mean_split_impl.hpp).
|
||||
|
||||
### `VantagePointSplit`
|
||||
|
||||
The `VantagePointSplit` class is a splitting strategy that can be used by
|
||||
[`BinarySpaceTree`](#binaryspacetree). It is the default strategy for splitting
|
||||
[`VPTree`s](vptree.md), and is detailed in
|
||||
[the paper](https://www.mlpack.org/papers/uhlmann91.pdf).
|
||||
Due to the nature of the split, ***`VantagePointSplit` should always be used
|
||||
with the [`HollowBallBound`](#hollowballbound)***.
|
||||
|
||||
The splitting strategy for the `VantagePointSplit` class is, given a set of
|
||||
points:
|
||||
|
||||
* Select a vantage point from a sample of 100 random candidate points (or use
|
||||
the full set if there are fewer than 100 points):
|
||||
- Compute the distances between each candidate point and 100 additional
|
||||
random samples (or the full set if there are fewer than 100 points).
|
||||
- Select the vantage point as the candidate with maximum average distance to
|
||||
the additional random samples.
|
||||
* Compute a boundary distance `mu` that is the median distance between the
|
||||
vantage point and its random samples.
|
||||
* Points with distance less than `mu` from the vantage point will go to the
|
||||
left child.
|
||||
* Points with distance greater than `mu` from the vantage point will go to the
|
||||
right child.
|
||||
|
||||
The `VantagePointSplit` class has three template parameters:
|
||||
|
||||
```
|
||||
VantagePointSplit<BoundType, MatType, MaxNumSamples = 100>
|
||||
```
|
||||
|
||||
If a custom number of samples `S` is desired, the easiest way to specify is via
|
||||
a template typedef:
|
||||
|
||||
```
|
||||
template<typename BoundType, typename MatType>
|
||||
using MyVantagePointSplit = VantagePointSplit<BoundType, MatType, S>;
|
||||
```
|
||||
|
||||
Then, `MyVantagePointSplit` can be used directly with `BinarySpaceTree` as a
|
||||
`SplitType`.
|
||||
|
||||
For implementation details, see
|
||||
[the source code](/src/mlpack/core/tree/binary_space_tree/vantage_point_split_impl.hpp).
|
||||
|
||||
### `RPTreeMeanSplit`
|
||||
|
||||
The `RPTreeMeanSplit` class is a splitting strategy that can be used by
|
||||
|
||||
@@ -0,0 +1,634 @@
|
||||
# `VPTree`
|
||||
|
||||
<!-- TODO: link to knn.md once it's done -->
|
||||
|
||||
The `VPTree` class represents a `k`-dimensional vantage point tree,
|
||||
and is a well-known data structure for efficient distance operations (such as
|
||||
nearest neighbor search) in low dimensions---typically less than 100. The
|
||||
vantage point tree is also known as the 'metric tree'.
|
||||
|
||||
A vantage point tree is a binary tree where each node selects a 'vantage
|
||||
point', and child nodes partition points into those that are nearer to the
|
||||
vantage point and those that are further from it. `VPTree` supports arbitrary
|
||||
[distance metrics](../distances.md) that are not
|
||||
[`LMetric`](../distances.md#lmetric), making it more flexible than `KDTree`.
|
||||
|
||||
mlpack's `VPTree` 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 vantage point 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
|
||||
|
||||
<!-- TODO: add links to all distance-based algorithms and other trees? -->
|
||||
|
||||
* [Vantage point tree on Wikipedia](https://en.wikipedia.org/wiki/Vantage-point_tree)
|
||||
* [`BinarySpaceTree`](binary_space_tree.md)
|
||||
* [Binary space partitioning on Wikipedia](https://dl.acm.org/doi/pdf/10.1145/361002.361007)
|
||||
* [Data structures and algorithms for nearest neighbor search in general metric spaces (pdf)](https://dl.acm.org/doi/pdf/10.5555/313559.313789)
|
||||
* [Satisfying General Proximity/Similarity Queries with Metric Trees (pdf)](https://www.mlpack.org/papers/uhlmann91.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 `VPTree` class takes three template parameters:
|
||||
|
||||
```
|
||||
VPTree<DistanceType, StatisticType, MatType>
|
||||
```
|
||||
|
||||
* `DistanceType`: the [distance metric](../distances.md) to use for distance
|
||||
computations. 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 `VPTree` class itself is a convenience typedef of the generic
|
||||
[`BinarySpaceTree`](binary_space_tree.md) class, using the
|
||||
[`HollowBallBound`](binary_space_tree.md#hollowballbound) class as the bounding
|
||||
structure, and using the
|
||||
[`VantagePointSplit`](binary_space_tree.md#vantagepointsplit) splitting strategy
|
||||
for construction, which splits points into those that are nearer and further
|
||||
from a 'vantage point'.
|
||||
|
||||
## Constructors
|
||||
|
||||
`VPTree`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 = VPTree(data, maxLeafSize=20)`
|
||||
* `node = VPTree(data, oldFromNew, maxLeafSize=20)`
|
||||
* `node = VPTree(data, oldFromNew, newFromOld, maxLeafSize=20)`
|
||||
- Construct a `VPTree` 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 = VPTree<DistanceType, StatisticType, MatType>(data, maxLeafSize=20)`
|
||||
* `node = VPTree<DistanceType, StatisticType, MatType>(data, oldFromNew, maxLeafSize=20)`
|
||||
* `node = VPTree<DistanceType, StatisticType, MatType>(data, oldFromNew, newFromOld, maxLeafSize=20)`
|
||||
- Construct a `VPTree` 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 = VPTree()`
|
||||
- Construct an empty vantage point tree with no children and no points.
|
||||
|
||||
---
|
||||
|
||||
***Notes:***
|
||||
|
||||
- The name `node` is used here for `VPTree` objects instead of `tree`, because
|
||||
each `VPTree` 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 `VPTree` is
|
||||
not supported, because this generally results in a vantage point tree with
|
||||
very loose bounding balls. It is better to simply build a new `VPTree` 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).
|
||||
|
||||
<!-- TODO: add links to RectangleTree above when it is documented -->
|
||||
|
||||
---
|
||||
|
||||
### 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<size_t>` | Mappings from points in `node.Dataset()` to points in `data`. | _(N/A)_ |
|
||||
| `newFromOld` | `std::vector<size_t>` | Mappings from points in `data` to points in `node.Dataset()`. | _(N/A)_ |
|
||||
|
||||
## Basic tree properties
|
||||
|
||||
Once a `VPTree` 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 `VPTree&` 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 `VPTree&`
|
||||
that can itself be used just like the root node of the tree!
|
||||
- `node.Left()` and `node.Right()` are convenience functions specific to
|
||||
`VPTree` that will return `VPTree*` (pointers) to the left and right
|
||||
children, respectively, or `NULL` if `node` has no children.
|
||||
|
||||
* `node.Parent()` will return a `VPTree*` that points to the parent of `node`,
|
||||
or `NULL` if `node` is the root of the `VPTree`.
|
||||
|
||||
---
|
||||
|
||||
### Accessing members of a tree
|
||||
|
||||
* `node.Bound()` will return an
|
||||
[`HollowBallBound&`](binary_space_tree.md#hollowballbound) object that
|
||||
represents the hollow bounding ball of `node`. This structure 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).
|
||||
|
||||
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 `VPTree` 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 `VPTree`, 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 `VPTree`, 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 `VPTree`, and so
|
||||
accessing them does not require any computation.
|
||||
|
||||
* `node.FurthestPointDistance()` returns a `double` representing the distance
|
||||
between the center of the hollow bounding ball 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 hollow bounding ball 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
|
||||
hollow ball bound.
|
||||
- This quantity is equivalent to `node.Bound().OuterRadius()`.
|
||||
|
||||
* `node.ParentDistance()` returns a `double` representing the distance between
|
||||
the center of the hollow bounding ball of `node` and the center of the
|
||||
hollow bounding ball 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 `VPTree`, 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 hollow bounding ball 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
|
||||
`VPTree`, 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 `VPTree` 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
|
||||
`VPTree`, 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 `VPTree` 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 `VPTree` node `other`.
|
||||
- This is equivalent to the minimum possible distance between any point
|
||||
contained in the hollow bounding ball of `node` and `point`, or between
|
||||
any point contained in the hollow bounding ball of `node` and any point
|
||||
contained in the hollow bounding ball of `other`.
|
||||
- `point` should be of type `arma::vec`. (If a [custom
|
||||
`MatType`](#template-parameters) was specified when constructing the
|
||||
`VPTree`, 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 `VPTree` node `other`.
|
||||
- This is equivalent to the maximum possible distance between any point
|
||||
contained in the hollow bounding ball of `node` and `point`, or between
|
||||
any point contained in the hollow bounding ball of `node` and any point
|
||||
contained in the hollow bounding ball of `other`.
|
||||
- `point` should be of type `arma::vec`. (If a [custom
|
||||
`MatType`](#template-parameters) was specified when constructing the
|
||||
`VPTree`, 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 `VPTree`, 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<float>`](../math.md#range)).
|
||||
|
||||
### Tree traversals
|
||||
|
||||
Like every mlpack tree, the `VPTree` 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.
|
||||
|
||||
* `VPTree::SingleTreeTraverser`
|
||||
- Implements a depth-first single-tree traverser.
|
||||
|
||||
* `VPTree::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:
|
||||
|
||||
* `VPTree::BreadthFirstDualTreeTraverser`
|
||||
- Implements a dual-breadth-first dual-tree traverser.
|
||||
- ***Note:*** this traverser is not useful for all tasks; because the
|
||||
`VPTree` 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 `VPTree` 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 vp-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::VPTree tree(...)` will work fine in C++20 or newer).
|
||||
mlpack::VPTree<> tree(std::move(dataset));
|
||||
|
||||
// Print the bounding ball of the root node. (There will be no hollow ball.)
|
||||
std::cout << "Bounding ball of root node:" << std::endl;
|
||||
std::cout << " - Center: " << tree.Bound().Center().t();
|
||||
std::cout << " - Outer radius: " << tree.Bound().OuterRadius() << "."
|
||||
<< std::endl;
|
||||
std::cout << " - Hollow center: " << tree.Bound().HollowCenter().t();
|
||||
std::cout << " - Inner radius: " << tree.Bound().InnerRadius() << "."
|
||||
<< std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
// Print the bounding ball of the right child. (This will have a hollow ball.)
|
||||
std::cout << "Bounding ball of right child: " << std::endl;
|
||||
std::cout << " - Center: " << tree.Right()->Bound().Center().t();
|
||||
std::cout << " - Outer radius: " << tree.Right()->Bound().OuterRadius() << "."
|
||||
<< std::endl;
|
||||
std::cout << " - Hollow center: " << tree.Right()->Bound().HollowCenter().t();
|
||||
std::cout << " - Inner radius: " << tree.Right()->Bound().InnerRadius() << "."
|
||||
<< std::endl;
|
||||
std::cout << " - Distance between centers: " <<
|
||||
mlpack::EuclideanDistance::Evaluate(tree.Right()->Bound().Center(),
|
||||
tree.Right()->Bound().HollowCenter()) << "." << 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;
|
||||
|
||||
// Print the center of the vp-tree.
|
||||
arma::vec center;
|
||||
tree.Center(center);
|
||||
std::cout << "Center of vp-tree: " << center.t();
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Build two `VPTree`s on subsets of the corel dataset and compute various
|
||||
bounding quantities.
|
||||
|
||||
```c++
|
||||
// See https://datasets.mlpack.org/corel-histogram.csv.
|
||||
arma::mat dataset;
|
||||
mlpack::data::Load("corel-histogram.csv", dataset, true);
|
||||
|
||||
// Build vp-trees on the first half and the second half of points.
|
||||
mlpack::VPTree<> tree1(dataset.cols(0, dataset.n_cols / 2));
|
||||
mlpack::VPTree<> 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::VPTree<>& 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::VPTree<>& 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 `VPTree` 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 VPTree 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::VPTree<mlpack::EuclideanDistance,
|
||||
mlpack::EmptyStatistic,
|
||||
arma::fmat> tree(std::move(dataset), 100);
|
||||
|
||||
// Save the VPTree 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 `VPTree` from disk, then traverse it manually and
|
||||
find the number of leaf nodes with less than 10 children.
|
||||
|
||||
```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::VPTree<mlpack::EuclideanDistance,
|
||||
mlpack::EmptyStatistic,
|
||||
arma::fmat> 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 less than 10 points.
|
||||
size_t leafCount = 0;
|
||||
size_t totalLeafCount = 0;
|
||||
std::stack<TreeType*> 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 less "
|
||||
<< "than 10 points." << std::endl;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Build a `VPTree` 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<size_t> oldFromNew, newFromOld;
|
||||
mlpack::VPTree<> 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();
|
||||
```
|
||||
+1
-1
@@ -111,7 +111,7 @@ DecisionTree(MatType&& data,
|
||||
WeightsType&& weights,
|
||||
const size_t minimumLeafSize = 10,
|
||||
const std::enable_if_t<arma::is_arma_type<
|
||||
typename std::remove_reference<WeightsType>::type>::value>*
|
||||
std::remove_reference_t<WeightsType>>::value>*
|
||||
= 0);
|
||||
```
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ namespace r {
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::string>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::string>>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a vector option.
|
||||
@@ -40,7 +40,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a string option.
|
||||
@@ -48,8 +48,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T, std::string>::value
|
||||
>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T, std::string>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a matrix option, a tuple option, a
|
||||
@@ -59,10 +58,10 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* /* junk */ = 0);
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>>* /* junk */ = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a model option (this returns the default
|
||||
@@ -71,8 +70,8 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of an option. This is the function that will be
|
||||
@@ -84,7 +83,7 @@ void DefaultParam(util::ParamData& data,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = DefaultParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
*outstr = DefaultParamImpl<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace r
|
||||
|
||||
@@ -24,15 +24,15 @@ namespace r {
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T, std::string>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T, std::string>>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
{
|
||||
// If this is the verbose option, print the default that uses the global
|
||||
// package option.
|
||||
@@ -58,13 +58,13 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
// Print each element in an array delimited by square brackets.
|
||||
std::ostringstream oss;
|
||||
const T& vector = std::any_cast<T>(data.value);
|
||||
oss << "c(";
|
||||
if (std::is_same<T, std::vector<std::string>>::value)
|
||||
if (std::is_same_v<T, std::vector<std::string>>)
|
||||
{
|
||||
if (vector.size() > 0)
|
||||
{
|
||||
@@ -101,7 +101,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T, std::string>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T, std::string>>*)
|
||||
{
|
||||
const std::string& s = *std::any_cast<std::string>(&data.value);
|
||||
return "\"" + s + "\"";
|
||||
@@ -114,21 +114,21 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* /* junk */)
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>>* /* junk */)
|
||||
{
|
||||
// Get the filename and return it, or return an empty string.
|
||||
if (std::is_same<T, arma::rowvec>::value ||
|
||||
std::is_same<T, arma::vec>::value ||
|
||||
std::is_same<T, arma::mat>::value)
|
||||
if (std::is_same_v<T, arma::rowvec> ||
|
||||
std::is_same_v<T, arma::vec> ||
|
||||
std::is_same_v<T, arma::mat>)
|
||||
{
|
||||
return "matrix(numeric(), 0, 0)";
|
||||
}
|
||||
else if (std::is_same<T, arma::Row<size_t>>::value ||
|
||||
std::is_same<T, arma::Col<size_t>>::value ||
|
||||
std::is_same<T, arma::Mat<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Row<size_t>> ||
|
||||
std::is_same_v<T, arma::Col<size_t>> ||
|
||||
std::is_same_v<T, arma::Mat<size_t>>)
|
||||
{
|
||||
return "matrix(integer(), 0, 0)";
|
||||
}
|
||||
@@ -144,8 +144,8 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return "NA";
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace r {
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::any_cast<T>(data.value);
|
||||
@@ -42,7 +42,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0)
|
||||
{
|
||||
const T& t = std::any_cast<T>(data.value);
|
||||
|
||||
@@ -58,7 +58,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// Get the matrix.
|
||||
const T& matrix = std::any_cast<T>(data.value);
|
||||
@@ -74,8 +74,8 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << data.cppType << " model at " << std::any_cast<T*>(data.value);
|
||||
@@ -88,8 +88,8 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// Get the matrix.
|
||||
const T& tuple = std::any_cast<T>(data.value);
|
||||
@@ -116,7 +116,7 @@ void GetPrintableParam(util::ParamData& data,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParam<typename std::remove_pointer<T>::type>(data);
|
||||
GetPrintableParam<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace r
|
||||
|
||||
@@ -23,88 +23,85 @@ namespace r {
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<int>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<int>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<int>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<int>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<double>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<double>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<double>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<double>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<std::string>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<
|
||||
!util::IsStdVector<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!data::HasSerialize<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!arma::is_arma_type<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!std::is_same<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<std::string>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<std::string>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<std::string>::value>*,
|
||||
const std::enable_if_t<
|
||||
!std::is_same_v<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<size_t>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<size_t,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<size_t>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<size_t>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<size_t>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<size_t,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<bool>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<bool>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<bool>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<bool>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<typename T>
|
||||
void GetPrintableType(util::ParamData& d,
|
||||
@@ -112,7 +109,7 @@ void GetPrintableType(util::ParamData& d,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableType<typename std::remove_pointer<T>::type>(d);
|
||||
GetPrintableType<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace r
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace r {
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
@@ -34,11 +34,11 @@ inline std::string GetPrintableType(
|
||||
template<>
|
||||
inline std::string GetPrintableType<int>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<int>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<int>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<int>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "integer";
|
||||
}
|
||||
@@ -46,11 +46,11 @@ inline std::string GetPrintableType<int>(
|
||||
template<>
|
||||
inline std::string GetPrintableType<double>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<double>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<double>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<double>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "numeric";
|
||||
}
|
||||
@@ -58,15 +58,12 @@ inline std::string GetPrintableType<double>(
|
||||
template<>
|
||||
inline std::string GetPrintableType<std::string>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<
|
||||
!util::IsStdVector<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!data::HasSerialize<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!arma::is_arma_type<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!std::is_same<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<std::string>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<std::string>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<std::string>::value>*,
|
||||
const std::enable_if_t<
|
||||
!std::is_same_v<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "character";
|
||||
}
|
||||
@@ -74,11 +71,11 @@ inline std::string GetPrintableType<std::string>(
|
||||
template<>
|
||||
inline std::string GetPrintableType<size_t>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<size_t,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<size_t>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<size_t>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<size_t>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<size_t,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "integer";
|
||||
}
|
||||
@@ -86,11 +83,11 @@ inline std::string GetPrintableType<size_t>(
|
||||
template<>
|
||||
inline std::string GetPrintableType<bool>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<bool>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<bool>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<bool>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "logical";
|
||||
}
|
||||
@@ -98,9 +95,9 @@ inline std::string GetPrintableType<bool>(
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "vector of " + GetPrintableType<typename T::value_type>(d) + "s";
|
||||
}
|
||||
@@ -108,17 +105,17 @@ inline std::string GetPrintableType(
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::string type = "numeric matrix";
|
||||
if (std::is_same<typename T::elem_type, double>::value)
|
||||
if (std::is_same_v<typename T::elem_type, double>)
|
||||
{
|
||||
if (T::is_row || T::is_col)
|
||||
type = "numeric vector";
|
||||
}
|
||||
else if (std::is_same<typename T::elem_type, size_t>::value)
|
||||
else if (std::is_same_v<typename T::elem_type, size_t>)
|
||||
{
|
||||
type = "integer matrix";
|
||||
if (T::is_row || T::is_col)
|
||||
@@ -131,8 +128,8 @@ inline std::string GetPrintableType(
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "categorical matrix/data.frame";
|
||||
}
|
||||
@@ -140,10 +137,10 @@ inline std::string GetPrintableType(
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::string type = util::StripType(d.cppType);
|
||||
if (type == "mlpackModel")
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace r {
|
||||
template<typename T>
|
||||
inline std::string GetRType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
@@ -35,11 +35,11 @@ inline std::string GetRType(
|
||||
template<>
|
||||
inline std::string GetRType<bool>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<bool>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<bool>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<bool>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "logical";
|
||||
}
|
||||
@@ -47,11 +47,11 @@ inline std::string GetRType<bool>(
|
||||
template<>
|
||||
inline std::string GetRType<int>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<int>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<int>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<int>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "integer";
|
||||
}
|
||||
@@ -59,11 +59,11 @@ inline std::string GetRType<int>(
|
||||
template<>
|
||||
inline std::string GetRType<size_t>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<size_t,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<size_t>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<size_t>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<size_t>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<size_t,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "integer";
|
||||
}
|
||||
@@ -71,11 +71,11 @@ inline std::string GetRType<size_t>(
|
||||
template<>
|
||||
inline std::string GetRType<double>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<double>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<double>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<double>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "numeric";
|
||||
}
|
||||
@@ -83,15 +83,12 @@ inline std::string GetRType<double>(
|
||||
template<>
|
||||
inline std::string GetRType<std::string>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<
|
||||
!util::IsStdVector<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!data::HasSerialize<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!arma::is_arma_type<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!std::is_same<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<std::string>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<std::string>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<std::string>::value>*,
|
||||
const std::enable_if_t<
|
||||
!std::is_same_v<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "character";
|
||||
}
|
||||
@@ -99,7 +96,7 @@ inline std::string GetRType<std::string>(
|
||||
template<typename T>
|
||||
inline std::string GetRType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0)
|
||||
{
|
||||
return GetRType<typename T::value_type>(d) + " vector";
|
||||
}
|
||||
@@ -107,9 +104,9 @@ inline std::string GetRType(
|
||||
template<typename T>
|
||||
inline std::string GetRType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0,
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
std::string elemType = GetRType<typename T::elem_type>(d);
|
||||
std::string type = "matrix";
|
||||
@@ -124,8 +121,8 @@ inline std::string GetRType(
|
||||
template<typename T>
|
||||
inline std::string GetRType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
return "numeric matrix/data.frame with info";
|
||||
}
|
||||
@@ -133,8 +130,8 @@ inline std::string GetRType(
|
||||
template<typename T>
|
||||
inline std::string GetRType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
return util::StripType(d.cppType);
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ namespace r {
|
||||
template<typename T>
|
||||
inline std::string GetType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
@@ -36,11 +36,11 @@ inline std::string GetType(
|
||||
template<>
|
||||
inline std::string GetType<int>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<int>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<int>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<int>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "Int";
|
||||
}
|
||||
@@ -48,11 +48,11 @@ inline std::string GetType<int>(
|
||||
template<>
|
||||
inline std::string GetType<float>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<float>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<float>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<float>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<float,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<float>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<float>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<float>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<float,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "Float";
|
||||
}
|
||||
@@ -60,11 +60,11 @@ inline std::string GetType<float>(
|
||||
template<>
|
||||
inline std::string GetType<double>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<double>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<double>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<double>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "Double";
|
||||
}
|
||||
@@ -72,14 +72,11 @@ inline std::string GetType<double>(
|
||||
template<>
|
||||
inline std::string GetType<std::string>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<
|
||||
!util::IsStdVector<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!data::HasSerialize<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!arma::is_arma_type<std::string>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<std::string>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<std::string>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<std::string>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "String";
|
||||
}
|
||||
@@ -87,11 +84,11 @@ inline std::string GetType<std::string>(
|
||||
template<>
|
||||
inline std::string GetType<bool>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<bool>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<bool>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<bool>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "Bool";
|
||||
}
|
||||
@@ -99,9 +96,9 @@ inline std::string GetType<bool>(
|
||||
template<typename T>
|
||||
inline std::string GetType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
return "Vec" + GetType<typename T::value_type>(d);
|
||||
}
|
||||
@@ -109,12 +106,12 @@ inline std::string GetType(
|
||||
template<typename T>
|
||||
inline std::string GetType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
std::string type = "";
|
||||
if (std::is_same<typename T::elem_type, double>::value)
|
||||
if (std::is_same_v<typename T::elem_type, double>)
|
||||
{
|
||||
if (T::is_row)
|
||||
type = "Row";
|
||||
@@ -123,7 +120,7 @@ inline std::string GetType(
|
||||
else
|
||||
type = "Mat";
|
||||
}
|
||||
else if (std::is_same<typename T::elem_type, size_t>::value)
|
||||
else if (std::is_same_v<typename T::elem_type, size_t>)
|
||||
{
|
||||
if (T::is_row)
|
||||
type = "URow";
|
||||
@@ -139,8 +136,8 @@ inline std::string GetType(
|
||||
template<typename T>
|
||||
inline std::string GetType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
return "MatWithInfo";
|
||||
}
|
||||
@@ -148,8 +145,8 @@ inline std::string GetType(
|
||||
template<typename T>
|
||||
inline std::string GetType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
return d.cppType;
|
||||
}
|
||||
@@ -170,7 +167,7 @@ void GetType(util::ParamData& d,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetType<typename std::remove_pointer<T>::type>(d);
|
||||
GetType<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace r
|
||||
|
||||
@@ -82,7 +82,7 @@ void PrintDoc(util::ParamData& d,
|
||||
}
|
||||
}
|
||||
|
||||
oss << " (" << GetRType<typename std::remove_pointer<T>::type>(d) << ").";
|
||||
oss << " (" << GetRType<std::remove_pointer_t<T>>(d) << ").";
|
||||
|
||||
if (out)
|
||||
oss << "}";
|
||||
|
||||
@@ -29,7 +29,7 @@ void PrintInputParam(util::ParamData& d,
|
||||
void* /* output */)
|
||||
{
|
||||
MLPACK_COUT_STREAM << d.name;
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
{
|
||||
if (d.name == "verbose")
|
||||
{
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace r {
|
||||
template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
if (!d.required)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ void PrintInputProcessing(
|
||||
template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
std::string extraTransStr = "";
|
||||
if (d.cppType == "arma::mat")
|
||||
@@ -135,8 +135,8 @@ void PrintInputProcessing(
|
||||
template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
if (!d.required)
|
||||
{
|
||||
@@ -182,8 +182,8 @@ void PrintInputProcessing(
|
||||
template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
if (!d.required)
|
||||
{
|
||||
@@ -229,7 +229,7 @@ void PrintInputProcessing(util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintInputProcessing<typename std::remove_pointer<T>::type>(d);
|
||||
PrintInputProcessing<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace r
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace r {
|
||||
template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
@@ -48,9 +48,9 @@ void PrintOutputProcessing(
|
||||
template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
@@ -69,8 +69,8 @@ void PrintOutputProcessing(
|
||||
template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
@@ -89,8 +89,8 @@ void PrintOutputProcessing(
|
||||
template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
@@ -112,7 +112,7 @@ void PrintOutputProcessing(util::ParamData& d,
|
||||
const void* /*input*/,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintOutputProcessing<typename std::remove_pointer<T>::type>(d);
|
||||
PrintOutputProcessing<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace r
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace r {
|
||||
template<typename T>
|
||||
void PrintSerializeUtil(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Do Nothing.
|
||||
}
|
||||
@@ -37,7 +37,7 @@ void PrintSerializeUtil(
|
||||
template<typename T>
|
||||
void PrintSerializeUtil(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// Do Nothing.
|
||||
}
|
||||
@@ -48,8 +48,8 @@ void PrintSerializeUtil(
|
||||
template<typename T>
|
||||
void PrintSerializeUtil(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
@@ -76,7 +76,7 @@ void PrintSerializeUtil(util::ParamData& d,
|
||||
const void* /*input*/,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintSerializeUtil<typename std::remove_pointer<T>::type>(d);
|
||||
PrintSerializeUtil<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace r
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace r {
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a vector.
|
||||
@@ -37,7 +37,7 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix option.
|
||||
@@ -45,7 +45,7 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix tuple option.
|
||||
@@ -53,8 +53,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a model.
|
||||
@@ -62,8 +62,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Print the command-line type of an option into a string.
|
||||
@@ -74,7 +74,7 @@ void PrintTypeDoc(util::ParamData& data,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
PrintTypeDoc<typename std::remove_pointer<T>::type>(data);
|
||||
PrintTypeDoc<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace r
|
||||
|
||||
@@ -24,29 +24,29 @@ namespace r {
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
// A flag type.
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
{
|
||||
return "A boolean flag option (i.e. `TRUE` or `FALSE`).";
|
||||
}
|
||||
// An integer.
|
||||
else if (std::is_same<T, int>::value)
|
||||
else if (std::is_same_v<T, int>)
|
||||
{
|
||||
return "An integer (i.e., `1`).";
|
||||
}
|
||||
// A floating point value.
|
||||
else if (std::is_same<T, double>::value)
|
||||
else if (std::is_same_v<T, double>)
|
||||
{
|
||||
return "A floating-point number (i.e., `0.5`).";
|
||||
}
|
||||
// A string.
|
||||
else if (std::is_same<T, std::string>::value)
|
||||
else if (std::is_same_v<T, std::string>)
|
||||
{
|
||||
return "A character string (i.e., `\"hello\"`).";
|
||||
}
|
||||
@@ -64,13 +64,13 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
if (std::is_same<T, std::vector<int>>::value)
|
||||
if (std::is_same_v<T, std::vector<int>>)
|
||||
{
|
||||
return "A vector of integers; i.e., `c(0, 1, 2)`.";
|
||||
}
|
||||
else if (std::is_same<T, std::vector<std::string>>::value)
|
||||
else if (std::is_same_v<T, std::vector<std::string>>)
|
||||
{
|
||||
return "A vector of strings; i.e., `c(\"hello\", \"goodbye\")`.";
|
||||
}
|
||||
@@ -86,9 +86,9 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*)
|
||||
{
|
||||
if (std::is_same<typename T::elem_type, double>::value)
|
||||
if (std::is_same_v<typename T::elem_type, double>)
|
||||
{
|
||||
if (T::is_col || T::is_row)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ std::string PrintTypeDoc(
|
||||
"2-d `matrix`).";
|
||||
}
|
||||
}
|
||||
else if (std::is_same<typename T::elem_type, size_t>::value)
|
||||
else if (std::is_same_v<typename T::elem_type, size_t>)
|
||||
{
|
||||
if (T::is_col || T::is_row)
|
||||
{
|
||||
@@ -128,8 +128,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "A 2-d array containing `numeric` data. Like the regular 2-d matrices"
|
||||
", this can be a `matrix`, or a `data.frame`. However, this type can also"
|
||||
@@ -146,8 +146,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return "An mlpack model pointer. `<Model>` refers to the type of model that "
|
||||
"is being stored, so, e.g., for `cf()`, the type will be `CFModel`. "
|
||||
|
||||
@@ -33,15 +33,12 @@ template<typename T>
|
||||
void AddToCLI11(const std::string& cliName,
|
||||
util::ParamData& param,
|
||||
CLI::App& app,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
bool>::value>::type* = 0,
|
||||
const typename std::enable_if<!
|
||||
arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!
|
||||
data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
const std::enable_if_t<!std::is_same_v<T, bool>>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* = 0)
|
||||
arma::mat>>>* = 0)
|
||||
{
|
||||
app.add_option_function<std::string>(cliName.c_str(),
|
||||
[¶m](const std::string& value)
|
||||
@@ -65,15 +62,12 @@ template<typename T>
|
||||
void AddToCLI11(const std::string& cliName,
|
||||
util::ParamData& param,
|
||||
CLI::App& app,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
bool>::value>::type* = 0,
|
||||
const typename std::enable_if<!
|
||||
arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<
|
||||
data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
const std::enable_if_t<!std::is_same_v<T, bool>>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* = 0)
|
||||
arma::mat>>>* = 0)
|
||||
{
|
||||
app.add_option_function<std::string>(cliName.c_str(),
|
||||
[¶m](const std::string& value)
|
||||
@@ -97,13 +91,11 @@ template<typename T>
|
||||
void AddToCLI11(const std::string& cliName,
|
||||
util::ParamData& param,
|
||||
CLI::App& app,
|
||||
const typename std::enable_if<!
|
||||
std::is_same<T, bool>::value>::type* = 0,
|
||||
const typename std::enable_if<
|
||||
arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
const std::enable_if_t<!std::is_same_v<T, bool>>* = 0,
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* = 0)
|
||||
arma::mat>>>* = 0)
|
||||
{
|
||||
app.add_option_function<std::string>(cliName.c_str(),
|
||||
[¶m](const std::string& value)
|
||||
@@ -127,15 +119,12 @@ template<typename T>
|
||||
void AddToCLI11(const std::string& cliName,
|
||||
util::ParamData& param,
|
||||
CLI::App& app,
|
||||
const typename std::enable_if<!
|
||||
std::is_same<T, bool>::value>::type* = 0,
|
||||
const typename std::enable_if<!
|
||||
arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!
|
||||
data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
const std::enable_if_t<!std::is_same_v<T, bool>>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* = 0)
|
||||
arma::mat>>>* = 0)
|
||||
{
|
||||
app.add_option_function<T>(cliName.c_str(),
|
||||
[¶m](const T& value)
|
||||
@@ -157,15 +146,12 @@ template<typename T>
|
||||
void AddToCLI11(const std::string& cliName,
|
||||
util::ParamData& param,
|
||||
CLI::App& app,
|
||||
const typename std::enable_if<
|
||||
std::is_same<T, bool>::value>::type* = 0,
|
||||
const typename std::enable_if<!
|
||||
arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!
|
||||
data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
const std::enable_if_t<std::is_same_v<T, bool>>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* = 0)
|
||||
arma::mat>>>* = 0)
|
||||
{
|
||||
app.add_flag_function(cliName.c_str(),
|
||||
[¶m](const T& value)
|
||||
@@ -194,14 +180,14 @@ void AddToCLI11(util::ParamData& param,
|
||||
|
||||
// Generate the name to be given to CLI11.
|
||||
const std::string mappedName =
|
||||
MapParameterName<typename std::remove_pointer<T>::type>(param.name);
|
||||
MapParameterName<std::remove_pointer_t<T>>(param.name);
|
||||
std::string cliName = (param.alias != '\0') ?
|
||||
"-" + std::string(1, param.alias) + ",--" + mappedName :
|
||||
"--" + mappedName;
|
||||
|
||||
// Note that we have to add the option as type equal to the mapped type, not
|
||||
// the true type of the option.
|
||||
AddToCLI11<typename std::remove_pointer<T>::type>(
|
||||
AddToCLI11<std::remove_pointer_t<T>>(
|
||||
cliName, param, *app);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,21 +91,20 @@ class CLIOption
|
||||
data.cppType = cppName;
|
||||
|
||||
// Apply default value.
|
||||
if (std::is_same<typename std::remove_pointer<N>::type,
|
||||
typename ParameterType<typename
|
||||
std::remove_pointer<N>::type>::type>::value)
|
||||
if (std::is_same_v<std::remove_pointer_t<N>,
|
||||
typename ParameterType<std::remove_pointer_t<N>>::type>)
|
||||
{
|
||||
data.value = defaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
typename ParameterType<typename std::remove_pointer<N>::type>::type tmp;
|
||||
typename ParameterType<std::remove_pointer_t<N>>::type tmp;
|
||||
data.value = std::tuple<N, decltype(tmp)>(defaultValue, tmp);
|
||||
}
|
||||
|
||||
const std::string tname = data.tname;
|
||||
const std::string cliName = MapParameterName<
|
||||
typename std::remove_pointer<N>::type>(identifier);
|
||||
std::remove_pointer_t<N>>(identifier);
|
||||
std::string progOptId = (alias[0] != '\0') ?
|
||||
"-" + std::string(1, alias[0]) + ",--" + cliName : "--" + cliName;
|
||||
|
||||
|
||||
@@ -26,13 +26,12 @@ namespace cli {
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::string>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T, std::string>>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a vector option.
|
||||
@@ -40,7 +39,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a string option.
|
||||
@@ -48,8 +47,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T, std::string>::value
|
||||
>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T, std::string>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a matrix option, a tuple option, a
|
||||
@@ -59,10 +57,10 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* /* junk */ = 0);
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>>* /* junk */ = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a model option (this returns the default
|
||||
@@ -71,8 +69,8 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of an option. This is the function that will be
|
||||
@@ -84,7 +82,7 @@ void DefaultParam(util::ParamData& data,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = DefaultParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
*outstr = DefaultParamImpl<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
|
||||
@@ -24,16 +24,15 @@ namespace cli {
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::string>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T, std::string>>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
if (!std::is_same<T, bool>::value)
|
||||
if (!std::is_same_v<T, bool>)
|
||||
oss << std::any_cast<T>(data.value);
|
||||
|
||||
return oss.str();
|
||||
@@ -45,13 +44,13 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
// Print each element in an array delimited by square brackets.
|
||||
std::ostringstream oss;
|
||||
const T& vector = std::any_cast<T>(data.value);
|
||||
oss << "[";
|
||||
if (std::is_same<T, std::vector<std::string>>::value)
|
||||
if (std::is_same_v<T, std::vector<std::string>>)
|
||||
{
|
||||
if (vector.size() > 0)
|
||||
{
|
||||
@@ -89,7 +88,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T, std::string>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T, std::string>>*)
|
||||
{
|
||||
const std::string& s = *std::any_cast<std::string>(&data.value);
|
||||
return "'" + s + "'";
|
||||
@@ -101,10 +100,10 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* /* junk */)
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>>* /* junk */)
|
||||
{
|
||||
// The filename will always be empty.
|
||||
return "''";
|
||||
@@ -116,8 +115,8 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return "''";
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace cli {
|
||||
template<typename T>
|
||||
void DeleteAllocatedMemoryImpl(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
@@ -30,7 +30,7 @@ void DeleteAllocatedMemoryImpl(
|
||||
template<typename T>
|
||||
void DeleteAllocatedMemoryImpl(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
@@ -38,8 +38,8 @@ void DeleteAllocatedMemoryImpl(
|
||||
template<typename T>
|
||||
void DeleteAllocatedMemoryImpl(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Delete the allocated memory (hopefully we actually own it).
|
||||
typedef std::tuple<T*, std::string> TupleType;
|
||||
@@ -52,7 +52,7 @@ void DeleteAllocatedMemory(
|
||||
const void* /* input */,
|
||||
void* /* output */)
|
||||
{
|
||||
DeleteAllocatedMemoryImpl<typename std::remove_pointer<T>::type>(d);
|
||||
DeleteAllocatedMemoryImpl<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace cli {
|
||||
template<typename T>
|
||||
void* GetAllocatedMemory(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ void* GetAllocatedMemory(
|
||||
template<typename T>
|
||||
void* GetAllocatedMemory(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -39,8 +39,8 @@ void* GetAllocatedMemory(
|
||||
template<typename T>
|
||||
void* GetAllocatedMemory(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Here we have a model, which is a tuple, and we need the address of the
|
||||
// memory.
|
||||
@@ -53,8 +53,7 @@ void GetAllocatedMemory(util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((void**) output) =
|
||||
GetAllocatedMemory<typename std::remove_pointer<T>::type>(d);
|
||||
*((void**) output) = GetAllocatedMemory<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
|
||||
@@ -28,10 +28,10 @@ namespace cli {
|
||||
template<typename T>
|
||||
T& GetParam(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// No mapping is needed, so just cast it directly.
|
||||
return *std::any_cast<T>(&d.value);
|
||||
@@ -45,7 +45,7 @@ T& GetParam(
|
||||
template<typename T>
|
||||
T& GetParam(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// If the matrix is an input matrix, we have to load the matrix. 'value'
|
||||
// contains the filename. It's possible we could load empty matrices many
|
||||
@@ -80,8 +80,8 @@ T& GetParam(
|
||||
template<typename T>
|
||||
T& GetParam(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// If this is an input parameter, we need to load both the matrix and the
|
||||
// dataset info.
|
||||
@@ -110,8 +110,8 @@ T& GetParam(
|
||||
template<typename T>
|
||||
T*& GetParam(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// If the model is an input model, we have to load it from file. 'value'
|
||||
// contains the filename.
|
||||
@@ -140,7 +140,7 @@ template<typename T>
|
||||
void GetParam(util::ParamData& d, const void* /* input */, void* output)
|
||||
{
|
||||
// Cast to the correct type.
|
||||
*((T**) output) = &GetParam<typename std::remove_pointer<T>::type>(d);
|
||||
*((T**) output) = &GetParam<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace cli {
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Print a vector option, with spaces between it.
|
||||
@@ -39,7 +39,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Print a matrix/tuple option (this just prints the filename).
|
||||
@@ -47,9 +47,8 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value ||
|
||||
std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value || std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Print a model option (this just prints the filename).
|
||||
@@ -57,8 +56,8 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Print an option into a std::string. This should print a short, one-line
|
||||
@@ -71,7 +70,7 @@ void GetPrintableParam(util::ParamData& data,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParam<typename std::remove_pointer<T>::type>(data);
|
||||
GetPrintableParam<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace cli {
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::any_cast<T>(data.value);
|
||||
@@ -38,8 +38,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*
|
||||
/* junk */)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* /* junk */)
|
||||
{
|
||||
const T& t = std::any_cast<T>(data.value);
|
||||
|
||||
@@ -53,7 +52,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetMatrixSize(
|
||||
T& matrix,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << matrix.n_rows << "x" << matrix.n_cols << " matrix";
|
||||
@@ -64,8 +63,8 @@ std::string GetMatrixSize(
|
||||
template<typename T>
|
||||
std::string GetMatrixSize(
|
||||
T& matrixAndInfo,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
return GetMatrixSize(std::get<1>(matrixAndInfo));
|
||||
}
|
||||
@@ -74,9 +73,8 @@ std::string GetMatrixSize(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value ||
|
||||
std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value || std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* /* junk */)
|
||||
{
|
||||
// Extract the string from the tuple that's being held.
|
||||
typedef std::tuple<T, typename ParameterType<T>::type> TupleType;
|
||||
@@ -103,8 +101,8 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
// Extract the string from the tuple that's being held.
|
||||
typedef std::tuple<T*, typename ParameterType<T>::type> TupleType;
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace cli {
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a matrix type (where the user has to pass the file
|
||||
@@ -38,7 +38,7 @@ std::string GetPrintableParamName(
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a serializable model type (where the user has to
|
||||
@@ -47,8 +47,8 @@ std::string GetPrintableParamName(
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a mapped matrix type (where the user has to pass
|
||||
@@ -57,8 +57,8 @@ std::string GetPrintableParamName(
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter's name as seen by the user.
|
||||
@@ -70,7 +70,7 @@ void GetPrintableParamName(
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParamName<typename std::remove_pointer<T>::type>(d);
|
||||
GetPrintableParamName<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace cli {
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "--" + data.name;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ std::string GetPrintableParamName(
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*)
|
||||
{
|
||||
return "--" + data.name + "_file";
|
||||
}
|
||||
@@ -53,8 +53,8 @@ std::string GetPrintableParamName(
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return "--" + data.name + "_file";
|
||||
}
|
||||
@@ -66,8 +66,8 @@ std::string GetPrintableParamName(
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "--" + data.name + "_file";
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& data,
|
||||
const std::string& value,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a matrix type (where the user has to pass the file
|
||||
@@ -40,7 +40,7 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& data,
|
||||
const std::string& value,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a serializable model type (where the user has to
|
||||
@@ -50,8 +50,8 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& data,
|
||||
const std::string& value,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a mapped matrix type (where the user has to pass
|
||||
@@ -61,8 +61,8 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& data,
|
||||
const std::string& value,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter's name as seen by the user.
|
||||
@@ -74,7 +74,7 @@ void GetPrintableParamValue(
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParamValue<typename std::remove_pointer<T>::type>(d,
|
||||
GetPrintableParamValue<std::remove_pointer_t<T>>(d,
|
||||
*((std::string*) input));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& /* data */,
|
||||
const std::string& input,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& /* data */,
|
||||
const std::string& input,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*)
|
||||
{
|
||||
return input + ".csv";
|
||||
}
|
||||
@@ -57,8 +57,8 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& /* data */,
|
||||
const std::string& input,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return input + ".bin";
|
||||
}
|
||||
@@ -71,8 +71,8 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& /* data */,
|
||||
const std::string& input,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return input + ".arff";
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace cli {
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a vector.
|
||||
@@ -35,7 +35,7 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix option.
|
||||
@@ -43,7 +43,7 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix tuple option.
|
||||
@@ -51,8 +51,8 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a model.
|
||||
@@ -60,8 +60,8 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Print the command-line type of an option into a string.
|
||||
@@ -71,8 +71,7 @@ void GetPrintableType(util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableType<typename std::remove_pointer<T>::type>(data);
|
||||
*((std::string*) output) = GetPrintableType<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
|
||||
@@ -25,19 +25,19 @@ namespace cli {
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
return "flag";
|
||||
else if (std::is_same<T, int>::value)
|
||||
else if (std::is_same_v<T, int>)
|
||||
return "int";
|
||||
else if (std::is_same<T, double>::value)
|
||||
else if (std::is_same_v<T, double>)
|
||||
return "double";
|
||||
else if (std::is_same<T, std::string>::value)
|
||||
else if (std::is_same_v<T, std::string>)
|
||||
return "string";
|
||||
else
|
||||
throw std::invalid_argument("unknown parameter type" + data.cppType);
|
||||
@@ -49,11 +49,11 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
if (std::is_same<T, std::vector<int>>::value)
|
||||
if (std::is_same_v<T, std::vector<int>>)
|
||||
return "int vector";
|
||||
else if (std::is_same<T, std::vector<std::string>>::value)
|
||||
else if (std::is_same_v<T, std::vector<std::string>>)
|
||||
return "string vector";
|
||||
else
|
||||
throw std::invalid_argument("unknown vector type " + data.cppType);
|
||||
@@ -65,19 +65,19 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*)
|
||||
{
|
||||
if (std::is_same<T, arma::mat>::value)
|
||||
if (std::is_same_v<T, arma::mat>)
|
||||
return "2-d matrix file";
|
||||
else if (std::is_same<T, arma::Mat<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Mat<size_t>>)
|
||||
return "2-d index matrix file";
|
||||
else if (std::is_same<T, arma::rowvec>::value)
|
||||
else if (std::is_same_v<T, arma::rowvec>)
|
||||
return "1-d matrix file";
|
||||
else if (std::is_same<T, arma::Row<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Row<size_t>>)
|
||||
return "1-d index matrix file";
|
||||
else if (std::is_same<T, arma::vec>::value)
|
||||
else if (std::is_same_v<T, arma::vec>)
|
||||
return "1-d matrix file";
|
||||
else if (std::is_same<T, arma::Col<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Col<size_t>>)
|
||||
return "1-d index matrix file";
|
||||
else
|
||||
throw std::invalid_argument("unknown Armadillo type" + data.cppType);
|
||||
@@ -89,8 +89,8 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "2-d categorical matrix file";
|
||||
}
|
||||
@@ -101,8 +101,8 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return data.cppType + " file";
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ namespace cli {
|
||||
template<typename T>
|
||||
T& GetRawParam(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// No mapping is needed, so just cast it directly.
|
||||
return *std::any_cast<T>(&d.value);
|
||||
@@ -42,10 +42,10 @@ T& GetRawParam(
|
||||
template<typename T>
|
||||
T& GetRawParam(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* = 0)
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>>* = 0)
|
||||
{
|
||||
// Don't load the matrix.
|
||||
typedef std::tuple<T, std::tuple<std::string, size_t, size_t>> TupleType;
|
||||
@@ -59,8 +59,8 @@ T& GetRawParam(
|
||||
template<typename T>
|
||||
T*& GetRawParam(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Don't load the model.
|
||||
typedef std::tuple<T*, std::string> TupleType;
|
||||
@@ -82,7 +82,7 @@ void GetRawParam(util::ParamData& d,
|
||||
void* output)
|
||||
{
|
||||
// Cast to the correct type.
|
||||
*((T**) output) = &GetRawParam<typename std::remove_pointer<T>::type>(
|
||||
*((T**) output) = &GetRawParam<std::remove_pointer_t<T>>(
|
||||
const_cast<util::ParamData&>(d));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ template<typename T>
|
||||
void InPlaceCopyInternal(
|
||||
util::ParamData& /* d */,
|
||||
util::ParamData& /* input */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// Nothing to do.
|
||||
}
|
||||
@@ -50,11 +50,10 @@ template<typename T>
|
||||
void InPlaceCopyInternal(
|
||||
util::ParamData& d,
|
||||
util::ParamData& input,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value
|
||||
>::type* = 0)
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo, arma::mat>>>*
|
||||
= 0)
|
||||
{
|
||||
// Make the output filename the same as the input filename.
|
||||
typedef std::tuple<T, typename ParameterType<T>::type> TupleType;
|
||||
@@ -76,8 +75,7 @@ template<typename T>
|
||||
void InPlaceCopyInternal(
|
||||
util::ParamData& d,
|
||||
util::ParamData& input,
|
||||
const typename std::enable_if<
|
||||
data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Make the output filename the same as the input filename.
|
||||
typedef std::tuple<T*, typename ParameterType<T>::type> TupleType;
|
||||
@@ -102,7 +100,7 @@ void InPlaceCopy(util::ParamData& d,
|
||||
void* /* output */)
|
||||
{
|
||||
// Cast to the correct type.
|
||||
InPlaceCopyInternal<typename std::remove_pointer<T>::type>(
|
||||
InPlaceCopyInternal<std::remove_pointer_t<T>>(
|
||||
const_cast<util::ParamData&>(d), *((util::ParamData*) input));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ namespace cli {
|
||||
template<typename T>
|
||||
std::string MapParameterName(
|
||||
const std::string& identifier,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
return identifier;
|
||||
}
|
||||
@@ -43,11 +43,10 @@ std::string MapParameterName(
|
||||
template<typename T>
|
||||
std::string MapParameterName(
|
||||
const std::string& identifier,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value ||
|
||||
data::HasSerialize<T>::value>::type* /* junk */ = 0)
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo, arma::mat>> ||
|
||||
data::HasSerialize<T>::value>* /* junk */ = 0)
|
||||
{
|
||||
return identifier + "_file";
|
||||
}
|
||||
@@ -67,7 +66,7 @@ void MapParameterName(util::ParamData& d,
|
||||
// Store the mapped name in the output pointer, which is actually a string
|
||||
// pointer.
|
||||
*((std::string*) output) =
|
||||
MapParameterName<typename std::remove_pointer<T>::type>(d.name);
|
||||
MapParameterName<std::remove_pointer_t<T>>(d.name);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace cli {
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Output a vector option (print to stdout).
|
||||
@@ -38,7 +38,7 @@ void OutputParamImpl(
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Output a matrix option (this saves it to the given file).
|
||||
@@ -46,7 +46,7 @@ void OutputParamImpl(
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Output a serializable class option (this saves it to the given file).
|
||||
@@ -54,8 +54,8 @@ void OutputParamImpl(
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Output a mapped dataset.
|
||||
@@ -63,8 +63,8 @@ void OutputParamImpl(
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Output an option. This is the function that will be called by the IO
|
||||
@@ -75,7 +75,7 @@ void OutputParam(util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* /* output */)
|
||||
{
|
||||
OutputParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
OutputParamImpl<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
|
||||
@@ -24,11 +24,11 @@ namespace cli {
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::cout << data.name << ": " << *std::any_cast<T>(&data.value)
|
||||
<< std::endl;
|
||||
@@ -38,7 +38,7 @@ void OutputParamImpl(
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
std::cout << data.name << ": ";
|
||||
const T& t = *std::any_cast<T>(&data.value);
|
||||
@@ -51,7 +51,7 @@ void OutputParamImpl(
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*)
|
||||
{
|
||||
typedef std::tuple<T, std::tuple<std::string, size_t, size_t>> TupleType;
|
||||
const T& output = std::get<0>(*std::any_cast<TupleType>(&data.value));
|
||||
@@ -71,8 +71,8 @@ void OutputParamImpl(
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
// 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
|
||||
@@ -91,8 +91,8 @@ void OutputParamImpl(
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* /* junk */)
|
||||
{
|
||||
// Output the matrix with the mappings.
|
||||
typedef std::tuple<T, std::tuple<std::string, size_t, size_t>> TupleType;
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace cli {
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a vector.
|
||||
@@ -37,7 +37,7 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix option.
|
||||
@@ -45,7 +45,7 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix tuple option.
|
||||
@@ -53,8 +53,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a model.
|
||||
@@ -62,8 +62,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Print the command-line type of an option into a string.
|
||||
@@ -73,8 +73,7 @@ void PrintTypeDoc(util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
PrintTypeDoc<typename std::remove_pointer<T>::type>(data);
|
||||
*((std::string*) output) = PrintTypeDoc<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
|
||||
@@ -24,30 +24,30 @@ namespace cli {
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
// A flag type.
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
{
|
||||
return "A boolean flag option. If not specified, it is false; if "
|
||||
"specified, it is true.";
|
||||
}
|
||||
// An integer.
|
||||
else if (std::is_same<T, int>::value)
|
||||
else if (std::is_same_v<T, int>)
|
||||
{
|
||||
return "An integer (i.e., \"1\").";
|
||||
}
|
||||
// A floating point value.
|
||||
else if (std::is_same<T, double>::value)
|
||||
else if (std::is_same_v<T, double>)
|
||||
{
|
||||
return "A floating-point number (i.e., \"0.5\").";
|
||||
}
|
||||
// A string.
|
||||
else if (std::is_same<T, std::string>::value)
|
||||
else if (std::is_same_v<T, std::string>)
|
||||
{
|
||||
return "A character string (i.e., \"hello\").";
|
||||
}
|
||||
@@ -64,13 +64,13 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
if (std::is_same<T, std::vector<int>>::value)
|
||||
if (std::is_same_v<T, std::vector<int>>)
|
||||
{
|
||||
return "A vector of integers, separated by commas (i.e., \"1,2,3\").";
|
||||
}
|
||||
else if (std::is_same<T, std::vector<std::string>>::value)
|
||||
else if (std::is_same_v<T, std::vector<std::string>>)
|
||||
{
|
||||
return "A vector of strings, separated by commas (i.e., "
|
||||
"\"hello\",\"goodbye\").";
|
||||
@@ -87,9 +87,9 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*)
|
||||
{
|
||||
if (std::is_same<T, arma::mat>::value)
|
||||
if (std::is_same_v<T, arma::mat>)
|
||||
{
|
||||
return "A data matrix filename. The file can be CSV (.csv), TSV (.csv), "
|
||||
"ASCII (space-separated values, .txt), Armadillo ASCII (.txt), PGM "
|
||||
@@ -102,7 +102,7 @@ std::string PrintTypeDoc(
|
||||
"is found, the first row will be loaded as a data point. All values of"
|
||||
" the matrix will be loaded as double-precision floating point data.";
|
||||
}
|
||||
else if (std::is_same<T, arma::Mat<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Mat<size_t>>)
|
||||
{
|
||||
return "A data matrix filename, where the matrix holds only non-negative "
|
||||
"integer values. This type is often used for labels or indices. The "
|
||||
@@ -117,15 +117,15 @@ std::string PrintTypeDoc(
|
||||
" loaded as a data point. All values of the matrix will be loaded as "
|
||||
"unsigned integers.";
|
||||
}
|
||||
else if (std::is_same<T, arma::rowvec>::value ||
|
||||
std::is_same<T, arma::vec>::value)
|
||||
else if (std::is_same_v<T, arma::rowvec> ||
|
||||
std::is_same_v<T, arma::vec>)
|
||||
{
|
||||
return "A one-dimensional vector filename. This file can take the same "
|
||||
"formats as the data matrix filenames; however, it must either contain "
|
||||
"one row and many columns, or one column and many rows.";
|
||||
}
|
||||
else if (std::is_same<T, arma::Row<size_t>>::value ||
|
||||
std::is_same<T, arma::Col<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Row<size_t>> ||
|
||||
std::is_same_v<T, arma::Col<size_t>>)
|
||||
{
|
||||
return "A one-dimensional vector filename, where the matrix holds only non-"
|
||||
"negative integer values. This type is typically used for labels or "
|
||||
@@ -145,8 +145,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "A filename for a data matrix that can contain categorical "
|
||||
"(non-numeric) data. If the file contains only numeric data, then the "
|
||||
@@ -165,8 +165,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return "A filename containing an mlpack model. These can have one of three "
|
||||
"formats: binary (.bin), text (.txt), and XML (.xml). The XML format "
|
||||
|
||||
@@ -27,11 +27,11 @@ template<typename T>
|
||||
void SetParam(
|
||||
util::ParamData& d,
|
||||
const std::any& value,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T, bool>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T, bool>>* = 0)
|
||||
{
|
||||
// No mapping is needed.
|
||||
d.value = *std::any_cast<T>(&value);
|
||||
@@ -44,7 +44,7 @@ template<typename T>
|
||||
void SetParam(
|
||||
util::ParamData& d,
|
||||
const std::any& /* value */,
|
||||
const typename std::enable_if<std::is_same<T, bool>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T, bool>>* = 0)
|
||||
{
|
||||
// Force set to the value of whether or not this was passed.
|
||||
d.value = d.wasPassed;
|
||||
@@ -58,9 +58,8 @@ template<typename T>
|
||||
void SetParam(
|
||||
util::ParamData& d,
|
||||
const std::any& value,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value ||
|
||||
std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value || std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// We're setting the string filename.
|
||||
typedef std::tuple<T, typename ParameterType<T>::type> TupleType;
|
||||
@@ -76,8 +75,8 @@ template<typename T>
|
||||
void SetParam(
|
||||
util::ParamData& d,
|
||||
const std::any& value,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// We're setting the string filename.
|
||||
typedef std::tuple<T*, typename ParameterType<T>::type> TupleType;
|
||||
@@ -96,7 +95,7 @@ void SetParam(
|
||||
template<typename T>
|
||||
void SetParam(util::ParamData& d, const void* input, void* /* output */)
|
||||
{
|
||||
SetParam<typename std::remove_pointer<T>::type>(
|
||||
SetParam<std::remove_pointer_t<T>>(
|
||||
const_cast<util::ParamData&>(d), *((std::any*) input));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,22 +26,22 @@ namespace cli {
|
||||
*/
|
||||
template<typename T>
|
||||
std::string StringTypeParamImpl(
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string containing the type of the parameter, for vector options.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string StringTypeParamImpl(
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string containing the type of the parameter,
|
||||
*/
|
||||
template<typename T>
|
||||
std::string StringTypeParamImpl(
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string containing the type of a parameter. This overload is used if
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace cli {
|
||||
*/
|
||||
template<typename T>
|
||||
std::string StringTypeParamImpl(
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*)
|
||||
{
|
||||
// Don't know what type this is.
|
||||
return "unknown";
|
||||
@@ -35,7 +35,7 @@ std::string StringTypeParamImpl(
|
||||
*/
|
||||
template<typename T>
|
||||
std::string StringTypeParamImpl(
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
return "vector";
|
||||
}
|
||||
@@ -45,7 +45,7 @@ std::string StringTypeParamImpl(
|
||||
*/
|
||||
template<typename T>
|
||||
std::string StringTypeParamImpl(
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return "string";
|
||||
}
|
||||
|
||||
@@ -26,13 +26,12 @@ namespace go {
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::string>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T, std::string>>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a vector option.
|
||||
@@ -40,7 +39,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a string option.
|
||||
@@ -48,8 +47,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T, std::string>::value
|
||||
>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T, std::string>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a matrix option, a tuple option, a
|
||||
@@ -59,10 +57,10 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* = 0);
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a model option (this returns the default
|
||||
@@ -71,8 +69,8 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of an option. This is the function that will be
|
||||
@@ -84,7 +82,7 @@ void DefaultParam(util::ParamData& data,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = DefaultParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
*outstr = DefaultParamImpl<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace go
|
||||
|
||||
@@ -24,16 +24,15 @@ namespace go {
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::string>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T, std::string>>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
oss << "false";
|
||||
else
|
||||
oss << std::any_cast<T>(data.value);
|
||||
@@ -47,12 +46,12 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
// Print each element in an array delimited by square brackets.
|
||||
std::ostringstream oss;
|
||||
const T& vector = std::any_cast<T>(data.value);
|
||||
if (std::is_same<T, std::vector<std::string>>::value)
|
||||
if (std::is_same_v<T, std::vector<std::string>>)
|
||||
{
|
||||
oss << "[]string{";
|
||||
if (vector.size() > 0)
|
||||
@@ -67,7 +66,7 @@ std::string DefaultParamImpl(
|
||||
|
||||
oss << "}";
|
||||
}
|
||||
else if (std::is_same<T, std::vector<int>>::value)
|
||||
else if (std::is_same_v<T, std::vector<int>>)
|
||||
{
|
||||
oss << "[]int{";
|
||||
if (vector.size() > 0)
|
||||
@@ -91,7 +90,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T, std::string>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T, std::string>>*)
|
||||
{
|
||||
const std::string& s = *std::any_cast<std::string>(&data.value);
|
||||
return "\"" + s + "\"";
|
||||
@@ -103,23 +102,22 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* /* junk */)
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>>* /* junk */)
|
||||
{
|
||||
// Get the filename and return it, or return an empty string.
|
||||
if (std::is_same<T, arma::rowvec>::value ||
|
||||
std::is_same<T, arma::vec>::value)
|
||||
if (std::is_same_v<T, arma::rowvec> || std::is_same_v<T, arma::vec>)
|
||||
{
|
||||
return "mat.NewDense(1, 1, nil)";
|
||||
}
|
||||
else if (std::is_same<T, arma::Col<size_t>>::value ||
|
||||
std::is_same<T, arma::Row<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Col<size_t>> ||
|
||||
std::is_same_v<T, arma::Row<size_t>>)
|
||||
{
|
||||
return "mat.NewDense(1, 1, nil)";
|
||||
}
|
||||
else if (std::is_same<T, arma::Mat<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Mat<size_t>>)
|
||||
{
|
||||
return "mat.NewDense(1, 1, nil)";
|
||||
}
|
||||
@@ -135,8 +133,8 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return "nil";
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace go {
|
||||
template<typename T>
|
||||
inline std::string GetGoType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
@@ -37,11 +37,11 @@ inline std::string GetGoType(
|
||||
template<>
|
||||
inline std::string GetGoType<int>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<int>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<int>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<int>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
@@ -49,11 +49,11 @@ inline std::string GetGoType<int>(
|
||||
template<>
|
||||
inline std::string GetGoType<float>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<float>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<float>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<float>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<float,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<float>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<float>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<float>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<float,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "float32";
|
||||
}
|
||||
@@ -61,11 +61,11 @@ inline std::string GetGoType<float>(
|
||||
template<>
|
||||
inline std::string GetGoType<double>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<double>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<double>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<double>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "float64";
|
||||
}
|
||||
@@ -73,14 +73,11 @@ inline std::string GetGoType<double>(
|
||||
template<>
|
||||
inline std::string GetGoType<std::string>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<
|
||||
!util::IsStdVector<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!data::HasSerialize<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!arma::is_arma_type<std::string>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<std::string>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<std::string>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<std::string>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "string";
|
||||
}
|
||||
@@ -88,11 +85,11 @@ inline std::string GetGoType<std::string>(
|
||||
template<>
|
||||
inline std::string GetGoType<bool>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<bool>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<bool>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<bool>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "bool";
|
||||
}
|
||||
@@ -100,7 +97,7 @@ inline std::string GetGoType<bool>(
|
||||
template<typename T>
|
||||
inline std::string GetGoType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0)
|
||||
{
|
||||
return "[]" + GetGoType<typename T::value_type>(d);
|
||||
}
|
||||
@@ -108,9 +105,9 @@ inline std::string GetGoType(
|
||||
template<typename T>
|
||||
inline std::string GetGoType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0,
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
return "mat.Dense";
|
||||
}
|
||||
@@ -118,8 +115,8 @@ inline std::string GetGoType(
|
||||
template<typename T>
|
||||
inline std::string GetGoType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
return "matrixWithInfo";
|
||||
}
|
||||
@@ -127,8 +124,8 @@ inline std::string GetGoType(
|
||||
template<typename T>
|
||||
inline std::string GetGoType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
std::string goStrippedType, strippedType, printedType, defaultsType;
|
||||
StripType(d.cppType, goStrippedType, strippedType, printedType, defaultsType);
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace go {
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::any_cast<T>(data.value);
|
||||
@@ -42,7 +42,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0)
|
||||
{
|
||||
const T& t = std::any_cast<T>(data.value);
|
||||
|
||||
@@ -58,7 +58,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// Get the matrix.
|
||||
const T& matrix = std::any_cast<T>(data.value);
|
||||
@@ -74,8 +74,8 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << data.cppType << " model at " << std::any_cast<T*>(data.value);
|
||||
@@ -88,16 +88,16 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// Get the matrix.
|
||||
const T& tuple = std::any_cast<T>(data.value);
|
||||
const arma::mat& matrix = std::get<1>(tuple);
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << matrix.n_rows << "x" << matrix.n_cols << " matrix with dimension type "
|
||||
<< "information";
|
||||
oss << matrix.n_rows << "x" << matrix.n_cols
|
||||
<< " matrix with dimension type information";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
@@ -115,8 +115,7 @@ void GetPrintableParam(util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParam<typename std::remove_pointer<T>::type>(data);
|
||||
*((std::string*) output) = GetPrintableParam<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace go
|
||||
|
||||
@@ -23,86 +23,82 @@ namespace go {
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<int>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<int>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<int>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<int>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<double>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<double>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<double>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<double>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<std::string>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<
|
||||
!util::IsStdVector<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!data::HasSerialize<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!arma::is_arma_type<std::string>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<std::string>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<std::string>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<std::string>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<bool>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<bool>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<bool>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<bool>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<typename T>
|
||||
void GetPrintableType(util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableType<typename std::remove_pointer<T>::type>(d);
|
||||
*((std::string*) output) = GetPrintableType<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace go
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace go {
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
@@ -35,11 +35,11 @@ inline std::string GetPrintableType(
|
||||
template<>
|
||||
inline std::string GetPrintableType<int>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<int>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<int>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<int>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
@@ -47,11 +47,11 @@ inline std::string GetPrintableType<int>(
|
||||
template<>
|
||||
inline std::string GetPrintableType<double>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<double>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<double>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<double>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "float64";
|
||||
}
|
||||
@@ -59,14 +59,11 @@ inline std::string GetPrintableType<double>(
|
||||
template<>
|
||||
inline std::string GetPrintableType<std::string>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<
|
||||
!util::IsStdVector<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!data::HasSerialize<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!arma::is_arma_type<std::string>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<std::string>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<std::string>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<std::string>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "string";
|
||||
}
|
||||
@@ -74,11 +71,11 @@ inline std::string GetPrintableType<std::string>(
|
||||
template<>
|
||||
inline std::string GetPrintableType<bool>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<bool>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<bool>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<bool>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "bool";
|
||||
}
|
||||
@@ -86,9 +83,9 @@ inline std::string GetPrintableType<bool>(
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "array of " + GetPrintableType<typename T::value_type>(d) + "s";
|
||||
}
|
||||
@@ -96,9 +93,9 @@ inline std::string GetPrintableType(
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::string type = "*mat.Dense";
|
||||
if (T::is_row || T::is_col)
|
||||
@@ -110,8 +107,8 @@ inline std::string GetPrintableType(
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "matrixWithInfo";
|
||||
}
|
||||
@@ -119,10 +116,10 @@ inline std::string GetPrintableType(
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::string goStrippedType, strippedType, printedType, defaultsType;
|
||||
StripType(d.cppType, goStrippedType, strippedType, printedType, defaultsType);
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace go {
|
||||
template<typename T>
|
||||
inline std::string GetType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
@@ -34,9 +34,9 @@ inline std::string GetType(
|
||||
template<>
|
||||
inline std::string GetType<int>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<int>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<int>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<int>::value>*)
|
||||
{
|
||||
return "Int";
|
||||
}
|
||||
@@ -44,9 +44,9 @@ inline std::string GetType<int>(
|
||||
template<>
|
||||
inline std::string GetType<float>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<float>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<float>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<float>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<float>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<float>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<float>::value>*)
|
||||
{
|
||||
return "Float";
|
||||
}
|
||||
@@ -54,9 +54,9 @@ inline std::string GetType<float>(
|
||||
template<>
|
||||
inline std::string GetType<double>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<double>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<double>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<double>::value>*)
|
||||
{
|
||||
return "Double";
|
||||
}
|
||||
@@ -64,12 +64,9 @@ inline std::string GetType<double>(
|
||||
template<>
|
||||
inline std::string GetType<std::string>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<
|
||||
!util::IsStdVector<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!data::HasSerialize<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!arma::is_arma_type<std::string>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<std::string>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<std::string>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<std::string>::value>*)
|
||||
{
|
||||
return "String";
|
||||
}
|
||||
@@ -77,9 +74,9 @@ inline std::string GetType<std::string>(
|
||||
template<>
|
||||
inline std::string GetType<bool>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<bool>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<bool>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<bool>::value>*)
|
||||
{
|
||||
return "Bool";
|
||||
}
|
||||
@@ -87,7 +84,7 @@ inline std::string GetType<bool>(
|
||||
template<typename T>
|
||||
inline std::string GetType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0)
|
||||
{
|
||||
return "Vec" + GetType<typename T::value_type>(d);
|
||||
}
|
||||
@@ -95,10 +92,10 @@ inline std::string GetType(
|
||||
template<typename T>
|
||||
inline std::string GetType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
std::string type = "";
|
||||
if (std::is_same<typename T::elem_type, double>::value)
|
||||
if (std::is_same_v<typename T::elem_type, double>)
|
||||
{
|
||||
if (T::is_row)
|
||||
type = "Row";
|
||||
@@ -107,7 +104,7 @@ inline std::string GetType(
|
||||
else
|
||||
type = "Mat";
|
||||
}
|
||||
else if (std::is_same<typename T::elem_type, size_t>::value)
|
||||
else if (std::is_same_v<typename T::elem_type, size_t>)
|
||||
{
|
||||
if (T::is_row)
|
||||
type = "Urow";
|
||||
@@ -123,8 +120,8 @@ inline std::string GetType(
|
||||
template<typename T>
|
||||
inline std::string GetType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
return d.cppType + "*";
|
||||
}
|
||||
@@ -144,8 +141,7 @@ void GetType(util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetType<typename std::remove_pointer<T>::type>(d);
|
||||
*((std::string*) output) = GetType<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace go
|
||||
|
||||
@@ -28,10 +28,10 @@ namespace go {
|
||||
template<typename T>
|
||||
void PrintDefnInput(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
if (d.required)
|
||||
{
|
||||
@@ -46,7 +46,7 @@ void PrintDefnInput(
|
||||
template<typename T>
|
||||
void PrintDefnInput(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// param_name *mat.Dense
|
||||
if (d.required)
|
||||
@@ -62,8 +62,8 @@ void PrintDefnInput(
|
||||
template<typename T>
|
||||
void PrintDefnInput(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// param_name *DataWithInfo
|
||||
if (d.required)
|
||||
@@ -79,8 +79,8 @@ void PrintDefnInput(
|
||||
template<typename T>
|
||||
void PrintDefnInput(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Get the type names we need to use.
|
||||
std::string goStrippedType, strippedType, printedType, defaultsType;
|
||||
@@ -113,7 +113,7 @@ void PrintDefnInput(util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintDefnInput<typename std::remove_pointer<T>::type>(d);
|
||||
PrintDefnInput<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace go
|
||||
|
||||
@@ -27,10 +27,10 @@ namespace go {
|
||||
template<typename T>
|
||||
void PrintDefnOutput(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
std::cout << GetGoType<T>(d);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ void PrintDefnOutput(
|
||||
template<typename T>
|
||||
void PrintDefnOutput(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// *mat.Dense
|
||||
std::cout << "*" << GetGoType<T>(d);
|
||||
@@ -53,8 +53,8 @@ void PrintDefnOutput(
|
||||
template<typename T>
|
||||
void PrintDefnOutput(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// *mat.Dense
|
||||
std::cout << "*" << GetGoType<T>(d);
|
||||
@@ -66,8 +66,8 @@ void PrintDefnOutput(
|
||||
template<typename T>
|
||||
void PrintDefnOutput(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Get the type names we need to use.
|
||||
std::string goStrippedType, strippedType, printedType, defaultsType;
|
||||
@@ -94,7 +94,7 @@ void PrintDefnOutput(util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintDefnOutput<typename std::remove_pointer<T>::type>(d);
|
||||
PrintDefnOutput<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace go
|
||||
|
||||
@@ -45,8 +45,7 @@ void PrintDoc(util::ParamData& d,
|
||||
std::ostringstream oss;
|
||||
oss << " - ";
|
||||
oss << util::CamelCase(d.name, Lower) << " (";
|
||||
oss << GetGoType<typename std::remove_pointer<T>::type>(d) << "): "
|
||||
<< d.desc;
|
||||
oss << GetGoType<std::remove_pointer_t<T>>(d) << "): " << d.desc;
|
||||
|
||||
// Print a default, if possible.
|
||||
if (!d.required)
|
||||
|
||||
@@ -29,15 +29,15 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
std::string def = "nil";
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
def = "false";
|
||||
|
||||
// Capitalize the first letter of parameter name so it is
|
||||
@@ -131,7 +131,7 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
@@ -206,8 +206,8 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
@@ -268,8 +268,8 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// First, get the correct classparamName if needed.
|
||||
std::string goStrippedType, strippedType, printedType, defaultsType;
|
||||
@@ -340,8 +340,7 @@ void PrintInputProcessing(util::ParamData& d,
|
||||
const void* input,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintInputProcessing<typename std::remove_pointer<T>::type>(d,
|
||||
*((size_t*) input));
|
||||
PrintInputProcessing<std::remove_pointer_t<T>>(d, *((size_t*) input));
|
||||
}
|
||||
|
||||
} // namespace go
|
||||
|
||||
@@ -29,15 +29,15 @@ template<typename T>
|
||||
void PrintMethodConfig(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
std::string def = "nil";
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
def = "false";
|
||||
|
||||
// Capitalize the first letter of parameter name so it is
|
||||
@@ -64,12 +64,12 @@ template<typename T>
|
||||
void PrintMethodConfig(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
std::string def = "nil";
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
def = "false";
|
||||
|
||||
// Capitalize the first letter of parameter name so it is
|
||||
@@ -96,13 +96,13 @@ template<typename T>
|
||||
void PrintMethodConfig(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
std::string def = "nil";
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
def = "false";
|
||||
|
||||
// Capitalize the first letter of parameter name so it is
|
||||
@@ -129,13 +129,13 @@ template<typename T>
|
||||
void PrintMethodConfig(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
std::string def = "nil";
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
def = "false";
|
||||
|
||||
// Capitalize the first letter of parameter name so it is
|
||||
@@ -171,8 +171,7 @@ void PrintMethodConfig(util::ParamData& d,
|
||||
const void* input,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintMethodConfig<typename std::remove_pointer<T>::type>(d,
|
||||
*((size_t*) input));
|
||||
PrintMethodConfig<std::remove_pointer_t<T>>(d, *((size_t*) input));
|
||||
}
|
||||
|
||||
} // namespace go
|
||||
|
||||
@@ -29,15 +29,15 @@ template<typename T>
|
||||
void PrintMethodInit(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
std::string def = "nil";
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
def = "false";
|
||||
|
||||
// Capitalize the first letter of parameter name so it is
|
||||
@@ -86,12 +86,12 @@ template<typename T>
|
||||
void PrintMethodInit(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
std::string def = "nil";
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
def = "false";
|
||||
|
||||
// Capitalize the first letter of parameter name so it is
|
||||
@@ -118,13 +118,13 @@ template<typename T>
|
||||
void PrintMethodInit(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
std::string def = "nil";
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
def = "false";
|
||||
|
||||
// Capitalize the first letter of parameter name so it is
|
||||
@@ -151,13 +151,13 @@ template<typename T>
|
||||
void PrintMethodInit(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
std::string def = "nil";
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
def = "false";
|
||||
|
||||
// Capitalize the first letter of parameter name so it is
|
||||
@@ -193,8 +193,7 @@ void PrintMethodInit(util::ParamData& d,
|
||||
const void* input,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintMethodInit<typename std::remove_pointer<T>::type>(d,
|
||||
*((size_t*) input));
|
||||
PrintMethodInit<std::remove_pointer_t<T>>(d, *((size_t*) input));
|
||||
}
|
||||
|
||||
} // namespace go
|
||||
|
||||
@@ -29,10 +29,10 @@ template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
@@ -56,9 +56,9 @@ template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
@@ -84,8 +84,8 @@ template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
@@ -111,8 +111,8 @@ template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Get the type names we need to use.
|
||||
std::string goStrippedType, strippedType, printedType, defaultsType;
|
||||
@@ -144,7 +144,7 @@ void PrintOutputProcessing(util::ParamData& d,
|
||||
const void* /*input*/,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintOutputProcessing<typename std::remove_pointer<T>::type>(d, 2);
|
||||
PrintOutputProcessing<std::remove_pointer_t<T>>(d, 2);
|
||||
}
|
||||
|
||||
} // namespace go
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace go {
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a vector.
|
||||
@@ -37,7 +37,7 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix option.
|
||||
@@ -45,7 +45,7 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix tuple option.
|
||||
@@ -53,8 +53,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a model.
|
||||
@@ -62,8 +62,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Print the command-line type of an option into a string.
|
||||
@@ -73,8 +73,7 @@ void PrintTypeDoc(util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
PrintTypeDoc<typename std::remove_pointer<T>::type>(data);
|
||||
*((std::string*) output) = PrintTypeDoc<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace go
|
||||
|
||||
@@ -24,29 +24,29 @@ namespace go {
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
// A flag type.
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
{
|
||||
return "A boolean flag option (`true` or `false`).";
|
||||
}
|
||||
// An integer.
|
||||
else if (std::is_same<T, int>::value)
|
||||
else if (std::is_same_v<T, int>)
|
||||
{
|
||||
return "An integer (i.e., `1`).";
|
||||
}
|
||||
// A floating point value.
|
||||
else if (std::is_same<T, double>::value)
|
||||
else if (std::is_same_v<T, double>)
|
||||
{
|
||||
return "A floating-point number (i.e., `0.5`).";
|
||||
}
|
||||
// A string.
|
||||
else if (std::is_same<T, std::string>::value)
|
||||
else if (std::is_same_v<T, std::string>)
|
||||
{
|
||||
return "A character string (i.e., `\"hello\"`).";
|
||||
}
|
||||
@@ -63,13 +63,13 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
if (std::is_same<T, std::vector<int>>::value)
|
||||
if (std::is_same_v<T, std::vector<int>>)
|
||||
{
|
||||
return "An array of integers; i.e., `[]int{0, 1, 2}`.";
|
||||
}
|
||||
else if (std::is_same<T, std::vector<std::string>>::value)
|
||||
else if (std::is_same_v<T, std::vector<std::string>>)
|
||||
{
|
||||
return "An array of strings; i.e., `[]string{\"hello\", \"goodbye\"}`.";
|
||||
}
|
||||
@@ -85,7 +85,7 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*)
|
||||
{
|
||||
if (T::is_col || T::is_row)
|
||||
{
|
||||
@@ -105,8 +105,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "A Tuple(matrixWithInfo) containing `float64` data (Data) along with a"
|
||||
" boolean array (Categoricals) indicating which dimensions are categorical"
|
||||
@@ -122,8 +122,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return "An mlpack model pointer. This type holds a pointer to C++ memory "
|
||||
"containing the mlpack model. Note that this means the mlpack model "
|
||||
|
||||
@@ -26,13 +26,12 @@ namespace julia {
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::string>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T, std::string>>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a vector option.
|
||||
@@ -40,7 +39,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a string option.
|
||||
@@ -48,8 +47,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T, std::string>::value
|
||||
>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T, std::string>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a matrix option, a tuple option, a
|
||||
@@ -59,10 +57,10 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* = 0);
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a model option (this returns the default
|
||||
@@ -71,8 +69,8 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of an option. This is the function that will be
|
||||
@@ -84,7 +82,7 @@ void DefaultParam(util::ParamData& data,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = DefaultParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
*outstr = DefaultParamImpl<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace julia
|
||||
|
||||
@@ -24,16 +24,15 @@ namespace julia {
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::string>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T, std::string>>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
oss << "false";
|
||||
else
|
||||
oss << std::any_cast<T>(data.value);
|
||||
@@ -47,13 +46,13 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
// Print each element in an array delimited by square brackets.
|
||||
std::ostringstream oss;
|
||||
const T& vector = std::any_cast<T>(data.value);
|
||||
oss << "[";
|
||||
if (std::is_same<T, std::vector<std::string>>::value)
|
||||
if (std::is_same_v<T, std::vector<std::string>>)
|
||||
{
|
||||
if (vector.size() > 0)
|
||||
{
|
||||
@@ -90,7 +89,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T, std::string>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T, std::string>>*)
|
||||
{
|
||||
const std::string& s = *std::any_cast<std::string>(&data.value);
|
||||
return "\"" + s + "\"";
|
||||
@@ -103,23 +102,22 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* /* junk */)
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>>* /* junk */)
|
||||
{
|
||||
// Get the filename and return it, or return an empty string.
|
||||
if (std::is_same<T, arma::rowvec>::value ||
|
||||
std::is_same<T, arma::vec>::value)
|
||||
if (std::is_same_v<T, arma::rowvec> || std::is_same_v<T, arma::vec>)
|
||||
{
|
||||
return "Float64[]";
|
||||
}
|
||||
else if (std::is_same<T, arma::Col<size_t>>::value ||
|
||||
std::is_same<T, arma::Row<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Col<size_t>> ||
|
||||
std::is_same_v<T, arma::Row<size_t>>)
|
||||
{
|
||||
return "Int[]";
|
||||
}
|
||||
else if (std::is_same<T, arma::Mat<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Mat<size_t>>)
|
||||
{
|
||||
return "zeros(Int, 0, 0)";
|
||||
}
|
||||
@@ -135,8 +133,8 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return "nothing";
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ namespace julia {
|
||||
template<typename T>
|
||||
inline std::string GetJuliaType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
return "unknown_"; // This will cause an error most likely...
|
||||
}
|
||||
@@ -33,11 +33,11 @@ inline std::string GetJuliaType(
|
||||
template<>
|
||||
inline std::string GetJuliaType<bool>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<bool>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<bool>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*,
|
||||
const std::enable_if_t<!data::HasSerialize<bool>::value>*)
|
||||
{
|
||||
return "Bool";
|
||||
}
|
||||
@@ -45,11 +45,11 @@ inline std::string GetJuliaType<bool>(
|
||||
template<>
|
||||
inline std::string GetJuliaType<int>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<int>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<int>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<int>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*,
|
||||
const std::enable_if_t<!data::HasSerialize<int>::value>*)
|
||||
{
|
||||
return "Int";
|
||||
}
|
||||
@@ -57,11 +57,11 @@ inline std::string GetJuliaType<int>(
|
||||
template<>
|
||||
inline std::string GetJuliaType<size_t>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<size_t,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<size_t>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<size_t>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<size_t,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*,
|
||||
const std::enable_if_t<!data::HasSerialize<size_t>::value>*)
|
||||
{
|
||||
return "UInt";
|
||||
}
|
||||
@@ -69,11 +69,11 @@ inline std::string GetJuliaType<size_t>(
|
||||
template<>
|
||||
inline std::string GetJuliaType<double>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<double>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<double>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<double>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*,
|
||||
const std::enable_if_t<!data::HasSerialize<double>::value>*)
|
||||
{
|
||||
// I suppose on some systems this may not be 64 bit.
|
||||
return "Float64";
|
||||
@@ -82,14 +82,11 @@ inline std::string GetJuliaType<double>(
|
||||
template<>
|
||||
inline std::string GetJuliaType<std::string>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<
|
||||
!util::IsStdVector<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!arma::is_arma_type<std::string>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!data::HasSerialize<std::string>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<std::string>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<std::string>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*,
|
||||
const std::enable_if_t<!data::HasSerialize<std::string>::value>*)
|
||||
{
|
||||
return "String";
|
||||
}
|
||||
@@ -97,10 +94,10 @@ inline std::string GetJuliaType<std::string>(
|
||||
template<typename T>
|
||||
inline std::string GetJuliaType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
return "Vector{" + GetJuliaType<typename T::value_type>(d) + "}";
|
||||
}
|
||||
@@ -108,14 +105,14 @@ inline std::string GetJuliaType(
|
||||
template<typename T>
|
||||
inline std::string GetJuliaType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0,
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// size_t matrices are special: we want to represent them in Julia as
|
||||
// Array{Int, X} not UInt because Julia displays UInts strangely.
|
||||
if (std::is_same<typename T::elem_type, size_t>::value)
|
||||
if (std::is_same_v<typename T::elem_type, size_t>)
|
||||
return std::string("Array{Int, ") + (T::is_col || T::is_row ? "1" : "2")
|
||||
+ "}";
|
||||
else
|
||||
@@ -126,8 +123,8 @@ inline std::string GetJuliaType(
|
||||
template<typename T>
|
||||
inline std::string GetJuliaType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
return "Tuple{Array{Bool, 1}, Array{Float64, 2}}";
|
||||
}
|
||||
@@ -136,9 +133,9 @@ inline std::string GetJuliaType(
|
||||
template<typename T>
|
||||
inline std::string GetJuliaType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Serializable types are just held as a pointer to nothing, but they're
|
||||
// wrapped in a struct.
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace julia {
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::any_cast<T>(data.value);
|
||||
@@ -42,7 +42,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0)
|
||||
{
|
||||
const T& t = std::any_cast<T>(data.value);
|
||||
|
||||
@@ -58,7 +58,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// Get the matrix.
|
||||
const T& matrix = std::any_cast<T>(data.value);
|
||||
@@ -74,8 +74,8 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << data.cppType << " model at " << std::any_cast<T*>(data.value);
|
||||
@@ -88,8 +88,8 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// Get the matrix.
|
||||
const T& tuple = std::any_cast<T>(data.value);
|
||||
@@ -115,8 +115,7 @@ void GetPrintableParam(util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParam<typename std::remove_pointer<T>::type>(data);
|
||||
*((std::string*) output) = GetPrintableParam<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace julia
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace julia {
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a vector.
|
||||
@@ -35,7 +35,7 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix option.
|
||||
@@ -43,7 +43,7 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix tuple option.
|
||||
@@ -51,8 +51,8 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a model.
|
||||
@@ -60,8 +60,8 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Print the command-line type of an option into a string.
|
||||
@@ -71,8 +71,7 @@ void GetPrintableType(util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableType<typename std::remove_pointer<T>::type>(data);
|
||||
*((std::string*) output) = GetPrintableType<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace julia
|
||||
|
||||
@@ -26,19 +26,19 @@ namespace julia {
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
return "Bool";
|
||||
else if (std::is_same<T, int>::value)
|
||||
else if (std::is_same_v<T, int>)
|
||||
return "Int";
|
||||
else if (std::is_same<T, double>::value)
|
||||
else if (std::is_same_v<T, double>)
|
||||
return "Float64";
|
||||
else if (std::is_same<T, std::string>::value)
|
||||
else if (std::is_same_v<T, std::string>)
|
||||
return "String";
|
||||
else
|
||||
throw std::invalid_argument("unknown parameter type " + data.cppType);
|
||||
@@ -50,11 +50,11 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
if (std::is_same<T, std::vector<int>>::value)
|
||||
if (std::is_same_v<T, std::vector<int>>)
|
||||
return "Array{Int, 1}";
|
||||
else if (std::is_same<T, std::vector<std::string>>::value)
|
||||
else if (std::is_same_v<T, std::vector<std::string>>)
|
||||
return "Array{String, 1}";
|
||||
else
|
||||
throw std::invalid_argument("unknown vector type " + data.cppType);
|
||||
@@ -66,19 +66,19 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*)
|
||||
{
|
||||
if (std::is_same<T, arma::mat>::value)
|
||||
if (std::is_same_v<T, arma::mat>)
|
||||
return "Float64 matrix-like";
|
||||
else if (std::is_same<T, arma::Mat<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Mat<size_t>>)
|
||||
return "Int matrix-like";
|
||||
else if (std::is_same<T, arma::rowvec>::value)
|
||||
else if (std::is_same_v<T, arma::rowvec>)
|
||||
return "Float64 vector-like";
|
||||
else if (std::is_same<T, arma::Row<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Row<size_t>>)
|
||||
return "Int vector-like";
|
||||
else if (std::is_same<T, arma::vec>::value)
|
||||
else if (std::is_same_v<T, arma::vec>)
|
||||
return "Float64 vector-like";
|
||||
else if (std::is_same<T, arma::Col<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Col<size_t>>)
|
||||
return "Int vector-like";
|
||||
else
|
||||
throw std::invalid_argument("unknown Armadillo type " + data.cppType);
|
||||
@@ -90,8 +90,8 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "Tuple{Array{Bool, 1}, Array{Float64, 2}}";
|
||||
}
|
||||
@@ -102,8 +102,8 @@ std::string GetPrintableType(
|
||||
template<typename T>
|
||||
std::string GetPrintableType(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
std::string type = util::StripType(data.cppType);
|
||||
if (type == "mlpackModel")
|
||||
|
||||
@@ -39,12 +39,11 @@ void PrintInputParam(util::ParamData& d,
|
||||
// If it's required, then we need the type.
|
||||
if (d.required)
|
||||
{
|
||||
std::cout << GetJuliaType<typename std::remove_pointer<T>::type>(d);
|
||||
std::cout << GetJuliaType<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Union{"
|
||||
<< GetJuliaType<typename std::remove_pointer<T>::type>(d)
|
||||
std::cout << "Union{" << GetJuliaType<std::remove_pointer_t<T>>(d)
|
||||
<< ", Missing} = missing";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& functionName,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Print the input processing for an Armadillo type.
|
||||
@@ -36,9 +36,9 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& functionName,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Print the input processing for a serializable type.
|
||||
@@ -47,10 +47,10 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& functionName,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Print the input processing (basically calling params.Get<>()) for a
|
||||
@@ -60,8 +60,8 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& functionName,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Print the input processing (basically calling params.Get<>()) for a type.
|
||||
@@ -72,8 +72,7 @@ void PrintInputProcessing(util::ParamData& d,
|
||||
void* /* output */)
|
||||
{
|
||||
// Call out to the right overload.
|
||||
PrintInputProcessing<typename std::remove_pointer<T>::type>(d,
|
||||
*((std::string*) input));
|
||||
PrintInputProcessing<std::remove_pointer_t<T>>(d, *((std::string*) input));
|
||||
}
|
||||
|
||||
} // namespace julia
|
||||
|
||||
@@ -27,10 +27,10 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& /* functionName */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
// "type" is a reserved keyword or function.
|
||||
const std::string juliaName = (d.name == "type") ? "type_" : d.name;
|
||||
@@ -66,9 +66,9 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& /* functionName */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
// "type" is a reserved keyword or function.
|
||||
const std::string juliaName = (d.name == "type") ? "type_" : d.name;
|
||||
@@ -83,7 +83,7 @@ void PrintInputProcessing(
|
||||
|
||||
// For an Armadillo type, we have to call a different overload for columns and
|
||||
// rows than for regular matrices.
|
||||
std::string uChar = (std::is_same<typename T::elem_type, size_t>::value) ?
|
||||
std::string uChar = (std::is_same_v<typename T::elem_type, size_t>) ?
|
||||
"U" : "";
|
||||
std::string indent(extraIndent + 2, ' ');
|
||||
std::string matTypeModifier = "";
|
||||
@@ -125,10 +125,10 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& functionName,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
// "type" is a reserved keyword or function.
|
||||
const std::string juliaName = (d.name == "type") ? "type_" : d.name;
|
||||
@@ -151,12 +151,12 @@ void PrintInputProcessing(
|
||||
std::string indent(extraIndent + 2, ' ');
|
||||
std::string type = util::StripType(d.cppType);
|
||||
std::cout << indent << "push!(modelPtrs, convert("
|
||||
<< GetJuliaType<typename std::remove_pointer<T>::type>(d) << ", "
|
||||
<< juliaName << ").ptr)" << std::endl;
|
||||
<< GetJuliaType<std::remove_pointer_t<T>>(d) << ", " << juliaName
|
||||
<< ").ptr)" << std::endl;
|
||||
std::cout << indent << functionName << "_internal.SetParam" << type
|
||||
<< "(p, \"" << d.name << "\", convert("
|
||||
<< GetJuliaType<typename std::remove_pointer<T>::type>(d) << ", "
|
||||
<< juliaName << "))" << std::endl;
|
||||
<< GetJuliaType<std::remove_pointer_t<T>>(d) << ", " << juliaName
|
||||
<< "))" << std::endl;
|
||||
|
||||
if (!d.required)
|
||||
{
|
||||
@@ -172,8 +172,8 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& /* functionName */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
// "type" is a reserved keyword or function.
|
||||
const std::string juliaName = (d.name == "type") ? "type_" : d.name;
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace julia {
|
||||
template<typename T>
|
||||
void PrintModelTypeImport(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
@@ -37,7 +37,7 @@ void PrintModelTypeImport(
|
||||
template<typename T>
|
||||
void PrintModelTypeImport(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
@@ -48,8 +48,8 @@ void PrintModelTypeImport(
|
||||
template<typename T>
|
||||
void PrintModelTypeImport(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// We need to print, e.g.,
|
||||
// import ..<type>
|
||||
@@ -67,7 +67,7 @@ void PrintModelTypeImport(util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintModelTypeImport<typename std::remove_pointer<T>::type>(d);
|
||||
PrintModelTypeImport<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace julia
|
||||
|
||||
@@ -26,10 +26,10 @@ template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& functionName,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Print the output processing for an Armadillo type.
|
||||
@@ -38,9 +38,9 @@ template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& functionName,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Print the output processing for a serializable type.
|
||||
@@ -49,10 +49,10 @@ template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& functionName,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Print the output processing for a mat/DatasetInfo tuple type.
|
||||
@@ -61,8 +61,8 @@ template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& functionName,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Print the output processing (basically calling params.Get<>()) for a type.
|
||||
@@ -73,8 +73,7 @@ void PrintOutputProcessing(util::ParamData& d,
|
||||
void* /* output */)
|
||||
{
|
||||
// Call out to the right overload.
|
||||
PrintOutputProcessing<typename std::remove_pointer<T>::type>(d,
|
||||
*((std::string*) input));
|
||||
PrintOutputProcessing<std::remove_pointer_t<T>>(d, *((std::string*) input));
|
||||
}
|
||||
|
||||
} // namespace julia
|
||||
|
||||
@@ -29,34 +29,34 @@ template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& /* functionName */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::string type;
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
type = "Bool";
|
||||
else if (std::is_same<T, int>::value)
|
||||
else if (std::is_same_v<T, int>)
|
||||
type = "Int";
|
||||
else if (std::is_same<T, double>::value)
|
||||
else if (std::is_same_v<T, double>)
|
||||
type = "Double";
|
||||
else if (std::is_same<T, std::string>::value)
|
||||
else if (std::is_same_v<T, std::string>)
|
||||
type = "String";
|
||||
else if (std::is_same<T, std::vector<std::string>>::value)
|
||||
else if (std::is_same_v<T, std::vector<std::string>>)
|
||||
type = "VectorStr";
|
||||
else if (std::is_same<T, std::vector<int>>::value)
|
||||
else if (std::is_same_v<T, std::vector<int>>)
|
||||
type = "VectorInt";
|
||||
else
|
||||
type = "Unknown";
|
||||
|
||||
// Strings need a little special handling.
|
||||
if (std::is_same<T, std::string>::value)
|
||||
if (std::is_same_v<T, std::string>)
|
||||
std::cout << "Base.unsafe_string(";
|
||||
|
||||
std::cout << "GetParam" << type << "(p, \"" << d.name << "\")";
|
||||
|
||||
if (std::is_same<T, std::string>::value)
|
||||
if (std::is_same_v<T, std::string>)
|
||||
std::cout << ")";
|
||||
}
|
||||
|
||||
@@ -67,11 +67,11 @@ template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& /* functionName */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::string uChar = (std::is_same<typename T::elem_type, size_t>::value) ?
|
||||
std::string uChar = (std::is_same_v<typename T::elem_type, size_t>) ?
|
||||
"U" : "";
|
||||
std::string matTypeSuffix = "";
|
||||
std::string extra = "";
|
||||
@@ -100,10 +100,10 @@ template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& functionName,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::string type = util::StripType(d.cppType);
|
||||
std::cout << functionName << "_internal.GetParam"
|
||||
@@ -117,8 +117,8 @@ template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const std::string& /* functionName */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::cout << "GetParamMatWithInfo(p, \"" << d.name << "\", juliaOwnedMemory)";
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ template<typename T>
|
||||
void PrintParamDefn(
|
||||
util::ParamData& /* d */,
|
||||
const std::string& /* programName */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
@@ -39,7 +39,7 @@ template<typename T>
|
||||
void PrintParamDefn(
|
||||
util::ParamData& /* d */,
|
||||
const std::string& /* programName */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
@@ -51,8 +51,8 @@ template<typename T>
|
||||
void PrintParamDefn(
|
||||
util::ParamData& d,
|
||||
const std::string& programName,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// We need to print something of the form below:
|
||||
//
|
||||
@@ -171,8 +171,7 @@ void PrintParamDefn(util::ParamData& d,
|
||||
const void* input,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintParamDefn<typename std::remove_pointer<T>::type>(d,
|
||||
*(std::string*) input);
|
||||
PrintParamDefn<std::remove_pointer_t<T>>(d, *(std::string*) input);
|
||||
}
|
||||
|
||||
} // namespace julia
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace julia {
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a vector.
|
||||
@@ -37,7 +37,7 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix option.
|
||||
@@ -45,7 +45,7 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix tuple option.
|
||||
@@ -53,8 +53,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a model.
|
||||
@@ -62,8 +62,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Print the command-line type of an option into a string.
|
||||
@@ -73,8 +73,7 @@ void PrintTypeDoc(util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
PrintTypeDoc<typename std::remove_pointer<T>::type>(data);
|
||||
*((std::string*) output) = PrintTypeDoc<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace julia
|
||||
|
||||
@@ -24,29 +24,29 @@ namespace julia {
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
// A flag type.
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
{
|
||||
return "A boolean flag option (`true` or `false`).";
|
||||
}
|
||||
// An integer.
|
||||
else if (std::is_same<T, int>::value)
|
||||
else if (std::is_same_v<T, int>)
|
||||
{
|
||||
return "An integer (i.e., `1`).";
|
||||
}
|
||||
// A floating point value.
|
||||
else if (std::is_same<T, double>::value)
|
||||
else if (std::is_same_v<T, double>)
|
||||
{
|
||||
return "A floating-point number (i.e., `0.5`).";
|
||||
}
|
||||
// A string.
|
||||
else if (std::is_same<T, std::string>::value)
|
||||
else if (std::is_same_v<T, std::string>)
|
||||
{
|
||||
return "A character string (i.e., `\"hello\"`).";
|
||||
}
|
||||
@@ -63,13 +63,13 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
if (std::is_same<T, std::vector<int>>::value)
|
||||
if (std::is_same_v<T, std::vector<int>>)
|
||||
{
|
||||
return "A vector of integers; i.e., `[0, 1, 2]`.";
|
||||
}
|
||||
else if (std::is_same<T, std::vector<std::string>>::value)
|
||||
else if (std::is_same_v<T, std::vector<std::string>>)
|
||||
{
|
||||
return "A vector of strings; i.e., `[\"hello\", \"goodbye\"]`.";
|
||||
}
|
||||
@@ -85,9 +85,9 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*)
|
||||
{
|
||||
if (std::is_same<typename T::elem_type, double>::value)
|
||||
if (std::is_same_v<typename T::elem_type, double>)
|
||||
{
|
||||
if (T::is_col || T::is_row)
|
||||
{
|
||||
@@ -104,7 +104,7 @@ std::string PrintTypeDoc(
|
||||
"`false` when calling mlpack bindings.";
|
||||
}
|
||||
}
|
||||
else if (std::is_same<typename T::elem_type, size_t>::value)
|
||||
else if (std::is_same_v<typename T::elem_type, size_t>)
|
||||
{
|
||||
if (T::is_col || T::is_row)
|
||||
{
|
||||
@@ -135,8 +135,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "A 2-d array containing `Float64` data along with a boolean array "
|
||||
"indicating which dimensions are categorical (represented by `true`) and "
|
||||
@@ -154,8 +154,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return "An mlpack model pointer. `<Model>` refers to the type of model that "
|
||||
"is being stored, so, e.g., for `CF()`, the type will be `CFModel`. "
|
||||
|
||||
@@ -38,27 +38,27 @@ void DefaultParam(util::ParamData& data,
|
||||
if (BindingInfo::Language() == "cli")
|
||||
{
|
||||
*((std::string*) output) =
|
||||
cli::DefaultParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
cli::DefaultParamImpl<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else if (BindingInfo::Language() == "python")
|
||||
{
|
||||
*((std::string*) output) =
|
||||
python::DefaultParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
python::DefaultParamImpl<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else if (BindingInfo::Language() == "julia")
|
||||
{
|
||||
*((std::string*) output) =
|
||||
julia::DefaultParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
julia::DefaultParamImpl<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else if (BindingInfo::Language() == "go")
|
||||
{
|
||||
*((std::string*) output) =
|
||||
go::DefaultParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
go::DefaultParamImpl<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else if (BindingInfo::Language() == "r")
|
||||
{
|
||||
*((std::string*) output) =
|
||||
r::DefaultParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
r::DefaultParamImpl<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace markdown {
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::any_cast<T>(data.value);
|
||||
@@ -42,7 +42,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0)
|
||||
{
|
||||
const T& t = std::any_cast<T>(data.value);
|
||||
|
||||
@@ -58,7 +58,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// Get the matrix.
|
||||
const T& matrix = std::any_cast<T>(data.value);
|
||||
@@ -74,8 +74,8 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << data.cppType << " model at " << std::any_cast<T*>(data.value);
|
||||
@@ -88,8 +88,8 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// Get the matrix.
|
||||
const T& tuple = std::any_cast<T>(data.value);
|
||||
@@ -115,8 +115,7 @@ void GetPrintableParam(util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParam<typename std::remove_pointer<T>::type>(data);
|
||||
*((std::string*) output) = GetPrintableParam<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace markdown
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace markdown {
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a matrix type (where the user has to pass the file
|
||||
@@ -38,7 +38,7 @@ std::string GetPrintableParamName(
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a serializable model type (where the user has to
|
||||
@@ -47,8 +47,8 @@ std::string GetPrintableParamName(
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a mapped matrix type (where the user has to pass
|
||||
@@ -57,8 +57,8 @@ std::string GetPrintableParamName(
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter's name as seen by the user.
|
||||
@@ -70,7 +70,7 @@ void GetPrintableParamName(
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParamName<typename std::remove_pointer<T>::type>(d);
|
||||
GetPrintableParamName<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace markdown
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace markdown {
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "--" + data.name;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ std::string GetPrintableParamName(
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*)
|
||||
{
|
||||
return "--" + data.name + "_file";
|
||||
}
|
||||
@@ -53,8 +53,8 @@ std::string GetPrintableParamName(
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return "--" + data.name + "_file";
|
||||
}
|
||||
@@ -66,8 +66,8 @@ std::string GetPrintableParamName(
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "--" + data.name + "_file";
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& data,
|
||||
const std::string& value,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a matrix type (where the user has to pass the file
|
||||
@@ -40,7 +40,7 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& data,
|
||||
const std::string& value,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a serializable model type (where the user has to
|
||||
@@ -50,8 +50,8 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& data,
|
||||
const std::string& value,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a mapped matrix type (where the user has to pass
|
||||
@@ -61,8 +61,8 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& data,
|
||||
const std::string& value,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter's name as seen by the user.
|
||||
@@ -74,7 +74,7 @@ void GetPrintableParamValue(
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParamValue<typename std::remove_pointer<T>::type>(d,
|
||||
GetPrintableParamValue<std::remove_pointer_t<T>>(d,
|
||||
*((std::string*) input));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& /* data */,
|
||||
const std::string& input,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& /* data */,
|
||||
const std::string& input,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*)
|
||||
{
|
||||
return input + ".csv";
|
||||
}
|
||||
@@ -57,8 +57,8 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& /* data */,
|
||||
const std::string& input,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return input + ".bin";
|
||||
}
|
||||
@@ -71,8 +71,8 @@ template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
util::ParamData& /* data */,
|
||||
const std::string& input,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return input + ".arff";
|
||||
}
|
||||
|
||||
@@ -37,27 +37,27 @@ void GetPrintableType(util::ParamData& data,
|
||||
if (BindingInfo::Language() == "cli")
|
||||
{
|
||||
*((std::string*) output) =
|
||||
cli::GetPrintableType<typename std::remove_pointer<T>::type>(data);
|
||||
cli::GetPrintableType<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else if (BindingInfo::Language() == "python")
|
||||
{
|
||||
*((std::string*) output) =
|
||||
python::GetPrintableType<typename std::remove_pointer<T>::type>(data);
|
||||
python::GetPrintableType<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else if (BindingInfo::Language() == "julia")
|
||||
{
|
||||
*((std::string*) output) =
|
||||
julia::GetPrintableType<typename std::remove_pointer<T>::type>(data);
|
||||
julia::GetPrintableType<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else if (BindingInfo::Language() == "go")
|
||||
{
|
||||
*((std::string*) output) =
|
||||
go::GetPrintableType<typename std::remove_pointer<T>::type>(data);
|
||||
go::GetPrintableType<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else if (BindingInfo::Language() == "r")
|
||||
{
|
||||
*((std::string*) output) =
|
||||
r::GetPrintableType<typename std::remove_pointer<T>::type>(data);
|
||||
r::GetPrintableType<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace markdown {
|
||||
*/
|
||||
template<typename T>
|
||||
bool IsSerializable(
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -35,8 +35,8 @@ bool IsSerializable(
|
||||
*/
|
||||
template<typename T>
|
||||
bool IsSerializable(
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ void IsSerializable(util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((bool*) output) = IsSerializable<typename std::remove_pointer<T>::type>();
|
||||
*((bool*) output) = IsSerializable<std::remove_pointer_t<T>>();
|
||||
}
|
||||
|
||||
} // namespace markdown
|
||||
|
||||
@@ -34,23 +34,23 @@ std::string PrintTypeDoc(util::ParamData& data)
|
||||
{
|
||||
if (BindingInfo::Language() == "cli")
|
||||
{
|
||||
return cli::PrintTypeDoc<typename std::remove_pointer<T>::type>(data);
|
||||
return cli::PrintTypeDoc<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else if (BindingInfo::Language() == "python")
|
||||
{
|
||||
return python::PrintTypeDoc<typename std::remove_pointer<T>::type>(data);
|
||||
return python::PrintTypeDoc<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else if (BindingInfo::Language() == "julia")
|
||||
{
|
||||
return julia::PrintTypeDoc<typename std::remove_pointer<T>::type>(data);
|
||||
return julia::PrintTypeDoc<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else if (BindingInfo::Language() == "go")
|
||||
{
|
||||
return go::PrintTypeDoc<typename std::remove_pointer<T>::type>(data);
|
||||
return go::PrintTypeDoc<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else if (BindingInfo::Language() == "r")
|
||||
{
|
||||
return r::PrintTypeDoc<typename std::remove_pointer<T>::type>(data);
|
||||
return r::PrintTypeDoc<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -26,13 +26,12 @@ namespace python {
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::string>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T, std::string>>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a vector option.
|
||||
@@ -40,7 +39,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a string option.
|
||||
@@ -48,8 +47,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T, std::string>::value
|
||||
>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T, std::string>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a matrix option, a tuple option, a
|
||||
@@ -59,10 +57,10 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* = 0);
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a model option (this returns the default
|
||||
@@ -71,8 +69,8 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of an option. This is the function that will be
|
||||
@@ -84,7 +82,7 @@ void DefaultParam(util::ParamData& data,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = DefaultParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
*outstr = DefaultParamImpl<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
|
||||
@@ -24,16 +24,15 @@ namespace python {
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::string>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T, std::string>>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
oss << "False";
|
||||
else
|
||||
oss << std::any_cast<T>(data.value);
|
||||
@@ -47,13 +46,13 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*)
|
||||
{
|
||||
// Print each element in an array delimited by square brackets.
|
||||
std::ostringstream oss;
|
||||
const T& vector = std::any_cast<T>(data.value);
|
||||
oss << "[";
|
||||
if (std::is_same<T, std::vector<std::string>>::value)
|
||||
if (std::is_same_v<T, std::vector<std::string>>)
|
||||
{
|
||||
if (vector.size() > 0)
|
||||
{
|
||||
@@ -90,7 +89,7 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T, std::string>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T, std::string>>*)
|
||||
{
|
||||
const std::string& s = *std::any_cast<std::string>(&data.value);
|
||||
return "'" + s + "'";
|
||||
@@ -103,23 +102,22 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<
|
||||
const std::enable_if_t<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* /* junk */)
|
||||
std::is_same_v<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>>* /* junk */)
|
||||
{
|
||||
// Get the filename and return it, or return an empty string.
|
||||
if (std::is_same<T, arma::rowvec>::value ||
|
||||
std::is_same<T, arma::vec>::value)
|
||||
if (std::is_same_v<T, arma::rowvec> || std::is_same_v<T, arma::vec>)
|
||||
{
|
||||
return "np.empty([0])";
|
||||
}
|
||||
else if (std::is_same<T, arma::Col<size_t>>::value ||
|
||||
std::is_same<T, arma::Row<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Col<size_t>> ||
|
||||
std::is_same_v<T, arma::Row<size_t>>)
|
||||
{
|
||||
return "np.empty([0], dtype=np.uint64)";
|
||||
}
|
||||
else if (std::is_same<T, arma::Mat<size_t>>::value)
|
||||
else if (std::is_same_v<T, arma::Mat<size_t>>)
|
||||
{
|
||||
return "np.empty([0, 0], dtype=np.uint64)";
|
||||
}
|
||||
@@ -135,8 +133,8 @@ std::string DefaultParamImpl(
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
util::ParamData& /* data */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*)
|
||||
{
|
||||
return "None";
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ namespace python {
|
||||
template<typename T>
|
||||
inline std::string GetCythonType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
@@ -33,9 +33,9 @@ inline std::string GetCythonType(
|
||||
template<>
|
||||
inline std::string GetCythonType<int>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<int>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<int>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<int>::value>*)
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
@@ -43,9 +43,9 @@ inline std::string GetCythonType<int>(
|
||||
template<>
|
||||
inline std::string GetCythonType<double>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<double>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<double>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<double>::value>*)
|
||||
{
|
||||
return "double";
|
||||
}
|
||||
@@ -53,12 +53,9 @@ inline std::string GetCythonType<double>(
|
||||
template<>
|
||||
inline std::string GetCythonType<std::string>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<
|
||||
!util::IsStdVector<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!data::HasSerialize<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!arma::is_arma_type<std::string>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<std::string>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<std::string>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<std::string>::value>*)
|
||||
{
|
||||
return "string";
|
||||
}
|
||||
@@ -66,9 +63,9 @@ inline std::string GetCythonType<std::string>(
|
||||
template<>
|
||||
inline std::string GetCythonType<size_t>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<size_t>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<size_t>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<size_t>::value>*)
|
||||
{
|
||||
return "size_t";
|
||||
}
|
||||
@@ -76,9 +73,9 @@ inline std::string GetCythonType<size_t>(
|
||||
template<>
|
||||
inline std::string GetCythonType<bool>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<bool>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<bool>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<bool>::value>*)
|
||||
{
|
||||
return "cbool";
|
||||
}
|
||||
@@ -86,7 +83,7 @@ inline std::string GetCythonType<bool>(
|
||||
template<typename T>
|
||||
inline std::string GetCythonType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0)
|
||||
{
|
||||
return "vector[" + GetCythonType<typename T::value_type>(d) + "]";
|
||||
}
|
||||
@@ -94,7 +91,7 @@ inline std::string GetCythonType(
|
||||
template<typename T>
|
||||
inline std::string GetCythonType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
std::string type = "Mat";
|
||||
if (T::is_row)
|
||||
@@ -108,8 +105,8 @@ inline std::string GetCythonType(
|
||||
template<typename T>
|
||||
inline std::string GetCythonType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
return d.cppType + "*";
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace python {
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::any_cast<T>(data.value);
|
||||
@@ -42,7 +42,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0)
|
||||
{
|
||||
const T& t = std::any_cast<T>(data.value);
|
||||
|
||||
@@ -58,7 +58,7 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// Get the matrix.
|
||||
const T& matrix = std::any_cast<T>(data.value);
|
||||
@@ -74,8 +74,8 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << data.cppType << " model at " << std::any_cast<T*>(data.value);
|
||||
@@ -88,8 +88,8 @@ std::string GetPrintableParam(
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// Get the matrix.
|
||||
const T& tuple = std::any_cast<T>(data.value);
|
||||
@@ -115,8 +115,7 @@ void GetPrintableParam(util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParam<typename std::remove_pointer<T>::type>(data);
|
||||
*((std::string*) output) = GetPrintableParam<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
|
||||
@@ -23,95 +23,91 @@ namespace python {
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<int>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<int>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<int>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<int>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<double>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<double>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<double>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<double>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<std::string>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<
|
||||
!util::IsStdVector<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!data::HasSerialize<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!arma::is_arma_type<std::string>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<std::string>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<std::string>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<std::string>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<size_t>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<size_t,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<size_t>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<size_t>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<size_t>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<size_t,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<>
|
||||
inline std::string GetPrintableType<bool>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*);
|
||||
const std::enable_if_t<!util::IsStdVector<bool>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<bool>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<bool>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*);
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
template<typename T>
|
||||
void GetPrintableType(util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableType<typename std::remove_pointer<T>::type>(d);
|
||||
*((std::string*) output) = GetPrintableType<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace python {
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
@@ -34,11 +34,11 @@ inline std::string GetPrintableType(
|
||||
template<>
|
||||
inline std::string GetPrintableType<int>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<int>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<int>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<int>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<int,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
@@ -46,11 +46,11 @@ inline std::string GetPrintableType<int>(
|
||||
template<>
|
||||
inline std::string GetPrintableType<double>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<double>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<double>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<double>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<double,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "float";
|
||||
}
|
||||
@@ -58,14 +58,11 @@ inline std::string GetPrintableType<double>(
|
||||
template<>
|
||||
inline std::string GetPrintableType<std::string>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<
|
||||
!util::IsStdVector<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!data::HasSerialize<std::string>::value>::type*,
|
||||
const typename std::enable_if<
|
||||
!arma::is_arma_type<std::string>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<std::string>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<std::string>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<std::string>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<std::string,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "str";
|
||||
}
|
||||
@@ -73,11 +70,11 @@ inline std::string GetPrintableType<std::string>(
|
||||
template<>
|
||||
inline std::string GetPrintableType<size_t>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<size_t>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<size_t>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<size_t>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<size_t,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<size_t>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<size_t>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<size_t>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<size_t,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
@@ -85,11 +82,11 @@ inline std::string GetPrintableType<size_t>(
|
||||
template<>
|
||||
inline std::string GetPrintableType<bool>(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
|
||||
const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
|
||||
const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!util::IsStdVector<bool>::value>*,
|
||||
const std::enable_if_t<!data::HasSerialize<bool>::value>*,
|
||||
const std::enable_if_t<!arma::is_arma_type<bool>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<bool,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "bool";
|
||||
}
|
||||
@@ -97,9 +94,9 @@ inline std::string GetPrintableType<bool>(
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "list of " + GetPrintableType<typename T::value_type>(d) + "s";
|
||||
}
|
||||
@@ -107,17 +104,17 @@ inline std::string GetPrintableType(
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
std::string type = "matrix";
|
||||
if (std::is_same<typename T::elem_type, double>::value)
|
||||
if (std::is_same_v<typename T::elem_type, double>)
|
||||
{
|
||||
if (T::is_row || T::is_col)
|
||||
type = "vector";
|
||||
}
|
||||
else if (std::is_same<typename T::elem_type, size_t>::value)
|
||||
else if (std::is_same_v<typename T::elem_type, size_t>)
|
||||
{
|
||||
type = "int matrix";
|
||||
if (T::is_row || T::is_col)
|
||||
@@ -130,8 +127,8 @@ inline std::string GetPrintableType(
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return "categorical matrix";
|
||||
}
|
||||
@@ -139,10 +136,10 @@ inline std::string GetPrintableType(
|
||||
template<typename T>
|
||||
inline std::string GetPrintableType(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type*,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type*,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>*,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>*,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>*)
|
||||
{
|
||||
return d.cppType + "Type";
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ template<typename T>
|
||||
void ImportDecl(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// First, we have to parse the type. If we have something like, e.g.,
|
||||
// 'LogisticRegression<>', we must convert this to 'LogisticRegression[T=*].'
|
||||
@@ -53,8 +53,8 @@ template<typename T>
|
||||
void ImportDecl(
|
||||
util::ParamData& /* d */,
|
||||
const size_t /* indent */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Print nothing.
|
||||
}
|
||||
@@ -66,7 +66,7 @@ template<typename T>
|
||||
void ImportDecl(
|
||||
util::ParamData& /* d */,
|
||||
const size_t /* indent */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// Print nothing.
|
||||
}
|
||||
@@ -84,7 +84,7 @@ void ImportDecl(util::ParamData& d,
|
||||
const void* indent,
|
||||
void* /* output */)
|
||||
{
|
||||
ImportDecl<typename std::remove_pointer<T>::type>(d, *((size_t*) indent));
|
||||
ImportDecl<std::remove_pointer_t<T>>(d, *((size_t*) indent));
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace python {
|
||||
template<typename T>
|
||||
inline bool IsSerializable(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ inline bool IsSerializable(
|
||||
template<typename T>
|
||||
inline bool IsSerializable(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -39,8 +39,7 @@ void IsSerializable(util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((bool*) output) =
|
||||
IsSerializable<typename std::remove_pointer<T>::type>(data);
|
||||
*((bool*) output) = IsSerializable<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace python {
|
||||
template<typename T>
|
||||
void PrintClassDefn(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
@@ -37,7 +37,7 @@ void PrintClassDefn(
|
||||
template<typename T>
|
||||
void PrintClassDefn(
|
||||
util::ParamData& /* d */,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
@@ -48,8 +48,8 @@ void PrintClassDefn(
|
||||
template<typename T>
|
||||
void PrintClassDefn(
|
||||
util::ParamData& d,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// First, we have to parse the type. If we have something like, e.g.,
|
||||
// 'LogisticRegression<>', we must convert this to 'LogisticRegression[].'
|
||||
@@ -153,7 +153,7 @@ void PrintClassDefn(util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintClassDefn<typename std::remove_pointer<T>::type>(d);
|
||||
PrintClassDefn<std::remove_pointer_t<T>>(d);
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
|
||||
@@ -32,7 +32,7 @@ void PrintDefn(util::ParamData& d,
|
||||
std::string name = GetValidName(d.name);
|
||||
|
||||
std::cout << name;
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
std::cout << "=False";
|
||||
else if (!d.required)
|
||||
std::cout << "=None";
|
||||
|
||||
@@ -42,8 +42,7 @@ void PrintDoc(util::ParamData& d,
|
||||
oss << " - ";
|
||||
oss << GetValidName(d.name);
|
||||
oss << " (";
|
||||
oss << GetPrintableType<typename std::remove_pointer<T>::type>(d) << "): "
|
||||
<< d.desc;
|
||||
oss << GetPrintableType<std::remove_pointer_t<T>>(d) << "): " << d.desc;
|
||||
|
||||
// Print a default, if possible.
|
||||
if (!d.required)
|
||||
|
||||
@@ -32,11 +32,11 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
// The copy_all_inputs parameter must be handled first, and therefore is
|
||||
// outside the scope of this code.
|
||||
@@ -46,7 +46,7 @@ void PrintInputProcessing(
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
std::string def = "None";
|
||||
if (std::is_same<T, bool>::value)
|
||||
if (std::is_same_v<T, bool>)
|
||||
def = "False";
|
||||
|
||||
// Make sure that we don't use names that are Python keywords.
|
||||
@@ -165,11 +165,11 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0,
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
@@ -255,8 +255,8 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
@@ -383,9 +383,9 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// First, get the correct class name if needed.
|
||||
std::string strippedType, printedType, defaultsType;
|
||||
@@ -458,9 +458,9 @@ template<typename T>
|
||||
void PrintInputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
std::string name = GetValidName(d.name);
|
||||
|
||||
@@ -550,8 +550,7 @@ void PrintInputProcessing(util::ParamData& d,
|
||||
const void* input,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintInputProcessing<typename std::remove_pointer<T>::type>(d,
|
||||
*((size_t*) input));
|
||||
PrintInputProcessing<std::remove_pointer_t<T>>(d, *((size_t*) input));
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
|
||||
@@ -31,10 +31,10 @@ void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const bool onlyOutput,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
@@ -88,7 +88,7 @@ void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const bool onlyOutput,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
@@ -129,8 +129,8 @@ void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const bool onlyOutput,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
@@ -171,8 +171,8 @@ void PrintOutputProcessing(
|
||||
util::ParamData& d,
|
||||
const size_t indent,
|
||||
const bool onlyOutput,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0)
|
||||
{
|
||||
// Get the type names we need to use.
|
||||
std::string strippedType, printedType, defaultsType;
|
||||
@@ -305,7 +305,7 @@ void PrintOutputProcessing(util::ParamData& d,
|
||||
typedef std::tuple<util::Params, std::tuple<size_t, bool>> TupleType;
|
||||
TupleType* tuple = (TupleType*) input;
|
||||
|
||||
PrintOutputProcessing<typename std::remove_pointer<T>::type>(
|
||||
PrintOutputProcessing<std::remove_pointer_t<T>>(
|
||||
std::get<0>(*tuple), d, std::get<0>(std::get<1>(*tuple)),
|
||||
std::get<1>(std::get<1>(*tuple)));
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace python {
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
|
||||
const typename std::enable_if<!std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<!util::IsStdVector<T>::value>* = 0,
|
||||
const std::enable_if_t<!data::HasSerialize<T>::value>* = 0,
|
||||
const std::enable_if_t<!std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a vector.
|
||||
@@ -37,7 +37,7 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
const std::enable_if_t<util::IsStdVector<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix option.
|
||||
@@ -45,7 +45,7 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0);
|
||||
const std::enable_if_t<arma::is_arma_type<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a matrix tuple option.
|
||||
@@ -53,8 +53,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
const std::enable_if_t<std::is_same_v<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>* = 0);
|
||||
|
||||
/**
|
||||
* Return a string representing the command-line type of a model.
|
||||
@@ -62,8 +62,8 @@ std::string PrintTypeDoc(
|
||||
template<typename T>
|
||||
std::string PrintTypeDoc(
|
||||
util::ParamData& data,
|
||||
const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
|
||||
const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0);
|
||||
const std::enable_if_t<!arma::is_arma_type<T>::value>* = 0,
|
||||
const std::enable_if_t<data::HasSerialize<T>::value>* = 0);
|
||||
|
||||
/**
|
||||
* Print the command-line type of an option into a string.
|
||||
@@ -73,8 +73,7 @@ void PrintTypeDoc(util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
PrintTypeDoc<typename std::remove_pointer<T>::type>(data);
|
||||
*((std::string*) output) = PrintTypeDoc<std::remove_pointer_t<T>>(data);
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user