raddy/make/var.rs
1use crate::Ad;
2use na::SVector;
3
4#[inline]
5/// Creates an active scalar Ad value with single input dimension
6///
7/// # Arguments
8/// * `value` - The scalar value to wrap in an Ad type
9///
10/// # Returns
11/// An Ad<1> instance representing an active scalar value with single input dimension
12pub fn scalar(value: f64) -> Ad<1> {
13 Ad::active_scalar(value)
14}
15
16#[inline]
17/// Creates a vector of active Ad values with specified input and vector dimensions
18///
19/// # Arguments
20/// * `values` - Slice of f64 values to convert to active Ad values
21///
22/// # Type Parameters
23/// * `L` - Both the input dimension (for gradients) and vector length
24///
25/// # Returns
26/// An SVector of `Ad<L>` values where each element is active
27pub fn vector_from_slice<const L: usize>(values: &[f64]) -> SVector<Ad<L>, L> {
28 Ad::active_from_slice(values)
29}
30
31#[inline]
32/// Creates a vector of active Ad values with specified input and vector dimensions
33///
34/// # Arguments
35/// * `values` - Slice of f64 values to convert to active Ad values
36///
37/// # Type Parameters
38/// * `L` - Both the input dimension (for gradients) and vector length
39///
40/// # Returns
41/// An SVector of `Ad<L>` values where each element is active
42pub fn vector<const L: usize>(vector: &SVector<f64, L>) -> SVector<Ad<L>, L> {
43 Ad::active_vector(vector)
44}