Template Class Var#

Inheritance Relationships#

Base Type#

Class Documentation#

template<typename T, Karana::Math::Quantity quantity = Karana::Math::Quantity::none>
class Var : public Karana::Core::NumericVar<T>#

A callable value with an optional compile-time physical quantity.

Template Parameters:
  • T – Value returned by the callable.

  • quantity – Physical quantity, or none for ordinary values.

Public Functions

inline Var(std::string_view name, const NumericVar<T> &other, std::string_view description)#

Rename constructor. Create a new Var with the same callable as other, but a different name and description.

Parameters:
  • name – Name of the new Var.

  • other – Var supplying the callable and metadata.

  • description – Description of the new Var.

template<class F>
inline Var(std::string_view name, const F &f, int vector_size, std::string_view description, std::string_view units = "")#

Construct a dynamic vector Var and resolve its units.

Template Parameters:

F – Callable returning T.

Parameters:
  • name – Name of the new Var.

  • f – Callable supplying a vector of the declared size.

  • vector_size – Number of vector entries, fixed for the callable’s lifetime.

  • description – Description of the new Var.

  • units – Explicit units, or empty for defaults when a quantity is declared.

template<class F>
inline Var(std::string_view name, const F &f, int matrix_rows, int matrix_cols, std::string_view description, std::string_view units = "")#

Construct a dynamic matrix Var and resolve its units.

Template Parameters:

F – Callable returning T.

Parameters:
  • name – Name of the new Var.

  • f – Callable supplying a matrix of the declared shape.

  • matrix_rows – Number of rows, fixed for the callable’s lifetime.

  • matrix_cols – Number of columns, fixed for the callable’s lifetime.

  • description – Description of the new Var.

  • units – Explicit units, or empty for defaults when a quantity is declared.

template<class F>
inline Var(std::string_view name, const F &f, std::string_view description, std::string_view units = "")#

Construct a scalar or fixed-size Var and resolve its units.

Template Parameters:

F – Callable returning T.

Parameters:
  • name – Name of the new Var.

  • f – Callable supplying the value.

  • description – Description of the new Var.

  • units – Explicit units, or empty for defaults when a quantity is declared.

Public Static Functions

template<class F>
static inline Karana::Core::ks_ptr<Var> create(std::string_view name, const F &f, int vector_size, std::string_view description, std::string_view units = "")#

Create a new instance of Var<km::Vec>.

Template Parameters:

F – Templated callable type that produces km::Vec.

Parameters:
  • name – The name of the new Var<km::Vec>

  • f – The callable that produces km::Vec.

  • vector_size – The size of the km::Vec that the callable produces. This must always be the same size.

  • description – A description of the Var.

  • units – The units of the Var.

Returns:

The newly created instance of Var<km::Vec>.

template<class F>
static inline Karana::Core::ks_ptr<Var> create(std::string_view name, const F &f, int vector_size, std::string_view description, std::string_view units = "")

Create a new instance of Var<km::VecInt>.

Template Parameters:

F – Templated callable type that produces km::VecInt.

Parameters:
  • name – The name of the new Var<km::VecInt>

  • f – The callable that produces km::VecInt.

  • vector_size – The size of the km::VecInt that the callable produces. This must always be the same size.

  • description – A description of the Var.

  • units – The units of the Var.

Returns:

The newly created instance of Var<km::VecInt>.

template<class F>
static inline Karana::Core::ks_ptr<Var> create(std::string_view name, const F &f, int matrix_rows, int matrix_cols, std::string_view description, std::string_view units = "")#

Create a new instance of Var<km::Mat>.

Template Parameters:

F – Templated callable type that produces km::Mat.

Parameters:
  • name – The name of the Var<km::Mat>

  • f – The callable that produces km::Mat.

  • matrix_rows – The number of rows in the km::Mat that the callable produces. The matrix that the callable produces must always be the same size.

  • matrix_cols – The number of cols in the km::Mat that the callable produces. The matrix that the callable produces must always be the same size.

  • description – A description of the Var.

  • units – The units of the Var.

Returns:

The newly created instance of Var<km::Mat>.

template<class F>
static inline Karana::Core::ks_ptr<Var> create(std::string_view name, const F &f, std::string_view description, std::string_view units = "")#

Create a new instance of Var<T>.

Template Parameters:

F – Templated callable type that produces type T.

Parameters:
  • name – The name of the Var<T>

  • f – The callable that produces type T.

  • description – A description of the Var.

  • units – The units of the Var.

Returns:

The newly created instance of Var<T>.

static inline Karana::Core::ks_ptr<Var> create(std::string_view name, const Karana::Core::ks_ptr<NumericVar<T>> &other, std::string_view description)#

Rename Var constructor.

This constructor keeps the same function, size, etc., but takes a new name and description.

Parameters:
  • name – The name of the new Var<T>

  • other – The other Var supplying the callable and units.

  • description – A description of the new Var.

Returns:

The newly created instance of Var<T>.

static inline ks_ptr<Var> create(std::string_view name, const NumericVar<T> &other, std::string_view description)#

Create a new Var with the same callable as other, but a new name and description.

Parameters:
  • name – Name of the new Var.

  • other – The Var supplying the callable and metadata.

  • description – Description of the new Var.

Returns:

A Var of this specialization retaining the source values.

static inline ks_ptr<Var> scaled(const ks_ptr<Var> &source, double factor, std::string_view units)#

Copy a Var and scale its output.

Parameters:
  • source – Var supplying the original callable.

  • factor – Multiplicative conversion factor.

  • units – Unit specification describing the scaled numeric values.

Returns:

A quantity Var with a native scaled callable and logging function.