Skip to content

Commit 2d7f477

Browse files
committed
Created function submodule and interface.
1 parent 1c86812 commit 2d7f477

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/stdlib_linalg.fypp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module stdlib_linalg
1111
public :: diag
1212
public :: eye
1313
public :: trace
14+
public :: outer_product
1415

1516
interface diag
1617
!! version: experimental
@@ -52,6 +53,7 @@ module stdlib_linalg
5253
#:endfor
5354
end interface
5455

56+
5557
! Matrix trace
5658
interface trace
5759
!! version: experimental
@@ -63,6 +65,22 @@ module stdlib_linalg
6365
#:endfor
6466
end interface
6567

68+
69+
! Outer product (of two vectors)
70+
interface outer_product
71+
!! version: experimental
72+
!!
73+
!! Computes outer product of two vectors, returning a matrix
74+
!! ([Specification](../page/specs/stdlib_linalg.html#description_3))
75+
#:for k1, t1 in RCI_KINDS_TYPES
76+
module function outer_product_${t1[0]}$${k1}$(u,v) result(res)
77+
${t1}$, intent(in) :: u(:), v(:)
78+
${t1}$ :: res(size(u),size(v))
79+
integer :: col
80+
end function outer_product_${t1[0]}$${k1}$
81+
#:endfor
82+
end interface outer_product
83+
6684
contains
6785

6886
function eye(n) result(res)

src/stdlib_linalg_outer_product.fypp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#:include "common.fypp"
2+
#:set RCI_KINDS_TYPES = REAL_KINDS_TYPES + CMPLX_KINDS_TYPES + INT_KINDS_TYPES
3+
submodule (stdlib_linalg) stdlib_linalg_outer_product
4+
5+
implicit none
6+
7+
contains
8+
9+
#:for k1, t1 in RCI_KINDS_TYPES
10+
module function outer_product_${t1[0]}$${k1}$(u,v) result(res)
11+
${t1}$, intent(in) :: u(:), v(:)
12+
${t1}$ :: res(size(u),size(v))
13+
integer :: col
14+
do col=1,size(v)
15+
res(:,col) = v(col) * u
16+
end do
17+
end function outer_product_${t1[0]}$${k1}$
18+
#:endfor
19+
20+
end submodule

0 commit comments

Comments
 (0)