-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from weso/vector-to-matrix
Vector to matrix implementation and changes in the tests accordingly
- Loading branch information
Showing
9 changed files
with
39 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
use sprs::CsVec; | ||
use sprs::{CsMat, TriMat}; | ||
|
||
use crate::storage::ZarrArray; | ||
|
||
use super::{EngineResult, EngineStrategy}; | ||
|
||
impl EngineStrategy<CsVec<u8>> for ZarrArray { | ||
fn get_subject(&self, index: usize) -> EngineResult<CsVec<u8>> { | ||
let selection = CsVec::new(self.rows(), vec![index], vec![1]); | ||
Ok(&self.transpose_view() * &selection) | ||
impl EngineStrategy<CsMat<u8>> for ZarrArray { | ||
fn get_subject(&self, index: usize) -> EngineResult<CsMat<u8>> { | ||
let mut matrix = TriMat::new((self.rows(), self.rows())); | ||
matrix.add_triplet(index, index, 1); | ||
let matrix = matrix.to_csc(); | ||
Ok(&matrix * self) | ||
} | ||
|
||
fn get_predicate(&self, index: usize) -> EngineResult<CsVec<u8>> { | ||
fn get_predicate(&self, _value: u8) -> EngineResult<CsMat<u8>> { | ||
unimplemented!() | ||
} | ||
|
||
fn get_object(&self, index: usize) -> EngineResult<CsVec<u8>> { | ||
let selection = CsVec::new(self.cols(), vec![index], vec![1]); | ||
Ok(self * &selection) | ||
fn get_object(&self, index: usize) -> EngineResult<CsMat<u8>> { | ||
let mut matrix = TriMat::new((self.cols(), self.cols())); | ||
matrix.add_triplet(index, index, 1); | ||
let matrix = matrix.to_csc(); | ||
Ok(self * &matrix) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters