alloy-rs / alloy-rs/ruint

`algorithms/gcd/matrix`: We can update r0 and r1 in place. This won't remove the partially

オープン
#120 コメント 0 件 リアクション 0 件 担当者 1 名 @recmo が担当を希望しています GitHub で見る
optimize tracker
主要言語
Rust
スター
225
フォーク
70
平均マージ
16時間 54分
マージ済み PR(30日)
8

説明

*On 2022-06-06 @recmo wrote in [`4c74c09`](https://github.com/recmo/uint/commit/4c74c09b4d6f425cda931e9f5e8d00f1367c4261) “Merge pull request #110 from recmo/gcd”:*

We can update r0 and r1 in place. This won't remove the partially
redundant call to lehmer_update, but it reduces memory usage.

```rust
/// Our approach is similar to Cohen, but instead doing the second round
/// on the same matrix, we start we a fresh matrix and multiply both in the
/// end. This requires 8 additional multiplications, but allows us to use
/// the tighter stopping conditions from Jebelean. It also seems the
/// simplest out of these solutions.
// OPT: We can update r0 and r1 in place. This won't remove the partially
// redundant call to lehmer_update, but it reduces memory usage.
#[must_use]
pub fn from_u128_prefix(r0: u128, r1: u128) -> Self {
debug_assert!(r0 >= r1);
let s = r0.leading_zeros();
let r0s = r0 << s;

```
*From [`src/algorithms/gcd/matrix.rs:298`](https://github.com/recmo/uint/blob/4c74c09b4d6f425cda931e9f5e8d00f1367c4261/src/algorithms/gcd/matrix.rs#L298)*

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。