Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are there sparse matrix algorithms in scirust? #30

Open
zkbpkp opened this issue Mar 22, 2017 · 2 comments
Open

Are there sparse matrix algorithms in scirust? #30

zkbpkp opened this issue Mar 22, 2017 · 2 comments

Comments

@zkbpkp
Copy link

zkbpkp commented Mar 22, 2017

I need a library to work with large-scale sparse matrices. Does scirust support sparse algorithms?

@zkbpkp zkbpkp changed the title Are there sparse matrix algorithms in SciRust? Are there sparse matrix algorithms in scirust? Mar 22, 2017
@zkbpkp
Copy link
Author

zkbpkp commented Mar 23, 2017

I've explored the code and found out that there's no sparse matrices support. So I want to suggest a refactoring: Matrix becomes a trait, and different matrices representations (like dense matrices, CSR and CSC) implement this trait.

pub trait Matrix<T: MagmaBase> {
    /// Returns the capacity of the matrix i.e. the number of elements it can
    /// hold
    fn capacity(&self) -> usize;

    /// Reshapes the matrix
    fn reshape(&mut self, rows: usize, cols: usize) -> bool;

    /// Returns an iterator over a specific row of the matrix
    fn row_iter(&self, r: isize) -> RowIterator<T>;

    /// Returns an iterator over a specific column of the matrix
    fn col_iter(&self, c: isize) -> ColIterator<T>;

    /// Returns an iterator over all cells of the matrix
    fn cell_iter(&self) -> CellIterator<T>;

    /// Provide the main diagonal elements
    fn diagonal_iter(&self) -> DiagIterator<T>;

    // ...more methods...
}

impl<T: MagmaBase> Matrix<T> for DenseMatrix<T> {
    // ...
}

impl<T: MagmaBase> Matrix<T> for SparseMatrix<T> {
    // ...
}

// ...more impl's...

With these changes it will be possible to operate with matrices of different representation, e.g. add "regular" matrix with CSR matrix.
If you are interested in such changes, I can work on it (actually, I've already started), but maybe I'll need some help.

P.S. Sorry if my English isn't very good.

@shailesh1729
Copy link
Contributor

Yes, at the moment there is no sparse matrix support. I will be able to merge the changes if and when you are ready. We can chat if you need any explanation on any part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants