Skip to content

Kronecker Product addition to stdlib_linalg #700

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

Merged
merged 12 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Adding spaces to = signs

Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
  • Loading branch information
adenchfi and jvdp1 authored Mar 4, 2023
commit 9612c71dbfe85b7c9b7ff7fc310d0cfb341da654
4 changes: 2 additions & 2 deletions src/stdlib_linalg_kronecker.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ contains
maxM2 = size(B, dim=1)
maxN2 = size(B, dim=2)

do n1=1, maxN1
do m1=1, maxM1
do n1 = 1, maxN1
do m1 = 1, maxM1
! We use the numpy.kron convention for ordering of the matrix elements
C((m1-1)*maxM2+1:m1*maxM2, (n1-1)*maxN2+1:n1*maxN2) = A(m1, n1) * B(:,:)
end do
Expand Down
6 changes: 3 additions & 3 deletions test/linalg/test_linalg.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -566,16 +566,16 @@ contains
subroutine test_kronecker_product_rsp(error)
!> Error handling
type(error_type), allocatable, intent(out) :: error
integer, parameter :: m1=1, n1=2, m2=2, n2=3
integer, parameter :: m1 = 1, n1 = 2, m2 = 2, n2 = 3
real(sp), parameter :: tol = 1.e-6

real(sp) :: A(m1,n1), B(m2,n2)
real(sp) :: C(m1*m2,n1*n2), expected(m1*m2,n1*n2), diff(m1*m2,n1*n2)

integer :: i,j

do j=1, n1
do i=1, m1
do j = 1, n1
do i = 1, m1
A(i,j) = i*j ! A = [1, 2]
end do
end do
Expand Down