Crate argmin_math
source ·Expand description
argmin-math provides mathematics related abstractions needed in argmin. It supports
implementations of these abstractions for basic Vec
s 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
Feature | Default | Comment |
---|---|---|
primitives | yes | basic integer and floating point types |
vec | yes | Vec s (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_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 |
§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.
§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§
- The
Error
type, a wrapper around a dynamic error type.
Traits§
- Add a
T
toself
- Return the conjugate
- (Pointwise) Divide a
T
byself
- Dot/scalar product of
T
andself
- Identity matrix
- Compute the inverse (
T
) ofself
- Compute the l1-norm (
U
) ofself
- Compute the l2-norm (
U
) ofself
- Minimum and Maximum of type
T
- (Pointwise) Multiply a
T
withself
- Create a random number
- Add a
T
scaled by anU
toself
- Subtract a
T
scaled by anU
fromself
- Returns a number that represents the sign of
self
. - Subtract a
T
fromself
- Return the transpose (
U
) ofself
- Dot/scalar product of
T
andself
weighted by W (p^TWv) - Return param vector of all zeros (for now, this is a hack. It should be done better)
- Zero for dynamically sized objects
- An automatically-implemented extension trait on
RngCore
providing high-level generic methods for sampling values and other convenience methods.