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

Function build_comparison_graph

ciphercore-base/src/ops/comparisons.rs:234–256  ·  view source on GitHub ↗

See [`ComparisonResult`]. `a` and `b` should have type `Array` with bits pulled out to the outermost dimension. Inputs are interpreted as unsigned numbers. The number of bits should be the same in `a` and `b`.

(a: Node, b: Node)

Source from the content-addressed store, hash-verified

232/// Inputs are interpreted as unsigned numbers. The number of bits should be the same
233/// in `a` and `b`.
234fn build_comparison_graph(a: Node, b: Node) -> Result<ComparisonResult> {
235 let mut to_shrink = ComparisonResult::from_a_b(a, b)?;
236 let mut remainders = vec![];
237 loop {
238 let shrink_res = to_shrink.shrink()?;
239
240 if let Some(remainder) = shrink_res.remainder {
241 remainders.push(remainder);
242 }
243
244 if let Some(shrinked) = shrink_res.shrinked {
245 to_shrink = shrinked;
246 } else {
247 break;
248 }
249 }
250
251 let mut res = remainders[0].clone();
252 for remainder in remainders[1..].iter() {
253 res = res.join(remainder)?;
254 }
255 Ok(res)
256}
257
258/// As we support broadcasting in comparison arguments, we need to make
259/// sure they are still broadcastable after bits are pulled out to the

Callers 1

Calls 4

cloneMethod · 0.80
shrinkMethod · 0.45
pushMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected