MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / subtract_vectors_u128

Function subtract_vectors_u128

ciphercore-base/src/bytes.rs:126–146  ·  view source on GitHub ↗
(
    vec1: &[u128],
    vec2: &[u128],
    modulus: Option<u128>,
)

Source from the content-addressed store, hash-verified

124 Ok(res)
125}
126pub fn subtract_vectors_u128(
127 vec1: &[u128],
128 vec2: &[u128],
129 modulus: Option<u128>,
130) -> Result<Vec<u128>> {
131 if vec1.len() != vec2.len() {
132 return Err(runtime_error!(
133 "Vectors of different lengths can't be subtracted"
134 ));
135 }
136 let mut res = vec![];
137 for i in 0..vec1.len() {
138 let val = u128::wrapping_sub(vec1[i], vec2[i]);
139 res.push(val);
140 }
141 if let Some(m) = modulus {
142 Ok(res.iter().map(|x| (x % m)).collect())
143 } else {
144 Ok(res)
145 }
146}
147pub fn multiply_vectors_u64(vec1: &[u64], vec2: &[u64], modulus: Option<u64>) -> Result<Vec<u64>> {
148 if vec1.len() != vec2.len() {
149 return Err(runtime_error!(

Callers 6

generalized_subtractFunction · 0.85
share_vectorFunction · 0.85
prepare_inputFunction · 0.85
prepare_inputFunction · 0.85
prepare_arithmetic_inputFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected