pub fn vec_f64_into_vec_float<T: NumKernel>(vec: Vec<f64>) -> Vec<T::RealType>
Expand description
Converts the input vec
of f64
values into a vector of floating point number, as described by the generic numerical kernel T
.
§Panics
In debug and release mode a panic!
will be emitted if the conversion from f64
to T::RealType
causes
some loss of information (e.g. if the type T
has less precision of f64
then there is the possbility
that some f64
values cannot be exactly represented by a T::RealType
).
§Example
use ftl_numkernel::{Native64, vec_f64_into_vec_float};
// Conditional compilation for the `rug` feature
#[cfg(feature = "rug")]
use ftl_numkernel::Rug;
// vector of f64 values
let a = vec![0., 1.];
let b = vec_f64_into_vec_float::<Native64>(a.clone());
assert_eq!(b[0], 0.);
assert_eq!(b[1], 1.);
// Conditional compilation for the `rug` feature
#[cfg(feature = "rug")]
{
const PRECISION: u32 = 100;
// vector of rug::Float values with PRECISION = 100
let b = vec_f64_into_vec_float::<Rug<PRECISION>>(a);
assert_eq!(b[0].as_ref(), &rug::Float::with_val(PRECISION, 0.));
assert_eq!(b[1].as_ref(), &rug::Float::with_val(PRECISION, 1.));
}