pub fn vec_f64_into_vec_real<RealType: RealScalar>(
vec: Vec<f64>,
) -> Vec<RealType>
Expand description
Converts a vector of f64
values into a vector of the specified real scalar type.
This is the panicking version of try_vec_f64_into_vec_real
. It converts each
f64
value to the target real scalar type, panicking if any conversion fails.
Use this function only when you are certain that all input values are valid for
the target type.
§Parameters
vec
: A vector off64
values to convert
§Return Value
A vector of validated real scalar values of type RealType
.
§Panics
Panics if any value in the input vector cannot be converted to RealType
.
This can happen for various reasons:
- Input contains
NaN
or infinite values when using strict finite validation - Precision loss when converting to arbitrary-precision types
- Values outside the representable range of the target type
§Usage Examples
§Successful Conversion
use num_valid::{vec_f64_into_vec_real, RealNative64StrictFinite};
let input = vec![0.0, 1.0, -2.5, 3.14159];
let validated_vec: Vec<RealNative64StrictFinite> = vec_f64_into_vec_real(input);
assert_eq!(validated_vec.len(), 4);
assert_eq!(*validated_vec[0].as_ref(), 0.0);
assert_eq!(*validated_vec[1].as_ref(), 1.0);
§When to Use
- Use this function when: You are certain all input values are valid for the target type
- Use
try_vec_f64_into_vec_real
when: Input validation is uncertain and you want to handle errors gracefully