Giter VIP home page Giter VIP logo

fsparse's Introduction

fsparse DOI

FSPARSE: Fortran Sparse Gallery library

FSparse is an initiative to build a OOP API of sparse matrices with some basic kernels and utility functions using Modern Fortran.

This project is very much a work in progress, contributions are wellcome.

Available Matrices

Matrix type no data real complex
COO COO_t COO_?p COO_c?p
CSR CSR_t CSR_?p CSR_c?p
CSC CSC_t CSC_?p CSC_c?p
ELL ELL_t ELL_?p ELL_c?p
SELL-C SELLC_t SELLC_?p SELLC_c?p

COO: COordinate Sparse format

CSR: Compressed Sparse Row format

CSC: Compressed Sparse Column format

ELL: ELLPACK

SELL-C: sliced ELLPACK format

(Where ? stands for the precision s,d,q)

Available Kernels

Conversion

Conversion subroutines follow the naming pattern _sourcetype2targettype_m ex:

call dense2coo( dense , coo )
Matrix dense COO CSR
dense
COO
CSR
CSC
ELL
SELL-C

Sparse Matrix-Vector product

(available) Matrix vector products are interfaced by the procedure

call matvec( Mat , vec_x, vec_y ) ! vec_y = vec_y + Mat * vec_x
Matrix full symmetric
COO
CSR
CSC (?)
ELL
SELL-C

A taste of FSPARSE

use fsparse
use iso_fortran_env, only: sp=>real32
type(COO_sp) :: COO
real(sp), allocatable :: dense(:,:)

allocate( dense(4,5) )
dense = reshape([9.0,4.0,0.0,4.0,0.0, &
                 7.0,8.0,0.0,0.0,0.0, &
                 -1.0,5.0,0.0,0.0,8.0,&
                 6.0,-3.0,0.0,0.0,0.0],[4,5])

call dense2coo( dense , COO )
use fsparse
use iso_fortran_env, only: dp=>real64
type(COO_dp) :: CSR
real(dp), allocatable :: vec_x(:)
real(dp), allocatable :: vec_y(:)

call CSR%malloc(4,5,10)
CSR%data(:)   = dble([9,-3,4,7,8,-1,8,4,5,6])
CSR%col(:)    = [1,5,1,2,2,3,4,1,3,4]
CSR%rowptr(:) = [1,3,5,8,11]

allocate( vec_x(5) , source = 1._dp )
allocate( vec_y(4) , source = 0._dp )
call matvec( CSR , vec_x, vec_y )

Building and using

FYPP is used to enable a generic programming framework, strongly inspired by the stdlib approach. A simple script is distributed to preprocess all .fypp files into .f90 before building.

Only simple and double preceision

python deployement.py

Adding quad precission support

python deployement.py --with_qp

The project was built using the Fortran Package Manager. A manifest file is included to build and test with FPM. For example:

fpm build --profile release
fpm test --profile release

To use fsparse within your FPM project, add the following to your fpm.toml file:

[dependencies]
fsparse = { git="https://github.com/jalvesz/FSPARSE" }

Inspiration & References

Iterative Methods for Sparse Linear Systems

Efficient Sparse Matrix-Vector Multiplication on cuda

gsl sparse matrices

Calcul Scientifique Parallèle

Implementing a Sparse Matrix Vector Product for the SELL-C/SELL-C-σ formats on NVIDIA GPUs

Authors and contributors

Acknowledgement

Compilation of this library was possible thanks to Transvalor S.A. research activities

fsparse's People

Contributors

jalvesz avatar samuelegiuli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.