MCPcopy Index your code
hub / github.com/douchuan/algorithm / scale

Method scale

src/math/sparse_vector.rs:81–87  ·  view source on GitHub ↗

Returns the scalar-vector product of this vector with the specified scalar.

(&self, alpha: f64)

Source from the content-addressed store, hash-verified

79
80 /// Returns the scalar-vector product of this vector with the specified scalar.
81 pub fn scale(&self, alpha: f64) -> Self {
82 let mut c = Self::new(self.d);
83 for &i in self.st.keys() {
84 c.put(i, alpha * self.get(i));
85 }
86 c
87 }
88}
89
90impl Add for SparseVector {

Callers 1

scaleFunction · 0.80

Calls 3

keysMethod · 0.45
putMethod · 0.45
getMethod · 0.45

Tested by 1

scaleFunction · 0.64