Expand description
argmin-math provides mathematics related abstractions needed in argmin. It supports
implementations of these abstractions for basic Vecs and for the ndarray, nalgebra,
and faer linear algebra libraries. 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.5.1"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
| Feature | Default | Comment |
|---|---|---|
primitives | yes | basic integer and floating point types |
vec | yes | Vecs (basic functionality) |
§ndarray
| Feature | Default | Comment |
|---|---|---|
ndarray_latest | no | latest supported version |
ndarray_latest-nolinalg | no | latest supported version without ndarray-linalg |
ndarray_v0_15 | no | version 0.15 with ndarray-linalg 0.16 |
ndarray_v0_15-nolinalg | no | version 0.15 without ndarray-linalg |
ndarray_v0_14-nolinalg | no | version 0.14 without ndarray-linalg |
ndarray_v0_13-nolinalg | no | version 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
| Feature | Default | Comment |
|---|---|---|
nalgebra_latest | no | latest supported version |
nalgebra_v0_34 | no | version 0.34 |
nalgebra_v0_33 | no | version 0.33 |
nalgebra_v0_32 | no | version 0.32 |
nalgebra_v0_31 | no | version 0.31 |
nalgebra_v0_30 | no | version 0.30 |
nalgebra_v0_29 | no | version 0.29 |
§faer
| Feature | Default | Comment |
|---|---|---|
faer_latest | no | latest supported version |
faer_v0_21 | no | version 0.21 |
faer_v0_20 | no | version 0.20 |
§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.5.1", 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.
§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
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
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§
- Error
- The
Errortype, a wrapper around a dynamic error type.
Traits§
- Argmin
Add - Add a
Ttoself - Argmin
Conj - Return the conjugate
- Argmin
Div - (Pointwise) Divide a
Tbyself - Argmin
Dot - Dot/scalar product of
Tandself - Argmin
Eye - Identity matrix
- Argmin
Inv - Compute the inverse (
T) ofself - Argmin
L1Norm - Compute the l1-norm (
U) ofself - Argmin
L2Norm - Compute the l2-norm (
U) ofself - Argmin
MinMax - Minimum and Maximum of type
T - Argmin
Mul - (Pointwise) Multiply a
Twithself - Argmin
Random - Create a random number
- Argmin
Scaled Add - Add a
Tscaled by anUtoself - Argmin
Scaled Sub - Subtract a
Tscaled by anUfromself - Argmin
Signum - Returns a number that represents the sign of
self. - Argmin
Sub - Subtract a
Tfromself - Argmin
Transpose - Return the transpose (
U) ofself - Argmin
Weighted Dot - Dot/scalar product of
Tandselfweighted by W (p^TWv) - Argmin
Zero - Return param vector of all zeros (for now, this is a hack. It should be done better)
- Argmin
Zero Like - Zero for dynamically sized objects
- Rng
- User-level interface for RNGs