Convert Array<A, D> into ArrayBase<S, D>
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
Rechercherichtung
Start by reading Array, ArrayBase, into_owned, and into_shared, then review the strongly typed strides discussion in issue #283. Determine whether an owned array can be generalized to ArrayBase without copying while preserving its strides, with results usable as both Array and RcArray.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
I would like to switch array type to implement a general library
pub fn algorithm<A, Si, So, D>(a: ArrayBase<Si, D>) -> ArrayBase<So, D>
where Si: Data<Elem = A>, So: DataOwned<Elem =A>, D: Dimension
{ ... }
Users of this library can get the result using both Array and RcArray:
let result1: Array2<f64> = algorithm(a);
let result2: RcArray2<f64> = algorithm(a);
However, some algorithm in this crate (e.g. ndarray::linalg::Dot::dot) returns Array,
and thus I try to write a function that convert Array<D> into ArrayBase<S: DataOwned, D> without data copy:
fn generalize<A, S, D>(a: Array<A, D>) -> ArrayBase<S, D>
where
S: DataOwned<Elem =A>,
D: Dimension,
{
ArrayBase::from_shape_vec(a.dim(), a.into_raw_vec())
}
This is an generalization of into_owned and into_shared. This generalize can be compiled, but does not keep its stride.
let a: Array3<f64> = Array::zeros((3, 2, 4).f()); // f-order
let ans = a.clone();
let a: Array3<f64> = generalize(a); // c-order
assert_eq!(a, ans); /// panic!
I cannot find a way to keep strides :< I suspect that I need the strongly typed strides #283
Is it possible to implement it correctly out of this crate? If impossible, please add such function.
- Vorherrschende Sprache
- Rust
- Sterne
- 4.3k
- Forks
- 391
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus rust-ndarray/ndarray
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
rust-ndarray/ndarray#1612 · 1 Kommentar ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
rust-ndarray/ndarray#1617 · 1 Kommentar ·
-
Stack overflow in `triu` Offenbug good first issue
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
rust-ndarray/ndarray#1615 · 1 Kommentar ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
rust-ndarray/ndarray#1610 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 72/100
rust-ndarray/ndarray#1609 ·
Alle Issues in rust-ndarray/ndarray
Ähnliche Issues
-
risk:low runtime status:in-progress type:test
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
zeroclaw-labs/zeroclaw#11023 ·
-
good first issue refactor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
EricSpencer00/Resilient#4835 · 1 Kommentar ·
-
agent:ready documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
cesarferreira/stax#890 ·
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100