-
Notifications
You must be signed in to change notification settings - Fork 167
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
Euler 37 repmat #683
Open
Euler-37
wants to merge
14
commits into
fortran-lang:master
Choose a base branch
from
Euler-37:Euler-37-repmat
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
Euler 37 repmat #683
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f7c5ae9
Create stdlib_linalg_repmat.fypp
Euler-37 5211579
Update stdlib_linalg.fypp
Euler-37 c30d5cf
Create example_linalg_repmat.f90
Euler-37 4b0df32
Update stdlib_linalg_repmat.fypp
Euler-37 5196edd
Update stdlib_linalg.fypp
Euler-37 8fe7467
Rename example_linalg_repmat.f90 to example_repmat.f90
Euler-37 4f18fab
Update stdlib_linalg.fypp
Euler-37 1f54a83
Update test_linalg.fypp
Euler-37 aa410fe
Update stdlib_linalg_repmat.fypp
Euler-37 0f82104
Update stdlib_linalg_repmat.fypp
Euler-37 78bebd7
Update test_linalg.fypp
Euler-37 911b199
Update test_linalg.fypp
Euler-37 334fb7d
Update CMakeLists.txt
Euler-37 06d866d
Update test/linalg/test_linalg.fypp
Euler-37 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 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
program example_repmat | ||
use stdlib_linalg, only: repmat | ||
implicit none | ||
real, allocatable :: a(:, :),b(:,:) | ||
a = reshape([1., 2., 3., 4.],[2, 2],order=[2, 1]) | ||
b = repmat(a, 2, 2) | ||
! A = reshape([1., 2., 1., 2.,& | ||
! 3., 4., 3., 4.,& | ||
! 1., 2., 1., 2.,& | ||
! 3., 4., 3., 4.,& | ||
! ], [4, 4],order=[2, 1]) | ||
end program example_repmat |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#:include "common.fypp" | ||
#:set RCI_KINDS_TYPES = REAL_KINDS_TYPES + CMPLX_KINDS_TYPES + INT_KINDS_TYPES | ||
submodule (stdlib_linalg) stdlib_linalg_repmat | ||
|
||
implicit none | ||
|
||
contains | ||
|
||
#:for k1, t1 in RCI_KINDS_TYPES | ||
pure module function repmat_${t1[0]}$${k1}$(a, m, n) result(res) | ||
${t1}$, intent(in) :: a(:,:) | ||
integer, intent(in) :: m,n | ||
${t1}$ :: res(m*size(a,1),n*size(a,2)) | ||
integer ::i,j,k,l | ||
associate(ma=>size(a,1),na=>size(a,2)) | ||
do j=1,n | ||
milancurcic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
do l=1,na | ||
do i=1,m | ||
do k=1,ma | ||
res((i-1)*ma+k,(j-1)*na+l)=a(k,l) | ||
end do | ||
end do | ||
end do | ||
end do | ||
end associate | ||
end function repmat_${t1[0]}$${k1}$ | ||
|
||
#:endfor | ||
|
||
end submodule |
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
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.
What is the difference with the intrinsic
spread
(i.e. "replicates a source array ncopies times along a specified dimension")?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.
"replicates a source ARRAY ncopies times along a specified dimension", this doesn't quite work for matrices (rank-2) as you will need to do some complicated trickery to reshape it.
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.
Actually ,Fortran's intrinsic array functions have some strange optimizations. It may generate temporary array and
copy
. And ifort will be slow if you do some elemental-wise array operation.