Skip to content

Commit e3c85bf

Browse files
committed
fix reshape permutation index
1 parent c2beec8 commit e3c85bf

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/stdlib_linalg_norms.fypp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
! Vector norms
99
submodule(stdlib_linalg) stdlib_linalg_norms
1010
use stdlib_linalg_constants
11-
use stdlib_linalg_blas
12-
use stdlib_linalg_lapack
11+
use stdlib_linalg_blas, only: nrm2
12+
use stdlib_linalg_lapack, only: lange
1313
use stdlib_linalg_state, only: linalg_state_type, linalg_error_handling, LINALG_ERROR, &
1414
LINALG_INTERNAL_ERROR, LINALG_VALUE_ERROR
1515
use iso_c_binding, only: c_intptr_t,c_char,c_loc
@@ -459,7 +459,7 @@ ${loop_variables_end(rank-1," "*12)}$
459459

460460
type(linalg_state_type) :: err_
461461
integer(ilp) :: j,m,n,lda,dims(2),norm_request
462-
integer(ilp), dimension(${rank}$) :: s,spack,perm
462+
integer(ilp), dimension(${rank}$) :: s,spack,perm,iperm
463463
integer(ilp), dimension(${rank}$), parameter :: dim_range = [(m,m=1_ilp,${rank}$_ilp)]
464464
integer(ilp) :: ${loop_variables('j',rank-2,2)}$
465465
logical :: contiguous_data
@@ -515,9 +515,10 @@ ${loop_variables_end(rank-1," "*12)}$
515515
else
516516

517517
! Dimension permutations to map dims(1),dims(2) => 1:2
518-
perm = [dims,pack(dim_range, dim_range/=dims(1) .and. dim_range/=dims(2))]
518+
perm = [dims,pack(dim_range, dim_range/=dims(1) .and. dim_range/=dims(2))]
519+
iperm(perm) = dim_range
519520
spack = s(perm)
520-
apack = reshape(a, shape=spack, order=perm)
521+
apack = reshape(a, shape=spack, order=iperm)
521522

522523
endif
523524

@@ -543,6 +544,8 @@ ${loop_variables_end(rank-2)}$
543544

544545
end function matrix_norm_${rank}$D_to_${rank-2}$D_${ii}$_${ri}$
545546

547+
#:endfor
548+
546549
#:endfor
547550
#:endfor
548551

0 commit comments

Comments
 (0)