MLPACK  1.0.7
Classes | Namespaces | Macros
cli.hpp File Reference
Include dependency graph for cli.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  mlpack::CLI
 Parses the command line for parameters and holds user-specified parameters. More...
 
struct  mlpack::ParamData
 Aids in the extensibility of CLI by focusing potential changes into one structure. More...
 

Namespaces

namespace  mlpack
 Linear algebra utility functions, generally performed on matrices or vectors.
 
namespace  mlpack::util
 

Macros

#define JOIN(x, y)   JOIN_AGAIN(x, y)
 
#define JOIN_AGAIN(x, y)   x ## y
 
#define PARAM(T, ID, DESC, ALIAS, DEF, REQ)
 Define an input parameter. More...
 
#define PARAM_DOUBLE(ID, DESC, ALIAS, DEF)   PARAM(double, ID, DESC, ALIAS, DEF, false)
 Define a double parameter. More...
 
#define PARAM_DOUBLE_REQ(ID, DESC, ALIAS)
 Define a required double parameter. More...
 
#define PARAM_FLAG(ID, DESC, ALIAS)   PARAM_FLAG_INTERNAL(ID, DESC, ALIAS);
 Define a flag parameter. More...
 
#define PARAM_FLAG_INTERNAL(ID, DESC, ALIAS)
 
#define PARAM_FLOAT(ID, DESC, ALIAS, DEF)   PARAM(float, ID, DESC, ALIAS, DEF, false)
 Define a floating-point parameter. More...
 
#define PARAM_FLOAT_REQ(ID, DESC, ALIAS)
 Define a required floating-point parameter. More...
 
#define PARAM_INT(ID, DESC, ALIAS, DEF)   PARAM(int, ID, DESC, ALIAS, DEF, false)
 Define an integer parameter. More...
 
#define PARAM_INT_REQ(ID, DESC, ALIAS)   PARAM(int, ID, DESC, ALIAS, 0, true)
 Define a required integer parameter. More...
 
#define PARAM_STRING(ID, DESC, ALIAS, DEF)   PARAM(std::string, ID, DESC, ALIAS, DEF, false)
 Define a string parameter. More...
 
#define PARAM_STRING_REQ(ID, DESC, ALIAS)
 Define a required string parameter. More...
 
#define PARAM_VECTOR(T, ID, DESC, ALIAS)   PARAM(std::vector<T>, ID, DESC, ALIAS, std::vector<T>(), false)
 Define a vector parameter. More...
 
#define PARAM_VECTOR_REQ(T, ID, DESC, ALIAS)
 Define a required vector parameter. More...
 
#define PROGRAM_INFO(NAME, DESC)
 Document an executable. More...
 
#define TYPENAME(x)   (std::string(typeid(x).name()))
 The TYPENAME macro is used internally to convert a type into a string. More...
 

Detailed Description

Author
Matthew Amidon

This file implements the CLI subsystem which is intended to replace FX. This can be used more or less regardless of context. In the future, it might be expanded to include file I/O.

This file is part of MLPACK 1.0.7.

MLPACK is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

MLPACK is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details (LICENSE.txt).

You should have received a copy of the GNU General Public License along with MLPACK. If not, see http://www.gnu.org/licenses/.

Definition in file cli.hpp.

Macro Definition Documentation

#define JOIN (   x,
 
)    JOIN_AGAIN(x, y)
#define JOIN_AGAIN (   x,
 
)    x ## y
#define PARAM (   T,
  ID,
  DESC,
  ALIAS,
  DEF,
  REQ 
)
Value:
JOIN(JOIN(io_option_dummy_object_, __LINE__), opt) (false, DEF, ID, \
DESC, ALIAS, REQ);

Define an input parameter.

Don't use this function; use the other ones above that call it. Note that we are using the LINE macro for naming these actual parameters when COUNTER does not exist, which is a bit of an ugly hack... but this is the preprocessor, after all. We don't have much choice other than ugliness.

Parameters
TType of the parameter.
IDName of the parameter.
DESCDescription of the parameter (1-2 sentences).
ALIASAlias for this parameter (one letter).
DEFDefault value of the parameter.
REQWhether or not parameter is required (boolean value).

Definition at line 356 of file cli.hpp.

#define PARAM_DOUBLE (   ID,
  DESC,
  ALIAS,
  DEF 
)    PARAM(double, ID, DESC, ALIAS, DEF, false)

Define a double parameter.

The parameter can then be specified on the command line with –ID=value.

Parameters
IDName of the parameter.
DESCQuick description of the parameter (1-2 sentences).
ALIASAn alias for the parameter (one letter).
DEFDefault value of the parameter.
See Also
mlpack::CLI, PROGRAM_INFO()
Bug:
The COUNTER variable is used in most cases to guarantee a unique global identifier for options declared using the PARAM_*() macros. However, not all compilers have this support–most notably, gcc < 4.3. In that case, the LINE macro is used as an attempt to get a unique global identifier, but collisions are still possible, and they produce bizarre error messages. See http://mlpack.org/trac/ticket/74 for more information.

Definition at line 145 of file cli.hpp.

#define PARAM_DOUBLE_REQ (   ID,
  DESC,
  ALIAS 
)
Value:
PARAM(double, ID, DESC, ALIAS, \
0.0f, true)

Define a required double parameter.

The parameter must then be specified on the command line with –ID=value.

Parameters
IDName of the parameter.
DESCQuick description of the parameter (1-2 sentences).
ALIASAn alias for the parameter (one letter).
See Also
mlpack::CLI, PROGRAM_INFO()
Bug:
The COUNTER variable is used in most cases to guarantee a unique global identifier for options declared using the PARAM_*() macros. However, not all compilers have this support–most notably, gcc < 4.3. In that case, the LINE macro is used as an attempt to get a unique global identifier, but collisions are still possible, and they produce bizarre error messages. See http://mlpack.org/trac/ticket/74 for more information.

Definition at line 266 of file cli.hpp.

#define PARAM_FLAG (   ID,
  DESC,
  ALIAS 
)    PARAM_FLAG_INTERNAL(ID, DESC, ALIAS);

Define a flag parameter.

Parameters
IDName of the parameter.
DESCQuick description of the parameter (1-2 sentences).
ALIASAn alias for the parameter (one letter).
See Also
mlpack::CLI, PROGRAM_INFO()
Bug:
The COUNTER variable is used in most cases to guarantee a unique global identifier for options declared using the PARAM_*() macros. However, not all compilers have this support–most notably, gcc < 4.3. In that case, the LINE macro is used as an attempt to get a unique global identifier, but collisions are still possible, and they produce bizarre error messages. See http://mlpack.org/trac/ticket/74 for more information.

Definition at line 73 of file cli.hpp.

#define PARAM_FLAG_INTERNAL (   ID,
  DESC,
  ALIAS 
)
Value:
static \
mlpack::util::Option<bool> JOIN(__io_option_flag_object_, __LINE__) \
(ID, DESC, ALIAS);
#define PARAM_FLOAT (   ID,
  DESC,
  ALIAS,
  DEF 
)    PARAM(float, ID, DESC, ALIAS, DEF, false)

Define a floating-point parameter.

You should use PARAM_DOUBLE instead.

The parameter can then be specified on the command line with –ID=value.

Parameters
IDName of the parameter.
DESCQuick description of the parameter (1-2 sentences).
ALIASAn alias for the parameter (one letter).
DEFDefault value of the parameter.
See Also
mlpack::CLI, PROGRAM_INFO()
Bug:
The COUNTER variable is used in most cases to guarantee a unique global identifier for options declared using the PARAM_*() macros. However, not all compilers have this support–most notably, gcc < 4.3. In that case, the LINE macro is used as an attempt to get a unique global identifier, but collisions are still possible, and they produce bizarre error messages. See http://mlpack.org/trac/ticket/74 for more information.

Definition at line 121 of file cli.hpp.

#define PARAM_FLOAT_REQ (   ID,
  DESC,
  ALIAS 
)
Value:
PARAM(float, ID, DESC, ALIAS, 0.0f, \
true)

Define a required floating-point parameter.

You should probably use a double instead.

The parameter must then be specified on the command line with –ID=value. If ALIAS is equal to DEF_MOD (which is set using the PROGRAM_INFO() macro), the parameter can be specified with just –ID=value.

Parameters
IDName of the parameter.
DESCQuick description of the parameter (1-2 sentences).
ALIASAn alias for the parameter (one letter).
See Also
mlpack::CLI, PROGRAM_INFO()
Bug:
The COUNTER variable is used in most cases to guarantee a unique global identifier for options declared using the PARAM_*() macros. However, not all compilers have this support–most notably, gcc < 4.3. In that case, the LINE macro is used as an attempt to get a unique global identifier, but collisions are still possible, and they produce bizarre error messages. See http://mlpack.org/trac/ticket/74 for more information.

Definition at line 243 of file cli.hpp.

#define PARAM_INT (   ID,
  DESC,
  ALIAS,
  DEF 
)    PARAM(int, ID, DESC, ALIAS, DEF, false)

Define an integer parameter.

The parameter can then be specified on the command line with –ID=value.

Parameters
IDName of the parameter.
DESCQuick description of the parameter (1-2 sentences).
ALIASAn alias for the parameter (one letter).
DEFDefault value of the parameter.
See Also
mlpack::CLI, PROGRAM_INFO()
Bug:
The COUNTER variable is used in most cases to guarantee a unique global identifier for options declared using the PARAM_*() macros. However, not all compilers have this support–most notably, gcc < 4.3. In that case, the LINE macro is used as an attempt to get a unique global identifier, but collisions are still possible, and they produce bizarre error messages. See http://mlpack.org/trac/ticket/74 for more information.

Definition at line 97 of file cli.hpp.

#define PARAM_INT_REQ (   ID,
  DESC,
  ALIAS 
)    PARAM(int, ID, DESC, ALIAS, 0, true)

Define a required integer parameter.

The parameter must then be specified on the command line with –ID=value.

Parameters
IDName of the parameter.
DESCQuick description of the parameter (1-2 sentences).
ALIASAn alias for the parameter (one letter).
See Also
mlpack::CLI, PROGRAM_INFO()
Bug:
The COUNTER variable is used in most cases to guarantee a unique global identifier for options declared using the PARAM_*() macros. However, not all compilers have this support–most notably, gcc < 4.3. In that case, the LINE macro is used as an attempt to get a unique global identifier, but collisions are still possible, and they produce bizarre error messages. See http://mlpack.org/trac/ticket/74 for more information.

Definition at line 219 of file cli.hpp.

#define PARAM_STRING (   ID,
  DESC,
  ALIAS,
  DEF 
)    PARAM(std::string, ID, DESC, ALIAS, DEF, false)

Define a string parameter.

The parameter can then be specified on the command line with –ID=value. If ALIAS is equal to DEF_MOD (which is set using the PROGRAM_INFO() macro), the parameter can be specified with just –ID=value.

Parameters
IDName of the parameter.
DESCQuick description of the parameter (1-2 sentences).
ALIASAn alias for the parameter (one letter).
DEFDefault value of the parameter.
See Also
mlpack::CLI, PROGRAM_INFO()
Bug:
The COUNTER variable is used in most cases to guarantee a unique global identifier for options declared using the PARAM_*() macros. However, not all compilers have this support–most notably, gcc < 4.3. In that case, the LINE macro is used as an attempt to get a unique global identifier, but collisions are still possible, and they produce bizarre error messages. See http://mlpack.org/trac/ticket/74 for more information.

Definition at line 170 of file cli.hpp.

#define PARAM_STRING_REQ (   ID,
  DESC,
  ALIAS 
)
Value:
PARAM(std::string, ID, DESC, \
ALIAS, "", true);

Define a required string parameter.

The parameter must then be specified on the command line with –ID=value.

Parameters
IDName of the parameter.
DESCQuick description of the parameter (1-2 sentences).
ALIASAn alias for the parameter (one letter).
See Also
mlpack::CLI, PROGRAM_INFO()
Bug:
The COUNTER variable is used in most cases to guarantee a unique global identifier for options declared using the PARAM_*() macros. However, not all compilers have this support–most notably, gcc < 4.3. In that case, the LINE macro is used as an attempt to get a unique global identifier, but collisions are still possible, and they produce bizarre error messages. See http://mlpack.org/trac/ticket/74 for more information.

Definition at line 289 of file cli.hpp.

#define PARAM_VECTOR (   T,
  ID,
  DESC,
  ALIAS 
)    PARAM(std::vector<T>, ID, DESC, ALIAS, std::vector<T>(), false)

Define a vector parameter.

The parameter can then be specified on the command line with –ID=value.

Parameters
IDName of the parameter.
DESCQuick description of the parameter (1-2 sentences).
ALIASAn alias for the parameter (one letter).
DEFDefault value of the parameter.
See Also
mlpack::CLI, PROGRAM_INFO()
Bug:
The COUNTER variable is used in most cases to guarantee a unique global identifier for options declared using the PARAM_*() macros. However, not all compilers have this support–most notably, gcc < 4.3. In that case, the LINE macro is used as an attempt to get a unique global identifier, but collisions are still possible, and they produce bizarre error messages. See http://mlpack.org/trac/ticket/74 for more information.

Definition at line 194 of file cli.hpp.

#define PARAM_VECTOR_REQ (   T,
  ID,
  DESC,
  ALIAS 
)
Value:
PARAM(std::vector<T>, ID, DESC, \
ALIAS, std::vector<T>(), true);

Define a required vector parameter.

The parameter must then be specified on the command line with –ID=value.

Parameters
IDName of the parameter.
DESCQuick description of the parameter (1-2 sentences).
ALIASAn alias for the parameter (one letter).
See Also
mlpack::CLI, PROGRAM_INFO()
Bug:
The COUNTER variable is used in most cases to guarantee a unique global identifier for options declared using the PARAM_*() macros. However, not all compilers have this support–most notably, gcc < 4.3. In that case, the LINE macro is used as an attempt to get a unique global identifier, but collisions are still possible, and they produce bizarre error messages. See http://mlpack.org/trac/ticket/74 for more information.

Definition at line 312 of file cli.hpp.

#define PROGRAM_INFO (   NAME,
  DESC 
)
Value:
static mlpack::util::ProgramDoc \
io_programdoc_dummy_object = mlpack::util::ProgramDoc(NAME, DESC);

Document an executable.

Only one instance of this macro should be present in your program! Therefore, use it in the main.cpp (or corresponding executable) in your program.

See Also
mlpack::CLI, PARAM_FLAG(), PARAM_INT(), PARAM_DOUBLE(), PARAM_STRING(), PARAM_VECTOR(), PARAM_INT_REQ(), PARAM_DOUBLE_REQ(), PARAM_STRING_REQ(), PARAM_VECTOR_REQ().
Parameters
NAMEShort string representing the name of the program.
DESCLong string describing what the program does and possibly a simple usage example. Newlines should not be used here; this is taken care of by CLI (however, you can explicitly specify newlines to denote new paragraphs).

Definition at line 53 of file cli.hpp.

#define TYPENAME (   x)    (std::string(typeid(x).name()))

The TYPENAME macro is used internally to convert a type into a string.

Definition at line 371 of file cli.hpp.