-
Notifications
You must be signed in to change notification settings - Fork 189
Tridagonal matrices and associated spmv kernel #957
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
Open
loiseaujc
wants to merge
12
commits into
fortran-lang:master
Choose a base branch
from
loiseaujc:tridiagonal_matrices
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3912f73
Added the Tridiagonal type and associated spmv kernel.
loiseaujc 872777d
Rename dense to dense_mat because of a naming conflict.
loiseaujc abb6904
Added test for Tridiagonal spmv.
loiseaujc 9d8710b
Changed comparison to account for floating point errors.
loiseaujc 9ae0554
Move implementations to a dedicated module.
loiseaujc fc61941
Implementation of basic operations for Tridiagonal matrices is done.
loiseaujc 9b8f650
In-code documentation.
loiseaujc de3098b
Added examples.
loiseaujc 6ead4ba
Specifications page.
loiseaujc 4698662
Fix typos in module header.
loiseaujc c9d2531
Fix errors in examples.
loiseaujc 9e91af3
Enabled `xdp` and `qp` for `spmv` kernels.
loiseaujc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,49 +1,49 @@ | ||
program example_sparse_data_accessors | ||
use stdlib_linalg_constants, only: dp | ||
use stdlib_sparse | ||
implicit none | ||
use stdlib_linalg_constants, only: dp | ||
use stdlib_sparse | ||
implicit none | ||
|
||
real(dp) :: mat(2,2) | ||
real(dp), allocatable :: dense(:,:) | ||
type(CSR_dp_type) :: CSR | ||
type(COO_dp_type) :: COO | ||
integer :: i, j, locdof(2) | ||
real(dp) :: mat(2, 2) | ||
real(dp), allocatable :: dense_matrix(:, :) | ||
type(CSR_dp_type) :: CSR | ||
type(COO_dp_type) :: COO | ||
integer :: i, j, locdof(2) | ||
|
||
! Initial data | ||
mat(:,1) = [1._dp,2._dp] | ||
mat(:,2) = [2._dp,1._dp] | ||
allocate(dense(5,5) , source = 0._dp) | ||
do i = 0, 3 | ||
dense(1+i:2+i,1+i:2+i) = dense(1+i:2+i,1+i:2+i) + mat | ||
end do | ||
! Initial data | ||
mat(:, 1) = [1._dp, 2._dp] | ||
mat(:, 2) = [2._dp, 1._dp] | ||
allocate (dense_matrix(5, 5), source=0._dp) | ||
do i = 0, 3 | ||
dense_matrix(1 + i:2 + i, 1 + i:2 + i) = dense_matrix(1 + i:2 + i, 1 + i:2 + i) + mat | ||
end do | ||
|
||
print *, 'Original Matrix' | ||
do j = 1 , 5 | ||
print '(5f8.1)',dense(j,:) | ||
end do | ||
print *, 'Original Matrix' | ||
do j = 1, 5 | ||
print '(5f8.1)', dense_matrix(j, :) | ||
end do | ||
|
||
! Initialize CSR data and reset dense reference matrix | ||
call dense2coo(dense,COO) | ||
call coo2csr(COO,CSR) | ||
CSR%data = 0._dp | ||
dense = 0._dp | ||
! Initialize CSR data and reset dense reference matrix | ||
call dense2coo(dense_matrix, COO) | ||
call coo2csr(COO, CSR) | ||
CSR%data = 0._dp | ||
dense_matrix = 0._dp | ||
|
||
! Iteratively add blocks of data | ||
do i = 0, 3 | ||
locdof(1:2) = [1+i,2+i] | ||
call CSR%add(locdof,locdof,mat) | ||
! lets print a dense view of every step | ||
call csr2dense(CSR,dense) | ||
print '(A,I2)', 'Add block :', i+1 | ||
do j = 1 , 5 | ||
print '(5f8.1)',dense(j,:) | ||
end do | ||
end do | ||
! Iteratively add blocks of data | ||
do i = 0, 3 | ||
locdof(1:2) = [1 + i, 2 + i] | ||
call CSR%add(locdof, locdof, mat) | ||
! lets print a dense view of every step | ||
call csr2dense(CSR, dense_matrix) | ||
print '(A,I2)', 'Add block :', i + 1 | ||
do j = 1, 5 | ||
print '(5f8.1)', dense_matrix(j, :) | ||
end do | ||
end do | ||
|
||
! Request values from the matrix | ||
print *, '' | ||
print *, 'within sparse pattern :',CSR%at(2,1) | ||
print *, 'outside sparse pattern :',CSR%at(5,2) | ||
print *, 'outside matrix pattern :',CSR%at(7,7) | ||
end program example_sparse_data_accessors | ||
! Request values from the matrix | ||
print *, '' | ||
print *, 'within sparse pattern :', CSR%at(2, 1) | ||
print *, 'outside sparse pattern :', CSR%at(5, 2) | ||
print *, 'outside matrix pattern :', CSR%at(7, 7) | ||
|
||
end program example_sparse_data_accessors |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about this. I did not realized I had
fprettify
set on on automatic formatting when saving.