Crate argmin_math

source ·
Expand description

argmin-math provides mathematics related abstractions needed in argmin. It supports implementations of these abstractions for basic Vecs and for ndarray and nalgebra. The traits can of course also be implemented for your own types to make them compatible with argmin.

For an introduction on how to use argmin, please also have a look at the book.

§Usage

Add the following line to your dependencies list:

[dependencies]
argmin-math = "0.4.0"

This will activate the primitives and vec features. For other backends see the section below.

§Features

Support for the various backends can be switched on via features. Please read this section carefully to the end before choosing a backend.

§Default features

FeatureDefaultComment
primitivesyesbasic integer and floating point types
vecyesVecs (basic functionality)

§ndarray

FeatureDefaultComment
ndarray_latestnolatest supported version
ndarray_latest-nolinalgnolatest supported version without ndarray-linalg
ndarray_v0_15noversion 0.15 with ndarray-linalg 0.16
ndarray_v0_15-nolinalgnoversion 0.15 without ndarray-linalg
ndarray_v0_14noversion 0.14 with ndarray-linalg 0.13
ndarray_v0_14-nolinalgnoversion 0.14 without ndarray-linalg
ndarray_v0_13noversion 0.13 with ndarray-linalg 0.12
ndarray_v0_13-nolinalgnoversion 0.13 without ndarray-linalg

Note that the *-nolinalg* features do NOT pull in ndarray-linalg as a dependency. This avoids linking against a BLAS library. This will however disable the implementation of ArgminInv, meaning that any solver which requires the matrix inverse will not work with the ndarray backend. It is recommended to use the *-nolinalg* options if the matrix inverse is not needed in order to keep the compilation times low and avoid problems when linking against a BLAS library.

Using the ndarray_* features with ndarray-linalg support may require to explicitly choose the ndarray-linalg BLAS backend in your Cargo.toml (see the ndarray-linalg documentation for details):

ndarray-linalg = { version = "<appropriate_version>", features = ["<linalg_backend>"] }

§nalgebra

FeatureDefaultComment
nalgebra_latestnolatest supported version
nalgebra_v0_32noversion 0.32
nalgebra_v0_31noversion 0.31
nalgebra_v0_30noversion 0.30
nalgebra_v0_29noversion 0.29

§Choosing a backend

It is not possible to activate two versions of the same backend.

The features labeled *latest* are an alias for the most recent supported version of the respective backend. It is however recommended to explicitly specify the desired version instead of using any of the *latest* features (see section about semantic versioning below).

The default features primitives and vec can be turned off in order to only compile the trait definitions. If another backend is chosen, primitives will automatically be turned on again.

§Example

Activate support for the latest supported ndarray version:

[dependencies]
argmin-math = { version = "0.4.0", features = ["ndarray_latest"] }

§Semantic versioning

This crate follows semantic versioning. Adding a new backend or a new version of a backend is not considered a breaking change. However, your code may still break if you use any of the features containing *latest*. It is therefore recommended to specify the actual version of the backend you are using.

§Development

For development and running the tests a backend for ndarray-linalg must be chosen. Normally one would add those as dev dependencies (the features would then be unified with the regular dependencies). However, linking somehow fails when the non-dev ndarra-linalg dependency is missing (which is the case for the *-nolinalg* features of the ndarray backend). To fix that, the _dev_linalg_* features were introduced. When testing and developing with one of the ndarray features with linalg support on, the appropriate _dev_linalg_* feature must be turned on as well. Note that the version number in _dev_linalg_* is always one below the ndarray version. For instance, for ndarray 0.15, one would use the _dev_linalg_0_14 feature.

Development FeatureComment
_dev_linalg_latestlatest ndarray-linalg for latest ndarray
_dev_linalg_0_16ndarray-linalg v0.16 for ndarray v0.15
_dev_linalg_0_13ndarray-linalg v0.13 for ndarray v0.14
_dev_linalg_0_12ndarray-linalg v0.12 for ndarray v0.13

§Contributing

You found a bug? Your favorite backend is not supported? Feel free to open an issue or ideally submit a PR.

§License

Licensed under either of

at your option.

§Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Structs§

  • The Error type, a wrapper around a dynamic error type.

Traits§