Skip to content

Commit 92e3525

Browse files
committed
doc for cross_product
1 parent a29bbde commit 92e3525

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

doc/specs/stdlib_linalg.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,41 @@ program demo_outer_product
206206
!A = reshape([3., 6., 9., 4., 8., 12.], [3,2])
207207
end program demo_outer_product
208208
```
209+
210+
## `cross_product` - Computes the Cross Product of Two 3-D Vectors
211+
212+
### Status
213+
214+
Experimental
215+
216+
### Description
217+
218+
Computes the cross product of two 3-D vectors
219+
220+
### Syntax
221+
222+
`c = [[stdlib_linalg(module):cross_product(interface)]](a, b)`
223+
224+
### Arguments
225+
226+
`a`: Shall be a rank-1 and size-3 array
227+
228+
`b`: Shall be a rank-1 and size-3 array
229+
230+
### Return value
231+
232+
Returns a rank-1 and size-3 array which is perpendicular to both `a` and `b`.
233+
234+
### Example
235+
236+
```fortran
237+
program demo_cross_product
238+
use stdlib_linalg, only: cross_product
239+
implicit none
240+
real :: a(3), b(3), c(3)
241+
a = [1., 0., 0.]
242+
b = [0., 1., 0.]
243+
c = cross_product(a, b)
244+
!c = [0., 0., 1.]
245+
end program demo_cross_product
246+
```

src/stdlib_linalg.fypp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ module stdlib_linalg
8686
interface cross_product
8787
!! version: experimental
8888
!!
89-
!! Computes the cross product of two vectors, returning a rank-2 array
90-
!! ([Specification](../page/specs/stdlib_linalg.html#description_3))
89+
!! Computes the cross product of two vectors, returning a rank-1 and size-3 array
90+
!! ([Specification](../page/specs/stdlib_linalg.html#cross_product-computes-the-cross-product-of-two-3-d-vectors))
9191
#:for k1, t1 in RCI_KINDS_TYPES
9292
module function cross_product_${t1[0]}$${k1}$(a, b) result(res)
9393
${t1}$, intent(in) :: a(:), b(:)

0 commit comments

Comments
 (0)