MCPcopy Create free account
hub / github.com/Rustixir/darkbird / vector_scaling

Method vector_scaling

src/darkbird/storage_vector.rs:390–394  ·  view source on GitHub ↗

Performs scalar multiplication of a vector stored in the storage. The vector is identified by its key (ID). The function returns the result of the scalar multiplication as a new vector. # Arguments `key` - The key (ID) of the vector to be scaled. `scalar` - The scalar value by which the vector is to be multiplied. # Returns An `Option` containing the result of the vector scaling as a new vect

(&self, key: &str, scalar: f32)

Source from the content-addressed store, hash-verified

388 /// assert_eq!(result, Some(vec![2.0, 4.0, 6.0]));
389 /// ```
390 pub fn vector_scaling(&self, key: &str, scalar: f32) -> Option<Vector> {
391 let v = self.vcache.get(key)?;
392 let v = v.0.iter().map(|x| x * scalar).collect();
393 return Some(Vector(v))
394 }
395
396
397

Callers 2

vec_scalingMethod · 0.80
vec_subtractionMethod · 0.80

Calls 3

VectorClass · 0.85
getMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected